Simcraft Docs

sd System Dynamics Components

Stock-and-flow system dynamics on the shared kernel. Stocks accumulate, flows move quantity between stocks at expression-defined rates, and auxiliaries hold intermediate equations. Each integration step ends at a boundary on the simulation clock (see the model's time.integration settings), so continuous dynamics interleave deterministically with discrete events.

Generated from spec/libraries/sd.library.json · library version 0.1.0 · OSDL 0.1

sd.stock StockStock & Flow#

An accumulation (level). Its value integrates the difference between connected inflows and outflows. Wire flow.out → stock.in for inflows and stock.out → flow.in for outflows. The current level is observable and referenceable as <id>.value.

Ports

PortDirectionDescription
in in multiple Inflows accumulate into this stock. connects only to sd.flow.out
out out multiple Outflows drain from this stock. connects only to sd.flow.in

Parameters

ParamTypeDescription
initialrequired numericValue Level at simulation start.
min scalarValue Lower bound on the level. A flow that would take the level below this bound moves less.
max scalarValue Upper bound on the level. A flow that would take the level above this bound moves less.
nonNegative boolean Shorthand for min: 0. default false
allocation "ordered" | "proportional" How the flows that a bound limits share what is available. ordered serves the flows in evaluation order, and each flow takes what the earlier flows left. proportional scales every limited flow by one shared factor. default "ordered" · "ordered" | "proportional"

Observable state

StateTypeDescription
value number The current level.

sd.flow FlowStock & Flow#

Moves quantity between stocks at rate (per model time unit), re-evaluated every integration step. An unconnected in draws from an unlimited source (cloud); an unconnected out drains to an unlimited sink. A negative rate reverses direction. A bound on a connected stock can limit what moves.

Ports

PortDirectionDescription
in in Connect from the upstream stock's out port; leave unconnected for a source (cloud). connects only to sd.stock.out
out out Connect to the downstream stock's in port; leave unconnected for a sink (cloud). connects only to sd.stock.in

Parameters

ParamTypeDescription
raterequired numericValue Quantity moved per model time unit; typically an expression over stocks, auxiliaries, parameters, and other components' state.

Observable state

StateTypeDescription
rate number The forward requested rate: the rate at the current values, which the next integration step requests.
realizedRate number The amount that moved over the last integration step, divided by the step size. It differs from rate when a bound limited the flow, and under RK4.

sd.auxiliary AuxiliaryStock & Flow#

A named intermediate value, re-evaluated every integration step. Auxiliaries have no ports; other components reference them in expressions as <id>.value. Useful for breaking complex equations apart and for bridging paradigms (e.g. deriving a server capacity from a stock level).

Parameters

ParamTypeDescription
valuerequired numericValue The auxiliary's equation: a constant, parameter reference, expression, or distribution.

Observable state

StateTypeDescription
value number The value at the current stock values.