Open mapi1 opened 1 year ago
Maybe it is not so relevant for more complex problems, but would it be reasonable to reset the step size after rescaling took place?
That sounds like a great suggestion, and in fact it sounds to me that the step size should be rescaled any time a new state is set to the integrator.
I've known of the problem you quote here for unstable systems for quite some time, but haven't done anything about it yet...
So, I tried to look deeper into this and have a try at fixing this by rescaling the step size.
There are several ways to achieve this, but I settled on calling reinit!()
instead of set_state!()
.
The thing is, it did not bring a significant improvement, sticking with the above example:
I added some debug printing and found that step!()
rapidly increased dt, with much larger increments than when I solve the same problem via solve(ODEProblem(parallel_rule(ds, [0.0, 1e-9])..., (1,111), [a]), Tsit5())
. The increments are actually the same as for solving solve(ODEProblem(sys, [0.0], (1,111), [a]), Tsit5())
which has the trivial solution 0 for all t. So it seems like the adaptivity is only decided on the first variable of the ParallelDynamicalSystem
which I could further trace down to the DynamicalSystemsBase.matrixnorm
that is used as internal norm. Removing it from the ParallelDynamicalSystem(ds::CoreDynamicalSystem, states)
definition and letting DE use its default gave substantially better results:
The remaining error is related to error control and adjusting that finally gave correct results, even if the dt reset is removed and the original lyapunov()
function is used:
I did not yet figure out what's wrong with the norm, but I wanted to write down my debugging results somewhere. Maybe this issue can be closed then and a new one in DynamicalSystemsBase should be opened
Describe the bug I was testing the![Screenshot from 2023-06-16 13-31-01](https://github.com/JuliaDynamics/ChaosTools.jl/assets/44611200/de44a7c3-0136-421b-b26d-b9d2ea1e6c8b)
lyapunov()
function for the simple exponential functiondx/dt = ax
as I know it has to bea
in this case. Tough, just using the function gives some interesting results whenT > 1
is set:Debugging a little I found that the problem might be related to the adaptiveness of the solver leading to large time steps and therefore wrong results after rescaling took place. Setting![Screenshot from 2023-06-16 14-17-12](https://github.com/JuliaDynamics/ChaosTools.jl/assets/44611200/4ce0b9b0-4dad-4fd3-9a93-fed10abc4c8b)
diffeq = (alg = Tsit5(), adaptive = false, dt = 1.0)
gives correct results:Maybe it is not so relevant for more complex problems, but would it be reasonable to reset the step size after rescaling took place?
Minimal Working Example
Package versions
With Julia v1.9.0: