Skip to content

stockflow.dsl.elements

Stock-flow element declarations -- frozen Pydantic models for user-facing declarations.

Bases: BaseModel

A state accumulator in a stock-flow diagram.

Maps to: GDS Mechanism (state update f) + Entity (state X). Emits a Level port; receives Rate ports from connected flows.

Source code in packages/gds-stockflow/stockflow/dsl/elements.py
class Stock(BaseModel, frozen=True):
    """A state accumulator in a stock-flow diagram.

    Maps to: GDS Mechanism (state update f) + Entity (state X).
    Emits a Level port; receives Rate ports from connected flows.
    """

    name: str
    initial: float | None = None
    units: str = ""
    non_negative: bool = True

Bases: BaseModel

A rate of change between stocks (or from/to clouds).

Maps to: GDS Policy (rate computation g). Emits a Rate port; drains from source stock, fills target stock.

Source code in packages/gds-stockflow/stockflow/dsl/elements.py
class Flow(BaseModel, frozen=True):
    """A rate of change between stocks (or from/to clouds).

    Maps to: GDS Policy (rate computation g).
    Emits a Rate port; drains from source stock, fills target stock.
    """

    name: str
    source: str = ""
    target: str = ""

Bases: BaseModel

An intermediate computation depending on other elements.

Maps to: GDS Policy (decision logic g). Emits a Signal port; receives Level/Signal ports from inputs.

Source code in packages/gds-stockflow/stockflow/dsl/elements.py
class Auxiliary(BaseModel, frozen=True):
    """An intermediate computation depending on other elements.

    Maps to: GDS Policy (decision logic g).
    Emits a Signal port; receives Level/Signal ports from inputs.
    """

    name: str
    inputs: list[str] = Field(default_factory=list)

Bases: BaseModel

An exogenous constant or parameter.

Maps to: GDS BoundaryAction (exogenous input U). Emits a Signal port; has no internal inputs.

Source code in packages/gds-stockflow/stockflow/dsl/elements.py
class Converter(BaseModel, frozen=True):
    """An exogenous constant or parameter.

    Maps to: GDS BoundaryAction (exogenous input U).
    Emits a Signal port; has no internal inputs.
    """

    name: str
    units: str = ""