pywr.nodes.Storage

class pywr.nodes.Storage(*args, **kwargs)

A generic storage Node

In terms of connections in the network the Storage node behaves like any other node, provided there is only 1 input and 1 output. If there are multiple sub-nodes the connections need to be explicit about which they are connecting to. For example:

>>> storage(model, 'reservoir', num_outputs=1, num_inputs=2)
>>> supply.connect(storage)
>>> storage.connect(demand1, from_slot=0)
>>> storage.connect(demand2, from_slot=1)

The attribtues of the sub-nodes can be modified directly (and independently). For example:

>>> storage.outputs[0].max_flow = 15.0

If a recorder is set on the storage node, instead of recording flow it records changes in storage. Any recorders set on the output or input sub-nodes record flow as normal.

Parameters:
modelModel

Model instance to which this storage node is attached.

namestr

The name of the storage node.

num_inputs, num_outputsinteger (optional)

The number of input and output nodes to create internally. Defaults to 1.

min_volumefloat (optional)

The minimum volume of the storage. Defaults to 0.0.

max_volumefloat, Parameter (optional)

The maximum volume of the storage. Defaults to 0.0.

initial_volume, initial_volume_pcfloat (optional)

Specify initial volume in either absolute or proportional terms. Both are required if max_volume is a parameter because the parameter will not be evaluated at the first time-step. If both are given and max_volume is not a Parameter, then the absolute value is ignored.

costfloat, Parameter (optional)

The cost of net flow in to the storage node. I.e. a positive cost penalises increasing volume by giving a benefit to negative net flow (release), and a negative cost penalises decreasing volume by giving a benefit to positive net flow (inflow).

area, levelfloat, Parameter (optional)

Optional float or Parameter defining the area and level of the storage node. These values are accessible through the get_area and get_level methods respectively.

__init__(model, name, outputs=1, inputs=1, *args, **kwargs)

Methods

__init__(model, name[, outputs, inputs])

after(self, Timestep ts, double[)

before(self, Timestep ts)

Called at the beginning of the timestep

check(self)

commit(self, int scenario_index, double value)

Called once for each route the node is a member of

commit_all(self, double[)

Called once for each route the node is a member of

connect(node[, from_slot, to_slot])

Create an edge from this Node to another Node

disconnect([node, slot_name, all_slots])

Remove a connection from this Node to another Node

finalise_load()

Finish loading a node by converting parameter name references to instance references.

finish(self)

get_all_cost(self, double[)

get_all_max_volume(self, double[)

get_all_min_volume(self, double[)

get_area(self, ScenarioIndex scenario_index)

get_cost(self, ScenarioIndex scenario_index)

Get the cost per unit flow at a given timestep

get_current_pc(self, ...)

Return the current proportion of full of the storage node.

get_initial_pc(self)

Returns the initial volume as a proportion.

get_initial_volume(self)

Returns the absolute initial volume.

get_level(self, ScenarioIndex scenario_index)

get_max_volume(self, ...)

get_min_volume(self, ...)

iter_slots([slot_name, is_connector, all_slots])

Returns the object(s) wich should be connected to given slot_name

pre_load(model, data)

Create a node instance from data.

reset(self)

Called at the beginning of a run

setup(self, model)

Called before the first run of the model

Attributes

allow_isolated

A property to flag whether this Node can be unconnected in a network.

area

comment

comment: basestring

component_attrs

components

Generator that returns all of the Components attached to the Node

cost

The cost per unit increased in volume stored

current_pc

Current proportion full.

domain

flow

Total flow via this node in the current timestep

fully_qualified_name

has_fixed_cost

Returns true if cost is not a Parameter.

initial_volume

initial_volume_pc

level

max_volume

min_volume

model

The recorder for the node, e.g. a NumpyArrayRecorder.

name

Name of the node.

parent

The parent Node/Storage of this object.

prev_flow

Total flow via this node in the previous timestep

recorders

Returns a list of pywr.recorders.Recorder objects attached to this node.

virtual

virtual: 'bool'

volume