C++ Module: sphericalHarmonicsGravityModel

class SphericalHarmonicsGravityModel : public GravityModel
#include <sphericalHarmonicsGravityModel.h>

The Spherical Harmonics gravity model

Public Functions

std::optional<std::string> initializeParameters() override

Initialize all parameters necessary for the computation of gravity.

The attributes muBodyand radEquator must be set separately.

Will return an error message (string) if cBar or sBar were not set. Otherwise, returns an empty optional.

std::optional<std::string> initializeParameters(const GravBodyData &body) override

Initialize the gravity model from the body parameters.

The attribute radEquator is kept if it is positive, for example when it was loaded from the coefficient file, since the normalized coefficients are only valid with the reference radius of their model. Otherwise, it is read from the radEquator of the given GravBodyData.

The attribute muBody is replaced by body.mu, which must be finite and positive so the field and other gravity consumers use the same parameter.

Parameters:

body – Gravity body supplying the gravitational parameter and fallback reference radius.

Returns:

An error message if body.mu is invalid or cBar or sBar were not set; otherwise, an empty optional.

Eigen::Vector3d computeField(const Eigen::Vector3d &position_planetFixed) const override

Returns the gravity acceleration at a position around this body.

The position is given in the body-fixed reference frame. Likewise, the resulting acceleration should be given in the body-fixed reference frame.

Eigen::Vector3d computeField(const Eigen::Vector3d &position_planetFixed, size_t degree, bool include_zero_degree) const

Returns the gravity acceleration at a position around this body.

The position is given in the body-fixed reference frame. Likewise, the resulting acceleration should be given in the body-fixed reference frame.

If the given degree is smaller than the maximum degree stored in this class, then the field is computed using only degrees up to degree. If the requested degree is higher than the available one, an error is thrown.

If include_zero_degree is false the degree that corresponds to the spherical term (point-mass) of the gravity is ignored.

double computePotentialEnergy(const Eigen::Vector3d &positionWrtPlanet_N) const override

Returns the gravitational potential energy at a position around this body.

The current implementation returns the potential energy of a point-mass (the spherical harmonics coefficients of the body are ignored)

The position is given relative to the body and in the inertial reference frame.

bool dependsOnOrientation() const override

Returns true if any retained coefficient of order >= 1 (a tesseral or sectoral term) is non-zero. Such terms vary with the body’s longitude, so the body orientation must be known to evaluate them correctly. A purely zonal field (only order-0 terms, e.g. a J2-only model) returns false.

Public Members

double radEquator = 0

[m] Reference radius of the spherical harmonics coefficients

double muBody = 0

[m^3/s^2] Gravitation parameter for the planet

size_t maxDeg = 0

The maximum degree of Spherical Harmonics to use

A value of maxDeg greater than the size of cBar or sBar will cause an error. A value that is lower will truncate the spherical harmonics, ignoring any parameters in cBar/sBar with degree greater than maxDeg.

std::vector<std::vector<double>> cBar

The normalized “C” spherical harmonics coefficients

std::vector<std::vector<double>> sBar

The normalized “S” spherical harmonics coefficients

mutable BSKLogger bskLogger

BSK Logging.

Private Members

mutable std::vector<std::vector<double>> aBar

The following parameters are used internally to compute the gravity.

They are coefficients used in the method of Pines for the gravity due to SH. For their definition, see the ‘Basilisk-GravityEffector’ documentation. [-] Eq. 61

std::vector<std::vector<double>> n1

[-] Eq. 63

std::vector<std::vector<double>> n2

[-] Eq. 64

std::vector<std::vector<double>> nQuot1

[-] Eq. 79

std::vector<std::vector<double>> nQuot2

[-] Eq. 80