Earth Atmosphere

Release 2.3 provides a model for the Earth’s atmosphere. This model determines the air density given a spaceship altitude and applies air resistance to the forward motion based on the density, cross sectional area, drag co-efficient and inertial mass.

There are two scenes that demonstrate the use of the Earth atmosphere model: Re-entry and Launch-Orbit (in the Scenes/Minigames folder). The simpler demonstration of the EarthAtmosphere class is the Re-entry mini-game scene. It presents a single spacecraft in an orbit that dips down close to the earth at a distance where the air resistance slows it and de-orbits the ship, bringing it crashing to Earth.

In this case the EarthAtmosphere class is attached to the spaceship directly. The inspector shows the attributes that are configured:

Earth: The NBody object that represents the Earth.

Impact Trigger: (Optional) An object with a component that implements the ImpactTrigger abstract class. The method Impact() will be called when the height of the spaceship is less than the height of the Earths surface. Typically this script will Inactivate or Remove the spaceship from GE. See the EarthImpact class for an example implementation.

Height Earth Surface: The height of the Earth surface. The scene uses Orbital units in GE, hence this value is in km.

Spaceship: (optional, if not specified the attached NBody will be assumed). The spaceship object to apply atmosphere resistance to.

Inertial Mass kg: The inertial mass of the spaceship in kg. This is used in the determination of the acceleration due to air resistance.

Cross Sectional Area: The cross sectional area in m^2 of the spaceship. In general this will vary based on the object orientation and could be updated based on that by a user provided script.

Coeef Drag: The co-efficient of drag. A dimensionless number that represents the resistance of the object based on its shape. Typically a number in the range of 2.0-2.3 (for a sphere it is about 2.1)

ImpactTrigger

The EarthAtmosphere class will invoke a callback when the spaceship reaches a height of 0 with respect the the surface of the Earth. The example provides a class EarthImpact which implements the ImpactTrigger abstract class.

Reporting Acceleration

The Re-Entry scene reports the acceleration on the ship due to air resistance. This is done by using a utility method GetAccelSI() provided by the EarthAtmosphere class:

 drag.text = string.Format(drag_format, atmosphere.GetAccelSI());

Implementation

The EarthAtmosphere class implements the interface GEExternalAcceleration. NBody objects that have a component that implements this interface are detected when the NBody is added to Gravity Engine. The interface consists of a single method:

  double[] acceleration(double time, GravityState gravityState, ref double massKg);

This callback will be triggered from within the numerical integrator during each force update in Gravity Engine. This allows the acceleration of atmosphere resistance or a rocket engine to be included in the force updates and physics integrations in the scene. Note that this routine will be called often, so taking steps to optimize the implementation is worthwhile. If trajectory prediction is enabled, then this routine will be called for both the worldState and the trajectoryState.

To reduce the amount of computation required on each call, the implementation of the Earth Atmosphere makes use a pre-computed table of density values and interpolates as necessary. The atmosphere model and code to compute the table are in the script to provide a model for users who wish to alter the class for other scenarios.