|
Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
|
Point charge with full electromagnetic field and dynamics. More...
#include <PointCharge.hpp>


Private Member Functions | |
| Vector3< Quantity< Meter > > | GetPositionAtOffset (const Quantity< Second > &offset) const |
| Get position at a time offset in the past. | |
| Vector3< Quantity< MeterPerSecond > > | GetVelocityAtOffset (const Quantity< Second > &offset) const |
| Get velocity at a time offset in the past. | |
| Vector3< Quantity< MeterPerSecondSquared > > | GetAccelerationAtOffset (const Quantity< Second > &offset) const |
| Get acceleration at a time offset in the past. | |
| Quantity< Second > | SolveRetardedTimeOffset (const Vector3< Quantity< Meter > > &point) const |
| Solve for the retarded time offset using Newton's method. | |
| Quantity< Second > | SolveRetardedTimeOffsetBisection (const Vector3< Quantity< Meter > > &point, Quantity< Second > dt_low, Quantity< Second > dt_high) const |
| Solve for the retarded time offset using bisection method. | |
Private Attributes | |
| Quantity< Coulomb > | charge_value_ |
| TimeHistory< Vector3< Quantity< Meter > > > | position_history_ {} |
| TimeHistory< Vector3< Quantity< MeterPerSecond > > > | velocity_history_ {} |
| TimeHistory< Vector3< Quantity< MeterPerSecondSquared > > > | acceleration_history_ {} |
Additional Inherited Members | |
Protected Attributes inherited from Phyth::Mechanics::Particle | |
| Quantity< Kilogram > | mass_ |
| Vector3< Quantity< MeterPerSecond > > | velocity_ {} |
| bool | fixed_ {false} |
| Vector3< Quantity< Newton > > | external_force_ {} |
| Vector3< Quantity< Meter > > | position_ |
| std::function< void(Particle *)> | compute_forces_func_ |
Point charge with full electromagnetic field and dynamics.
PointCharge represents a moving charged particle that produces electric and magnetic fields via the Liénard-Wiechert potentials. It inherits from Particle for dynamics and implements both ChargeSource and MagneticSource interfaces.
The electric field consists of two components:
Example: auto charge = std::make_shared<PointCharge>( 1.0_kg, Vector3<Quantity<Meter>>(0_m, 0_m, 0_m), 1.0_C );
// Add a force function (e.g., Lorentz force) charge->SetComputeForcesFunction([](PointCharge* q) { Vector3<Quantity<NewtonPerCoulomb>> E(0_V/m, 0_V/m, -1.0_V/m); q->ApplyElectricFieldForce(E); });
// In simulation loop: charge->Integrate(); auto E = charge->GetElectricFieldAt(point); auto B = charge->GetMagneticFieldAt(point);
Note: The field and potential diverge at the charge location. Querying at the charge position throws an exception.
Definition at line 43 of file PointCharge.hpp.
|
inlineexplicit |
Construct a point charge.
| mass | Mass of the particle (kg) |
| position | Initial position (m) |
| charge_value | Electric charge (Coulombs) |
Definition at line 54 of file PointCharge.hpp.
|
inline |
Apply force from an electric field: F = q * E.
| field | Electric field intensity at the charge position |
Definition at line 223 of file PointCharge.hpp.
|
inline |
Apply the full Lorentz force: F = q * (E + v cross B)
| electric_field | Electric field intensity (N/C) |
| magnetic_field | Magnetic flux density (Tesla) |
Definition at line 242 of file PointCharge.hpp.
|
inline |
Apply force from a magnetic field: F = q * v cross B.
| field | Magnetic flux density at the charge position |
Definition at line 232 of file PointCharge.hpp.
|
inlineprivate |
Get acceleration at a time offset in the past.
Definition at line 309 of file PointCharge.hpp.
|
inlineoverridevirtual |
Get the electric field at a point using Liénard-Wiechert formulas.
The electric field is: E = k_E * q * (hat_R - beta) / (gamma^2 * R^2 * (1 - hat_R dot beta)^3)
The first term is the velocity field (1/r^2), the second is the acceleration field (radiation, 1/r).
| point | Position to evaluate the field (meters) |
| std::runtime_error | If point is at the charge location |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 95 of file PointCharge.hpp.
|
inlineoverridevirtual |
Get the electric potential at a point.
The Liénard-Wiechert potential is: V = k_E * q / (R - hat_R dot beta * R)
| point | Position to evaluate the potential (meters) |
| std::runtime_error | If point is at the charge location or the denominator factor approaches zero |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 182 of file PointCharge.hpp.
|
inlineoverridevirtual |
Get the magnetic field at a point using Liénard-Wiechert formulas.
The magnetic field is related to the electric field by: B = (hat_R / c) cross E
| point | Position to evaluate the field (meters) |
| std::runtime_error | If point is at the charge location |
Implements Phyth::Electromagnetics::MagneticSource.
Definition at line 151 of file PointCharge.hpp.
|
inlineoverridevirtual |
Get the minimum distance from a point to the charge location.
| point | Position to compute distance from |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 264 of file PointCharge.hpp.
|
inlineprivate |
Get position at a time offset in the past.
Definition at line 291 of file PointCharge.hpp.
|
inlineoverridevirtual |
Get the total charge value.
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 253 of file PointCharge.hpp.
|
inlineprivate |
Get velocity at a time offset in the past.
Definition at line 300 of file PointCharge.hpp.
|
inlineoverridevirtualnoexcept |
Integrate dynamics using velocity Verlet.
Overrides Particle::Integrate to also update history buffers for retarded field computations.
Reimplemented from Phyth::Mechanics::Particle.
Definition at line 274 of file PointCharge.hpp.
|
inlinenoexcept |
Set the force computation function.
| func | Function that applies forces to the charge via ApplyForce() |
This wraps the Particle::SetComputeForcesFunction to accept PointCharge pointers directly.
Definition at line 72 of file PointCharge.hpp.
|
inlineprivate |
Solve for the retarded time offset using Newton's method.
Solves R(t_ret) = c * (t - t_ret) for t_ret. Falls back to bisection if Newton fails.
Definition at line 323 of file PointCharge.hpp.
|
inlineprivate |
Solve for the retarded time offset using bisection method.
Fallback when Newton's method fails to converge.
| std::runtime_error | If no solution exists in the interval |
Definition at line 375 of file PointCharge.hpp.
|
private |
Definition at line 287 of file PointCharge.hpp.
Definition at line 283 of file PointCharge.hpp.
|
private |
Definition at line 285 of file PointCharge.hpp.
|
private |
Definition at line 286 of file PointCharge.hpp.