% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stockflow.R
\name{stockflow}
\alias{stockflow}
\title{Create a new stock-and-flow model}
\usage{
stockflow(template = NULL, version = NULL)
}
\arguments{
\item{template}{Name of the template to load (case-insensitive). If \code{NULL},
an empty stock-and-flow model is created with default simulation parameters
and a default meta. If specified, \code{template} should be one of:
\itemize{
\item \strong{logistic_model}: Population growth with carrying capacity (v1.0.0)
\item \strong{sir}: Epidemic model (Susceptible-Infected-Recovered) (v1.0.0)
\item \strong{predator_prey}: Lotka-Volterra dynamics (v1.0.0)
\item \strong{cusp}: Cusp catastrophe (v1.0.0)
\item \strong{crielaard2022}: Eating behavior (doi: 10.1037/met0000484) (v1.0.0)
\item \strong{coffee_cup}: Temperature equilibration (Meadows) (v1.0.0)
\item \strong{bank_account}: Compound interest (Meadows) (v1.0.0)
\item \strong{lorenz}: Lorenz attractor (chaotic) (v1.0.0)
\item \strong{rossler}: Rossler attractor (chaotic) (v1.0.0)
\item \strong{vanderpol}: Van der Pol oscillator (v1.0.0)
\item \strong{duffing}: Forced Duffing oscillator (v1.0.0)
\item \strong{chua}: Chua's circuit (chaotic) (v1.0.0)
\item \strong{burnout}: Toy model of burnout (v1.0.0)
\item \strong{fitzhugh_nagumo}: Two-variable excitable neuron model (v1.0.0)
\item \strong{queue}: Simple demonstration model of people waiting in a queue (v1.0.0)
\item \strong{jdr}: Job Demands-Resources Theory (JD-R, version 1.0.0) as formalized in Evers et al. (under review) (v1.0.0)
\item \strong{jdr}: Job Demands-Resources Theory (JD-R, version 2.0.0) as formalized in Evers et al. (under review) (v2.0.0)
\item \strong{jdr}: Job Demands-Resources Theory (JD-R, version 3.0.0) as formalized in Evers et al. (under review) (v3.0.0)
}}

\item{version}{Optional semantic version of the template to load. Flexible in
what it accepts: a number (\code{1}), a string (\code{"1.2.1"}), an optional \code{"v"} prefix
(\code{"v1"}), a \code{\link[=package_version]{package_version()}} value (injected with \verb{!!}), or a bare symbol
(\code{v1.0.0}). Matching is prefix-based: \code{version = 1} returns the highest \verb{1.x.y},
\code{version = "1.2"} the highest \verb{1.2.y}, and \code{version = "1.2.1"} is exact.
Defaults to the latest available version.}
}
\value{
A stock-and-flow model object of class \code{\link{stockflow}}. Its structure is based
on \href{https://docs.oasis-open.org/xmile/xmile/v1.0/os/xmile-v1.0-os.html}{XML Interchange Language for System Dynamics (XMILE)}. It is a nested list, containing:
\describe{
\item{meta}{Meta-information about model. A list containing arguments listed in \code{\link[=meta]{meta()}}.}
\item{sim_settings}{Simulation specifications. A list containing arguments listed in \code{\link[=sim_settings]{sim_settings()}}.}
\item{model}{Model variables, grouped under the variable types stock, flow, aux (auxiliaries), constant, gf (graphical functions), and func (custom functions). Each variable contains arguments as listed in \code{\link[=update]{update()}}.}
}

Use \code{\link[=summary]{summary()}} to run model diagnostics, \code{\link[=as.data.frame]{as.data.frame()}} to convert to a data.frame, \code{\link[=plot]{plot()}} to visualize.
}
\description{
Initialize a stock-and-flow model of class \code{\link{stockflow}}. You can
either create an empty stock-and-flow model or load a template from the model
library.
}
\details{
Do not edit the object manually; this will likely lead to errors downstream.
Rather, use \code{\link[=meta]{meta()}}, \code{\link[=sim_settings]{sim_settings()}}, \code{\link[=update]{update()}}, and \code{\link[=custom_func]{custom_func()}} for safe manipulation.
}
\examples{
sfm <- stockflow()
summary(sfm)

\dontshow{
sfm <- sim_settings(sfm, save_by = 1)
}

# Load a template
sfm <- stockflow("lorenz")
sim <- simulate(sfm)
plot(sim)
}
\seealso{
\code{\link[=update]{update()}}, \code{\link[=meta]{meta()}}, \code{\link[=custom_func]{custom_func()}}, \code{\link[=sim_settings]{sim_settings()}}
}
\concept{build}
