5.5. Create a Dynamics Simulator Object

At the moment, the following dynamics simulators are available or under development in Tudat:

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

The bodyMap, integratorSettigns and the propagatorSettings are binded together when the dynamicsSimulator is created as shown below:

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

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

// 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. During otherwise will result in 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.