Utility
-
double SBody::absolute_accuracy = 1e-15
Global absolute accuracy.
-
double SBody::relative_accuracy = 1e-15
Global relative accuracy.
-
constexpr long double SBody::M_2PI = 6.28318530717958647692528676655900576l
\(2\pi\).
-
constexpr long double SBody::M_PI2 = 9.86960440108935861883449099987615111l
\(\pi^2\).
-
constexpr long double SBody::M_SQRT27 = 5.19615242270663188058233902451761710l
\(\sqrt{27}\)
-
constexpr long double SBody::EPSILON = 1e-10l
Epsilon, a small value. \(\varepsilon\).
-
constexpr long double SBody::SIN_EPSILON = 1e-10l
\(\sin\varepsilon\).
-
constexpr long double SBody::COS_EPSILON = 0.999999999999999999995l
\(\cos\varepsilon\).
-
constexpr long double SBody::EPSILON_CIRCLE_AREA = M_PI * GSL_DBL_EPSILON
Area of a circle with radius of GSL_SQRT_DBL_EPSILON. \(\pi\varepsilon^2\).
-
constexpr int SBody::SAMPLE_NUMBER = 100
Sample number.
-
constexpr long double SBody::ANGLE_INTERVAL = M_2PI / SAMPLE_NUMBER
The angle corresponding to the sample number.
-
constexpr long double SBody::EPSILON_POLYGON_AREA = 0.06279051952931337 / ANGLE_INTERVAL * EPSILON_CIRCLE_AREA
Area of the regular polygon with SAMPLE_NUMBER edges.
Integrator
-
class Integrator
A wrapper of the gsl_odeiv2_evolve.
Public Functions
-
inline Integrator(int (*function)(double, const double*, double*, void*), int (*jacobian)(double, const double*, double*, double*, void*), void *params = nullptr, const gsl_odeiv2_step_type *type = gsl_odeiv2_step_rk8pd)
Construct a new Integrator object.
- Parameters:
function – The function calculates
\[\frac{\mathrm dy_i(t)}{\mathrm dt}=f_i\left[t,y_1(t),\dots,y_n(t)\right].\]jacobian – The jacobian of the function
\[J_{ij}=\frac{\partial f_i\left[t,y(t)\right]}{\partial y_j}.\]params – The parameters passed to the function, like the PN parameter, or the spin of the black hole.
type – Type of the algorithms. Explicit embedded Runge-Kutta Prince-Dormand (8, 9) method is set by default.
-
inline ~Integrator()
Destructor.
-
inline int Apply(double *t, long double t1, double *h, double *y)
gsl_odeiv2_evolve_apply
.- Parameters:
t – time.
t1 – maximum time not to be exceeded by the time step.
h – step size.
y – values of the integrated system.
- Returns:
status
-
inline int ApplyStep(double *t, long double t1, double *h, double *y)
gsl_odeiv2_evolve_apply
.- Parameters:
t – time.
t1 – maximum time not to be exceeded by the time step.
h – step size.
y – values of the integrated system.
- Returns:
status
-
inline int ApplyFixedStep(double *t, const long double h, double *y)
gsl_odeiv2_evolve_apply_fixed_step
.- Parameters:
t – time.
h – step size.
y – values of the integrated system.
- Returns:
status
-
inline int Reset()
Resets the evolution function and the stepping function.
- Returns:
status
-
int CheckCoordinate(long double *y)
- Parameters:
y –
- Returns:
status
-
inline Integrator(int (*function)(double, const double*, double*, void*), int (*jacobian)(double, const double*, double*, double*, void*), void *params = nullptr, const gsl_odeiv2_step_type *type = gsl_odeiv2_step_rk8pd)
Solver
-
class Solver
Subclassed by SBody::DerivativeSolver
DerivativeSolver
-
class DerivativeSolver : public SBody::Solver
MultiSolver
-
class MultiSolver
Subclassed by SBody::MultiDerivativeSolver, SBody::MultiFunctionSolver
MultiFunctionSolver
-
class MultiFunctionSolver : public SBody::MultiSolver
MultiDerivativeSolver
-
class MultiDerivativeSolver : public SBody::MultiSolver
GslBlock
-
class GslBlock
A wrapper of the
gsl_vector
,gsl_matrix
, andgsl_permutation
.Public Functions
-
~GslBlock()
Destructor.
-
gsl_vector *VectorAlloc(size_t n)
gsl_vector_alloc
, creates a vector of lengthn
- Parameters:
n – length of the vector
- Returns:
pointer
-
gsl_vector *VectorCalloc(size_t n)
gsl_vector_calloc
, creates a vector of lengthn
and initializes all the elements of the vector to zero.- Parameters:
n – length of the vector
- Returns:
pointer
-
gsl_vector *VectorAllocFromBlock(gsl_block *block, const size_t offset, const size_t n, const size_t stride = 1)
gsl_vector_alloc_from_block
, creates a vector as a slice of an existingblock
.- Parameters:
block – target block
offset – offset to the data block
n – length of the vector
stride – step-size of the vector
- Returns:
pointer
-
gsl_vector *VectorAllocRowFromMatrix(gsl_matrix *matrix, const size_t i)
gsl_vector_alloc_row_from_matrix
, allocates a newgsl_vector
which points to thei
-th row of thematrix
.- Parameters:
matrix – target matrix
i – row index
- Returns:
pointer
-
gsl_vector *VectorAllocColFromMatrix(gsl_matrix *matrix, const size_t j)
gsl_vector_alloc_col_from_matrix
, allocates a newgsl_vector
which points to thej
-th column of thematrix
.- Parameters:
matrix – target matrix
j – column index
- Returns:
pointer
-
gsl_matrix *MatrixAlloc(size_t n1, size_t n2)
gsl_matrix_alloc
, creates a matrix of sizen1
rows byn2
columns.- Parameters:
n1 – rows of the matrix
n2 – columns of the matrix
- Returns:
pointer
-
gsl_matrix *MatrixCalloc(size_t n1, size_t n2)
gsl_matrix_alloc
, creates a matrix of sizen1
rows byn2
columns and initializes all the elements of the matrix to zero- Parameters:
n1 – rows of the matrix
n2 – columns of the matrix
- Returns:
pointer
-
gsl_permutation *PermutationAlloc(size_t n)
gsl_permutation_alloc
, allocates memory for a new permutation of sizen
- Parameters:
n – size of the permutation
- Returns:
pointer
-
gsl_permutation *PermutationCalloc(size_t n)
gsl_permutation_alloc
, allocates memory for a new permutation of sizen
and initializes it to the identity- Parameters:
n – size of the permutation
- Returns:
pointer
-
~GslBlock()
Math
Warning
doxygenfunction: Unable to resolve function “SBody::Dot” with arguments (const double[], const double[], size_t) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> Type Dot(const Type x[], const Type y[], size_t dimension = 3)
- template<typename Type> Type Dot(const Type x[], size_t dimension = 3)
Warning
doxygenfunction: Unable to resolve function “SBody::Dot” with arguments (const double[], size_t) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> Type Dot(const Type x[], const Type y[], size_t dimension = 3)
- template<typename Type> Type Dot(const Type x[], size_t dimension = 3)
Warning
doxygenfunction: Unable to resolve function “SBody::Norm” with arguments None in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type, std::size_t N> Type Norm(const std::array<Type, N> &x)
- template<typename Type> Type Norm(const Type x[], size_t dimension = 3)
-
template<typename Type>
int SBody::Cross(const Type x[], const Type y[], Type z[]) Cross product of vector
x
andy
, stored inz
. \(\vec{z}=\vec{x}\times\vec{y}\).- Parameters:
x – 3 dimensional vector
y – 3 dimensional vector
z – 3 dimensional vector
- Returns:
status
-
template<typename Type>
Type SBody::DotCross(const Type x[], const Type y[], const Type z[]) Dot product of vector
x
and the cross product of vectory
and vectorz
. \(\vec{x}\cdot(\vec{y}\times\vec{z})\).- Parameters:
x – 3 dimensional vector
y – 3 dimensional vector
z – 3 dimensional vector
- Returns:
result
Warning
doxygenfunction: Unable to resolve function “SBody::TriangleArea” with arguments (double, double, double) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> Type TriangleArea(const std::array<Type, 3> &x, const std::array<Type, 3> &y, const std::array<Type, 3> &z)
Warning
doxygenfunction: Unable to resolve function “SBody::TriangleArea” with arguments (const double[], const double[], const double[]) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> Type TriangleArea(const std::array<Type, 3> &x, const std::array<Type, 3> &y, const std::array<Type, 3> &z)
-
template<typename Type>
int SBody::RotateAroundAxis(Type x[], Axis axis, Type angle) Rotate vector
x
around theaxis
byangle
.- Parameters:
x – 3 dimensional vector
axis – the rotation axis.
angle – in rad
- Returns:
status
Warning
doxygenfunction: Unable to resolve function “SBody::CartesianToSpherical” with arguments (const double[], double[], size_t) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> int CartesianToSpherical(Type x[], size_t dimension = 8)
- template<typename Type> int CartesianToSpherical(const Type cartesian[], Type spherical[], size_t dimension = 8)
Warning
doxygenfunction: Unable to resolve function “SBody::CartesianToSpherical” with arguments (double[], size_t) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> int CartesianToSpherical(Type x[], size_t dimension = 8)
- template<typename Type> int CartesianToSpherical(const Type cartesian[], Type spherical[], size_t dimension = 8)
Warning
doxygenfunction: Unable to resolve function “SBody::SphericalToCartesian” with arguments (const double[], double[], size_t) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> int SphericalToCartesian(Type x[], size_t dimension = 8)
- template<typename Type> int SphericalToCartesian(const Type spherical[], Type cartesian[], size_t dimension = 8)
Warning
doxygenfunction: Unable to resolve function “SBody::SphericalToCartesian” with arguments (double[], size_t) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> int SphericalToCartesian(Type x[], size_t dimension = 8)
- template<typename Type> int SphericalToCartesian(const Type spherical[], Type cartesian[], size_t dimension = 8)
-
template<typename Type>
int SBody::OppositeSign(Type x, Type y) Return
1
ifx
,y
have opposite signs, else0
.- Parameters:
x – number
y – number
- Returns:
result
Warning
doxygenfunction: Unable to resolve function “SBody::MapTheta” with arguments None in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> int MapTheta(const Type theta_0, Type y[])
- template<typename Type> int MapTheta(const Type theta_0, double y[])
-
template<typename Type>
Type SBody::ModBy2Pi(Type phi) Return
phi
in \([0, 2\pi)\).- Parameters:
phi – \(\phi\)
- Returns:
result
-
template<typename Type>
Type SBody::PhiDifference(Type phi) Similar to
ModBy2Pi
, but returnphi
in \([-\pi, \pi)\).- Parameters:
phi – \(\phi\)
- Returns:
result
Warning
doxygenfunction: Unable to resolve function “SBody::LinearInterpolation” with arguments (double, double, double, double, double) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> Type LinearInterpolation(Type x, Type x0, Type x1, Type y0, Type y1)
- template<typename Type> int LinearInterpolation(Type x, Type x0, Type x1, const Type y0[], const Type y1[], Type y[], size_t size)
Warning
doxygenfunction: Unable to resolve function “SBody::LinearInterpolation” with arguments (double, double, double, const double[], const double[], double[], size_t) in doxygen xml output for project “SBody” from directory: ../doxygen. Potential matches:
- template<typename Type> Type LinearInterpolation(Type x, Type x0, Type x1, Type y0, Type y1)
- template<typename Type> int LinearInterpolation(Type x, Type x0, Type x1, const Type y0[], const Type y1[], Type y[], size_t size)
-
template<typename Type>
int SBody::InterpolateSphericalPositionToCartesian(Type t, Type t0, Type t1, const Type y0[], const Type y1[], Type y[]) Linear interpolation of two spherical positions
y0
andy1
att
, stored iny
.\[y=\frac{\text{SphericalToCartesian}(y_0)(t_1-t)+\text{SphericalToCartesian}(y_1)(t-t_0)}{t_1-t_0}\]- Parameters:
t – time to evaluate \(y\)
t0 – \(t_0\)
t1 – \(t_1\)
y0 – 8 dimensional vector, spherical, \(y_0\)
y1 – 8 dimensional vector, spherical, \(y_1\)
y – 8 dimensional vector, cartesian, \(y\)
- Returns:
status
-
template<typename Type>
Type SBody::Flux(Type luminosity, Type magnification, Type redshift) Calculate the bolometric flux. The result is.
\[F_\text{obs}=\frac{L_\text{src}}{(1+z)^2}\frac{\Omega_\text{src}}{\Omega_\text{obs}}.\]The additional \((1+z)^{-1}\) comes from the expansion of the frequency that \((1+z)^{-1}=\frac{\nu_\text{obs}}{\nu_\text{src}}\).- Parameters:
luminosity – intrinsic luminosity of the source, \(L_\text{src}\)
magnification – magnification of the source, including the relativistic redshift and beaming, and gravitational lensing. \(\frac{\Omega_\text{src}}{(1+z)\Omega_\text{obs}}\)
redshift – relativistic redshift of the source, \(1+z\)
- Returns:
result
-
template<typename Type>
Type SBody::FluxDensity(Type spectral_density, Type magnification) Calculate the flux density. The result is.
\[F_{\nu,\text{obs}}=\frac{L_{\nu,\text{src}}}{1+z}\frac{\Omega_\text{src}}{\Omega_\text{obs}}.\]- Parameters:
spectral_density – intrinsic spectral density of the source, \(L_{\nu,\text{src}}\)
magnification – magnification of the source, including the relativistic redshift and beaming, and gravitational lensing. \(\frac{\Omega_\text{src}}{(1+z)\Omega_\text{obs}}\)
- Returns:
result
Elliptic Integrals
Calculate the elliptic integrals using the Legendre forms. Further information can be found in GSL Manual, Carlson (1988), Carlson (1989), Carlson (1991), and Carlson (1992).
-
template<typename Type>
Type SBody::EllipticIntegral(int p5, Type y, Type x, Type a5, Type b5, Type a1, Type b1, Type a2, Type b2, Type a3, Type b3, Type a4 = 1., Type b4 = 0.)
-
template<typename Type>
Type SBody::EllipticIntegral2Complex(int p5, Type y, Type x, Type a5, Type b5, Type f, Type g, Type h, Type a1, Type b1, Type a4 = 1., Type b4 = 0.)
-
template<typename Type>
Type SBody::EllipticIntegral4Complex(int p5, Type y, Type x, Type a5, Type b5, Type f1, Type g1, Type h1, Type f2, Type g2, Type h2)
Warning
doxygenfunction: Cannot find function “SBody::Carlson_RC” in doxygen xml output for project “SBody” from directory: ../doxygen
Warning
doxygenfunction: Cannot find function “SBody::Carlson_RJ” in doxygen xml output for project “SBody” from directory: ../doxygen