Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

deSolve-internal

Internal deSolve Functions


Description

Internal deSolve functions, these are not to be called by the user.

Usage

timestep(prev = TRUE)

Arguments

prev

if TRUE will return the timestep previously used; when FALSE will return the time step to be currently tried by the integrator.

Details

Function timestep is intended to return the current or next timestep of the integration. It works only under specific circumstances and should not be used by the end user.

Instead of this, please see the example below for a pure R solution.

See Also

diagnostics for information about the time steps used,
lagvalue and lagderiv that can be used for DDEs.

Examples

###################################################
### This example shows how to retrieve information 
### about the used time steps.
###################################################

## a function closure  ('lexical scoping')
modelClosure <- function(t0) {
  t.old <- t.act <- t0
  function(t, y, parms) {
    t.old  <<- t.act
    t.act  <<- t
    cat(t, "\t", t - t.old, "\n")
    with (as.list(c(y, parms)), {
      dP <- a * P      -  b * P * K
      dK <- b * P * K  -  c * K
      list(c(dP, dK))
    })
  }
}

model <- modelClosure(0) # initialization

parms <- c(a = 0.1, b = 0.1, c = 0.1)

y <- c(P = 1, K = 2)

out <- ode(y = y, func = model, times = c(0, 2),
 parms = parms, method = "lsoda")

ls() # prove that t.old and t.new are local within 'model'

deSolve

Solvers for Initial Value Problems of Differential Equations ('ODE', 'DAE', 'DDE')

v1.28
GPL (>= 2)
Authors
Karline Soetaert [aut] (<https://orcid.org/0000-0003-4603-7100>), Thomas Petzoldt [aut, cre] (<https://orcid.org/0000-0002-4951-6468>), R. Woodrow Setzer [aut] (<https://orcid.org/0000-0002-6709-9186>), Peter N. Brown [ctb] (files ddaspk.f, dvode.f, zvode.f), George D. Byrne [ctb] (files dvode.f, zvode.f), Ernst Hairer [ctb] (files radau5.f, radau5a), Alan C. Hindmarsh [ctb] (files ddaspk.f, dlsode.f, dvode.f, zvode.f, opdkmain.f, opdka1.f), Cleve Moler [ctb] (file dlinpck.f), Linda R. Petzold [ctb] (files ddaspk.f, dlsoda.f), Youcef Saad [ctb] (file dsparsk.f), Clement W. Ulrich [ctb] (file ddaspk.f)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.