Description Usage Arguments Details Value Examples
A factory function that creates a sdStaticModelClass
object
from a list of algebraic
equations that calculates the system in equilibrium and a default scenario
describing the system environment (variables and default values).
1 2 3 |
staticModelId |
A character string with the model ID. Any non-word
character will be removed and the result will be converted to a valid name
(see |
staticModelDescription |
A string with the model description. |
defaultScenario |
The model default scenario, a
|
equations |
(Optional) A list with the model algebraic equations in strings or R-expressions written in R-format. They have access to the following variables: (t, ct, par, inp, sw, eq).
Where The algebraic equation are evaluated at each time step during simulations. See the function |
InitVars |
(Optional) An R-function that initialize or change the initial values of the model variables before the solver call when running a simulation. It can be used, for example, to compute some dependent parameter variables or the initial value of variables, using the arguments. It must be defined as: function(ct, par, inp, sw, eq). Where The return value of the |
globalFunctions |
A named list of extra functions that can be executed in the scope of any other function or algebraic equation defined in the model. They can be called by their names in the list. |
To load a model from a XML file use the sdLoadModel
function.
To simulate a model in different scenarios use the sdSimulate
function.
A sdStaticModelClass
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Let's create a simplified model to represent an environment capacity
# regulated by a population size
# define the parameter: the environment carrying capacity
parEnv <- data.frame(Variable = c("K"),
Value = c(10),
Description =c("carrying capacity"))
# define the input: the population size
inpEnv <- data.frame(Variable = c("P"),
Value = c(1),
Description = c("Population size"))
# define the algebraic equation that regulate the capacity
algEqEnvironment <- list(regulatingCapacity = "1 - inp$P/par$K")
# create the environment capacity scenario
envScen <- sdScenario(scenarioId = "EnvironmentCapacityScen",
parameter = parEnv,
input = inpEnv,
times = list(from = 0, to = 200, by = 1))
# create the static model of an environment capacity
envCapacity <- sdStaticModel(staticModelId = "EnvironmentCapacity",
defaultScenario = envScen,
equations = algEqEnvironment)
# validate the equations and simulate the model
envCapacity$verifyModel()
outEnvCapacity <- sdSimulate(envCapacity)
print(outEnvCapacity)
# note that static models without time series variables have constant result
# and therefore will only be simulated for the first time step if not coupled
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.