pywr.nodes.PiecewiseLink¶
-
class
pywr.nodes.PiecewiseLink(*args, **kwargs)¶ An extension of Node that represents a non-linear Link with a piece wise cost function.
This object is intended to model situations where there is a benefit of supplying certain flow rates but beyond a fixed limit there is a change in (or zero) cost.
- Parameters
- max_flowiterable
A monotonic increasing list of maximum flows for the piece wise function
- costiterable
A list of costs corresponding to the max_flow steps
Notes
This Node is implemented using a compound node structure like so:
| Separate Domain | Output -> Sublink 0 -> Sub Output -> Input -> Sublink 1 ---^ ... | -> Sublink n ---|
This means routes do not directly traverse this node due to the separate domain in the middle. Instead several new routes are made for each of the sublinks and connections to the Output/Input node. The reason for this breaking of the route is to avoid an geometric increase in the number of routes when multiple PiecewiseLinks are present in the same route.
-
__init__(*args, **kwargs)¶ Initialise a new Node object
- Parameters
- modelModel
The model the node belongs to
- namestring
A unique name for the node
Methods
__init__(*args, **kwargs)Initialise a new Node object
after(timestep)Set total flow on this link as sum of sublinks
before(self, Timestep ts)Called at the beginning of the timestep
check()Check the node is valid
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
finish(self)get_conversion_factor(self)Get the conversion factor
get_cost(self, ScenarioIndex scenario_index)Get the cost per unit flow at a given timestep
get_max_flow(self, ScenarioIndex scenario_index)Get the maximum flow at a given timestep
get_min_flow(self, ScenarioIndex scenario_index)Get the minimum flow at a given timestep
iter_slots([slot_name, is_connector])Returns the object(s) wich should be connected to given slot_name
load(data, model)reset(self)Called at the beginning of a run
setup(self, model)Called before the first run of the model
Attributes
allow_isolatedA property to flag whether this Node can be unconnected in a network.
commentcomment: basestring
component_attrscomponentsGenerator that returns all of the Components attached to the Node
conversion_factorThe conversion between inflow and outflow for the node
costThe cost per unit flow via the node
domainflowTotal flow via this node in the current timestep
fully_qualified_namemax_flowThe maximum flow constraint on the node
min_flowThe minimum flow constraint on the node
modelThe recorder for the node, e.g.
nameName of the node.
parentThe parent Node/Storage of this object.
prev_flowTotal flow via this node in the previous timestep
recordersReturns a list of pywr.recorders.Recorder objects attached to this node.
virtualvirtual: ‘bool’