Open jtravs opened 3 years ago
One thought: if the energy drops close to zero, so that the pulse change per step is estimated to be negligible, then the step size will dramatically increase, and hence the linear propagator might error becuase of a larger attenuation coefficient.
The reason the NaN
error is printed is just that the printing doesn't check whether the last step is ok
. So if a step fails with s.err
being NaN
, it can still be printed.
I think you're right about the energy being the problem--the field just disappears and the error estimation essentially divides by zero. I saw something similar at some point when I forgot to turn off the loss for a PCF simulation. Fundamentally I suppose the step size should go to infinity and the propagation finish instantly. Does it improve if you change the limit we apply toα
in LinearOps
?
Actually there are two potential issues aren't there: the error estimate may divide by zero and give nonsense answers (this would lead to stepsize collapse though?) or the stepsize gets too big and exp(α) is the problem.
I think you're right about the energy being the problem--the field just disappears and the error estimation essentially divides by zero.
Isn't that handled by atol
?
Isn't that handled by atol?
Yes you're right, it is.
Changing the limit on α in LinearOps.conj_clamp
to 30 (from 3000) makes the simulation run to the finish. Setting a maximum stepsize, however, does not fix it, even if it's 100 μm. (I tested this while setting the energy to a few pJ; otherwise it takes forever.)
Options to solve this I can see:
conj_clamp
user-configurable. This is relatively quick but takes trial and error for each case.conj_clamp
(or just the clamping part) from LinearOps
to RK45
. Then we could check in a place where the stepsize is available. This risks potentially silently changing the physics of the propagation, however.
Granted, these parameters are rather ridiculous (see core size), but they arose during an optimisation routine and we should probably handle this better. In fact, it ought to complete succesfully (essentially we shoudl just loose all energy).
This propagates very slowly, but seems to be working. But then it errors withs:
(the full error is included below).
I am concerned about the sudden increase in step-size in the last few steps, and that a
NaN
leaks into the printed value of the error. Looking atRK45.jl
I would have thought that this was handled at https://github.com/LupoLab/Luna/blob/8964ab0544accb4eec13e50aa74aa5e907a93f0a/src/RK45.jl#L380Before that, if we get a
NaN
ins.err
from the solver, then this should evaluate tofalse
: https://github.com/LupoLab/Luna/blob/8964ab0544accb4eec13e50aa74aa5e907a93f0a/src/RK45.jl#L178 becuase every comparison toNaN
is defined to befalse
.So I am confused what is happening here.
error.txt