rk4.integrate | R Documentation |
Runge-Kutta integration with Cash-Karp adjustment of the time step.
rk4.integrate(dydt, ystart = 0, tv, tol = 0.005)
dydt |
A function that provides the derivative to be integrated. This function needs to be valid for any index including fractional indices that represent the "time" variable. It should have arguments "y" and "t" and should return the value of the derivative of "y" at time "t". As used for example in ReviseT.R, the function may reference values in the calling environment like the time-response parameters or the original time series as for the recovery temperature. |
ystart |
An initial value assigned to the integrated result. Default is zero. |
tv |
An array of indices for which the integral is evaluated. Typically "1:nrow(D)" where "D" is the data frame containing the variables that determine the derivative. There is no default. |
tol |
The tolerance in the estimated error for a time step. If the estimated error exceeds this limit the time step is broken into smaller steps to span the original time interval. Default is 0.005, an absolute value. |
This is a somewhat specialized function that has not been tested very much and in included for some special uses like that for sensible-heat flux. It is suggested that the R function rmutil::runge.kutta be used instead unless problems with stability and accuracy arise with that function. Here the fourth-order Runge-Kutta method is used to integrate the derivative provided as the first argument. If the estimated uncertainty does not meet the tolerance specified, the step-size is made shorter and the integration is repeated over the initial interval with smaller steps. Unlike the standard Cash-Karp method, no provision is provided for increasing the time step because it is assumed that results are needed for each time interval in the time series. The function calls another called rk4.step() repeatedly to perform the actual integration. That function is only available internally and can't be called separate from rk4.integrate().
A vector representing the integration of the derivative at each time interval specified by "tv". The entire integration is done following one call when "tv" is a vector, but a single step can be specified also to do the integration sequentially.
William Cooper
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.