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


Static Private Member Functions | |
| static Vector3< Quantity< CoulombMeter > > | ComputeRelativisticDipoleMoment (const Vector3< Quantity< MeterPerSecond > > &v, const Vector3< Quantity< AmpereMeterSquared > > &m) |
| Compute the relativistic electric dipole moment. | |
Private Attributes | |
| Vector3< Quantity< AmpereMeterSquared > > | moment_ |
| Vector3< Quantity< AmpereMeterSquared > > | initial_moment_ |
| Quantity< KilogramMeterSquared > | moment_of_inertia_ |
| Quaternion< Scalar > | orientation_ {} |
| Vector3< Quantity< RadianPerSecond > > | angular_velocity_ {} |
| Vector3< Quantity< NewtonMeter > > | external_torque_ {} |
| TimeHistory< Vector3< Quantity< Meter > > > | position_history_ |
| TimeHistory< Vector3< Quantity< MeterPerSecond > > > | velocity_history_ |
| TimeHistory< Vector3< Quantity< MeterPerSecondSquared > > > | acceleration_history_ |
| TimeHistory< Vector3< Quantity< AmpereMeterSquared > > > | moment_history_ |
| TimeHistory< Vector3< Quantity< CoulombMeter > > > | electric_dipole_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_ |
Magnetic dipole with full electromagnetic field and dynamics.
MagneticDipole represents a moving magnetic dipole that produces both magnetic and electric fields. It inherits from Particle for dynamics, and implements both MagneticSource and ChargeSource interfaces.
The magnetic dipole moment m can rotate (with moment of inertia) and the moving dipole produces a relativistic electric dipole moment p = -(gamma / c^2) * v x m.
Example: auto dipole = std::make_shared<MagneticDipole>( 1.0_kg, Vector3<Quantity<Meter>>(0_m, 0_m, 0_m), Vector3<Quantity<AmpereMeterSquared>>(1.0_Am2, 0_Am2, 0_Am2) );
// Add a magnetic field source dipole->ApplyMagneticForce(magnetic_field);
// In simulation loop: dipole->Integrate();
Definition at line 39 of file MagneticDipole.hpp.
|
inlineexplicit |
Construct a magnetic dipole.
| mass | Mass of the dipole (kg) |
| position | Initial position (m) |
| moment | Magnetic dipole moment (A*m^2) |
| moment_of_inertia | Moment of inertia (kg*m^2), default 0 |
The dipole moment can rotate if moment_of_inertia > 0. The initial orientation is aligned with the moment vector.
Definition at line 54 of file MagneticDipole.hpp.
|
inline |
Apply all electric forces (gradient + torque)
Definition at line 336 of file MagneticDipole.hpp.
|
inline |
Apply force from electric field gradient.
F = grad(p dot E)
| field_source | The electric field source |
Definition at line 310 of file MagneticDipole.hpp.
|
inline |
Apply torque from electric field.
tau = p x E
| field_source | The electric field source |
Definition at line 322 of file MagneticDipole.hpp.
|
inline |
Apply both magnetic and electric forces.
| magnetic_source | The magnetic field source |
| electric_source | The electric field source |
Definition at line 347 of file MagneticDipole.hpp.
|
inline |
Apply all magnetic forces (gradient + torque)
Definition at line 330 of file MagneticDipole.hpp.
|
inline |
Apply force from magnetic field gradient.
F = grad(m dot B)
| field_source | The magnetic field source |
Definition at line 285 of file MagneticDipole.hpp.
|
inline |
Apply torque from magnetic field.
tau = m x B
| field_source | The magnetic field source |
Definition at line 297 of file MagneticDipole.hpp.
|
inline |
Apply a torque to the dipole.
| torque | Torque vector (N*m) |
The torque affects the dipole's orientation if moment_of_inertia > 0.
Definition at line 360 of file MagneticDipole.hpp.
|
inlineprivate |
Compute first time derivative of acceleration at retarded time.
Definition at line 734 of file MagneticDipole.hpp.
|
inlineprivate |
Compute first time derivative of electric dipole moment at retarded time.
Definition at line 681 of file MagneticDipole.hpp.
|
inlineprivate |
Compute second time derivative of electric dipole moment at retarded time.
Definition at line 706 of file MagneticDipole.hpp.
|
inlineprivate |
Compute electric gradient force using finite differences.
F = grad(p dot E)
Uses central differences with step epsilon_m.
Definition at line 804 of file MagneticDipole.hpp.
|
inlineprivate |
Compute magnetic gradient force using finite differences.
F = grad(m dot B)
Uses central differences with step epsilon_m.
Definition at line 763 of file MagneticDipole.hpp.
|
inlineprivate |
Compute first time derivative of magnetic moment at retarded time.
Definition at line 628 of file MagneticDipole.hpp.
|
inlineprivate |
Compute second time derivative of magnetic moment at retarded time.
Definition at line 653 of file MagneticDipole.hpp.
|
inlinestaticprivate |
Compute the relativistic electric dipole moment.
p = -(gamma / c^2) * v x m gamma = 1 / sqrt(1 - (v/c)^2)
For v near c, uses the ultra-relativistic limit: p = -v x m / c^2
Definition at line 481 of file MagneticDipole.hpp.
|
inlineprivate |
Get acceleration at a time offset in the past.
Definition at line 516 of file MagneticDipole.hpp.
|
inline |
Definition at line 436 of file MagneticDipole.hpp.
|
inlineprivate |
Get electric dipole moment at a time offset in the past.
Definition at line 530 of file MagneticDipole.hpp.
|
inline |
Definition at line 274 of file MagneticDipole.hpp.
|
inlineoverridevirtual |
Get the electric field at a point.
For stationary dipoles, uses the static electric dipole formula: E = k_E * (3 * (p dot hat_r) * hat_r - p) / r^3 where p is the relativistic electric dipole moment.
For moving dipoles, uses retarded potentials with contributions from the electric dipole moment and its time derivatives.
| point | Position to evaluate the field (meters) |
| std::runtime_error | If point is at the dipole location |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 159 of file MagneticDipole.hpp.
|
inlineoverridevirtual |
Get the electric potential at a point.
For stationary dipoles, returns 0 (electric dipole potential is zero in the static limit).
For moving dipoles, uses the retarded potential: V = k_E * (p dot hat_R) / (R^2 * (1 - hat_R dot beta))
| point | Position to evaluate the potential (meters) |
| std::runtime_error | If point is at the dipole location or the denominator factor approaches zero |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 219 of file MagneticDipole.hpp.
|
inlineoverridevirtual |
Get the magnetic field at a point.
For stationary or slowly moving dipoles, uses the static dipole formula: B = (mu_0 / (4 * pi)) * (3 * (m dot hat_r) * hat_r - m) / r^3
For moving dipoles, uses retarded potentials with contributions from the dipole moment and its time derivatives.
| point | Position to evaluate the field (meters) |
| std::runtime_error | If point is at the dipole location |
Implements Phyth::Electromagnetics::MagneticSource.
Definition at line 101 of file MagneticDipole.hpp.
|
inlineoverridevirtual |
Get the minimum distance from a point to the dipole location.
| point | Position to compute distance from |
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 268 of file MagneticDipole.hpp.
|
inline |
Definition at line 414 of file MagneticDipole.hpp.
|
inlineprivate |
Get magnetic moment at a time offset in the past.
Definition at line 523 of file MagneticDipole.hpp.
|
inline |
Definition at line 446 of file MagneticDipole.hpp.
|
inline |
Definition at line 419 of file MagneticDipole.hpp.
|
inlineprivate |
Get position at a time offset in the past.
Definition at line 502 of file MagneticDipole.hpp.
|
inlineprivate |
Definition at line 496 of file MagneticDipole.hpp.
|
inlineoverridevirtual |
Get the total charge of the dipole.
Implements Phyth::Electromagnetics::ChargeSource.
Definition at line 257 of file MagneticDipole.hpp.
|
inlineprivate |
Get velocity at a time offset in the past.
Definition at line 509 of file MagneticDipole.hpp.
|
inlineoverridevirtualnoexcept |
Integrate dynamics using velocity Verlet.
Overrides Particle::Integrate to also update dipole orientation, moment, and history buffers.
Reimplemented from Phyth::Mechanics::Particle.
Definition at line 370 of file MagneticDipole.hpp.
|
inline |
Set the angular velocity.
Definition at line 441 of file MagneticDipole.hpp.
|
inlinenoexcept |
Set the force computation function.
| func | Function that applies forces to the dipole via ApplyForce() |
This wraps the Particle::SetComputeForcesFunction to accept MagneticDipole pointers directly.
Definition at line 80 of file MagneticDipole.hpp.
|
inline |
Set the magnetic dipole moment.
| m | New magnetic dipole moment (A*m^2) |
The initial moment is updated and the current moment is aligned with the current orientation.
Definition at line 408 of file MagneticDipole.hpp.
|
inline |
Set the moment of inertia.
Definition at line 451 of file MagneticDipole.hpp.
|
inline |
Set the orientation quaternion.
| q | The new orientation (will be normalized) |
The magnetic moment is updated to align with the new orientation.
Definition at line 430 of file MagneticDipole.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 542 of file MagneticDipole.hpp.
|
inlineprivate |
Solve for the retarded time offset using bisection method.
Fallback when Newton's method fails to converge.
Definition at line 588 of file MagneticDipole.hpp.
|
private |
Definition at line 466 of file MagneticDipole.hpp.
|
private |
Definition at line 461 of file MagneticDipole.hpp.
|
private |
Definition at line 469 of file MagneticDipole.hpp.
|
private |
Definition at line 462 of file MagneticDipole.hpp.
|
private |
Definition at line 457 of file MagneticDipole.hpp.
|
private |
Definition at line 456 of file MagneticDipole.hpp.
|
private |
Definition at line 467 of file MagneticDipole.hpp.
|
private |
Definition at line 459 of file MagneticDipole.hpp.
|
private |
Definition at line 460 of file MagneticDipole.hpp.
|
private |
Definition at line 464 of file MagneticDipole.hpp.
|
private |
Definition at line 465 of file MagneticDipole.hpp.