Gravity Models¶
Gravity acceleration functions including point-mass and spherical harmonic models.
Note
For conceptual explanations and examples, see Gravity Models in the Learn section.
Point-Mass Gravity¶
accel_point_mass_gravity builtin ¶
Compute acceleration due to point-mass gravity.
Accepts either a 3D position vector or a 6D state vector for r_object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r_object | ndarray | Position (length 3) or state (length 6) of the object. Units: (m) | required |
r_central_body | ndarray | Position vector of the central body. Units: (m) | required |
gm | float | Gravitational parameter. Units: (m³/s²) | required |
Returns:
| Type | Description |
|---|---|
ndarray | np.ndarray: Acceleration due to gravity. Units: (m/s²) |
Spherical Harmonic Gravity¶
accel_gravity_spherical_harmonics builtin ¶
accel_gravity_spherical_harmonics(r_eci: ndarray, R_i2b: ndarray, gravity_model: GravityModel, n_max: int, m_max: int) -> ndarray
Compute acceleration due to spherical harmonic gravity model.
This function computes the gravitational acceleration on an object using a spherical harmonic expansion of Earth's gravity field. It transforms the position to body-fixed coordinates, evaluates the spherical harmonics, and transforms the acceleration back to the inertial frame.
Accepts either a 3D position vector or a 6D state vector for r_eci.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r_eci | ndarray | Position (length 3) or state (length 6) in ECI frame. Units: (m) | required |
R_i2b | ndarray | Rotation matrix from ECI to body-fixed frame (3x3) | required |
gravity_model | GravityModel | Gravity model to use | required |
n_max | int | Maximum degree to evaluate (n_max <= model.n_max) | required |
m_max | int | Maximum order to evaluate (m_max <= min(n_max, model.m_max)) | required |
Returns:
| Type | Description |
|---|---|
ndarray | np.ndarray: Acceleration in ECI frame. Units: (m/s²) |
Raises:
| Type | Description |
|---|---|
Exception | If n_max or m_max exceed model limits or if m_max > n_max |
Example
Gravity Model Class¶
GravityModel ¶
Spherical harmonic gravity model for high-fidelity gravitational acceleration computation.
This class represents a spherical harmonic expansion of Earth's gravitational potential, allowing for accurate modeling of Earth's non-uniform gravity field.
Initialize instance.
compute_spherical_harmonics method descriptor ¶
Compute gravitational acceleration in body-fixed frame using spherical harmonics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r_body | ndarray | Position vector in body-fixed frame. Units: (m) | required |
n_max | int | Maximum degree to evaluate (n_max <= model.n_max) | required |
m_max | int | Maximum order to evaluate (m_max <= min(n_max, model.m_max)) | required |
Returns:
| Type | Description |
|---|---|
ndarray | np.ndarray: Acceleration in body-fixed frame. Units: (m/s²) |
Raises:
| Type | Description |
|---|---|
Exception | If n_max or m_max exceed model limits or if m_max > n_max |
from_file builtin ¶
from_file(filepath: str) -> GravityModel
Load gravity model from a .gfc file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath | str | Path to the .gfc gravity model file | required |
Returns:
| Name | Type | Description |
|---|---|---|
GravityModel | GravityModel | Loaded gravity model |
Raises:
| Type | Description |
|---|---|
Exception | If file cannot be loaded or parsed |
from_model_type builtin ¶
from_model_type(model_type: GravityModelType) -> GravityModel
Load a gravity model from a GravityModelType.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type | GravityModelType | Which model to load (packaged or from file) | required |
Returns:
| Name | Type | Description |
|---|---|---|
GravityModel | GravityModel | Loaded gravity model |
Raises:
| Type | Description |
|---|---|
Exception | If file loading fails (for FromFile variant) |
Example
get method descriptor ¶
Get spherical harmonic coefficients for a specific degree and order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n | int | Degree (0 <= n <= n_max) | required |
m | int | Order (0 <= m <= min(n, m_max)) | required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple | Tuple | (C_nm, S_nm) coefficients |
Raises:
| Type | Description |
|---|---|
Exception | If n or m are out of bounds |
set_max_degree_order method descriptor ¶
Truncate the gravity model to a smaller degree and order to save memory.
This method resizes the internal coefficient matrix in-place, discarding coefficients beyond the specified limits. This is useful when loading a high-fidelity model but only needing a lower-degree expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n | int | New maximum degree (must be <= current n_max) | required |
m | int | New maximum order (must be <= min(n, current m_max)) | required |
Raises:
| Type | Description |
|---|---|
ValueError | If m > n or if n/m exceed current model limits |
Example
Gravity Model Type¶
GravityModelType selects which spherical harmonic field is loaded into a GravityModel (or wired into a GravityConfiguration). In addition to the packaged constants EGM2008_360, GGM05S, and JGM3, two constructors load external models:
GravityModelType.from_file(path)— load any.gfcfile from disk.GravityModelType.icgem(body, name)— reference any model from the ICGEM catalog; the matching.gfcfile is downloaded into$BRAHE_CACHE/icgem/models/<body>/on first use and cached permanently.
The same GravityModelType can be passed to GravityConfiguration.spherical_harmonic(model_type=...) to use the model as the central-body field in a NumericalOrbitPropagator. For end-to-end usage examples see the ICGEM dataset guide and the Gravity Models user guide.
GravityModelType ¶
Default gravity models packaged with Brahe.
These models provide varying levels of fidelity for Earth's gravitational field. Models can either be packaged with Brahe or loaded from external files.
Initialize instance.
EGM2008_360 class-attribute ¶
EGM2008_360: Any = GravityModelType.EGM2008_360
Default gravity models packaged with Brahe.
These models provide varying levels of fidelity for Earth's gravitational field. Models can either be packaged with Brahe or loaded from external files.
GGM05S class-attribute ¶
GGM05S: Any = GravityModelType.GGM05S
Default gravity models packaged with Brahe.
These models provide varying levels of fidelity for Earth's gravitational field. Models can either be packaged with Brahe or loaded from external files.
JGM3 class-attribute ¶
JGM3: Any = GravityModelType.JGM3
Default gravity models packaged with Brahe.
These models provide varying levels of fidelity for Earth's gravitational field. Models can either be packaged with Brahe or loaded from external files.
from_file staticmethod ¶
from_file(filepath: str) -> GravityModelType
Load a custom gravity model from a file.
Validates that the file exists before returning the model type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath | str | Path to the gravity model file in GFC format. | required |
Returns:
| Name | Type | Description |
|---|---|---|
GravityModelType | GravityModelType | Gravity model type for loading from file. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If the file does not exist. |
IsADirectoryError | If the path is a directory, not a file. |
icgem staticmethod ¶
icgem(body: str, name: str) -> GravityModelType
Build a GravityModelType referencing an ICGEM model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body | str | Body name ("earth", "moon", "mars", "venus", "ceres", or other). | required |
name | str | Model name, optionally with | required |
Returns:
| Name | Type | Description |
|---|---|---|
GravityModelType | GravityModelType | A new GravityModelType referencing the ICGEM model. |
See Also¶
- Gravity Models (Learn) - Conceptual explanation and examples
- ICGEM Dataset Interface (Learn) - Discovering and downloading ICGEM models
- ICGEM Functions API -
brahe.datasets.icgemAPI reference - Force Models (Learn) - Using a gravity model in a numerical propagator
- Orbital Dynamics Module - Complete orbit dynamics API reference