| steady {rootSolve} | R Documentation |
Estimates the steady-state condition for a system of ordinary differential equations.
This is a wrapper around steady-state solvers stode and stodes.
steady(y, time=0, func, parms=NULL, method="stode",...)
y |
the initial guess of (state) values for the ODE system, a vector. If y has a name attribute, the names will be used to label the output matrix. |
time |
time for which steady-state is wanted; the default is time=0 |
func |
either an R-function that computes the values of the derivatives in the ode system (the model defininition) at time time,
or a character string giving the name of a compiled function in a dynamically loaded shared library.
If func is an R-function, it must be defined as:
yprime = func(t, y, parms,...). t is the current time point
in the integration, y is the current estimate of the variables
in the ODE system. If the initial values y has a names
attribute, the names will be available inside func. parms is
a vector or list of parameters; ... (optional) are any other arguments passed to the function.
The return value of func should be a list, whose first element is a
vector containing the derivatives of y with respect to
time, and whose next elements are global values whose steady-state value is also required. |
parms |
parameters passed to func |
method |
the solution method to use, one of stode, stodes or runsteady |
... |
additional arguments passed to function stode, stodes or runsteady |
This is simply a wrapper around the various steady-state solvers.
See help file of stode for information about specifying the model in compiled code.
See the selected solver for the additional options
A list containing
y |
A vector with the state variable values from the last iteration during estimation of steady-state condition of the system of equations.
If y has a names attribute, it will be used to label the output values. |
... |
the number of "global" values returned |
The output will have the attribute steady, which returns TRUE, if steady-state has been reached and the attribute
precis with the precision attained during each iteration.
Karline Soetaert <k.soetaert@nioo.knaw.nl>
stode and stodes for the additional options
steady.1D, for steady-state estimation of 1-D models
steady.2D, for steady-state estimation of 2-D models
steady.band, for solving steady-state when the jacobian matrix is banded
#########################################
### Bacteria growing on a substrate
#########################################
# Bacteria (Bac) are growing on a substrate (Sub)
model <- function(t,state,pars)
{
with (as.list(c(state,pars)), {
# substrate uptake death respiration
dBact = gmax*eff*Sub/(Sub+ks)*Bact - dB*Bact - rB*Bact
dSub =-gmax *Sub/(Sub+ks)*Bact + dB*Bact +input
return(list(c(dBact,dSub)))
})
}
pars <- list(gmax =0.5,eff = 0.5,
ks =0.5, rB =0.01, dB =0.01, input=0.1)
# Newton-Raphson
steady(y=c(Bact=0.1,Sub=0),time=0,
func=model,parms=pars,pos=TRUE)
# Dynamic run to steady-state
as.data.frame(steady(y=c(Bact=0.1,Sub=0),time=c(0,1e5),
func=model,parms=pars,method="runsteady"))