Are you sure ? I’ve tested your code and it does what is asked.
Beware that using integrator.setInitialStepSize changes the initial step size of the integrator (so only for the first step).
Is this what you want or do you want to change the maximum step size ?
I want to change the integration step in the middle of calculations (no matter which one)
Code works - but the step does not change
I tried to initialize a new integrator with a different step, adding all the forces - and added a new integrator to the same propagator (one propagator) - also does not work
The new propagator doesn’t work either - But there are a lot of events in my propagater, it’s better not to change it
This is not possible.
A propagator uses only one integrator and a variable step integrator manages the steps by itself, using the threshold to estimate errors and deducing next step size. There are currently no way to force a step size change at integrator level during integration.
In order to change step size, you should probably change the errors settings (i.e. the threshold) and restart propagation. For many embedded Runge-Kutta integrators like Dormand-Prince 8 (5, 3), this is not really costly, next step involve only one right hand side function evaluation less than first step (because most of these integrators are FSAL: First Same As Last). The overhead in restarting integration is mainly on initialization of events handlers, but this is ofter a small amount of computation relatively to right hand side evaluation.
If all you need is change the output step (i.e. not the internal integration step), then you could rely on a step handler that uses the interpolator, and decide by yourself when you switch to finer or broader sampling, but I am not sure this is what you need.
@luc Thank you, I knew you’d answer like that - and that’s also exactly my thoughts. Now I’m looking for a way to change the integration step - to make the calculation faster with a large integration step - and the subsequent one with a small integration step.
It is possible to break my propogator into two propagators that will be similar to everyone except the integration step and the beginning and end times. I’m still thinking
I know that Dorman Prince himself changes the integration step depending on how we set them - that’s not what I need right now.
If you need to switch just once, then set up a custom function to build the propagators taking tolerance as input parameters and call it twice to have two propagators. Then when the first one stops, use the final state as the initial state of the second one.
If you need to switch back and forth between two configurations, then set up two different NumericalPropagatorBuilder instances, one with each settings, and create the propagators as needed, each time using the final state of one propagator as the initial state of the next one.
I reckon @luc already solved your issue.
But if you’re ok with calling two successive propagate methods (as in your first example) you can use method integrator.setStepSizeControl to change the min/max step of your integrator between two consecutive propagations.
I’ve used the initial orbit from NumericalPropagation tutorial and your setup for the integration.
First propagation of 100s with initial step (step0) = 30s and max step 30s.
Second propagation of 2400s with initial step = 1s and max step 600s.
Here is the output (t0: step start date, tf: step end date, dt: step size)
Breaking the code for me is not a way out - I have a lot of lines of code and events - you will need to remember many states of one propagator to go to another