HydPy-Exch-Branch-HBV96 (branch model adopted from IHMS-HBV96)

exch_branch_hbv96 allows branching the summed input from some inlet nodes to an arbitrary number of outlet nodes. The original HBV96 implementation is supposed to split inflowing discharge, but exch_branch_hbv96 is suitable for splitting arbitrary variables. Calculations are performed for each branch individually by linear interpolation (or extrapolation) following tabulated supporting points. Additionally, exch_branch_hbv96 allows adjusting the input data with differences that can vary monthly.

Integration tests

Note

When new to HydPy, consider reading section Integration Tests first.

We perform the following examples over a simulation period of 11 hours:

>>> from hydpy import pub, Nodes, Element
>>> pub.timegrids = "01.01.2000 00:00", "01.01.2000 11:00", "1h"

exch_branch_hbv96 has no parameter with values depending on the simulation step size, which is why we can pass anything (or nothing) to function parameterstep() without changing the following results:

>>> from hydpy.models.exch_branch_hbv96 import *
>>> parameterstep()

exch_branch_hbv96 queries inflow from two inlet Node objects and passes the branched outflow to three outlet Node objects. Thus, In contrast to most other application models, we need to define the parameter values before connecting the model to its Element object, called branch:

>>> nodes = Nodes("input1", "input2", "output1", "output2", "output3")
>>> branch = Element("branch",
...                  inlets=["input1", "input2"],
...                  outlets=["output1", "output2", "output3"])
>>> delta(-1.0)
>>> minimum(-1.0)
>>> xpoints(0.0, 2.0, 4.0, 6.0)
>>> ypoints(output1=[0.0, 1.0, 2.0, 3.0],
...         output2=[0.0, 1.0, 0.0, 0.0],
...         output3=[0.0, 0.0, 2.0, 6.0])
>>> branch.model = model

We do not have to define any initial values in the test settings because the exch_branch_hbv96 has no memory:

>>> from hydpy.core.testtools import IntegrationTest
>>> test = IntegrationTest(branch)
>>> test.dateformat = "%H:%M"

The (identical) values of the inlet nodes input1 and input2 define no realistic inflow series. Instead, they serve to show the behaviour of exch_branch_hbv96 within and outside the current range defined by parameter XPoints:

>>> import numpy
>>> nodes.input1.sequences.sim.series = numpy.arange(-1.0, 10.0)/2
>>> nodes.input2.sequences.sim.series = numpy.arange(-1.0, 10.0)/2

output1 shows linear continuations below and above the current range of parameter XPoints. output2 points out that inverse relationships are allowed. output3 shows that exch_branch_hbv96 does not enforce equality between the total sum of input and output values:

>>> test("exch_branch_hbv96_ex1")
Click to see the table
Click to see the graph
class hydpy.models.exch_branch_hbv96.Model[source]

Bases: AdHocModel

HydPy-Exch-Branch-HBV96 (branch model adopted from IHMS-HBV96).

The following “inlet update methods” are called in the given sequence at the beginning of each simulation step:
The following “run methods” are called in the given sequence during each simulation step:
The following “outlet update methods” are called in the given sequence at the end of each simulation step:
DOCNAME: DocName = ('Exch-Branch-HBV96', 'branch model adopted from IHMS-HBV96')
nodenames: list[str]

Names of the output nodes.

connect() None[source]

Connect the LinkSequence instances handled by the actual model to the NodeSequence instances handled by one inlet node and multiple outlet nodes.

exch_branch_hbv96 passes multiple output values to different outlet nodes, which requires additional information regarding the “direction” of each output value. Therefore, it uses node names as keywords. Assume the discharge values of both nodes inflow1 and inflow2 shall be branched to nodes outflow1 and outflow2 via element branch:

>>> from hydpy import Element, pub
>>> branch = Element("mybranch",
...                  inlets=["inflow1", "inflow2"],
...                  outlets=["outflow1", "outflow2"])

Then, parameter YPoints relates different supporting points via keyword arguments to the respective nodes:

>>> pub.timegrids = "2000-01-01", "2000-01-02", "1d"
>>> from hydpy.models.exch_branch_hbv96 import *
>>> parameterstep()
>>> delta(0.0)
>>> xpoints(0.0, 3.0)
>>> ypoints(outflow1=[0.0, 1.0], outflow2=[0.0, 2.0])
>>> parameters.update()

After connecting the model with its element, the total discharge value of nodes inflow1 and inflow2 can be adequately divided:

>>> branch.model = model
>>> branch.inlets.inflow1.sequences.sim = 1.0
>>> branch.inlets.inflow2.sequences.sim = 5.0
>>> model.simulate(0)
>>> branch.outlets.outflow1.sequences.sim
sim(2.0)
>>> branch.outlets.outflow2.sequences.sim
sim(4.0)

The following error is raised in case of missing (or misspelt) outlet nodes:

>>> branch.outlets.remove_device(branch.outlets.outflow1, force=True)
>>> parameters.update()
>>> model.connect()
Traceback (most recent call last):
...
RuntimeError: Model `exch_branch_hbv96` of element `mybranch` tried to connect to an outlet node named `outflow1`, which is not an available outlet node of element `mybranch`.
REUSABLE_METHODS: ClassVar[tuple[type[ReusableMethod], ...]] = ()
class hydpy.models.exch_branch_hbv96.ControlParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Control parameters of model exch_branch_hbv96.

The following classes are selected:
  • Delta() Monthly varying difference for increasing or decreasing the input [e.g. m³/s].

  • Minimum() The allowed minimum value of the adjusted input [e.g. m³/s].

  • XPoints() Supporting points for the independent input variable [e.g. m³/s].

  • YPoints() Supporting points for the dependent output variables [e.g. m³/s].

class hydpy.models.exch_branch_hbv96.DerivedParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Derived parameters of model exch_branch_hbv96.

The following classes are selected:
  • MOY() References the “global” month of the year index array [-].

  • NmbBranches() The number of branches [-].

  • NmbPoints() The number of supporting points for linear interpolation [-].

class hydpy.models.exch_branch_hbv96.FluxSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: FluxSequences

Flux sequences of model exch_branch_hbv96.

The following classes are selected:
class hydpy.models.exch_branch_hbv96.InletSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: InletSequences

Inlet sequences of model exch_branch_hbv96.

The following classes are selected:
  • Total() Total input [e.g. m³/s].

class hydpy.models.exch_branch_hbv96.OutletSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: OutletSequences

Outlet sequences of model exch_branch_hbv96.

The following classes are selected: