Open PeterXiaoGuo opened 5 years ago
Transferred from docs to DelayDiffEq.jl. @devmotion do you think it might be a weird instability issue related to https://github.com/JuliaDiffEq/DelayDiffEq.jl/issues/67 ?
Hmm.... It seems the provided example errors since S(t)S(t-tau_ext)
becomes negative and hence it's not possible to compute the square root of this term anymore. I guess that's also the reason for the lines you commented out (BTW they are not correct since you try to write complex values to a vector of real numbers)?
First of all, it would be interesting to see your MATLAB implementation, if that's possible. Did you consider possibly negative values of S(t)S(t-tau_ext)
therein (e.g. by specifying that S
should be non-negative)? Or did you just constrain the step size?
Actually, a bit more than one year ago I worked with a DDE that was also not defined for negative values. You can find a Julia implementation of it here, and you can also have a look at simulations with different solvers. As you can see in the Julia implementation, I set the derivatives of variables that should be non-negative to max(0, dxdt)
, following Shampine's advice. In my case, this implementation together with a suitable algorithm such as Rodas5
was sufficient to be able to compute simulations of my model reliably. However, you might want to have a look at isoutofdomain
and the PositiveDomain
callback, which are explained in the documentation. Another approach (which might be a bit more elegant) could be to enforce the positivity of S
by considering the dynamics of a new variable T = f(S)
instead of the dynamics of S
, where f
is a bijective function and T
is unconstrained, contrary to S
.
Thanks for your reply! @devmotion Actually, S(t) has a physical meaning - it's photon density. Therefore, it cannot be negative. the lines you commented out is an naive attempt to let program runs and it fails. I will try your advice and update how 's it going in Julia.
Thanks, Peter
Dear All,
I'm involved to simulate a result from a dynamic model in laser to match with measured experimental results and I fail to obtain expected result in Matlab (using dde23, ddesd). Therefore, I transfer to use Julia and face a problem as well (cannot even let laser lasing...)
The model describes an optical feedback effect back in laser and the model (rate euqations) are described here, on page 581 for this paper: https://www.osapublishing.org/aop/abstract.cfm?URI=aop-7-3-570 and this is a screenshot for the rate equation:
The three differential equations above the the photon density, carrier density and phase changing with time.
$$\tau_{ext}$$ is the time-dependent lag in a harmonic motion: $$2L/c + 2lambda/c * sin(2\pi f t)$$
below is the code I write in Julia and refer to official example on documentation: `
but I cannot get the result even as matlab did from this dynamic model (rate euqation).
Below is the matlab simulation result (simulated by ddesd solver):
Even the above beautiful waveform is not the same as what I simulate from a steady-state equation (derived from rate equation above), which looks like this:
In experiment, we can observe the tilt and sharp fringes like the picture above and this is the expectation.
I appreciate guys who replied to my previous problem and specially for Chris who replied me in email.
I have make my effort during this vacation and try to avoid any trivial mistake and till now I cannot figure out what is the problem behind. I cannot understand why matlab gives different simulation results as well.
Any help is appreciated and for this issue, I think Julia DDE solver for this laser model doesn't work for some reasons.
Thank you very much! Xiao