naginterfaces.library.ode.ivp_rkts_onestep¶
- naginterfaces.library.ode.ivp_rkts_onestep(f, n, comm, data=None)[source]¶
ivp_rkts_onestep
is a one-step function for solving an initial value problem for a first-order system of ordinary differential equations using Runge–Kutta methods.For full information please refer to the NAG Library document for d02pf
https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/d02/d02pff.html
- Parameters
- fcallable yp = f(t, y, data=None)
must evaluate the functions (that is the first derivatives ) for given values of the arguments , .
- Parameters
- tfloat
, the current value of the independent variable.
- yfloat, ndarray, shape
The current values of the dependent variables, , for .
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- ypfloat, array-like, shape
The values of , for .
- nint
, the number of ordinary differential equations in the system to be solved.
- commdict, communication object, modified in place
Communication structure.
This argument must have been initialized by a prior call to
ivp_rkts_setup()
.- dataarbitrary, optional
User-communication data for callback functions.
- Returns
- tnowfloat
, the value of the independent variable at which a solution has been computed.
- ynowfloat, ndarray, shape
An approximation to the solution at . The local error of the step to was no greater than permitted by the specified tolerances (see
ivp_rkts_setup()
).- ypnowfloat, ndarray, shape
An approximation to the first derivative of the solution at .
- Raises
- NagValueError
- (errno )
, as specified in the setup function, has already been reached. To start a new problem, you will need to call the setup function. To continue integration beyond then
ivp_rkts_reset_tend()
must first be called to reset to a new end value.- (errno )
A call to this function cannot be made after it has returned an error.
The setup function must be called to start another problem.
- (errno )
On entry, a previous call to the setup function has not been made or the communication arrays have become corrupted.
- (errno )
On entry, , but the value passed to the setup function was .
- (errno )
On entry, the communication arrays have become corrupted, or a catastrophic error has already been detected elsewhere. You cannot continue integrating the problem.
- Warns
- NagAlgorithmicWarning
- (errno )
More than output points have been obtained by integrating to (as specified in the setup function). They have been so clustered that it would probably be (much) more efficient to use the interpolation function (if , switch to at setup). However, you can continue integrating the problem.
- (errno )
Approximately function evaluations have been used to compute the solution since the integration started or since this message was last printed. However, you can continue integrating the problem.
- (errno )
Approximately function evaluations have been used to compute the solution since the integration started or since this message was last printed. Your problem has been diagnosed as stiff. If the situation persists, it will cost roughly times as much to reach (setup) as it has cost to reach the current time. You should probably call functions intended for stiff problems. However, you can continue integrating the problem.
- (errno )
Your problem has been diagnosed as stiff. If the situation persists, it will cost roughly times as much to reach (setup) as it has cost to reach the current time. You should probably call functions intended for stiff problems. However, you can continue integrating the problem.
- (errno )
In order to satisfy your error requirements the solver has to use a step size of at the current time, . This step size is too small for the machine precision, and is smaller than .
- (errno )
The global error assessment may not be reliable for times beyond .
The integration is being terminated.
- (errno )
The global error assessment algorithm failed at start of integration.
The integration is being terminated.
- Notes
ivp_rkts_onestep
and its associated functions (ivp_rkts_setup()
,ivp_rkts_reset_tend()
,ivp_rkts_interp()
,ivp_rkts_diag()
andivp_rkts_errass()
) solve an initial value problem for a first-order system of ordinary differential equations. The functions, based on Runge–Kutta methods and derived from RKSUITE (see Brankin et al. (1991)), integratewhere is the vector of solution components and is the independent variable.
ivp_rkts_onestep
is designed to be used in complicated tasks when solving systems of ordinary differential equations. You must first callivp_rkts_setup()
to specify the problem and how it is to be solved. Thereafter you (repeatedly) callivp_rkts_onestep
to take one integration step at a time from in the direction of (as specified inivp_rkts_setup()
). In this mannerivp_rkts_onestep
returns an approximation to the solution and its derivative at successive points . Ifivp_rkts_onestep
encounters some difficulty in taking a step, the integration is not advanced and the function returns with the same values of , and as returned on the previous successful step.ivp_rkts_onestep
tries to advance the integration as far as possible subject to passing the test on the local error and not going past .In the call to
ivp_rkts_setup()
you can specify either the first step size forivp_rkts_onestep
to attempt or that it computes automatically an appropriate value. Thereafterivp_rkts_onestep
estimates an appropriate step size for its next step. This value and other details of the integration can be obtained after any call toivp_rkts_onestep
by a call toivp_rkts_diag()
. The local error is controlled at every step as specified inivp_rkts_setup()
. If you wish to assess the true error, you must set to a positive value in the call toivp_rkts_setup()
. This assessment can be obtained after any call toivp_rkts_onestep
by a call toivp_rkts_errass()
.If you want answers at specific points there are two ways to proceed:
The more efficient way is to step past the point where a solution is desired, and then call
ivp_rkts_interp()
to get an answer there. Within the span of the current step, you can get all the answers you want at very little cost by repeated calls toivp_rkts_interp()
. This is very valuable when you want to find where something happens, e.g., where a particular solution component vanishes. You cannot proceed in this way with or .The other way to get an answer at a specific point is to set to this value and integrate to .
ivp_rkts_onestep
will not step past , so when a step would carry it past, it will reduce the step size so as to produce an answer at exactly. After getting an answer there (), you can reset to the next point where you want an answer, and repeat. could be reset by a call toivp_rkts_setup()
, but you should not do this. You should useivp_rkts_reset_tend()
instead because it is both easier to use and much more efficient. This way of getting answers at specific points can be used with any of the available methods, but it is the only way with or . It can be inefficient. Should this be the case, the code will bring the matter to your attention.
- References
Brankin, R W, Gladwell, I and Shampine, L F, 1991, RKSUITE: A suite of Runge–Kutta codes for the initial value problems for ODEs, SoftReport 91-S1, Southern Methodist University