XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ dverka()

void dverka ( int  n,
void(*)(int, double, double *, double *)  f,
double *  t,
double  y[],
double  tout,
double  tend,
double  tol,
int  mode,
double  work[],
int  lwork,
int  iwork[],
int  liwork,
int *  info 
)

Initial value problem of ordinary differential equations (6(5)-th order Runge-Kutta-Verner method)

Purpose
This program integrates a system of first order ordinary differential equations of the form
dy/dt = f(t, y), y = y0 at t = t0
where y is the n vector and the system consists of n equations. t0 and y0 are the given initial values of t and y, respectively.
This program is the rewrite of the 6(5)-th order Runge-Kutta-Verner program DVERK (Reference (1)) by adding a dense output function using the interpolation formula of Enright et al. (Reference (2)).
Parameters
[in]nNumber of differential equations. (n >= 1)
[in]fThe user supplied subroutine, which calculates the derivatives of the differential equations, defined as follows.
void f(int n, double t, const double y[], double yp[])
{
Compute dy/dt and store in yp[].
}
where n is the number of equations, and dy/dt (= f(t, y[])) is the computed derivative at given t and y[].
[in,out]tIndependent variable t. This program integrates from the initial value of t to tend. Depending on the setting of mode, this program may return at tout or every successful step to provide an intermediate result. [in] An initial value of t (t0).
[out] t = tend if the integration has been completed. t = tout or t of the latest step depending on mode in the case of intermediate return.
[in,out]y[]Array y[ly] (ly >= n)
Dependent variable y.
[in] Initial value of y (y0) at initial t (t0).
[out] The value of y (computed numerical solution) at t.
[in]toutSet tout to the point (t) at which an intermediate result is desired in mode = 2 or 3. tout is not referenced in mode = 0 or 1.
In mode 2 or 3, y at tout is computed and returned with info = 2 or 3 respectively. To continue the integration to get result at new tout, it is possible to call this program again with new tout and without changing other variables including info.
t < tout <= tend is required. However, if the integration is in backward direction, tend <= tout < t is required. If tend is reached before tout, the integration is terminated immediately and t = tend and info = 0 is returned.
[in]tendThe point at which an integration is completed. If tend is reached, the integration is terminated and t = tend and info = 0 is returned. The integration is possible for both forward (tend > t) and backward (tend < t) direction.
[in]tolError tolerance. (tol > 0)
This program attempts to control a norm of the local error in such a way that the global error is proportional to tol. The norm is a max norm with weights that depend on the error control strategy specified by iwork[11] parameter. The default weight is 1/max(1, abs(y(i))), which provides a mixture of absolute and relative error control.
[in]modeMode of operation.
This program integrates from t0 to tend. Four modes of operation are provided depending on the timing of returning imtermediate results. When tend is reached, the integration is terminated and info = 0 is returned in any of four modes. = 0: Not return until tend. tout is not referenced.
= 1: Returns at every successful step (info = 1 is returned). tout is not referenced. The end point of the last step is returned in t. In the final step, the step size is adjusted to fit into tend.
= 2: Returns at tout during the ingegration to provide an intermediate result (t = tout and info = 2 are returned). To continue the integration to get result at new tout, it is possible to call this program again with new tout. In the final step, the step size is adjusted to fit into tout.
= 3: Returns at tout during the ingegration to provide an intermediate result (t = tout and info = 3 are returned). To continue the integration to get result at new tout, it is possible to call this program again with new tout. Different from mode = 2, the value of y at tout is computed by interpolation, and the step size is not adjusted even in the last step before tout. The steps through integration are same with those of mode = 1.
[in,out]work[]Array work[lwork]
Work array.
work[0] to work[19] serve as parameters for the program. If the input parameter is set to 0, the default parameter value defined for each parameter will be used.
[in]
work[0]: Initial step size (default = hmax*tol^(1/6))
work[2]: Parameter to determine maximum step size (hmax).
hmax = min(abs(work[2]), 2/abs(scale)) (hmax = abs(work[2]) if scale = 0).
(default: hmax = 2/abs(scale) (hmax = 2 if scale = 0))
work[11]: Minimum step size (hmin). (default = 10*max(dwarf, rreb*max((weighted norm of y)/tol, abs(t))), where dwarf is a very small positive machine number (= 1.0e-50) and rreb is the relative roundoff error bound.)
work[12]: Measure of the scale of the problem (scale). (default = 1)
This parameter is used to determine hmax and to modify the acceptance criterion. Larger values of scale tend to make the method more reliable,
work[13]: Floor value used when iwork[11] = 3.
[in]lworkSize of array work[]. (abs(lwork) >= 12*n + 40)
If lwork < 0, the abs(lwork) is used, and all parameters work[0] to work[19] are cleared to 0.
[in,out]iwork[]Array iwork[liwork]
Integer work array.
iwork[0] to iwork[19] serve as parameters for the program. If the input parameter is set to 0, the default parameter value defined for each parameter will be used.
[in]
iwork[1]: Maximum number of allowed steps. (default = 10000)
iwork[11]: Error control indicator, which specifies the weights of the error estimate vector for error control. (default = 0)
= 0: weight = 1/max(1, abs(y(i))) (mixture of absolute and relative error control)
= 1: weight = 1 (absolute error control)
= 2: weight = 1/abs(y(i)) (relative error control)
= 3: weight = 1/max(abs(work[13]), abs(y(i))) (relative error control, unless abs(y(i)) is less than the floor value abs(work[13]))
iwork[12]: Specifies when counters iwork[13] to iwork[17] are reset to zero. (default = 0)
= 0: Reset if info = 0.
= 1: Do not reset even if info = 0.
[out]
Statistical information (counters).
iwork[13]: Number of function evaluations.
iwork[15]: Number of all computed steps.
iwork[16]: Number of accepted steps.
iwork[17]: Number of rejected steps.
[in]liworkSize of array iwork[]. (abs(liwork) >= 40)
If liwork < 0, the abs(liwork) is used, and all parameters iwork[0] to iwork[19] are cleared to 0.
[in,out]info[in] Control code.
= 0: Set info = 0 on the initial call to start new problem. All variables will be initialized and the computation will begin.
= 1, 2, 3: When returned with info = 1, 2 or 3, it is possible to call this program again with new tout and without changing info to continue the integration.
[out] Return code.
= 0: Successful exit. Integration to tend completed.
< 0: The (-info)-th argument is invalid.
= 1: Returned to provide intermediate result in mode = 1. It is possible to call this program again to forward to the next step.
= 2: Returned at t = tout to provide intermediate result in mode = 2. It is possible to call this program again with new tout.
= 3: Returned at t = tout to provide intermediate result in mode = 3. It is possible to call this program again with new tout.
= 11: (Error) Maximum number of steps exceeded.
= 12: (Error) Step size becomes too small.
= 13: (Error) Problem is probably stiff.
Reference
(1) netlib/ode
(2) W. H. Enright, et al.: "Interpolants for Runge-Kutta Formulas", ACM Transactions on Mathematocal Software, Vol.12, No.3. (1986)