|
Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
|
Magnetic field from a straight current-carrying wire segment. More...
#include <CurrentSegment.hpp>


Public Member Functions | |
| CurrentSegment (const Vector3< Quantity< Meter > > &start, const Vector3< Quantity< Meter > > &end, const Quantity< Ampere > ¤t) | |
| Construct a current segment from start to end. | |
| Vector3< Quantity< Tesla > > | GetMagneticFieldAt (const Vector3< Quantity< Meter > > &point) const override |
| Compute the magnetic field at a point. | |
| Quantity< Ampere > | GetCurrent () const |
| Quantity< Meter > | GetLength () const |
| const Vector3< Quantity< Meter > > & | GetStart () const |
| const Vector3< Quantity< Meter > > & | GetEnd () const |
Public Member Functions inherited from Phyth::Electromagnetics::MagneticSource | |
| virtual | ~MagneticSource ()=default |
Private Member Functions | |
| Vector3< Quantity< Tesla > > | AnalyticSolution (const Vector3< Quantity< Meter > > &point) const |
| Closed-form Biot-Savart solution for a finite straight wire. | |
| bool | IsPointOnWire (const Vector3< Quantity< Meter > > &point) const |
| Check if a point lies on the wire segment. | |
| Quantity< Meter > | GetMinimumDistanceTo (const Vector3< Quantity< Meter > > &point) const |
| Compute the minimum distance from a point to the wire segment. | |
Private Attributes | |
| Vector3< Quantity< Meter > > | start_ |
| Vector3< Quantity< Meter > > | end_ |
| Vector3< Scalar > | direction_ |
| Quantity< Meter > | length_ |
| Quantity< Ampere > | current_ |
Magnetic field from a straight current-carrying wire segment.
CurrentSegment computes the magnetic field generated by a finite straight wire segment carrying a steady current, using the Biot-Savart law in closed form.
The magnetic field direction follows the right-hand rule around the current direction (from start to end).
Example: auto start = Vector3<Quantity<Meter>>(-1.0_m, 0_m, 0_m); auto end = Vector3<Quantity<Meter>>(1.0_m, 0_m, 0_m); auto current = 5.0_A;
CurrentSegment wire(start, end, current); auto point = Vector3<Quantity<Meter>>(0_m, 0.1_m, 0_m); auto B = wire.GetMagneticFieldAt(point);
Note: The field is singular on the wire axis. Points on the wire will throw an exception.
Definition at line 32 of file CurrentSegment.hpp.
|
inline |
Construct a current segment from start to end.
| start | Starting point of the segment (meters) |
| end | Ending point of the segment (meters) |
| current | Current flowing from start to end (Amperes) |
| std::invalid_argument | If segment length is zero |
Definition at line 43 of file CurrentSegment.hpp.
|
inlineprivate |
Closed-form Biot-Savart solution for a finite straight wire.
The magnetic field at a point P is: B = (mu_0 * I / (4 * pi * rho)) * (z2/sqrt(rho^2 + z2^2) - z1/sqrt(rho^2 + z1^2)) * phi_hat
where:
| point | Position to evaluate the field |
If rho is near zero (point on the wire axis), returns zero instead of throwing. The singularity is handled by the caller.
Definition at line 123 of file CurrentSegment.hpp.
Definition at line 78 of file CurrentSegment.hpp.
|
inline |
Definition at line 93 of file CurrentSegment.hpp.
Definition at line 83 of file CurrentSegment.hpp.
|
inlineoverridevirtual |
Compute the magnetic field at a point.
| point | Position in 3D space (meters) |
| std::runtime_error | If the point lies on the wire axis |
The field is computed using the Biot-Savart law closed-form solution for a finite straight wire.
Implements Phyth::Electromagnetics::MagneticSource.
Definition at line 69 of file CurrentSegment.hpp.
|
inlineprivate |
Compute the minimum distance from a point to the wire segment.
| point | Position to compute distance from |
This is used by MagneticSource interface for regularization.
Definition at line 189 of file CurrentSegment.hpp.
|
inline |
Definition at line 88 of file CurrentSegment.hpp.
|
inlineprivate |
Check if a point lies on the wire segment.
A point is considered "on the wire" if it is within tolerance of the wire axis and its projection falls within the segment bounds.
| point | Position to check |
Definition at line 162 of file CurrentSegment.hpp.
Definition at line 102 of file CurrentSegment.hpp.
Definition at line 100 of file CurrentSegment.hpp.
Definition at line 99 of file CurrentSegment.hpp.
Definition at line 101 of file CurrentSegment.hpp.
Definition at line 98 of file CurrentSegment.hpp.