sdSimulate: Simulate System Dynamics Models and Static Models

Description Usage Arguments Details Value Examples

Description

Simulates a model using it's default scenario merged with the given scenario. A wrapper around the ode solver.

Usage

1
2
3
4
sdSimulate(model, scenario = NULL, from = NULL, to = NULL, by = NULL,
  method = NULL, events = T, maxroots = 100, terminalroot = NULL,
  ties = "notordered", storeAuxTrajectory = T,
  storeTimeSeriesTrajectory = F, verbose = F)

Arguments

model

A sdModelClass, a sdCoupledModelClass or a sdStaticModelClass object.

scenario

A sdScenarioClass object or a character string with a scenario XML or EXCEL file name.

If the model is a sdCoupledModelClass object the scenario must be a coupled scenario object (created with the sdBuildCoupledScenario function), or a list of sdScenarioClass objects and/or character strings with a scenario XML or EXCEL file name - the elements of this list must be named with the component ID that will use it.

from

If not missing, overwrites the starting value of the time sequence. Of length 1.

to

If not missing, overwrites the end (maximal) value of the time sequence. Of length 1.

by

If not missing, overwrites the increment of the time sequence. A number of length 1.

method

If not missing, overwrites the integration method.

The integrator to be used in the simulation, a string ("lsoda", "lsode", "lsodes","lsodar","vode", "daspk", "euler", "rk4", "ode23", "ode45", "radau", "bdf", "bdf_d", "adams", "impAdams" or "impAdams_d"). Default value is "lsoda".

When running with support to events the given method must be one of the following routines, which have root-finding capability: lsoda, lsode or radau; If the given method is different from any of these three routines the simulator will run with the default method "lsoda".

See the ode and the events details section for more information.

events

logical: if TRUE run the simulation with support to events (only if the model have a root specification); if FALSE do not run the simulation with support to events. Default is TRUE.

maxroots

When events = TRUE and events are triggered by a root, the maximal number of times at with a root is found and that are kept; defaults to 100. If the number of roots > maxroot, then only the first maxroot will be outputted.

terminalroot

When events = TRUE and events are triggered by a root, the default is that the simulation continues after the event is executed. In terminalroot, we can specify which roots should terminate the simulation.

ties

When events = TRUE and events are specified by a data.frame and are "ordered", set to "ordered". The default is "notordered". This will save some computational time.

storeAuxTrajectory

logical: if TRUE record the model auxiliary equations trajectories if any (good for visualization, but loses performance). Default is TRUE.

storeTimeSeriesTrajectory

logical: if TRUE builds the time series trajectories if any (good for visualization, but loses performance). Default is FALSE.

verbose

Logical: If TRUE provides additional details as to what the computer is doing. Default is FALSE.

Details

If performance is crucial remember to garantee that the model is already verified and the following logical parameters are set to FALSE: storeAuxTrajectory, storeTimeSeriesTrajectory, verbose.

Value

A sdOutput object initialized with the simulation trajectories.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Load the Bouncing Ball model from the sdsim repository
bb <- sdLoadModel(file = "BouncingBall", repository = TRUE)

# simulate the model with validation and plot the results
outbb <- sdSimulate(model = bb, verbose = TRUE)
outbb$plot("height speed", multipleYAxis = TRUE, units = TRUE)

# simualte the Bouncing Ball model in a different scenario with the 
# coeficient of restitution equals 0.5 and a shorter time sequence
hardBallScen <- sdScenario(scenarioId = "hardBall", 
                           times = list(to = 5),
                           input = list(k = 0.5))
outbbHard <- sdSimulate(model = bb, scenario = hardBallScen)
plot(outbbHard)

EmbrapaInformaticaAgropecuaria/sdsim documentation built on May 10, 2019, 9:58 a.m.