pywr.nodes.RollingVirtualStorage

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

A rolling virtual storage node useful for implementing rolling licences.

The volume of the node is updated each timestep with the volume of water utilised in the timestep immediately prior to the rolling period.

If the initial volume of the storage is less than the maximum volume then the parameter will calculate an initial utilisation value. This is set equal to: (max volume - initial volume) / (timesteps - 1). This utilisation is assumed to occurred equally across each timestep of the rolling period. The storage is replenished by this value for each timestep until a full rolling period is completed. At this point, replenishment will be based on the previous utilisation of the storage during the model run. Note that this changes the previous default behaviour of the node up to Pywr version 1.17.1, where no initial utilisation was calculated. This meant that it was impossible for the storage volume to be higher than the initial volume even if this was lower than the max volume.

Parameters:
model: pywr.core.Model
name: str

The name of the virtual node

nodes: list of nodes

List of inflow/out flow nodes that affect the storage volume

factors: list of floats

List of factors to multiply node flow by. Positive factors remove water from the storage, negative factors remove it.

min_volume: float or parameter

The minimum volume the storage is allowed to reach.

max_volume: float or parameter

The maximum volume of the storage.

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.

timestepsint

The number of timesteps to apply to the rolling storage over.

daysint

The number of days to apply the rolling storage over. Specifying a number of days (instead of a number of timesteps) is only valid with models running a timestep of daily frequency.

cost: float or parameter

The cost of flow into/outfrom the storage.

Notes

TODO: The cost property is not currently respected. See issue #242.

__init__(model, name, nodes, **kwargs)

Methods

__init__(model, name, nodes, **kwargs)

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

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, ...)

pre_load(model, data)

Create a node instance from data.

reset(self)

setup(self, model)

Attributes

active

active: 'bool'

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

factors

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.

nodes

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.

timesteps

timesteps: 'int'

virtual

virtual: 'bool'

volume