Skip to contents

Initialize an empty stock-and-flow model of class sdbuildR_xmile. You can either create an empty stock-and-flow model or load a template from the model library.

Usage

xmile(name = NULL)

Arguments

name

Name of the template to load. If NULL, an empty stock-and-flow model will be created with default simulation parameters and a default header. If specified, the name should be one of "logistic_model", "SIR", "predator_prey", "cusp", "Crielaard2022", "coffee_cup", "bank_account", "Lorenz", "Rossler", "vanderPol", "Duffing", "Chua".

Value

Stock-and-flow model of class sdbuildR_xmile. Its structure is based on XML Interchange Language for System Dynamics (XMILE). It is a nested list, containing:

header

Meta-information about model. A list containing arguments listed in header().

sim_specs

Simulation specifications. A list containing arguments listed in sim_specs().

model

Model variables, grouped under the variable types stock, flow, aux (auxiliaries), constant, and gf (graphical functions). Each variable contains arguments as listed in build().

macro

Global variable or functions. A list containing arguments listed in macro().

model_units

Custom model units. A list containing arguments listed in model_units().

Details

Do not edit the object manually; this will likely lead to errors downstream. Rather, use header(), sim_specs(), build(), macro(), and model_units() for safe manipulation.

Examples

sfm <- xmile()
summary(sfm)
#> Your model contains:
#> * 0 Stocks
#> * 0 Flows
#> * 0 Constants
#> * 0 Auxiliaries
#> * 0 Graphical Functions
#> * 0 Custom model units
#> * 0 Macros
#> 
#> Simulation time: 0.0 to 100.0 seconds (dt = 0.01)
#> Simulation settings: solver euler in R


# Load a template
sfm <- xmile("Lorenz")
sim <- simulate(sfm)
plot(sim)