solveODE              package:ifultools              R Documentation

_N_u_m_e_r_i_c_a_l _i_n_t_e_g_r_a_t_i_o_n _o_f _O_D_E_s

_D_e_s_c_r_i_p_t_i_o_n:

     Solve a system of ordinary differential equations via a fourth
     order Runge-Kutta numerical integration scheme.

_U_s_a_g_e:

     solveODE(FUN, initial=NULL, step=0.01, n.sample=1000, n.transient=100, ...)

_A_r_g_u_m_e_n_t_s:

     FUN: a function defining the sytem of ODEs. This function should
          have as an input X, where X is a vector whose length is equal
          to the order of the ODEs. It should return a value for each
          order (state) of the system.

     ...: additional arguments sent directly to 'FUN'.

 initial: a vector of initial values, one element for each state of the
          system defined by the ODEs. By default, this value is 'NULL',
          in which case 'FUN' is called with a 'X=NULL'. Therefore,
          'FUN' should be able to handle a 'NULL' value input if you do
          not specify an initial condition. Default: 'NULL'.

n.sample: the number of desired samples for each state beyond that
          specified for the transient ala 'n.transient'. Default: 1000.

n.transient: the numeber of transient points. These points are excluded
          from the output. Default: 100.

    step: a numerical integration time step. Default: 0.1.

_V_a_l_u_e:

     a 'data.frame' containing the estimated system response variables.

_S_e_e _A_l_s_o:

     'par'.

_E_x_a_m_p_l_e_s:

     ## estimate response of the chaotic Lorenz system 
     "lorode" <- function(x, sigma = 10, r = 28, b = 8/3){
         c(sigma * (x[2] - x[1]), x[1] * (r - x[3]) - x[2],  - b * x[3]
            + x[1] * x[2])
     }

     z <- solveODE(lorode,  initial=c(0.1,0.3,1), n.transient=1500,
         n.sample=2000)
     nms <- c("X","Y","Z")

     ## plot the results 
     stackPlot(x=seq(150, by=0.1, length=2000), y=z,
         ylab=nms, main="Lorenz System in Chaos", xlab="Time")

