|
Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
|
Uniform line charge along a straight segment. More...
#include <LineCharge.hpp>


Private Member Functions | |
| Quantity< Volt > | AnalyticPotential (const Vector3< Quantity< Meter > > &point) const |
| Analytic potential for finite line charge. | |
| Vector3< Quantity< NewtonPerCoulomb > > | NumericalIntegrateField (const Vector3< Quantity< Meter > > &point, const int segments) const |
| Numerical integration of electric field along the line. | |
Private Attributes | |
| Vector3< Quantity< Meter > > | start_ |
| Vector3< Quantity< Meter > > | end_ |
| Vector3< Scalar > | direction_ |
| Quantity< Meter > | length_ |
| Quantity< CoulombPerMeter > | lambda_ |
Uniform line charge along a straight segment.
LineCharge represents a straight segment with uniform linear charge density lambda (C/m). The electric field is computed by numerical integration (64 segments by default), while the potential uses an analytic closed-form solution.
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 lambda = 1.0e-9_C/m;
LineCharge line(start, end, lambda); auto point = Vector3<Quantity<Meter>>(0_m, 0.1_m, 0_m); auto E = line.GetElectricFieldAt(point); auto V = line.GetElectricPotentialAt(point);
Note: The field and potential diverge on the line charge itself. Querying at points on the line throws an exception.
Definition at line 28 of file LineCharge.hpp.
|
inline |
Construct a uniform line charge.
| start | Starting point of the line (meters) |
| end | Ending point of the line (meters) |
| lambda | Linear charge density (C/m) |
Definition at line 37 of file LineCharge.hpp.
|
inlineprivate |
Analytic potential for finite line charge.
The formula is: V = k_E * lambda * ln((r1 + r2 + L) / (r1 + r2 - L))
where r1 = |point - start|, r2 = |point - end|, L = segment length.
| point | Position to evaluate the potential |
| std::runtime_error | If point is on the line charge |
Note: The denominator (r1 + r2 - L) approaches zero when the point lies on the line segment, causing a logarithmic divergence.
Definition at line 122 of file LineCharge.hpp.
|
inlineoverridevirtual |
Compute the electric field at a point using numerical integration.
| point | Position to evaluate the field (meters) |
The field is integrated using the midpoint rule with 64 segments. Points on the line are skipped (their contribution is ignored).
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 55 of file LineCharge.hpp.
|
inlineoverridevirtual |
Compute the electric potential at a point using analytic formula.
The potential for a finite line charge is: V = k_E * lambda * ln((r1 + r2 + L) / (r1 + r2 - L)) where r1, r2 are distances to the endpoints and L is the segment length.
| point | Position to evaluate the potential (meters) |
| std::runtime_error | If point is on the line charge |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 72 of file LineCharge.hpp.
|
inlineoverridevirtual |
Get the minimum distance from a point to the line segment.
| point | Position to compute distance from |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 92 of file LineCharge.hpp.
|
inlineoverridevirtual |
Get the total charge of the line.
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 81 of file LineCharge.hpp.
|
inlineprivate |
Numerical integration of electric field along the line.
Uses the midpoint rule with the specified number of segments. Each segment contributes dE = k_E * dq / r^2 * hat_r.
| point | Evaluation point |
| segments | Number of line segments for integration |
Definition at line 151 of file LineCharge.hpp.
Definition at line 101 of file LineCharge.hpp.
Definition at line 100 of file LineCharge.hpp.
|
private |
Definition at line 103 of file LineCharge.hpp.
Definition at line 102 of file LineCharge.hpp.
Definition at line 100 of file LineCharge.hpp.