Spacecraft Models Package 2.0
Spacecraft Models for DSim
Public Member Functions | Protected Attributes | List of all members
gravity_spice Class Reference

SPICE library ephemeris interface class. More...

#include <gravity_spice.h>

Inherits dsim_model.

Public Member Functions

 gravity_spice (dsim_model_setup *setup)
 Constructor.
 
 ~gravity_spice ()
 Destructor.
 
void * describe_setup (void *ds)
 Describe the setup data.
 
bool parse_setup (const char *command, const char *data)
 Parse input setup commands. More...
 
void initialize_data ()
 Initialize the model data. More...
 
void initialization_complete ()
 Finish initialization. More...
 
void initialize_timestep ()
 Computations done prior to numerical integration. More...
 
void rhs (double t, double jd)
 Right hand side.
 
void complete_timestep ()
 Computations done after numerical integration.
 

Protected Attributes

dsim_variable parent_mass
 mass of parent object
 
dsim_variable parent_pos
 position of parent object
 
dsim_variable parent_vel
 velocity of parent object
 

Outputs

dsim_variable n_files
 Number of SPK kernel files loaded.
 
dsim_variable planet_index
 Matrix storing NAIF integer IDs of targets.
 
dsim_variable positionBody
 Matrix for storing positions of bodies.
 
dsim_variable velocityBody
 Matrix for storing velocities of bodies.
 
dsim_variable radiusBody
 Matrix for storing radii of bodies

 
dsim_variable rotationMatrixBody
 Matrix for storing rotation of bodies

 
dsim_variable angularRateVectorBody
 Matrix for storing rotation rate vector of bodies

 
dsim_variable muBody_dsim
 Matrix for storing mu

 
dsim_variable accel
 Matrix for storing acceleration (3x1)
 
dsim_variable observer
 NAIF integer ID of observer, defaults to sun (10)

 

Detailed Description

SPICE library ephemeris interface class.

Compute gravity for planets specified by using the SPICE ephemeris routines. Maintains an index to the center body and treats the others as perturbations. This model must be a direct child of the object subject to gravity. Makes available ephemeris data including the position, velocity, and radius of the bodies.

As with all PSS gravity models, for the purposes of gravitional acceleration computation the spacecraft position vector $\mathbf{r}$ is considered to be sum of the spacecraft position vector and the center of mass vector:

\[ \mathbf{r} = position + \mathbf{A} (center\_mass) / 1000 \]

In this equation, $\mathbf{A}$ is the rotation matrix from body coordinates to ECI, produced from the parent quaternion.

This routine loads SPICE ephemeris and uses it to compute the acceleration on the parent object due to gravity.

This provides an interface to load SPK files and get body states using the SPICE library function spkgeo_c. The DSim epoch in Julian Date is assumed to be in Terrestrial DT.

Bodies are referred to by their NAIF integer IDs. The planet barycenters have low IDs, i.e. 0 - solar system, 1 - Mercury, 3 - Earth/Moon, 10 - sun. The planets themselves are the 99th body of the barycenter, i.e. Mercury - 199, Earth - 399, Moon - 301. Spacecraft have negative IDs.

Built-in inertial frames are J2000 (Earth mean equator and equinox of J2000 frame), and ECLIPJ2000 (Mean ecliptic and equinox of J2000).

This model requires access to the leapsecond kernel, naif0008.tls, at the root level. This file is in effect until at least December 31, 2008.

SPICE toolkit from NAIF http://naif.jpl.nasa.gov/naif/

Member Function Documentation

◆ parse_setup()

bool gravity_spice::parse_setup ( const char *  command,
const char *  data 
)

Parse input setup commands.

Parses AddBody and AddCenter lines and adds planets to the linked list.

The AddBody command is followed by the planet name or ID, for example:

AddBody Sun, or AddBody 10

AddCenter Earth, or AddCenter 399

AddBody Jupiter

A separate line is required for each planet.

Adding a planet causes a set of published variables to be added to the model, including:

  • Planet_Pos
  • Planet_Vel
  • Planet_Rad
  • Planet_RangeRate
  • Planet_Min_Range

A frame may be selected using SetFrame. The available frames are

  • ECLIPJ2000
  • J2000

At least one SPK file is required.

References n_files, and observer.

◆ initialize_data()

void gravity_spice::initialize_data ( )

Initialize the model data.

String for SPICE frame, name, i.e. "J2000" or "ECLIPJ2000"

References accel, angularRateVectorBody, muBody_dsim, n_files, observer, planet_index, positionBody, radiusBody, rotationMatrixBody, and velocityBody.

◆ initialization_complete()

void gravity_spice::initialization_complete ( )

Finish initialization.

Initialize SPICE.

This includes loading the leapseconds kernel and planetary constants in the files:

  • naif0008.tls
  • pck00008.tpc
  • Gravity.tpc

Internal matrices are initialized to the correct size and the planetary constants are stored in local variables.

References angularRateVectorBody, muBody_dsim, n_files, observer, parent_mass, parent_pos, parent_vel, planet_index, positionBody, radiusBody, rotationMatrixBody, and velocityBody.

◆ initialize_timestep()

void gravity_spice::initialize_timestep ( )

Computations done prior to numerical integration.

Step the ephemeris at the beginning of the timestep.

SJT: better to update every intermediate step for big timesteps? Loop through the planet IDs and make a call to the SPICE library for each target. Use the current DSim Julian Date as the epoch. If no files have been loaded, output zero.

References planet_index.


The documentation for this class was generated from the following files: