# 5.5. Create a Dynamics Simulator Object¶

At the moment, the following DynamicsSimulator options are available or under development in Tudat:

• Single-arc dynamics simulator.
• Multi-arc dynamics simulator.
• Hybrid dynamics simulator (under development).

These are implemented in derived classes and are discussed below.

class DynamicsSimulator

Base class from which the classes below are derived.

class SingleArcDynamicsSimulator

This derived class simulates single arc dynamics and its constructor is:

SingleArcDynamicsSimulator< StateScalarType, TimeType >( bodyMap,
integratorSettings,
propagatorSettings );


where:

• StateScalarType

Template argument used to set the precision of the state, in general double is used. For some application where a high precision is required this can be changed to e.g. :literallong double.

• TimeType

Template argument used to set the precision of the time, in general double is used. For some application where a high precision is required this can be changed to e.g. :literallong double.

• bodyMap

NamedBodyMap the map containing al the objects of type Body used in the simulation.

• integratorSettings

IntegratorSettings contains the settings of the integrator used, as discussed in Integrator Settings.

• propagatorSettings

PropagatorSettings contains the settings that defines how the orbit is propagated, as described in Propagator Settings: Basics.

class MultiArcDynamicsSimulator

This derived class allows the numerical propagation to be performed in an arc-wise manner. It is constructed using:

MultiArcDynamicsSimulator(
bodyMap,
integratorSettings,
propagatorSettings,
arcStartTimes )


where:

• arcStartTimes

std::vector< double > contains the times at which the separate arcs start.

class HybridDynamicsSimulator

Allows some bodies to be propagated in a single arc, and some in a multi-arc fashion. This has the strict requirement that the single-arc bodies’ dynamics does not depend on the multi-arc bodies. For instance, the multi-arc bodies are typically spacecraft and the single-arc bodies solar system bodies. The vehicles do not exert an acceleration on the planets, but the planets exert accelerations on the spacecraft. When using hybrid-arc propagation, the single-arc bodies are first propagated, followed by the multi-arc bodies.

Note

This feature is under development, and therefore not yet available in the current version of Tudat.

By default, the equations of motion are integrated once the object is created. This can be changed by adding additional arguments to the cosntructors of the DynamicsSimulator, as shown below for the SingleArcDynamicsSimulator:

// Create simulation object and propagate dynamics.
SingleArcDynamicsSimulator< > dynamicsSimulator(
bodyMap, integratorSettings, propagatorSettings , areEquationsOfMotionToBeIntegrated , clearNumericalSolutions , setIntegratedResult );


where:

• areEquationsOfMotionToBeIntegrated
Boolean to denote whether equations of motion should be integrated immediately at the end of the contructor or not (default true).
• clearNumericalSolutions
Boolean to determine whether to clear the raw numerical solution member variables after propagation and resetting ephemerides (default true).
• setIntegratedResult
Boolean to determine whether to automatically use the integrated results to set ephemerides (default true).

Warning

It is important to ensure that the propagator settings are compatible with the dynamics simulator type selected. Otherwise it will result in an exception being thrown during run-time.

## 5.5.1. Retrieving the propagation history¶

Once the DynamicsSimulator object has been created and the equations of motion have been integrated, the propagation history of the selected bodies is stored within the DynamicsSimulator. To make use of it using software, such history needs to be retrieved and saved to a file.

If the state propagation history needs to be saved, the following code needs to be placed after the DynamicsSimulator object creation:

// Write body propagation history to file.
writeDataMapToTextFile( dynamicsSimulator.getEquationsOfMotionNumericalSolution( ),
"bodyPropagationHistory.dat",
outputPath,
"",
std::numeric_limits< double >::digits10,
std::numeric_limits< double >::digits10,
"," );


If the dependent variable history needs to be saved, the following code needs to be placed after the DynamicsSimulator object creation:

// Write body dependent variable history to file.
writeDataMapToTextFile( dynamicsSimulator.getDependentVariableHistory( ),
"bodyDependentVariableHistory.dat",
outputPath,
"",
std::numeric_limits< double >::digits10,
std::numeric_limits< double >::digits10,
"," );


These two code snippets will save two .dat files in the folder specified by the outputPath. You can make use of the tudat_applications::getOutputPath( ) function to get a folder name relative to the project folder.