Metric

template<typename T>
class Metric

The base class of all kinds of metrics.

Subclassed by sbody::Hayward< T >, sbody::Kerr< T >, sbody::KerrNewman< T >, sbody::KerrTaubNUT< T >, sbody::PostNewtonian< T >, sbody::ReissnerNordstrom< T >, sbody::Schwarzschild< T >

Public Functions

virtual std::string name() const = 0

Return the name of the metric.

Returns:

name of the metric.

virtual int metricTensor(const boost::numeric::ublas::bounded_vector<T, 8> &position, boost::numeric::ublas::bounded_matrix<T, 4, 4> &metric) const = 0

Calculate the metric tensor at position, stored in metric.

Parameters:
  • position – 4 dimensional vector

  • metric – matrix with size 4×4

Returns:

status

template<typename VecExp1, typename VecExp2>
inline T dotProduct(const boost::numeric::ublas::bounded_vector<T, 8> &position, const VecExp1 &x, const VecExp2 &y, bool include_time) const

Dot product of vector x and y at position. \(g_{\mu\nu}x^\mu y^\nu\).

Parameters:
  • position – 4 dimensional vector, position to calcuate the dot product of x and y.

  • x – 4 dimensional vector

  • y – 4 dimensional vector

  • include_time – include time related terms if true.

Returns:

result

virtual T distanceSquare(const boost::numeric::ublas::bounded_vector<T, 8> &x, const boost::numeric::ublas::bounded_vector<T, 8> &y, bool include_time) const = 0

Calculate the square of the distance between x and y at x. \(g_{\mu\nu}(x^\mu-y^\mu)(x^\nu-y^\nu)\).

Parameters:
  • x – 8 dimensional vector

  • y – 8 dimensional vector

Returns:

result

inline int localInertialFrame(const boost::numeric::ublas::bounded_vector<T, 8> &position, TimeSystem time, boost::numeric::ublas::bounded_matrix<T, 4, 4> &coordinate) const

Calculate the local inertial frame coordinate of the object at position, stored in coordinate.

Parameters:
  • position – 8 dimensional vector

  • time – time systme of the object

  • coordinate – matrix with size 4×4

Returns:

status

virtual int lagrangianToHamiltonian(boost::numeric::ublas::bounded_vector<T, 8> &y) const = 0

Convert the coordinate system from Lagrangian to Hamiltonian.

Parameters:

y – 8 dimensional vector

Returns:

status

virtual int hamiltonianToLagrangian(boost::numeric::ublas::bounded_vector<T, 8> &y) const = 0

Convert the coordinate system from Hamiltonian to Lagrangian.

Parameters:

y – 8 dimensional vector

Returns:

status

virtual int angularMomentumCarterConstantToAlphaBeta(T l, T q2, T cos_theta, T sin_theta, T &alpha, T &abs_beta) const = 0

Convert the photon constants \((l,q^2)\) to the apparent position \((\alpha,\beta)\) at the observer.

Each metric implements its own relation; the base class returns \(\mathrm{NOT\_IMPLEMENTED}\).

Parameters:
  • l – specific angular momentum

  • q2 – Carter constant divided by \(E^2\)

  • cos_theta – cosine of the observer polar angle

  • sin_theta – sine of the observer polar angle

  • alpha – apparent position in the first screen direction

  • abs_beta – absolute value of the apparent position in the second screen direction

Returns:

status

virtual int fastTrace(const T r_observer, const T theta_observer, const T sin_theta_observer, const T cos_theta_observer, const T r_object, const T theta_object, const T phi_object, T &alpha, T &beta, boost::numeric::ublas::bounded_vector<T, 8> &photon, T &photon_time, T absolute_accuracy, T relative_accuracy, const InfraContext &infra_context) const = 0

Trace the photon from the observer to the target, using elliptic integrals.

Parameters:
  • r_observer – radius of the observer, \(r_\text{obs}\).

  • theta_observer – theta of the observer, \(\theta_\text{obs}\).

  • sin_theta_observer – sin(theta_observer), \(\sin\theta_\text{obs}\).

  • cos_theta_observer – cos(theta_observer), \(\cos\theta_\text{obs}\).

  • r_object – radius of the target, \(r_\text{tar}\).

  • theta_object – theta of the target, \(\theta_\text{tar}\).

  • phi_object – phi of the target, \(\phi_\text{tar}\).

  • alpha – x position of the target in the observer’s view.

  • beta – y position of the target in the observer’s view.

  • photon – 8 dimensional vector, position and the velocity of the photon traced to the target.

  • photon_time – look back time of the photon.

  • absolute_accuracy – absolute accuracy for the trace.

  • relative_accuracy – relative accuracy for the trace.

  • infra_context – context for log and output.

Returns:

status

virtual T energy(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const = 0

Calculate the energy of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

virtual T angularMomentum(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const = 0

Calculate the angular momentum of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

virtual T carterConstant(const boost::numeric::ublas::bounded_vector<T, 8> &y, const T mu2, TimeSystem time, DynamicalSystem dynamics) const = 0

Calculate the Carter constant of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T dopplerFactor(const boost::numeric::ublas::bounded_vector<T, 8> &y, const boost::numeric::ublas::bounded_vector<T, 8> &photon_position, TimeSystem object_time, TimeSystem photon_time) const

Calculate the Doppler factor of the object, \(g=1/(1+z)=E_\text{obs}/E_\text{emit}\).

Parameters:
  • y – 8 dimensional vector of the object

  • photon – photon traced to the object

  • object_time – time system of the object

  • photon_time – time system of the photon

Returns:

result

inline T redshift(const boost::numeric::ublas::bounded_vector<T, 8> &y, const boost::numeric::ublas::bounded_vector<T, 8> &photon_position, TimeSystem object_time, TimeSystem photon_time) const

Calculate the redshift \(1+z=E_\text{emit}/E_\text{obs}\).

Parameters:
  • y – 8 dimensional vector of the object

  • photon – photon traced to the object

  • object_time – time system of the object

  • photon_time – time system of the photon

Returns:

result

virtual int normalizeTimelikeGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y) const = 0

Normalize the timelike geodesic.

Parameters:

y – 8 dimensional vector

Returns:

status

virtual int normalizeNullGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y, T frequency = 1.) const = 0

Normalize the null geodesic.

The 8-vector follows TimeSystem::T: y[4] = dlambda/dt. The affine rate frequency must be positive (future-directed); it is not the photon energy.

Parameters:
  • y – 8 dimensional vector

  • frequency – affine rate dlambda/dt (> 0)

Returns:

status

virtual int getIntegrationSystem(std::function<void(const boost::numeric::ublas::bounded_vector<T, 8>&, boost::numeric::ublas::bounded_vector<T, 8>&, T)> &system, TimeSystem time, DynamicalSystem dynamics, MotionMode motion = MotionMode::GEODESIC) const = 0

Get the integration system to calculate the motion of the object.

Parameters:
  • time – time system of the object

  • dynamics – dynamical system of the object

  • motion – motion mode of the object

Returns:

integrator system

Newton & Post-Newtonian

Warning

doxygenclass: Cannot find class “sbody::Newton” in doxygen xml output for project “SBody” from directory: ../doxygen

template<typename T>
class PN1 : public sbody::PostNewtonian<T>

Public Functions

inline virtual std::string name() const override

Return the name of the metric.

Returns:

name of the metric.

inline virtual int getIntegrationSystem(std::function<void(const boost::numeric::ublas::bounded_vector<T, 8>&, boost::numeric::ublas::bounded_vector<T, 8>&, T)> &system, TimeSystem time, DynamicalSystem dynamics, MotionMode motion = MotionMode::GEODESIC) const override

Get the integration system to calculate the motion of the object.

Parameters:
  • time – time system of the object

  • dynamics – dynamical system of the object

  • motion – motion mode of the object

Returns:

integrator system

Schwarzschild

template<typename T>
class Schwarzschild : public sbody::Metric<T>
\[\begin{split}g_{\mu\nu}=\begin{pmatrix}-1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1\end{pmatrix}\end{split}\]

Reissner-Nördstrom

template<typename T>
class ReissnerNordstrom : public sbody::Metric<T>

Public Functions

inline virtual std::string name() const override

Return the name of the metric.

Returns:

name of the metric.

inline virtual int angularMomentumCarterConstantToAlphaBeta(T l, T q2, T cos_theta, T sin_theta, T &alpha, T &abs_beta) const override

Convert the photon constants \((l,q^2)\) to the apparent position \((\alpha,\beta)\) at the observer.

Each metric implements its own relation; the base class returns \(\mathrm{NOT\_IMPLEMENTED}\).

Parameters:
  • l – specific angular momentum

  • q2 – Carter constant divided by \(E^2\)

  • cos_theta – cosine of the observer polar angle

  • sin_theta – sine of the observer polar angle

  • alpha – apparent position in the first screen direction

  • abs_beta – absolute value of the apparent position in the second screen direction

Returns:

status

inline virtual int metricTensor(const boost::numeric::ublas::bounded_vector<T, 8> &position, boost::numeric::ublas::bounded_matrix<T, 4, 4> &metric) const override

Calculate the metric tensor at position, stored in metric.

Parameters:
  • position – 4 dimensional vector

  • metric – matrix with size 4×4

Returns:

status

inline virtual T distanceSquare(const boost::numeric::ublas::bounded_vector<T, 8> &x, const boost::numeric::ublas::bounded_vector<T, 8> &y, bool include_time) const override

Calculate the square of the distance between x and y at x. \(g_{\mu\nu}(x^\mu-y^\mu)(x^\nu-y^\nu)\).

Parameters:
  • x – 8 dimensional vector

  • y – 8 dimensional vector

Returns:

result

inline virtual int lagrangianToHamiltonian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Lagrangian to Hamiltonian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int hamiltonianToLagrangian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Hamiltonian to Lagrangian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int fastTrace(const T r_observer, const T theta_observer, const T sin_theta_observer, const T cos_theta_observer, const T r_object, const T theta_object, const T phi_object, T &alpha, T &beta, boost::numeric::ublas::bounded_vector<T, 8> &photon, T &photon_time, T absolute_accuracy, T relative_accuracy, const InfraContext &infra_context) const override

Trace the photon from the observer to the target, using elliptic integrals.

Parameters:
  • r_observer – radius of the observer, \(r_\text{obs}\).

  • theta_observer – theta of the observer, \(\theta_\text{obs}\).

  • sin_theta_observer – sin(theta_observer), \(\sin\theta_\text{obs}\).

  • cos_theta_observer – cos(theta_observer), \(\cos\theta_\text{obs}\).

  • r_object – radius of the target, \(r_\text{tar}\).

  • theta_object – theta of the target, \(\theta_\text{tar}\).

  • phi_object – phi of the target, \(\phi_\text{tar}\).

  • alpha – x position of the target in the observer’s view.

  • beta – y position of the target in the observer’s view.

  • photon – 8 dimensional vector, position and the velocity of the photon traced to the target.

  • photon_time – look back time of the photon.

  • absolute_accuracy – absolute accuracy for the trace.

  • relative_accuracy – relative accuracy for the trace.

  • infra_context – context for log and output.

Returns:

status

inline virtual T energy(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the energy of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T angularMomentum(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the angular momentum of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T carterConstant(const boost::numeric::ublas::bounded_vector<T, 8> &y, const T mu2, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the Carter constant of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual int normalizeTimelikeGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Normalize the timelike geodesic.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int normalizeNullGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y, T frequency = 1.) const override

Normalize the null geodesic.

The 8-vector follows TimeSystem::T: y[4] = dlambda/dt. The affine rate frequency must be positive (future-directed); it is not the photon energy.

Parameters:
  • y – 8 dimensional vector

  • frequency – affine rate dlambda/dt (> 0)

Returns:

status

inline virtual int getIntegrationSystem(std::function<void(const boost::numeric::ublas::bounded_vector<T, 8>&, boost::numeric::ublas::bounded_vector<T, 8>&, T)> &system, TimeSystem time, DynamicalSystem dynamics, MotionMode motion = MotionMode::GEODESIC) const override

Get the integration system to calculate the motion of the object.

Parameters:
  • time – time system of the object

  • dynamics – dynamical system of the object

  • motion – motion mode of the object

Returns:

integrator system

Kerr

template<typename T>
class Kerr : public sbody::Metric<T>

Public Functions

inline virtual std::string name() const override

Return the name of the metric.

Returns:

name of the metric.

inline virtual int angularMomentumCarterConstantToAlphaBeta(T l, T q2, T cos_theta, T sin_theta, T &alpha, T &abs_beta) const override

Convert the photon constants \((l,q^2)\) to the apparent position \((\alpha,\beta)\) at the observer.

Each metric implements its own relation; the base class returns \(\mathrm{NOT\_IMPLEMENTED}\).

Parameters:
  • l – specific angular momentum

  • q2 – Carter constant divided by \(E^2\)

  • cos_theta – cosine of the observer polar angle

  • sin_theta – sine of the observer polar angle

  • alpha – apparent position in the first screen direction

  • abs_beta – absolute value of the apparent position in the second screen direction

Returns:

status

inline virtual int metricTensor(const boost::numeric::ublas::bounded_vector<T, 8> &position, boost::numeric::ublas::bounded_matrix<T, 4, 4> &metric) const override

Calculate the metric tensor at position, stored in metric.

Parameters:
  • position – 4 dimensional vector

  • metric – matrix with size 4×4

Returns:

status

inline virtual T distanceSquare(const boost::numeric::ublas::bounded_vector<T, 8> &x, const boost::numeric::ublas::bounded_vector<T, 8> &y, bool include_time) const override

Calculate the square of the distance between x and y at x. \(g_{\mu\nu}(x^\mu-y^\mu)(x^\nu-y^\nu)\).

Parameters:
  • x – 8 dimensional vector

  • y – 8 dimensional vector

Returns:

result

inline virtual int lagrangianToHamiltonian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Lagrangian to Hamiltonian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int hamiltonianToLagrangian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Hamiltonian to Lagrangian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int fastTrace(const T r_observer, const T theta_observer, const T sin_theta_observer, const T cos_theta_observer, const T r_object, const T theta_object, const T phi_object, T &alpha, T &beta, boost::numeric::ublas::bounded_vector<T, 8> &photon, T &photon_time, T absolute_accuracy, T relative_accuracy, const InfraContext &infra_context) const override

Trace the photon from the observer to the target, using elliptic integrals.

Parameters:
  • r_observer – radius of the observer, \(r_\text{obs}\).

  • theta_observer – theta of the observer, \(\theta_\text{obs}\).

  • sin_theta_observer – sin(theta_observer), \(\sin\theta_\text{obs}\).

  • cos_theta_observer – cos(theta_observer), \(\cos\theta_\text{obs}\).

  • r_object – radius of the target, \(r_\text{tar}\).

  • theta_object – theta of the target, \(\theta_\text{tar}\).

  • phi_object – phi of the target, \(\phi_\text{tar}\).

  • alpha – x position of the target in the observer’s view.

  • beta – y position of the target in the observer’s view.

  • photon – 8 dimensional vector, position and the velocity of the photon traced to the target.

  • photon_time – look back time of the photon.

  • absolute_accuracy – absolute accuracy for the trace.

  • relative_accuracy – relative accuracy for the trace.

  • infra_context – context for log and output.

Returns:

status

inline virtual T energy(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the energy of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T angularMomentum(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the angular momentum of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T carterConstant(const boost::numeric::ublas::bounded_vector<T, 8> &y, const T mu2, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the Carter constant of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual int normalizeTimelikeGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Normalize the timelike geodesic.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int normalizeNullGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y, T frequency = 1.) const override

Normalize the null geodesic.

The 8-vector follows TimeSystem::T: y[4] = dlambda/dt. The affine rate frequency must be positive (future-directed); it is not the photon energy.

Parameters:
  • y – 8 dimensional vector

  • frequency – affine rate dlambda/dt (> 0)

Returns:

status

inline virtual int getIntegrationSystem(std::function<void(const boost::numeric::ublas::bounded_vector<T, 8>&, boost::numeric::ublas::bounded_vector<T, 8>&, T)> &system, TimeSystem time, DynamicalSystem dynamics, MotionMode motion = MotionMode::GEODESIC) const override

Get the integration system to calculate the motion of the object.

Parameters:
  • time – time system of the object

  • dynamics – dynamical system of the object

  • motion – motion mode of the object

Returns:

integrator system

Kerr-Newman

template<typename T>
class KerrNewman : public sbody::Metric<T>

Public Functions

inline virtual std::string name() const override

Return the name of the metric.

Returns:

name of the metric.

inline virtual int angularMomentumCarterConstantToAlphaBeta(T l, T q2, T cos_theta, T sin_theta, T &alpha, T &abs_beta) const override

Convert the photon constants \((l,q^2)\) to the apparent position \((\alpha,\beta)\) at the observer.

Each metric implements its own relation; the base class returns \(\mathrm{NOT\_IMPLEMENTED}\).

Parameters:
  • l – specific angular momentum

  • q2 – Carter constant divided by \(E^2\)

  • cos_theta – cosine of the observer polar angle

  • sin_theta – sine of the observer polar angle

  • alpha – apparent position in the first screen direction

  • abs_beta – absolute value of the apparent position in the second screen direction

Returns:

status

inline virtual int metricTensor(const boost::numeric::ublas::bounded_vector<T, 8> &position, boost::numeric::ublas::bounded_matrix<T, 4, 4> &metric) const override

Calculate the metric tensor at position, stored in metric.

Parameters:
  • position – 4 dimensional vector

  • metric – matrix with size 4×4

Returns:

status

inline virtual T distanceSquare(const boost::numeric::ublas::bounded_vector<T, 8> &x, const boost::numeric::ublas::bounded_vector<T, 8> &y, bool include_time) const override

Calculate the square of the distance between x and y at x. \(g_{\mu\nu}(x^\mu-y^\mu)(x^\nu-y^\nu)\).

Parameters:
  • x – 8 dimensional vector

  • y – 8 dimensional vector

Returns:

result

inline virtual int lagrangianToHamiltonian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Lagrangian to Hamiltonian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int hamiltonianToLagrangian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Hamiltonian to Lagrangian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int fastTrace(const T r_observer, const T theta_observer, const T sin_theta_observer, const T cos_theta_observer, const T r_object, const T theta_object, const T phi_object, T &alpha, T &beta, boost::numeric::ublas::bounded_vector<T, 8> &photon, T &photon_time, T absolute_accuracy, T relative_accuracy, const InfraContext &infra_context) const override

Trace the photon from the observer to the target, using elliptic integrals.

Parameters:
  • r_observer – radius of the observer, \(r_\text{obs}\).

  • theta_observer – theta of the observer, \(\theta_\text{obs}\).

  • sin_theta_observer – sin(theta_observer), \(\sin\theta_\text{obs}\).

  • cos_theta_observer – cos(theta_observer), \(\cos\theta_\text{obs}\).

  • r_object – radius of the target, \(r_\text{tar}\).

  • theta_object – theta of the target, \(\theta_\text{tar}\).

  • phi_object – phi of the target, \(\phi_\text{tar}\).

  • alpha – x position of the target in the observer’s view.

  • beta – y position of the target in the observer’s view.

  • photon – 8 dimensional vector, position and the velocity of the photon traced to the target.

  • photon_time – look back time of the photon.

  • absolute_accuracy – absolute accuracy for the trace.

  • relative_accuracy – relative accuracy for the trace.

  • infra_context – context for log and output.

Returns:

status

inline virtual T energy(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the energy of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T angularMomentum(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the angular momentum of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T carterConstant(const boost::numeric::ublas::bounded_vector<T, 8> &y, const T mu2, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the Carter constant of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual int normalizeTimelikeGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Normalize the timelike geodesic.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int normalizeNullGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y, T frequency = 1.) const override

Normalize the null geodesic.

The 8-vector follows TimeSystem::T: y[4] = dlambda/dt. The affine rate frequency must be positive (future-directed); it is not the photon energy.

Parameters:
  • y – 8 dimensional vector

  • frequency – affine rate dlambda/dt (> 0)

Returns:

status

inline virtual int getIntegrationSystem(std::function<void(const boost::numeric::ublas::bounded_vector<T, 8>&, boost::numeric::ublas::bounded_vector<T, 8>&, T)> &system, TimeSystem time, DynamicalSystem dynamics, MotionMode motion = MotionMode::GEODESIC) const override

Get the integration system to calculate the motion of the object.

Parameters:
  • time – time system of the object

  • dynamics – dynamical system of the object

  • motion – motion mode of the object

Returns:

integrator system

Kerr-Taub-NUT

template<typename T>
class KerrTaubNUT : public sbody::Metric<T>

Public Functions

inline virtual std::string name() const override

Return the name of the metric.

Returns:

name of the metric.

inline virtual int angularMomentumCarterConstantToAlphaBeta(T l, T q2, T cos_theta, T sin_theta, T &alpha, T &abs_beta) const override

Convert the photon constants \((l,q^2)\) to the apparent position \((\alpha,\beta)\) at the observer.

Each metric implements its own relation; the base class returns \(\mathrm{NOT\_IMPLEMENTED}\).

Parameters:
  • l – specific angular momentum

  • q2 – Carter constant divided by \(E^2\)

  • cos_theta – cosine of the observer polar angle

  • sin_theta – sine of the observer polar angle

  • alpha – apparent position in the first screen direction

  • abs_beta – absolute value of the apparent position in the second screen direction

Returns:

status

inline virtual int metricTensor(const boost::numeric::ublas::bounded_vector<T, 8> &position, boost::numeric::ublas::bounded_matrix<T, 4, 4> &metric) const override

Calculate the metric tensor at position, stored in metric.

Parameters:
  • position – 4 dimensional vector

  • metric – matrix with size 4×4

Returns:

status

inline virtual T distanceSquare(const boost::numeric::ublas::bounded_vector<T, 8> &x, const boost::numeric::ublas::bounded_vector<T, 8> &y, bool include_time) const override

Calculate the square of the distance between x and y at x. \(g_{\mu\nu}(x^\mu-y^\mu)(x^\nu-y^\nu)\).

Parameters:
  • x – 8 dimensional vector

  • y – 8 dimensional vector

Returns:

result

inline virtual int lagrangianToHamiltonian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Lagrangian to Hamiltonian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int hamiltonianToLagrangian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Hamiltonian to Lagrangian.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int fastTrace(const T r_observer, const T theta_observer, const T sin_theta_observer, const T cos_theta_observer, const T r_object, const T theta_object, const T phi_object, T &alpha, T &beta, boost::numeric::ublas::bounded_vector<T, 8> &photon, T &photon_time, T absolute_accuracy, T relative_accuracy, const InfraContext &infra_context) const override

Trace the photon from the observer to the target, using elliptic integrals.

Parameters:
  • r_observer – radius of the observer, \(r_\text{obs}\).

  • theta_observer – theta of the observer, \(\theta_\text{obs}\).

  • sin_theta_observer – sin(theta_observer), \(\sin\theta_\text{obs}\).

  • cos_theta_observer – cos(theta_observer), \(\cos\theta_\text{obs}\).

  • r_object – radius of the target, \(r_\text{tar}\).

  • theta_object – theta of the target, \(\theta_\text{tar}\).

  • phi_object – phi of the target, \(\phi_\text{tar}\).

  • alpha – x position of the target in the observer’s view.

  • beta – y position of the target in the observer’s view.

  • photon – 8 dimensional vector, position and the velocity of the photon traced to the target.

  • photon_time – look back time of the photon.

  • absolute_accuracy – absolute accuracy for the trace.

  • relative_accuracy – relative accuracy for the trace.

  • infra_context – context for log and output.

Returns:

status

inline virtual T energy(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the energy of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T angularMomentum(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the angular momentum of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual T carterConstant(const boost::numeric::ublas::bounded_vector<T, 8> &y, const T mu2, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the Carter constant of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

inline virtual int normalizeTimelikeGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Normalize the timelike geodesic.

Parameters:

y – 8 dimensional vector

Returns:

status

inline virtual int normalizeNullGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y, T frequency = 1.) const override

Normalize the null geodesic.

The 8-vector follows TimeSystem::T: y[4] = dlambda/dt. The affine rate frequency must be positive (future-directed); it is not the photon energy.

Parameters:
  • y – 8 dimensional vector

  • frequency – affine rate dlambda/dt (> 0)

Returns:

status

inline virtual int getIntegrationSystem(std::function<void(const boost::numeric::ublas::bounded_vector<T, 8>&, boost::numeric::ublas::bounded_vector<T, 8>&, T)> &system, TimeSystem time, DynamicalSystem dynamics, MotionMode motion = MotionMode::GEODESIC) const override

Get the integration system to calculate the motion of the object.

Parameters:
  • time – time system of the object

  • dynamics – dynamical system of the object

  • motion – motion mode of the object

Returns:

integrator system

Hayward

template<typename T>
class Hayward : public sbody::Metric<T>

Public Functions

virtual std::string name() const override

Return the name of the metric.

Returns:

name of the metric.

inline virtual int angularMomentumCarterConstantToAlphaBeta(T l, T q2, T cos_theta, T sin_theta, T &alpha, T &abs_beta) const override

Convert the photon constants \((l,q^2)\) to the apparent position \((\alpha,\beta)\) at the observer.

Each metric implements its own relation; the base class returns \(\mathrm{NOT\_IMPLEMENTED}\).

Parameters:
  • l – specific angular momentum

  • q2 – Carter constant divided by \(E^2\)

  • cos_theta – cosine of the observer polar angle

  • sin_theta – sine of the observer polar angle

  • alpha – apparent position in the first screen direction

  • abs_beta – absolute value of the apparent position in the second screen direction

Returns:

status

virtual int metricTensor(const boost::numeric::ublas::bounded_vector<T, 8> &position, boost::numeric::ublas::bounded_matrix<T, 4, 4> &metric) const override

Calculate the metric tensor at position, stored in metric.

Parameters:
  • position – 4 dimensional vector

  • metric – matrix with size 4×4

Returns:

status

virtual T distanceSquare(const boost::numeric::ublas::bounded_vector<T, 8> &x, const boost::numeric::ublas::bounded_vector<T, 8> &y, bool include_time) const override

Calculate the square of the distance between x and y at x. \(g_{\mu\nu}(x^\mu-y^\mu)(x^\nu-y^\nu)\).

Parameters:
  • x – 8 dimensional vector

  • y – 8 dimensional vector

Returns:

result

virtual int lagrangianToHamiltonian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Lagrangian to Hamiltonian.

Parameters:

y – 8 dimensional vector

Returns:

status

virtual int hamiltonianToLagrangian(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Convert the coordinate system from Hamiltonian to Lagrangian.

Parameters:

y – 8 dimensional vector

Returns:

status

virtual T energy(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the energy of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

virtual T angularMomentum(const boost::numeric::ublas::bounded_vector<T, 8> &y, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the angular momentum of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

virtual T carterConstant(const boost::numeric::ublas::bounded_vector<T, 8> &y, const T mu2, TimeSystem time, DynamicalSystem dynamics) const override

Calculate the Carter constant of the object.

Parameters:
  • y – 8 dimensional vector

  • time – time system of the object

  • dynamics – dynamical system of the object

Returns:

result

virtual int normalizeTimelikeGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y) const override

Normalize the timelike geodesic.

Parameters:

y – 8 dimensional vector

Returns:

status

virtual int normalizeNullGeodesic(boost::numeric::ublas::bounded_vector<T, 8> &y, T frequency = 1.) const override

Normalize the null geodesic.

The 8-vector follows TimeSystem::T: y[4] = dlambda/dt. The affine rate frequency must be positive (future-directed); it is not the photon energy.

Parameters:
  • y – 8 dimensional vector

  • frequency – affine rate dlambda/dt (> 0)

Returns:

status

virtual int getIntegrationSystem(std::function<void(const boost::numeric::ublas::bounded_vector<T, 8>&, boost::numeric::ublas::bounded_vector<T, 8>&, T)> &system, TimeSystem time, DynamicalSystem dynamics, MotionMode motion = MotionMode::GEODESIC) const override

Get the integration system to calculate the motion of the object.

Parameters:
  • time – time system of the object

  • dynamics – dynamical system of the object

  • motion – motion mode of the object

Returns:

integrator system