3.8. Time and State Templates¶

Various classes like IntegratorSettings and TranslationalStatePropagatorSettings require inputs called StateScalarType or TimeType. These parameters are called template parameters in C++, and they are used in classes and functions to declare a special kind of parameter type (for more information on templates in C++, go here). The templates can be used to define the accuracy of the state and/or the time used in the class, which can have a large influence on the total accuracy of the simulation, as can be seen in the figure at the end of this page.

StateScalarType is used in classes which contain variables that are used to define the state of the object. This template has a default value of double. The other option for StateScalarType is long double, which, depending on your computer, has a higher accuracy then a double variable. When one of the options is chosen for a specific class, all variables that are of the StateScalarType in that class will have an accuracy which corresponds to the chosen option.

The TimeType has slightly different options. The default option is the same as for the StateScalarType, i.e. double. However, the second option is a class called Time. This class has a special way of calculating time, because of the reduction of the quality of time variables over longer periods of time. For example, when double or long double variables are used to determine the time, the accuracy of these variables will be in the order of (for a time period of 3 years) $$10^{-8}$$ or $$10^{-11}$$, respectively, which is insufficient for various applications. The Time option uses an int to keep track of the number of hours that have passed, and a long double to represent the number of seconds into the present hour. This provides a resulution of < 1 femtosecond, over a range of 2147483647 hours (about 300,000 years), which is more than sufficient for practical applications.

The most important cases where these types can be chosen are:

• In the integratorSettings class, where only the TimeType needs to be chosen. If the default value needs to be chosen, <> can be left empty.
IntegratorSettings<TimeType>()
• In the TranslationalStatePropagatorSetting class, where only the StateScalarType needs to be chosen. If the default value needs to be chosen, <> can be left empty.
TranslationalStatePropagatorSettings<StateScalarType>()
• In the SingleArcDynamicsSimulator class, where both the StateScalarType and TimeType needs to be chosen. If the default values need to be chosen, <> can be left empty.
SingleArcDynamicsSimulator<StateScalarType, TimeType>

There are other classes where these types need to be used as an input, but these are the most commonly used ones.