Python - Scipy: ode module: problem with solver step selectability

I wanted to keep the various integration steps taken by the solver when I named it:

solver1.integrate(t_end) 

So, I made a while loop and enabled the step parameter, setting its value to True :

 while solver1.successful() and solver1.t < t0+dt: solver1.integrate(t_end,step=True) time.append(solver1.t) 

Then I draw y , the result of the integration, and here my problem arises. I have instabilities that appear in the located area:

y enabling the step option of the solver

I thought this was due to a loop or something similar, so I checked the result by removing step :

 while solver1.successful() and solver1.t < t0+dt: solver1.integrate(t_end) 

And surprise ... I have the correct result:

y disabling the step option of the solver

This is a rather strange situation ... I would be grateful if one of your guys could help me in this matter.

EDIT:

To install the solver, follow these steps:

 solver1 = ode(y_dot,jac).set_integrator('vode',with_jacobian=True) solver1.set_initial_value(x0,t0) 

And I save the result with .append()

+6
source share
1 answer

When you set step=True , you indirectly provide the vode._integrator.runner (Fortran routine) instructions for using itask=2 , and by default itask=1 . You can get more details about this runner :

 r._integrator.runner? 

In the SciPy 0.12.0 documentation you will not find an explanation of what happens for different itask=1 or itask=2 , but you can find it here :

 ITASK = An index specifying the task to be performed. ! Input only. ITASK has the following values and meanings. ! 1 means normal computation of output values of y(t) at ! t = TOUT(by overshooting and interpolating). ! 2 means take one step only and return. ! 3 means stop at the first internal mesh point at or ! beyond t = TOUT and return. ! 4 means normal computation of output values of y(t) at ! t = TOUT but without overshooting t = TCRIT. ! TCRIT must be input as RUSER(1). TCRIT may be equal to ! or beyond TOUT, but not behind it in the direction of ! integration. This option is useful if the problem ! has a singularity at or beyond t = TCRIT. ! 5 means take one step, without passing TCRIT, and return. ! TCRIT must be input as RUSER(1). 
+2
source

All Articles