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

◆ odex2_r()

void odex2_r ( int  n,
double *  t,
double  y[],
double  yp[],
double  tout,
double *  rtol,
double *  atol,
int  itol,
int  iout,
double  work[],
int  lwork,
int  iwork[],
int  liwork,
double  rcont[],
int  lrcont,
int  icont[],
int  licont,
int *  info,
double *  tt,
double  yy[],
double  yypp[],
int *  irtrn,
int *  irev 
)

Initial value problem of ordinary differential equations (extrapolation method) (for second order differential equations) (reverse communication version)

NOTE - THIS ROUTINE IS DEPRECATED AND WILL BE REMOVED IN THE NEXT VERSION.

Purpose
This routine integrates a system of second order ordinary differential equations of the form
d2y/dt2 = f(t, y), y = y0, y' = y'0 at t = t0
where t0, y0 and y'0 are the given initial values of t, y and y', respectively. y and y' may be a vector if the above is a system of differential equations.

odex2 is an extrapolation algorithm code, based on the Stoermer's rule with step size control, order selection and dense output.

See for details in the reference below.

odex2_r is the reverse communication version of odex2.
Parameters
[in]nNumber of differential equations. (n >= 1)
[in,out]tThis routine integrates from t to tout. The initial point of the integration is to be given, and the last point of the final step will be returned.
[in] Initial value of the independent variable t.
[out] Last value of the independent variable t of the final step (normally equals to tout). The solution was successfully advanced to this point. It is possible to continue the integration to new point by recalling this routine with the new tout value.
[in,out]y[]Array y[ly] (ly >= n)
[in] Initial values of the dependent variables y[] at initial t.
[out] Computed solution approximation at last t (normally equals to tout).
[in,out]yp[]Array yp[lyp] (lyp >= n)
[in] Initial derivative values y'1, ..., y'n at initial t.
[out] Computed approximations of derivatives at last t (normally euqals to tout).
[in]toutSet tout to the point at which a solution is desired. Integration either forward in t (tout > t) or backward in t (tout < t) is permitted.
The routine advances the solution from t to tout using step sizes which are automatically selected so as to achieve the desired accuracy.
[in]rtolScalar if itol = 0, or array rtol[lrtol] if itol = 1 (lrtol >= 2n) (rtol or all components of rtol[] >= 0)
The relative error tolerance(s). The routine keeps, roughly, the local errors of y[i] and yp[i] below
rtol*abs(y[i]) + atol and rtol*abs(yp[i]) + atol (i = 0 to n-1) (if itol = 0)
or
rtol[i]*abs(y[i]) + atol[i] and rtol[i+n]*abs(yp[i]) + atol[i+n] (i = 0 to n-1) (if itol = 1).
Both rtol and atol, or, rtol[i] and atol[i] (i = 0 to 2n-1) should not be 0 at the same time.
[in]atolScalar if itol = 0, or array atol[latol] if itol = 1 (latol >= 2n) (atol or all components of atol[] >= 0)
The absolute error tolerance(s). The routine keeps, roughly, the local errors of y[i] and yp[i] below
rtol*abs(y[i]) + atol and rtol*abs(yp[i]) + atol (i = 0 to n-1) (if itol = 0)
or
rtol[i]*abs(y[i]) + atol[i] and rtol[i+n]*abs(yp[i]) + atol[i+n] (i = 0 to n-1) (if itol = 1).
Both rtol and atol, or, rtol[i] and atol[i] (i = 0 to 2n-1) should not be 0 at the same time.
[in]itolSpecifies whether the parameters rtol and atol are scalars or arrays.
= 0: rtol and atol are scalars.
= 1: rtol and atol are arrays.
(For other values, itol = 0 is assumed.)
[in]ioutSwitch to return to print out the intermediate solutions (see irev = 50, 51).
= 0: Not return
= 1: Return for intermediate output
= 2: Return for intermediate output with dense output. In this case, number of components for which dense output is required (nrdens) must be specified in iwork[7].
(For other values, iout = 0 is assumed.)
[in]work[]Array work[lwork]
Array of working space. However, work[0] to work[19] serve as parameters for the program. If the parameter is set to 0, the default parameter value will be loaded.
[in]
work[0]: Initial step size guess.
= 1/(norm of f'), usually 1.0e-1 or 1.0e-3 is good. This choice is not very important. (default: = 1.0e-4)
work[1]: Maximum step size (default = tout - t)
work[3], work[4]: Parameters for step size selection. The new step size for the j-th diagonal entry is chosen subject to the restriction
facmin/work[4] <= j-th hnew/hold <= 1/facmin
where facmin = work[3]^(1/(2*j - 1)).
(default: work[3] = 0.02, work[4] = 4)
work[5], work[6]: Parameters for the order selection.
Step size is decreased if w[k-2] <= w[k-1]*work[5].
Step size is increased if w[k-1] <= w[k-2]*work[6].
(default: work[5] = 0.8, work[6] = 0.9)
work[7], work[8]: Safety factors for step control algorithm
hnew = h*work[8]*(work[7]*tol/err)**(1/(j - 1))
(default: work[7] = 0.65, work[8] = 0.94)
work[9]: Step size is reduced by this factor if during the computation of the extrapolation table divergence is observed (default = 0.5)
[out]
work[0]: Predicted step size of the last accepted step.
[in]lworkSize of array work[]. (lwork >= n*(2*km + 6) + 5*km + km*(2*km + 3)*nrdens + 20 (km: see iwork[2], nrdens: see iwork[7]))
If lwork < 0, abs(lwork) will be used and work[0] to work[19] will be initialized to zeros.
[in,out]iwork[]Array iwork[liwork]
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 loaded.
[in]
iwork[1]: Maximum number of allowed steps. (default = 10000) (if iwork[1] < 0, default value will be used)
iwork[2]: km = maximum number of columns in the extrapolation table. (iwork[2] >= 3) (default = 9) (if iwork[2] < 3, default value will be used)
iwork[3]: Switch for the step size sequence. (iwork[3] >= 4 if iout = 2) (if iwork[3] is out of range, default value will be used)
= 1: 2, 4, 6, 8, 10, 12, 14, 16, ...
= 2: 2, 4, 8, 12, 16, 20, 24, 28, ...
= 3: 2, 4, 6, 8, 12, 16, 24, 32, ...
= 4: 2, 6, 10, 14, 18, 22, 26, 30, ...
(default = 1 if iout = 0 or 1, 4 if iout = 2)
iwork[6]: Determines the degree of interpolation formula.
mu = 2*kappa - iwork[6] + 1 (1 <= iwork[6] <= 8)
(default = 6) (if iwork[6] < 1 or iwork[6] > 8, default value will be used)
iwork[7]: nrdens = number of components for which dense output is required. If iwork[7] < 0, nrdens = abs(iwork[7]) is assumed. (default = n)
nrdens is effective only if iout = 2. Otherwise, nrdens = 0 is assumed.
If 0 < nrdens < n, icont[] must be set (see below).
iwork[8]: Switch for error estimator in the dense output formula.
= 0: Activated
= 1: Suppressed
(default = 0) (effective when iout = 2)
iwork[12]: Specifies when iwork[13] to iwork[17] are reset to zero.
= 0: Reset whenever this routine is called.
!= 0: Reset if info = 0.
[out]
iwork[13]: nfcn = number of function evaluations
iwork[15]: nstep = number of computed steps
iwork[16]: naccept = number of accepted steps
iwork[17]: nreject = number of rejected steps (due to error test) (step rejections in the first step are not counted)
[in]liworkSize of array iwork[]. (liwork >= km + 20 (km: see iwork[2]))
If liwork < 0, abs(liwork) will be used and iwork[0] to iwork[19] will be initialized to zeros.
[out]rcont[]Array rcont[lrcont]
Control information area for dense output. Used only when iout = 2.
[in]lrcontSize of array rcont[]. (lrcont >= (2*km + 6)*nrdens (km: see iwork[2], nrdens: see iwork[7]))
[in,out]icont[]Array icont[licont]
Component number list for which dense output is required. Used only when iout = 2.
If nrdens = n or iwork[7] < 0, it will be automatically set to 1, ..., nrdens.
If 0 < nrdens < n, user must set the component numbers for which dense output is required. See iwork[7] for nrdens.
[in]licontSize of array icont[]. (licont >= nrdens (nrdens: see iwork[7]))
[in,out]info[in]
= 0: Initialize and start computation (Solve new problem).
= 1: Continue computation with new tout value (Resume computation of previous call).
[out]
= -1: The argument n had an illegal value (n < 1)
= -6: The argument rtol had an illegal value (rtol < 0 or rtol[i] < 0)
= -6: The argument rtol or atol had an illegal value (rtol = 0 and atol = 0, or rtol[i] = 0 and atol[i] = 0)
= -7: The argument atol had an illegal value (atol < 0 or atol[i] < 0)
= -11: The argument lwork had an illegal value (lwork too small)
= -13: The argument liwork had an illegal value (liwork too small)
= -15: The argument lrcont had an illegal value (lrcont too small)
= -17: The argument licont had an illegal value (licont too small)
= -18: the argument info had an illegal value (info != 0 and info != 1)
= -23: the argument irev had an illegal value (irev != 1, ..., 6, 50 nor 51)
= 1: Successful exit
= 2: Interrupted by irtrn (normal return)
= 11: Maximum number of steps exceeded
[out]ttirev = 1 to 6: The value of t where the second order derivative values should be evaluated and given in yypp[] in the next call.
[out]yy[]Array yy[lyy] (lyy >= n)
irev = 1 to 6: The value of y where the second order derivative values should be evaluated and given in yypp[] in the next call.
[in]yypp[]Array yypp[lyypp] (lyypp >= n)
irev = 1 to 6: The computed second order derivatives at given t (= tt) and y (= yy[]), i.e. yypp[i] = d2yi/dt2 = fi(tt, yy[0], ..., yy[n-1]) (i = 0 to n-1), should be given in the next call.
[in,out]irtrn[in] irev = 50 or 51: Do not alter irtrn unless user want to interrupt the integration. If irtrn is set to the negative value, the integration will be interrupted and exit with info = 2.
[out] irev = 50 or 51: The output value will be 0, 1 or 2 in the first, intermediate or last return with irev = 50 or 51, respectively.
[in,out]irevControl variable for reverse communication.
[in] Before first call, irev should be initialized to zero. On succeeding calls, irev should not be altered.
[out] If irev is not zero, complete the following process and call this routine again.
= 0: Computation finished. See return code in info.
= 1 to 6: User should set the computed second order derivative values at tt and yy[] in yypp[]. Do not alter any variables other than yypp[].
= 50, 51: To be returned with this code to print out the intermediate solutions after every successful step if iout = 1 or 2. The values of y[] at t are provided. tt is the previous value of t.
Dense output is supported by the control information rcont[] and icont[] if iout = 2. The solution y[i] (0 <= i <= n-1) at the arbitrary point t2 in the interval [tt, t] can be computed by the function call
y[i] = contx2(i, t2, rcont, icont);
Reference
E. Hairer, S.P. Norsett and G. Wanner, "Solving Ordinary Differential Equations. Nonstiff Problems. 2nd edition", Springer Series in Computational Mathematics, Springer-Verlag (1993)