Closed drsaroj closed 4 years ago
Next, I want to collect all solutions in a text file having three columns(in this case) where the 1st column is time steps, 2nd for prey population and 3rd for the predator population. Given examples only gives the dependent states eg. prey and predator. Although we know the time steps as we have given in for loop.
I am not exactly sure what you want, but you can always get the current time of the integrator by DDE.t
(if DDE
is your integrator object).
You are not really asking a question here, but yes this is possible. I won’t write the entire code for you, but from the JiTCDDE side, the following may be relevant:
You can either compute the entire solution first and then detect local extrema or you can do this on the fly, which is more tedious, since you have to keep track of the past. Alternatively you can use get_state
and determine whether the cubic Hermite interpolant has a local maximum and use this (which will be a bit more precise).
Also, you can avoid compiling for every parameter value using set_parameters
, but you have to address initial continuities every time you do.
Most of this is a simple Python problem though, so I suggest that you get a bit more familiar with it first.
The solver given by Thompson and Shampine has event locator facility inbuilt. Is there anything like this in jitcxde where it can be used for impulsive differential equation solution.
No. However in case of a simple threshold criterion, you can rather easily build this yourself by applying get_state
and determining when the interpolation of the last two points crosses the threshold.
Traceback (most recent call last):
File "mine.py", line 99, in
atol: 1.000000e-18 rtol: 1.000000e-15 min_step: 1.000000e-10
The system actually has solutions but yet in spite of modifying the tolerance value, the integrator is unable to solve it. mine.txt
Your values for atol
and rtol
are very low. In fact rtol
is close to the relative representation accuracies of (double-precision floating-point) numbers. Therefore it is not surprising that your integration failed. Do you also have issues with the default values? Apart from that, it’s hard to say anything without your code.
Yes I got the error when default values of tolerance was there, that is why I changed it to current value. Moreover, the code is attached as text file "mine.txt", please check the previous massage.
Your dynamics is happening on a time scale that is too small for the standard settings of step_on_discontinuities
. You can fix this with DDE.step_on_discontinuities(max_step=0.01)
(and not adjusting the integration parameters otherwise).
Thank you for your comment. Now it is working perfectly.
My problem is the following:
I want to solve a system of DDEs say for example 2D prey-predator model with some given initial function in interval [0, Tf].
Next, I want to collect all solutions in a text file having three columns(in this case) where the 1st column is time steps, 2nd for prey population and 3rd for the predator population. Given examples only gives the dependent states eg. prey and predator. Although we know the time steps as we have given in for loop.
my second problem is for bifurcation diagram, where I want to collect all the maximum points in consecutive three points taken for each iterate and for each dependent variable in whole time sapce and at a partcular value of parameter 'p' i.e.
say y1(t_i) represent the solution of the system at ith time step. y1'=f1(y1(t),y2(t),y1(t-tau1),y2(t-tau2),p) y2'=f2(y1(t),y2(t),y1(t-tau1),y2(t-tau2),p) at p, then program should do the following
Finally, my second file should contain the 1st column as p and the second column as values c i.e. y1 which is maximum in the selected three points. If there is no maximum for given i, it should go to the next value of i till the last point without printing p and c.