|
|
◆ derkf_r()
| void derkf_r |
( |
int |
n, |
|
|
double * |
t, |
|
|
double |
y[], |
|
|
double |
tout, |
|
|
double * |
rtol, |
|
|
double * |
atol, |
|
|
int |
itol, |
|
|
int |
mode, |
|
|
double |
work[], |
|
|
int |
lwork, |
|
|
int |
iwork[], |
|
|
int |
liwork, |
|
|
int * |
info, |
|
|
double * |
tt, |
|
|
double |
yy[], |
|
|
double |
yyp[], |
|
|
int * |
irev |
|
) |
| |
Initial value problem of a system of first order ordinary differential equations (5(4)-th order Runge-Kutta-Fehlberg method) (reverse communication version)
NOTE - THIS ROUTINE IS DEPRECATED AND WILL BE REMOVED IN THE NEXT VERSION.
- Purpose
- This routine integrates a system of first order ordinary differential equations of the form
dy/dt = f(t, y), y = y0 at t = t0
where t0 and y0 are the given initial values of t and y, respectively. y may be a vector if the above is a system of differential equations.
This is the code in the package of differential equation solvers DEPAC, consisting of the codes derkf, deabm, and debdf.
derkf is a 5(4)-th order Runge-Kutta-Fehlberg code. It is the simplest of the three choices, both algorithmically and in the use of the code. It is primarily designed to solve non-stiff and mildly stiff differential equations when derivative evaluations are not expensive. It should generally not be used to get high accuracy results nor answers at a great many specific points. Because derkf has very low overhead costs, it will usually result in the least expensive integration when solving problems requiring a modest amount of accuracy and having equations that are not costly to evaluate.
derkf is a driver for a modification of the code RKF45 written by H. A. Watts and L. F. Shampine.
derkf_r is the reverse communication version of derkf.
- Parameters
-
| [in] | n | Number of differential equations. (n >= 1) |
| [in,out] | t | This 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.
It is possible to continue the integration to get result at new tout. This is the interval mode of operation. t should be equal to the previous tout on continuation call.
It is also possible for the routine to return with the solution at each intermediate step on the way to tout. This is the intermediate-output mode of operation. This mode is a good way to proceed if you want to see the behavior of the solution.
The mode of operation is specified by the parameter mode.
[in] Initial value of the independent variable t.
[out] Last value of the independent variable t of the final step (normally equals to tout in interval mode). The solution was successfully advanced to this point. |
| [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 (= tout in interval mode). |
| [in] | tout | Set tout to the point at which a solution is desired. You can take tout = t, in which case the code will evaluate the derivative of the solution at t and return. Integration either forward in t (tout > t) or backward in t (tout < t) is permitted. It is, however, not allowed to change the direction of integration without restarting.
The code advances the solution from t to tout using step sizes which are automatically selected so as to achieve the desired accuracy. If you wish, the code will return with the solution and its derivative following each intermediate step (intermediate-output mode) so that you can monitor them, but you still must provide tout in accord with the basic aim of the code. |
| [in,out] | rtol | Scalar if itol = 0, or array rtol[lrtol] if itol = 1 (lrtol >= n) (rtol or all components of rtol[] >= 0)
The relative error tolerance(s) to tell the code how accurately you want the solution to be computed. This parameter may be a scalar or an array according to the itol. The array can be used to control the error test more precisely.
The tolerances are used by the code in a local error test at each step which requires roughly that
abs(local error) <= rtol*abs(y[i]) + atol (if itol = 0)
or
abs(local error) <= rtol[i]*abs(y[i]) + atol[i] (if itol = 1)
for each component of y[] (i = 0 to n-1).
Setting rtol = 0 yields a pure absolute error test on that component.
If you want relative accuracies smaller than about 1.0e-8, you should not ordinarily use derkf. The code deabm in DEPAC obtains stringent accuracies more efficiently.
[in] Relative error tolerance(s) for the error test.
[out] When returned with info = 4, the error tolarance(s) will be increased to the value appropriate for continuing the computation. Otherwise, it will remain unchanged. |
| [in,out] | atol | Scalar if itol = 0, or array atol[latol] if itol = 1 (latol >= n) (atol or all components of atol[] >= 0)
The absolute error tolerance(s) to tell the code how accurately you want the solution to be computed. This parameter may be a scalar or an array according to the itol. The array can be used to control the error test more precisely.
The tolerances are used by the code in a local error test at each step which requires roughly that
abs(local error) <= rtol*abs(y[i]) + atol (if itol = 0)
or
abs(local error) <= rtol[i]*abs(y[i]) + atol[i] (if itol = 1)
for each component of y[] (i = 0 to n-1).
Setting atol = 0 results in a pure relative error test on that component.
If you want relative accuracies smaller than about 1.0e-8, you should not ordinarily use derkf. The code deabm in DEPAC obtains stringent accuracies more efficiently.
[in] Absolute error tolerance(s) for the error test.
[out] When returned with info = 4, the error tolarance(s) will be increased to the value appropriate for continuing the computation. Otherwise, it will remain unchanged. |
| [in] | itol | Specifies whether the parameters rtol and atol are scalars or arrays. It cannot be changed after the first call for the current problem.
= 0: rtol and atol are scalars.
= 1: rtol and atol are arrays.
(For other values, itol = 0 is assumed.) |
| [in] | mode | Mode of operation.
= 0: Return only at tout (interval mode)
= 1: Return at every step (intermediate output mode)
= 2: Return at every step (intermediate output mode). Dense output is enabled, i.e. derkf_int routine can be used to compute the interpolated values within latest step interval when returned with info = 2 (info = 1 for last step).
(For other values, mode = 0 is assumed.) |
| [out] | work[] | Array work[lwork]
Work array. |
| [in] | lwork | The length of work[]. (lwork >= 7*n + 20 (9*n + 20 if mode = 2)) |
| [out] | iwork[] | Array iwork[liwork]
Work array. |
| [in] | liwork | The length of iwork[]. (liwork >= 20) |
| [out] | info | [in] Control code.
= 0: Set info = 0 on the initial call for the problem (to start new problem). The routine will be initialized and the computation for the new problem will be started.
= 1, 2 or 11 to 15: When returned from the routine with info = 1, 2 or 11 to 15, user can reenter without changing info to continue computation. See descriptions below.
[out] Return code. By examining this code, user can call this routine again when info = 1, 2 or 11 to 15 as a next action if necessary.
= -1: The argument n had an illegal value (n < 1)
= -2: The argument t had an illegal value (t = tout or t != previous tout on continuation call)
= -4: The argument tout had an illegal value (direction of integration is changed)
= -5: The argument rtol had an illegal value (rtol < 0 or rtol[i] < 0)
= -6: The argument atol had an illegal value (atol < 0 or atol[i] < 0)
= -10: The argument lwork had an illegal value (lwork too small)
= -12: The argument liwork had an illegal value (liwork to small)
= -13: The argument info had an illegal value (info != 0, 1, 2 nor 11 to 15)
= 1: Successful exit (t = tout). User can reenter with a new tout, which must be different from t.
= 2: Interruption in intermediate-output mode (still not reached tout). User can reenter to resume for another step in the direction of tout.
= 3: Maximum number of steps (10000) exceeded. User can reenter to resume. Additional 10000 steps will be allowed.
= 4: Error tolerances are too stringent. User can reenter to continue with automatically relaxed tolerances. User can also reenter with manually changed tolerances.
= 5: Pure relative error test (atol = 0) is impossible because computed solution is zero. User can reenter with positive atol value to continue computation.
= 6: Problem is probably stiff. User can reenter to continue, but the other programs such as debdf in DEPAC which handle stiff problems efficiently are recommended.
= 7: Natural step size is being restricted by too frequent output. User can reenter to continue, but other programs with dense output feature are recommended.
= 8: Infinite loop has been detected. |
| [out] | tt | irev = 1 to 11: The value of t where the derivative values should be evaluated and given in yyp[] in the next call. |
| [out] | yy[] | Array yy[lyy] (lyy >= n)
irev = 1 to 11: The value of y where the derivative values should be evaluated and given in yyp[] in the next call. |
| [in] | yyp[] | Array yyp[lyyp] (lyyp >= n)
irev = 1 to 11: The computed derivatives at given t (= tt) and y (= yy[]), i.e. yyp[i] = dyi/dt = fi(tt, yy[0], ..., yy[n-1]) (i = 0 to n-1), should be given in the next call. |
| [in,out] | irev | Control 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 tasks and call this routine again without changing irev.
= 0: Computation finished. See return code in info.
= 1 to 11: User should set the computed derivative values at tt and yy[] in yyp[]. Do not alter any variables other than yyp[]. |
- Reference
- SLATEC (DEPAC)
|