tudat-team / tudat-space

An introduction and guide to tudat-space.
https://tudat-space.readthedocs.io
14 stars 17 forks source link

Behavior of extrapolation integrators #117

Closed alopezrivera closed 1 year ago

alopezrivera commented 1 year ago

Hi! First of all, thank you for all the work put into the library! It's very much appreciated.

I have run into some behavior when attempting to create fixed-step size extrapolation sequence integrators using Tudat.


Table of contents:

  1. Initial step size not respected unless setting large tolerances
  2. Effect of maximum_factor_increase and minimum_factor_increase
  3. Suggestions to improve the documentation

Initial step size not respected unless setting large tolerances

I first attempted to constrain the step size used by the extrapolation sequence integrators by setting the initial_time_step, maximum_step_size and minimum_step_size equal to my desired, fixed step size, as follows:

# Create integrator settings
integrator = propagation_setup.integrator

integrator_settings = integrator.bulirsch_stoer(
    initial_time_step        = step_size,
    extrapolation_sequence   = integrator_coefficient_set,
    maximum_number_of_steps  = 3,
    minimum_step_size        = step_size,
    maximum_step_size        = step_size)

Doing this causes an error however, because the integrators will not use the provided initial_time_step unless the relative_error_tolerance and absolute_error_tolerance are set to large values (np.inf, see the solution below).

While the main Tudat library site instructs us to do this1 to force the integrators to use a constant step size, this behavior is rather unintuitive and could be changed or better documented, as currently

For the sake of completeness, the desired behavior can be achieved as follows:

# Create integrator settings
integrator = propagation_setup.integrator

integrator_settings = integrator.bulirsch_stoer(
    initial_time_step        = step_size,
    extrapolation_sequence   = integrator_coefficient_set,
    maximum_number_of_steps  = 3,
    minimum_step_size        = step_size,
    maximum_step_size        = step_size,
    relative_error_tolerance = np.inf,
    absolute_error_tolerance = np.inf)

Effect of maximum_factor_increase and minimum_factor_increase

I attempted to force the extrapolation integrators to use a constant step size as well by setting the maximum_factor_increase and minimum_factor_increase to 1.0, as follows.

# Create integrator settings
integrator = propagation_setup.integrator

integrator_settings = integrator.bulirsch_stoer(
    initial_time_step        = step_size,
    extrapolation_sequence   = integrator_coefficient_set,
    maximum_number_of_steps  = 3,
    maximum_factor_increase  = 1.0,
    minimum_factor_increase  = 1.0)

This did not have the desired effect, but it did seem to somewhat constrain the step sizes used by the integrators, as can be seen in the figures below:

figure 4 figure 3

While I can understand that these factors could be used for the intermediate steps instead, I could find no information in the API documentation on extrapolation integrators that could explain how the large step size changes seen in figure above come to be, and why the step size would stabilize to an almost constant value as it does.

Suggestions to improve the documentation

Thank you very much for your time and have a nice day!

References

DominicDirkx commented 1 year ago

Hi Antonio,

Thanks a lot for this suggestion! We've added new function to the develop branch of tudatpy:

https://github.com/tudat-team/tudatpy/commit/294b28703881f151ee9dec6be15ac6052f5cb702

which can be used to create fixed-step BS integrators, and fixed-step and/or fixed-order ABM integrators. The following changes to tudat were made:

https://github.com/tudat-team/tudat/commit/4f70741686d33964ce7fe8071a2becf4db5da6e9 https://github.com/tudat-team/tudat/commit/4329896221d951ccaced8a472e065c91fae98ae1 (fix of the fix)

Docs are not yet updated, but will be done next. Thanks for the suggestion on this, it was much needed!