Stock

BPTK API Documentation for the Stock class
Keywords

system dynamics, bptk, bptk-py, python, business prototyping

Stock

Stock Constructor

Stock(model, name)

Stock in a SD DSL model.

Stock.equation

property equation()

Returns the equation as originally set.

  • Returns

    The equation, either a SD DSL Element or Operator.

A stock is what a system remembers. Its value at any instant cannot be read off the rest of the system: it is the accumulation of everything that has flowed in and out since the start, which is why it needs both an initial value and an equation.

Create one through the model rather than directly: model.stock("population").

Stock.initial_value

property initial_value

The value the stock holds at starttime, before any flow has acted on it. Set it to a number or to a Constant, which is what lets a scenario override it.

population = model.stock("population")
population.initial_value = 80000000.0

Stock.equation

property equation

The net change per timestep, not the value — usually the inflows minus the outflows.

population.equation = births - deaths

Inherited from Element

Everything else — equation, function_string, plot() and the arrayed-element API — comes from Element, where it is documented once for all element types.