compute_magnetic#

namespace saltro
namespace orbits

Functions

bool compute_magnetic(const Eigen::Matrix<double, 3, saltro::limits::MAX_LENGTH_TRAJ> &R, const Eigen::Matrix<double, 1, saltro::limits::MAX_LENGTH_TRAJ> &jtime, const int jtime_length, const int magnetic_model, Eigen::Matrix<double, 3, saltro::limits::MAX_LENGTH_TRAJ> &B)#

Compute geomagnetic field along a trajectory using a selected model.

Dispatches magnetic field computation to one of the available geomagnetic models based on the integer selector magnetic_model.

For each trajectory sample \(k\), the magnetic field is evaluated as:

\[ \mathbf{B}_k = \mathbf{B}_{\text{model}}\!\left(\mathbf{R}_k, t_k\right) \]

where:

  • \(\mathbf{R}_k\) is the spacecraft position vector (meters),

  • \(t_k\) is the corresponding Julian time,

  • \(\mathbf{B}_k\) is the magnetic field vector (Tesla).

Supported models:

  • \(0\) → Tilted dipole approximation

  • \(1\) → IGRF-8 spherical harmonic model

  • \(2\) → IGRF-13 spherical harmonic model

The output magnetic field is written column-wise:

\[ \mathbf{B} = \begin{bmatrix} \mathbf{B}_0 & \mathbf{B}_1 & \cdots & \mathbf{B}_{N-1} \end{bmatrix} \]

This function performs model selection only; the physical computation is delegated to the corresponding model implementation.

Parameters:
  • R – Spacecraft position vectors (meters). Each column corresponds to one trajectory sample.

  • jtime – Julian time values associated with each trajectory sample.

  • jtime_length – Number of valid trajectory samples.

  • magnetic_model – Integer identifier selecting the magnetic model: 0 = tilted dipole, 1 = IGRF-8, 2 = IGRF-13.

  • B – Output magnetic field vectors (Tesla), column-wise.

Returns:

True if the selected model computation succeeds for all samples, false if the model identifier is invalid or a computation fails.