HydPy-SW1D (base model)

HydPy-SW1D provides features for implementing models for approximating the 1-dimensional shallow water equations in a “hydrodynamic” manner to account for situations like backwater effects that “hydrological” methods cannot handle well. Method Features —————

class hydpy.models.sw1d.sw1d_model.Model[source]

Bases: SubstepModel

HydPy-SW1D (base model).

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:
The following interface methods are available to main models using the defined model as a submodel:
The following “additional methods” might be called by one or more of the other methods or are meant to be directly called by the user:
Users can hook submodels into the defined main model if they satisfy one of the following interfaces:
  • CrossSectionModel_V2 Interface for calculating discharge-related properties at a channel cross-section.

  • ChannelModel_V1 Interface for handling routing and storage submodels.

  • StorageModel_V1 Interface for calculating the water amount stored in a single channel segment.

  • RoutingModel_V1 Interface for calculating the inflow into a channel.

  • RoutingModel_V2 Interface for calculating the discharge between two channel segments.

  • RoutingModel_V3 Interface for calculating the outflow of a channel.

DOCNAME: DocName = ('SW1D', 'base model')
crosssection

Required submodel that complies with the following interface: CrossSectionModel_V2.

crosssection_is_mainmodel
crosssection_typeid
channelmodels

Vector of submodels that comply with the following interface: ChannelModel_V1.

storagemodels

Vector of submodels that comply with the following interface: StorageModel_V1.

routingmodels

Vector of submodels that comply with the following interface: RoutingModel_V1.

storagemodelupstream

Required submodel that complies with the following interface: StorageModel_V1.

storagemodelupstream_is_mainmodel
storagemodelupstream_typeid
storagemodeldownstream

Required submodel that complies with the following interface: StorageModel_V1.

storagemodeldownstream_is_mainmodel
storagemodeldownstream_typeid
routingmodelsupstream

Vector of submodels that comply with the following interfaces: RoutingModel_V1, RoutingModel_V2, or RoutingModel_V3.

routingmodelsdownstream

Vector of submodels that comply with the following interfaces: RoutingModel_V2, RoutingModel_V3, or RoutingModel_V3.

REUSABLE_METHODS: ClassVar[tuple[type[ReusableMethod], ...]] = ()
class hydpy.models.sw1d.sw1d_model.Pick_Inflow_V1[source]

Bases: Method

Pick the longitudinal inflow from an arbitrary number of inlet sequences.

Required by the method:

Perform_Preprocessing_V1

Requires the inlet sequence:

LongQ

Calculates the flux sequence:

Inflow

class hydpy.models.sw1d.sw1d_model.Pick_Outflow_V1[source]

Bases: Method

Pick the longitudinal outflow from an arbitrary number of outlet sequences.

Required by the method:

Perform_Preprocessing_V4

Requires the outlet sequence:

LongQ

Calculates the flux sequence:

Outflow

class hydpy.models.sw1d.sw1d_model.Pick_LateralFlow_V1[source]

Bases: Method

Pick the lateral inflow from an arbitrary number of inlet sequences.

Required by the method:

Perform_Preprocessing_V3

Requires the inlet sequence:

LatQ

Calculates the flux sequence:

LateralFlow

class hydpy.models.sw1d.sw1d_model.Pick_WaterLevelDownstream_V1[source]

Bases: Method

Pick the water level downstream from a receiver sequence.

Required by the method:

Perform_Preprocessing_V5

Requires the receiver sequence:

WaterLevel

Calculates the factor sequence:

WaterLevelDownstream

class hydpy.models.sw1d.sw1d_model.Pass_Discharge_V1[source]

Bases: Method

Pass the calculated average discharge of the current simulation step to an arbitrary number of inlet or outlet sequences.

Required by the method:

Perform_Postprocessing_V2

Requires the derived parameter:

Seconds

Requires the flux sequence:

DischargeVolume

Calculates the inlet sequence:

LongQ

Calculates the outlet sequence:

LongQ

Basic equation:

\(QLong = DischargeVolume / Seconds\)

In contrast to typical methods for passing data to nodes, Pass_Discharge_V1 not only passes data to outlet sequences but also to inlet sequences. This functionality addresses the rare but allowed setting of a discharge calculating routing model lying at the inlet position of a subchannel, which is necessary for modelling branches.

Examples:

Without any node connection, Pass_Discharge_V1 does nothing:

>>> from hydpy import Element, Nodes, prepare_model
>>> e1 = Element("e1")
>>> e1.model = prepare_model("sw1d_lias")
>>> e1.model.pass_discharge_v1()

If any connections exist, Pass_Discharge_V1 updates all corresponding sequences with the same average discharge value:

>>> ni, no1, no2 = Nodes("ni", "no1", "no2", defaultvariable="LongQ")
>>> ni.sequences.sim = 1.0
>>> no1.sequences.sim = 2.0
>>> no2.sequences.sim = 3.0
>>> e2 = Element("e2", inlets=ni, outlets=(no1, no2))
>>> e2.model = prepare_model("sw1d_lias")
>>> e2.model.parameters.derived.seconds(60.0)
>>> e2.model.sequences.fluxes.dischargevolume = 120.0
>>> e2.model.pass_discharge_v1()
>>> ni.sequences.sim
sim(3.0)
>>> no1.sequences.sim
sim(4.0)
>>> no2.sequences.sim
sim(5.0)
class hydpy.models.sw1d.sw1d_model.Pass_WaterLevel_V1[source]

Bases: Method

Pass the calculated water level to an arbitrary number of sender sequences.

Required by the method:

Perform_Postprocessing_V3

Requires the factor sequence:

WaterLevel

Calculates the sender sequence:

WaterLevel

class hydpy.models.sw1d.sw1d_model.Trigger_Preprocessing_V1[source]

Bases: Method

Order all submodels following the StorageModel_V1, RoutingModel_V1, RoutingModel_V2, or RoutingModel_V3 interface to prepare all invariant data for a new internal simulation step.

Example:

>>> from hydpy import Element, Node, prepare_model
>>> nlong = Node("nlong", variable="LongQ")
>>> nlat = Node("nlat", variable="LatQ")
>>> e = Element("e", inlets=(nlong, nlat))
>>> channel = prepare_model("sw1d_channel")
>>> channel.parameters.control.nmbsegments(1)
>>> with channel.add_routingmodel_v1("sw1d_q_in", position=0, update=False):
...     pass
>>> with channel.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> e.model = channel
>>> nlong.sequences.sim = 1.0
>>> nlat.sequences.sim = 2.0
>>> channel.trigger_preprocessing_v1()
>>> channel.routingmodels[0].sequences.fluxes.inflow
inflow(1.0)
>>> channel.storagemodels[0].sequences.fluxes.lateralflow
lateralflow(2.0)
class hydpy.models.sw1d.sw1d_model.Trigger_Postprocessing_V1[source]

Bases: Method

Order all submodels following the StorageModel_V1, RoutingModel_V1, RoutingModel_V2, or RoutingModel_V3 interface to execute all tasks relevant at the end of each external simulation step.

Example:

>>> from hydpy import Element, Node, prepare_model
>>> nw = Node("nw", variable="WaterLevel")
>>> e = Element("e", senders=nw)
>>> channel = prepare_model("sw1d_channel")
>>> channel.parameters.control.nmbsegments(1)
>>> with channel.add_routingmodel_v1("sw1d_q_in", position=0, update=False):
...     derived.seconds(60.0)
...     fluxes.inflow = 2.0
>>> with channel.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     factors.waterlevel = 2.0
>>> e.model = channel
>>> channel.trigger_postprocessing_v1()
>>> channel.routingmodels[0].sequences.fluxes.dischargevolume
dischargevolume(120.0)
>>> nw.sequences.sim
sim(2.0)
class hydpy.models.sw1d.sw1d_model.Calc_MaxTimeStep_V1[source]

Bases: Method

Estimate the highest possible computation time step for which we can expect stability for a central LIAS-like routing model.

Required by the method:

Determine_MaxTimeStep_V1

Requires the control parameter:

TimeStepFactor

Requires the derived parameter:

LengthMin

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequence:

WaterDepth

Calculates the factor sequence:

MaxTimeStep

Basic equation (Bates et al., 2010):

\(MaxTimeStep = TimeStepFactor \cdot \frac{1000 \cdot LengthMin}{GravitationalAcceleration \cdot WaterDepth}\)

Examples:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> timestepfactor(0.5)
>>> derived.lengthmin(2.0)
>>> factors.waterdepth = 4.0
>>> model.calc_maxtimestep_v1()
>>> factors.maxtimestep
maxtimestep(159.637714)

Calc_MaxTimeStep_V1 handles the case of zero water depth by setting the maximum time step to infinity:

>>> factors.waterdepth = 0.0
>>> model.calc_maxtimestep_v1()
>>> factors.maxtimestep
maxtimestep(inf)
class hydpy.models.sw1d.sw1d_model.Calc_MaxTimeStep_V2[source]

Bases: Method

Estimate the highest possible computation time step for which we can expect stability for an inflow-providing routing model.

Required by the method:

Determine_MaxTimeStep_V2

Requires the control parameters:

LengthDownstream TimeStepFactor

Requires the factor sequence:

WettedArea

Requires the flux sequence:

Inflow

Calculates the factor sequence:

MaxTimeStep

Basic equation:

\(MaxTimeStep = TimeStepFactor \cdot \frac{1000 \cdot LengthDownstream}{5 / 3 \cdot |Inflow| \cdot WettedArea}\)

Examples:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> timestepfactor(0.5)
>>> lengthdownstream(2.0)
>>> factors.wettedarea = 5.0
>>> fluxes.inflow = 6.0
>>> model.calc_maxtimestep_v2()
>>> factors.maxtimestep
maxtimestep(500.0)

For zero inflow values, the computation time step needs no restriction:

>>> fluxes.inflow = 0.0
>>> model.calc_maxtimestep_v2()
>>> factors.maxtimestep
maxtimestep(inf)

To prevent zero division, Calc_MaxTimeStep_V2 also sets the maximum time step to infinity if there is no wetted area:

>>> fluxes.inflow = 6.0
>>> factors.wettedarea = 0.0
>>> model.calc_maxtimestep_v2()
>>> factors.maxtimestep
maxtimestep(inf)
class hydpy.models.sw1d.sw1d_model.Calc_MaxTimeStep_V3[source]

Bases: Method

Estimate the highest possible computation time step for which we can expect stability for a weir-like routing model.

Required by the method:

Determine_MaxTimeStep_V3

Requires the control parameters:

LengthUpstream TimeStepFactor FlowCoefficient CrestHeight

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequence:

WaterLevel

Calculates the factor sequence:

MaxTimeStep

Basic equation:
\[\begin{split}MaxTimeStep = f \cdot \frac{1000 \cdot l}{c\cdot \sqrt{2 \cdot g \cdot h}} \\ \\ f = TimeStepFactor \\ l = LengthDownstream \\ c = FlowCoefficient \\ g = GravitationalAcceleration \\ h = WaterLevel - CrestHeight\end{split}\]

Examples:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> crestheight(5.0)
>>> flowcoefficient(0.6)
>>> timestepfactor(0.5)
>>> lengthupstream(2.0)
>>> factors.waterlevel = 7.0
>>> model.calc_maxtimestep_v3()
>>> factors.maxtimestep
maxtimestep(266.062857)

For water levels equal to or below the crest height, the flow over the weir is zero and thus cannot cause instability. Hence, Calc_MaxTimeStep_V3 sets MaxTimeStep to infinity in such cases:

>>> factors.waterlevel = 5.0
>>> model.calc_maxtimestep_v3()
>>> factors.maxtimestep
maxtimestep(inf)
>>> factors.waterlevel = 3.0
>>> model.calc_maxtimestep_v3()
>>> factors.maxtimestep
maxtimestep(inf)
class hydpy.models.sw1d.sw1d_model.Calc_MaxTimeStep_V4[source]

Bases: Method

Estimate the highest possible computation time step for which we can expect stability for an outflow-providing routing model.

Required by the method:

Determine_MaxTimeStep_V4

Requires the control parameters:

LengthUpstream TimeStepFactor

Requires the factor sequence:

WettedArea

Requires the flux sequence:

Outflow

Calculates the factor sequence:

MaxTimeStep

Basic equation:

\(MaxTimeStep = TimeStepFactor \cdot \frac{1000 \cdot LengthUpstream}{5 / 3 \cdot |Outflow| \cdot WettedArea}\)

Examples:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> timestepfactor(0.5)
>>> lengthupstream(2.0)
>>> factors.wettedarea = 5.0
>>> fluxes.outflow = 6.0
>>> model.calc_maxtimestep_v4()
>>> factors.maxtimestep
maxtimestep(500.0)

For zero outflow values, the computation time step needs no restriction:

>>> fluxes.outflow = 0.0
>>> model.calc_maxtimestep_v4()
>>> factors.maxtimestep
maxtimestep(inf)

To prevent zero division, Calc_MaxTimeStep_V4 also sets the maximum time step to infinity if there is no wetted area:

>>> fluxes.outflow = 6.0
>>> factors.wettedarea = 0.0
>>> model.calc_maxtimestep_v4()
>>> factors.maxtimestep
maxtimestep(inf)
class hydpy.models.sw1d.sw1d_model.Calc_MaxTimeStep_V5[source]

Bases: Method

Estimate the highest possible computation time step for which we can expect stability for a gate-like routing model.

Required by the method:

Determine_MaxTimeStep_V5

Requires the control parameters:

LengthUpstream BottomLevel GateHeight FlowCoefficient TimeStepFactor

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequences:

WaterLevel WaterLevelUpstream WaterLevelDownstream

Calculates the factor sequence:

MaxTimeStep

Basic equation:
\[\begin{split}MaxTimeStep = f \cdot \frac{1000 \cdot l}{c \cdot \big( min (h, \ l) - b \big) \cdot \sqrt{2 \cdot g \cdot (l_u - l_d)}} \\ \\ f = TimeStepFactor \\ c = FlowCoefficient \\ h = GateHeight \\ l = WaterLevel \\ l_u = WaterLevelUpstream \\ l_d = WaterLevelDownstream\\ b = BottomLevel \\ g = GravitationalAcceleration\end{split}\]

Examples:

The following examples all correspond to selected ones of Calc_Discharge_V3.

The case of a submerged gate and downstream flow:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> bottomlevel(4.0)
>>> gateheight(6.0)
>>> flowcoefficient(0.6)
>>> lengthupstream(4.0)
>>> timestepfactor(0.5)
>>> factors.waterlevel = 8.0
>>> factors.waterlevelupstream = 9.0
>>> factors.waterleveldownstream = 7.0
>>> model.calc_maxtimestep_v5()
>>> factors.maxtimestep
maxtimestep(266.062857)

The case of a non-submerged gate and upstream flow:

>>> gateheight(8.0)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_maxtimestep_v5()
>>> factors.maxtimestep
maxtimestep(133.031429)

The case of a negative effective gate opening with zero discharge:

>>> gateheight(0.0)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_maxtimestep_v5()
>>> factors.maxtimestep
maxtimestep(inf)

The case of a controlled gate opening:

>>> def sluice(model) -> None:
...     con = model.parameters.control.fastaccess
...     fac = model.sequences.factors.fastaccess
...     if fac.waterlevelupstream < fac.waterleveldownstream:
...         con.gateheight = 4.0
...     else:
...         con.gateheight = 10.0
>>> gateheight(callback=sluice)
>>> factors.waterlevelupstream = 9.0
>>> factors.waterleveldownstream = 7.0
>>> model.calc_maxtimestep_v5()
>>> factors.maxtimestep
maxtimestep(133.031429)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_maxtimestep_v5()
>>> factors.maxtimestep
maxtimestep(inf)
class hydpy.models.sw1d.sw1d_model.Calc_MaxTimeStep_V6[source]

Bases: Method

Estimate the highest possible computation time step for which we can expect stability for an inflow- and outflow-providing routing model.

Required by the method:

Determine_MaxTimeStep_V6

Requires the control parameter:

TimeStepFactor

Requires the derived parameter:

LengthMin

Requires the factor sequence:

WettedArea

Requires the state sequence:

Discharge

Calculates the factor sequence:

MaxTimeStep

Basic equation:

\(MaxTimeStep = TimeStepFactor \cdot \frac{1000 \cdot LengthMin}{5 / 3 \cdot |Discharge| \cdot WettedArea}\)

Examples:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> timestepfactor(0.5)
>>> derived.lengthmin(2.0)
>>> factors.wettedarea = 5.0
>>> states.discharge = -6.0
>>> model.calc_maxtimestep_v6()
>>> factors.maxtimestep
maxtimestep(500.0)

For zero outflow values, the computation time step needs no restriction:

>>> states.discharge = 0.0
>>> model.calc_maxtimestep_v6()
>>> factors.maxtimestep
maxtimestep(inf)

To prevent zero division, Calc_MaxTimeStep_V4 also sets the maximum time step to infinity if there is no wetted area:

>>> states.discharge = 6.0
>>> factors.wettedarea = 0.0
>>> model.calc_maxtimestep_v6()
>>> factors.maxtimestep
maxtimestep(inf)
class hydpy.models.sw1d.sw1d_model.Calc_MaxTimeSteps_V1[source]

Bases: Method

Order all submodels that follow the RoutingModel_V1, RoutingModel_V2, or RoutingModel_V3 interface to estimate the highest possible computation time step.

Example:

>>> from hydpy.models.sw1d_channel import *
>>> parameterstep()
>>> nmbsegments(2)
>>> with model.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     factors.waterlevel = 6.0
>>> with model.add_routingmodel_v2("sw1d_lias", position=1, update=False):
...     timestepfactor(0.5)
...     derived.weightupstream(0.5)
...     derived.lengthmin(2.0)
...     factors.waterdepth = 4.0
>>> with model.add_storagemodel_v1("sw1d_storage", position=1, update=False):
...     factors.waterlevel = 4.0
>>> model.calc_maxtimesteps_v1()
>>> model.routingmodels[1].sequences.factors.maxtimestep
maxtimestep(159.637714)
class hydpy.models.sw1d.sw1d_model.Calc_TimeStep_V1[source]

Bases: Method

Determine the computation time step for which we can expect stability for a complete channel network.

Calculates the factor sequence:

TimeStep

Examples:

Usually, Calc_TimeStep_V1 takes the minimum of the individual routing models’ MaxTimeStep estimates:

>>> from hydpy.models.sw1d_channel import *
>>> parameterstep()
>>> nmbsegments(2)
>>> with model.add_routingmodel_v2("sw1d_lias", position=0, update=False):
...     factors.maxtimestep = 6.0
>>> with model.add_routingmodel_v2("sw1d_lias", position=1, update=False):
...     factors.maxtimestep = 7.0
>>> model.timeleft = 7.0
>>> model.calc_timestep_v1()
>>> factors.timestep
timestep(6.0)
>>> from hydpy import round_
>>> round_(model.timeleft)
1.0

When appropriate, the timeleft argument synchronises the end of the next internal computation step with the end of the current external simulation step:

>>> model.timeleft = 5.0
>>> model.calc_timestep_v1()
>>> factors.timestep
timestep(5.0)
>>> round_(model.timeleft)
0.0
class hydpy.models.sw1d.sw1d_model.Send_TimeStep_V1[source]

Bases: Method

Send the actual computation time step to all submodels following the StorageModel_V1, RoutingModel_V1, RoutingModel_V2, or RoutingModel_V3 interface.

Requires the factor sequence:

TimeStep

Example:

>>> from hydpy.models.sw1d_channel import *
>>> parameterstep()
>>> nmbsegments(1)
>>> with model.add_routingmodel_v2("sw1d_lias", position=0, update=False):
...     factors.maxtimestep = 6.0
>>> with model.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     factors.maxtimestep = 6.0
>>> factors.timestep = 5.0
>>> model.send_timestep_v1()
>>> model.routingmodels[0].sequences.factors.timestep
timestep(5.0)
>>> model.storagemodels[0].sequences.factors.timestep
timestep(5.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterLevelUpstream_V1[source]

Bases: Method

Query the water level from an upstream submodel that follows the StorageModel_V1 interface.

Required by the methods:

Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V5 Determine_MaxTimeStep_V6

Calculates the factor sequence:

WaterLevelUpstream

Example:

>>> from hydpy import prepare_model
>>> main, sub = prepare_model("sw1d"), prepare_model("sw1d_storage")
>>> sub.sequences.factors.waterlevel = 2.0
>>> main.storagemodelupstream = sub
>>> main.storagemodelupstream_typeid = 1
>>> main.calc_waterlevelupstream_v1()
>>> main.sequences.factors.waterlevelupstream
waterlevelupstream(2.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterLevelDownstream_V1[source]

Bases: Method

Query the water level from a downstream submodel that follows the StorageModel_V1 interface.

Required by the methods:

Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V6

Calculates the factor sequence:

WaterLevelDownstream

Example:

>>> from hydpy import prepare_model
>>> main, sub = prepare_model("sw1d"), prepare_model("sw1d_storage")
>>> sub.sequences.factors.waterlevel = 2.0
>>> main.storagemodeldownstream = sub
>>> main.storagemodeldownstream_typeid = 1
>>> main.calc_waterleveldownstream_v1()
>>> main.sequences.factors.waterleveldownstream
waterleveldownstream(2.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterVolumeUpstream_V1[source]

Bases: Method

Query the water volume from an upstream submodel that follows the StorageModel_V1 interface.

Required by the methods:

Determine_Discharge_V1 Determine_Discharge_V5

Calculates the factor sequence:

WaterVolumeUpstream

Example:

>>> from hydpy import prepare_model
>>> main, sub = prepare_model("sw1d"), prepare_model("sw1d_storage")
>>> sub.sequences.states.watervolume = 2.0
>>> main.storagemodelupstream = sub
>>> main.storagemodelupstream_typeid = 1
>>> main.calc_watervolumeupstream_v1()
>>> main.sequences.factors.watervolumeupstream
watervolumeupstream(2.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterVolumeDownstream_V1[source]

Bases: Method

Query the water volume from a downstream submodel that follows the StorageModel_V1 interface.

Required by the methods:

Determine_Discharge_V1 Determine_Discharge_V5

Calculates the factor sequence:

WaterVolumeDownstream

Example:

>>> from hydpy import prepare_model
>>> main, sub = prepare_model("sw1d"), prepare_model("sw1d_storage")
>>> sub.sequences.states.watervolume = 2.0
>>> main.storagemodeldownstream = sub
>>> main.storagemodeldownstream_typeid = 1
>>> main.calc_watervolumedownstream_v1()
>>> main.sequences.factors.watervolumedownstream
watervolumedownstream(2.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterLevel_V1[source]

Bases: Method

Interpolate the water level based on the water levels of the adjacent channel segments.

Required by the methods:

Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V6

Requires the derived parameter:

WeightUpstream

Requires the factor sequences:

WaterLevelUpstream WaterLevelDownstream

Calculates the factor sequence:

WaterLevel

Basic equation:
\[\begin{split}WaterLevel = \omega \cdot WaterLevelUpstream + (1 - \omega) \cdot WaterLevelDownstream \\ \\ \omega = WeightUpstream\end{split}\]

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> derived.weightupstream(0.8)
>>> factors.waterlevelupstream = 3.0
>>> factors.waterleveldownstream = 1.0
>>> model.calc_waterlevel_v1()
>>> factors.waterlevel
waterlevel(2.6)
class hydpy.models.sw1d.sw1d_model.Calc_WaterLevel_V2[source]

Bases: Method

Take the water level from the downstream channel segment.

Required by the method:

Determine_MaxTimeStep_V2

Requires the factor sequence:

WaterLevelDownstream

Calculates the factor sequence:

WaterLevel

Basic equation:

\(WaterLevel = WaterLevelDownstream\)

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> factors.waterleveldownstream = 3.0
>>> model.calc_waterlevel_v2()
>>> factors.waterlevel
waterlevel(3.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterLevel_V3[source]

Bases: Method

Take the water level from the upstream channel segment.

Required by the methods:

Determine_Discharge_V7 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V4

Requires the factor sequence:

WaterLevelUpstream

Calculates the factor sequence:

WaterLevel

Basic equation:

\(WaterLevel = WaterLevelUpstream\)

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> factors.waterlevelupstream = 3.0
>>> model.calc_waterlevel_v3()
>>> factors.waterlevel
waterlevel(3.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterLevel_V4[source]

Bases: Method

Average the upstream and the downstream water level.

Required by the method:

Determine_MaxTimeStep_V5

Requires the factor sequences:

WaterLevelUpstream WaterLevelDownstream

Calculates the factor sequence:

WaterLevel

Basic equation:

\(WaterLevel = (WaterLevelUpstream + WaterLevelUpstream) / 2\)

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> factors.waterlevelupstream = 3.0
>>> factors.waterleveldownstream = 1.0
>>> model.calc_waterlevel_v4()
>>> factors.waterlevel
waterlevel(2.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterDepth_WaterLevel_CrossSectionModel_V2[source]

Bases: Method

Let a submodel that follows the CrossSectionModel_V2 submodel interface calculate the water depth and level based on the current water volume.

Required by the method:

Calc_WaterDepth_WaterLevel_V1

Requires the control parameter:

Length

Requires the state sequence:

WaterVolume

Calculates the factor sequences:

WaterDepth WaterLevel

class hydpy.models.sw1d.sw1d_model.Calc_WaterDepth_WaterLevel_V1[source]

Bases: Method

Let a submodel that follows the CrossSectionModel_V2 submodel interface calculate the water depth and level based on the current water volume.

Required by the methods:

Perform_Preprocessing_V3 Update_Storage_V1

Required submethod:

Calc_WaterDepth_WaterLevel_CrossSectionModel_V2

Requires the control parameter:

Length

Requires the state sequence:

WaterVolume

Calculates the factor sequences:

WaterDepth WaterLevel

Example:

We use wq_trapeze as an example submodel and configure it so that a wetted area of 18 m² corresponds to water depth of 4 m and a water level of 5 m:

>>> from hydpy.models.sw1d_storage import *
>>> parameterstep()
>>> length(2.0)
>>> with model.add_crosssection_v2("wq_trapeze"):
...     nmbtrapezes(3)
...     bottomlevels(1.0, 3.0, 4.0)
...     bottomwidths(2.0, 0.0, 2.0)
...     sideslopes(0.0, 2.0, 2.0)
>>> states.watervolume = 36.0
>>> model.calc_waterdepth_waterlevel_v1()
>>> factors.waterdepth
waterdepth(4.0)
>>> factors.waterlevel
waterlevel(5.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterDepth_WettedArea_CrossSectionModel_V2[source]

Bases: Method

Let a submodel that follows the CrossSectionModel_V2 submodel interface calculate the water depth and the wetted area based on the current water level.

Required by the method:

Calc_WaterDepth_WettedArea_V1

Requires the factor sequence:

WaterLevel

Calculates the factor sequences:

WaterDepth WettedArea

class hydpy.models.sw1d.sw1d_model.Calc_WaterDepth_WettedArea_V1[source]

Bases: Method

Let a submodel that follows the CrossSectionModel_V2 submodel interface calculate the water depth and the wetted area based on the current water level.

Required by the methods:

Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V6

Required submethod:

Calc_WaterDepth_WettedArea_CrossSectionModel_V2

Requires the factor sequence:

WaterLevel

Calculates the factor sequences:

WaterDepth WettedArea

Example:

We use wq_trapeze as an example submodel and configure it so that a water level of 5 m corresponds to a water depth of 4 m and a wetted area of 18 m²:

>>> from hydpy.models.sw1d_pump import *
>>> parameterstep()
>>> with model.add_crosssection_v2("wq_trapeze"):
...     nmbtrapezes(3)
...     bottomlevels(1.0, 3.0, 4.0)
...     bottomwidths(2.0, 0.0, 2.0)
...     sideslopes(0.0, 2.0, 2.0)
>>> factors.waterlevel = 5.0
>>> model.calc_waterdepth_wettedarea_v1()
>>> factors.waterdepth
waterdepth(4.0)
>>> factors.wettedarea
wettedarea(18.0)
class hydpy.models.sw1d.sw1d_model.Calc_WaterDepth_WettedArea_WettedPerimeter_CrossSectionModel_V2[source]

Bases: Method

Let a submodel that follows the CrossSectionModel_V2 submodel interface calculate the water depth, the wetted area, and the wetted perimeter based on the current water level.

Required by the method:

Calc_WaterDepth_WettedArea_WettedPerimeter_V1

Requires the factor sequence:

WaterLevel

Calculates the factor sequences:

WaterDepth WettedArea WettedPerimeter

class hydpy.models.sw1d.sw1d_model.Calc_WaterDepth_WettedArea_WettedPerimeter_V1[source]

Bases: Method

Let a submodel that follows the CrossSectionModel_V2 submodel interface calculate the water depth, the wetted area, and the wetted perimeter based on the current water level.

Required by the method:

Determine_MaxTimeStep_V1

Required submethod:

Calc_WaterDepth_WettedArea_WettedPerimeter_CrossSectionModel_V2

Requires the factor sequence:

WaterLevel

Calculates the factor sequences:

WaterDepth WettedArea WettedPerimeter

Example:

We use wq_trapeze as an example submodel and configure it so that a water level of 5 m corresponds to a water depth of 4 m, a wetted area of 18 m², and a wetted perimeter of nearly 23 m:

>>> from hydpy.models.sw1d_lias import *
>>> parameterstep()
>>> with model.add_crosssection_v2("wq_trapeze"):
...     nmbtrapezes(3)
...     bottomlevels(1.0, 3.0, 4.0)
...     bottomwidths(2.0, 0.0, 2.0)
...     sideslopes(0.0, 2.0, 2.0)
>>> factors.waterlevel = 5.0
>>> model.calc_waterdepth_wettedarea_wettedperimeter_v1()
>>> factors.waterdepth
waterdepth(4.0)
>>> factors.wettedarea
wettedarea(18.0)
>>> factors.wettedperimeter
wettedperimeter(22.944272)
class hydpy.models.sw1d.sw1d_model.Calc_DischargeUpstream_V1[source]

Bases: Method

Sum the (partial) discharge of all upstream routing submodels following the RoutingModel_V1 or RoutingModel_V2 interface.

Required by the method:

Determine_MaxTimeStep_V1

Requires the state sequence:

Discharge

Calculates the flux sequence:

DischargeUpstream

Examples:

If there is no upstream model, DischargeUpstream is zero:

>>> from hydpy import prepare_model
>>> c2 = prepare_model("sw1d_channel")
>>> c2.parameters.control.nmbsegments(1)
>>> with c2.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> with c2.add_routingmodel_v2("sw1d_lias", position=1, update=False) as r2:
...     states.discharge = 5.0
>>> r2.calc_dischargeupstream_v1()
>>> r2.sequences.fluxes.dischargeupstream
dischargeupstream(0.0)

Otherwise, Calc_DischargeUpstream_V1 totals the individual (partial) discharge values:

>>> from hydpy import Element, Node
>>> n012 = Node("n012", variable="LongQ")
>>> e2 = Element("e2", inlets=n012)
>>> e2.model = c2
>>> e0, e1 = Element("e0", outlets=n012), Element("e1", outlets=n012)
>>> for element, discharge in ((e0, 1.0), (e1, 3.0)):
...     c = prepare_model("sw1d_channel")
...     element.model = c
...     c.parameters.control.nmbsegments(1)
...     with c.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...         pass
...     with c.add_routingmodel_v2("sw1d_lias", position=1, update=False):
...         states.discharge = discharge
>>> network = c2.couple_models(nodes=(n012,), elements=(e0, e1, e2))
>>> r2.calc_dischargeupstream_v1()
>>> r2.sequences.fluxes.dischargeupstream
dischargeupstream(4.0)
class hydpy.models.sw1d.sw1d_model.Calc_DischargeDownstream_V1[source]

Bases: Method

Sum the (partial) discharge of all downstream routing submodels following the RoutingModel_V2 or RoutingModel_V3 interface.

Required by the method:

Determine_MaxTimeStep_V1

Requires the state sequence:

Discharge

Calculates the flux sequence:

DischargeDownstream

Examples:

If there is no downstream model, DischargeDownstream is zero:

>>> from hydpy import prepare_model
>>> c0 = prepare_model("sw1d_channel")
>>> c0.parameters.control.nmbsegments(1)
>>> with c0.add_routingmodel_v2("sw1d_lias", position=0, update=False) as r0:
...     states.discharge = 5.0
>>> with c0.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> r0.calc_dischargedownstream_v1()
>>> r0.sequences.fluxes.dischargedownstream
dischargedownstream(0.0)

Otherwise, Calc_DischargeDownstream_V1 totals the individual (partial) discharge values:

>>> from hydpy import Element, Node
>>> n012 = Node("n012", variable="LongQ")
>>> e0 = Element("e0", outlets=n012)
>>> e0.model = c0
>>> e1, e2 = Element("e1", inlets=n012), Element("e2", inlets=n012)
>>> for element, discharge in ((e1, 1.0), (e2, 3.0)):
...     c = prepare_model("sw1d_channel")
...     element.model = c
...     c.parameters.control.nmbsegments(1)
...     with c.add_routingmodel_v2("sw1d_lias", position=0, update=False):
...         states.discharge = discharge
...     with c.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...         pass
>>> network = c0.couple_models(nodes=(n012,), elements=(e0, e1, e2))
>>> r0.calc_dischargedownstream_v1()
>>> r0.sequences.fluxes.dischargedownstream
dischargedownstream(4.0)
class hydpy.models.sw1d.sw1d_model.Calc_Discharge_V1[source]

Bases: Method

Calculate the discharge according to Bates et al. (2010) and de Almeida et al. (2012).

Required by the methods:

Determine_Discharge_V1 Determine_Discharge_V5

Requires the control parameters:

DiffusionFactor StricklerCoefficient

Requires the derived parameter:

LengthMean

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequences:

TimeStep WettedArea WettedPerimeter WaterLevelUpstream WaterLevelDownstream

Requires the flux sequences:

DischargeUpstream DischargeDownstream

Updates the state sequence:

Discharge

Basic equation (de Almeida et al., 2012):
\[\begin{split}Q_{i-1/2}^{n+1} = \frac{\left[ (1-\theta) \cdot Q_{i-1/2}^n + \frac{\theta}{2} \cdot \left( Q_{i-3/2}^n + Q_{i+1/2}^n\right) \right] + g \cdot A_f \cdot \Delta t^n \cdot (y_{i-1}^n - y_i^n) / \Delta x} {1 + g \cdot \Delta t \cdot k_{st}^{-2} \cdot \left| Q_{i-1/2}^n \right| \cdot {P_f^n}^{\frac{4}{3}} \cdot {A_f^n}^{-\frac{7}{3}}} \\ \\ Q = Discharge \\ \theta = DiffusionFactor \\ g = GravitationalAcceleration \\ A_f = WettedArea \\ \Delta t = TimeStep \\ \Delta x = Length \\ y = WaterLevel \\ k_{st} = StricklerCoefficient \\ P_f = WettedPerimeter\end{split}\]

Examples:

The following channel configuration corresponds to a rectangular profile and a water surface slope of one meter per kilometre:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> diffusionfactor(0.2)
>>> stricklercoefficient(50.0)
>>> derived.lengthmean(2.0)
>>> factors.timestep = 100.0
>>> factors.wettedarea = 6.0
>>> factors.wettedperimeter = 8.0
>>> factors.waterlevelupstream = 5.0
>>> factors.waterleveldownstream = 3.0

According to the Manning-Strickler equation, this configuration corresponds to a discharge of about 8 m³/s:

>>> dh = factors.waterlevelupstream - factors.waterleveldownstream
>>> i = dh/ (1000.0 * derived.lengthmean)
>>> r = factors.wettedarea / factors.wettedperimeter
>>> v = stricklercoefficient * r**(2.0/3.0) * i**0.5
>>> q = factors.wettedarea * v
>>> from hydpy import round_
>>> round_(q)
7.831208

If we use this value as the “old” discharge, relevant for the local inertial term, Calc_Discharge_V1 calculates the same value as the “new” discharge, demonstrating its agreement with Manning-Stricker for stationary conditions:

>>> fluxes.dischargeupstream = q
>>> fluxes.dischargedownstream = q
>>> states.discharge = q
>>> model.calc_discharge_v1()
>>> states.discharge
discharge(7.831208)

Reversing the surface water slope and the “old” discharge reverses the “new” discharge:

>>> factors.waterlevelupstream = -5.0
>>> factors.waterleveldownstream = -3.0
>>> fluxes.dischargeupstream = -q
>>> fluxes.dischargedownstream = -q
>>> states.discharge = -q
>>> model.calc_discharge_v1()
>>> states.discharge
discharge(-7.831208)

With zero initial discharge, the estimated discharge becomes smaller:

>>> factors.waterlevelupstream = 5.0
>>> factors.waterleveldownstream = 3.0
>>> fluxes.dischargeupstream = 0.0
>>> fluxes.dischargedownstream = 0.0
>>> states.discharge = 0.0
>>> model.calc_discharge_v1()
>>> states.discharge
discharge(5.886)

For differences between the initial discharge at the upstream, the actual, and the downstream position, the extension introduced by de Almeida et al. (2012) to increase computational stability via numerical diffusion becomes relevant:

>>> states.discharge = q
>>> model.calc_discharge_v1()
>>> states.discharge
discharge(6.937035)

Calc_Discharge_V1 sets the discharge directly to zero for zero wetted cross-section areas to prevent zero division errors:

>>> factors.wettedarea = 0.0
>>> model.calc_discharge_v1()
>>> states.discharge
discharge(0.0)
class hydpy.models.sw1d.sw1d_model.Calc_Discharge_V2[source]

Bases: Method

Calculate the free weir flow after Poleni.

Required by the method:

Determine_Discharge_V3

Requires the control parameters:

CrestHeight CrestWidth FlowCoefficient

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequence:

WaterLevel

Updates the state sequence:

Discharge

Basic equation:
\[\begin{split}Q = w \cdot 2 / 3 \cdot c \cdot \sqrt{2 \cdot g} \cdot h^{3/2} \\ \\ w = CrestWidth \\ c = FlowCoefficient \\ g = GravitationalAcceleration \\ h = max(WaterLevel - CrestHeight, \ 0)\end{split}\]

Examples:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> crestwidth(10.0)
>>> crestheight(5.0)
>>> flowcoefficient(0.6)
>>> factors.waterlevel = 7.0
>>> model.calc_discharge_v2()
>>> states.discharge
discharge(50.113471)
>>> factors.waterlevel = 4.0
>>> model.calc_discharge_v2()
>>> states.discharge
discharge(0.0)
>>> factors.waterlevel = 5.0
>>> model.calc_discharge_v2()
>>> states.discharge
discharge(0.0)
class hydpy.models.sw1d.sw1d_model.Calc_Discharge_V3[source]

Bases: Method

Calculate the flow under a gate.

Required by the method:

Determine_Discharge_V6

Requires the control parameters:

BottomLevel GateWidth GateHeight FlowCoefficient DampingRadius

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequences:

WaterLevel WaterLevelUpstream WaterLevelDownstream

Updates the state sequence:

Discharge

Basic equation:
\[\begin{split}Q = d \cdot w \cdot c \cdot \big( min (h, \ l) - b \big) \cdot \sqrt{2 \cdot g \cdot (l_u - l_d)} \\ \\ d = f_{filter\_norm}(l_u, \ l_d, \ DampingRadius) \\ w = GateWidth \\ c = FlowCoefficient \\ h = GateHeight \\ l = WaterLevel \\ l_u = WaterLevelUpstream \\ l_d = WaterLevelDownstream\\ b = BottomLevel \\ g = GravitationalAcceleration\end{split}\]

Examples:

The first two examples deal with flow under a submerged gate:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> bottomlevel(4.0)
>>> gateheight(6.0)
>>> gatewidth(3.0)
>>> flowcoefficient(0.6)
>>> dampingradius(0.0)
>>> factors.waterlevel = 8.0
>>> factors.waterlevelupstream = 9.0
>>> factors.waterleveldownstream = 7.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(22.551062)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(-22.551062)

The next two examples deal with a gate submerge “on one side”:

>>> gateheight(8.0)
>>> factors.waterlevelupstream = 9.0
>>> factors.waterleveldownstream = 7.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(45.102124)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(-45.102124)

For non-submerged gates, the water level becomes the effective gate opening:

>>> gateheight(10.0)
>>> factors.waterlevelupstream = 9.0
>>> factors.waterleveldownstream = 7.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(45.102124)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(-45.102124)

Negative effective gate openings result in zero discharge values:

>>> gateheight(0.0)
>>> factors.waterlevelupstream = 9.0
>>> factors.waterleveldownstream = 7.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(0.0)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(0.0)

According to the given base equation, the change in flow rate with respect to changes in the water level gradient is highest for little water level gradients. For nearly zero gradients, these changes are so extreme that numerically solving this ordinary differential equation in combination with the ones of other routing models may introduce considerable artificial oscillations.

In the following example, a water level gradient of 1 mm corresponds to a discharge of only 0.3 m³/s, but also to a discharge increase of nearly 1600 m³/s per meter rise of the upstream water level:

>>> gateheight(10.0)
>>> factors.waterlevelupstream = 8.0001
>>> factors.waterleveldownstream = 8.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(0.31892)
>>> from hydpy import NumericalDifferentiator, round_
>>> numdiff = NumericalDifferentiator(
...     xsequence=factors.waterlevelupstream,
...     ysequences=[states.discharge],
...     methods=[model.calc_discharge_v3])
>>> numdiff()
d_discharge/d_waterlevelupstream: 1594.591021

Principally, one could reduce the resulting oscillations by decreasing the internal calculation step size. However, this alone sometimes results in unacceptable increases in computation time. Hence, we suggest using the DampingRadius parameter to prevent such oscillations. Setting it, for example, to 1 mm reduces the change in discharge to 40 m³/s per meter:

>>> dampingradius(0.001)
>>> numdiff()
d_discharge/d_waterlevelupstream: 39.685825

Be careful not to set larger values than necessary, as this stabilisation trick does not only reduce the discharge derivative but also the discharge itself:

>>> model.calc_discharge_v3()
>>> states.discharge
discharge(0.001591)

All of the above examples deal with fixed gate openings. However, in reality, gates are often controlled, so their opening degree depends on other properties. Therefore, parameter GateHeight alternatively accepts a callback function for adjusting its values based on the current model state. One can, for example, define a “sluice” function that prevents any flow for reversed water level gradients:

>>> def sluice(model) -> None:
...     con = model.parameters.control.fastaccess
...     fac = model.sequences.factors.fastaccess
...     if fac.waterlevelupstream < fac.waterleveldownstream:
...         con.gateheight = 4.0
...     else:
...         con.gateheight = 10.0
>>> ();gateheight(callback=sluice);()  
(...)

Method Calc_Discharge_V3 applies this callback function before performing its further calculations. Hence, the following results agree with the “non-submerged gates” example for a positive water level gradient and the “negative effective gate opening” example for a negative one:

>>> factors.waterlevelupstream = 9.0
>>> factors.waterleveldownstream = 7.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(45.102124)
>>> factors.waterlevelupstream = 7.0
>>> factors.waterleveldownstream = 9.0
>>> model.calc_discharge_v3()
>>> states.discharge
discharge(0.0)
class hydpy.models.sw1d.sw1d_model.Calc_Discharge_V4[source]

Bases: Method

Calculate the pumping rate.

Required by the method:

Determine_Discharge_V7

Requires the control parameters:

Gradient2PumpingRate TargetWaterLevel1 TargetWaterLevel2

Requires the factor sequences:

WaterLevelUpstream WaterLevelDownstream

Updates the state sequence:

Discharge

Basic equation:
\[\]
Basic equations:
\[\begin{split}Discharge = \begin{cases} 0 &|\ h_u < t_1 \\ Q^* \cdot \frac{h_u - t_1}{t_2 - t_1} &|\ t_1 \leq h_u < t_2 \\ Q^* &|\ t_2 \leq h_u \end{cases} \\ \\ \\ Q^* = max \big( f_{gradient2pumpingrate}(h_d - h_u), \ 0 \big) \\ h_u = WaterLevelUpstream \\ h_d = WaterLevelDownstream \\ t_1 = TargetWaterLevel1 \\ t_2 = TargetWaterLevel2\end{split}\]

Examples:

The maximum pumping rate is 1 m³/s for equal water levels and decreases linearly with rising downstream water levels until it reaches 0 m³/s:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> gradient2pumpingrate(PPoly(Poly(x0=0.0, cs=[1.0, -0.1]),
...                            Poly(x0=10.0, cs=[0.0])))

We prepare a UnitTest object to demonstrate how Calc_Discharge_V4 behaves when the upstream water level changes:

>>> from hydpy import UnitTest
>>> test = UnitTest(
...     model, model.calc_discharge_v4,
...     last_example=7,
...     parseqs=(factors.waterlevelupstream, states.discharge))

We fix the downstream water level to 2 m and vary the upstream water level between 1.5 m to 4.5 m:

>>> factors.waterleveldownstream = 2.0
>>> test.nexts.waterlevelupstream = 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5

If we set both target water levels to the same value, the pump becomes fully activated or deactivated when the upstream water level exceeds or falls below this threshold:

>>> targetwaterlevel1(2.0)
>>> targetwaterlevel2(2.0)
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.5 |       0.0 |
|   2 |                2.0 |       1.0 |
|   3 |                2.5 |      0.95 |
|   4 |                3.0 |       0.9 |
|   5 |                3.5 |      0.85 |
|   6 |                4.0 |       0.8 |
|   7 |                4.5 |      0.75 |

Setting TargetWaterLevel1 and TargetWaterLevel2 to the same value might result in situations with frequent “on-off switching”, which may eventually have adverse effects on computational efficiency or simulation accuracy. After setting TargetWaterLevel2 to 4 m, the pump’s transition between on and off becomes smoother:

>>> targetwaterlevel2(4.0)
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.5 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                2.5 |    0.2375 |
|   4 |                3.0 |      0.45 |
|   5 |                3.5 |    0.6375 |
|   6 |                4.0 |       0.8 |
|   7 |                4.5 |      0.75 |
class hydpy.models.sw1d.sw1d_model.Update_Discharge_V1[source]

Bases: Method

Reduce the already calculated discharge due to limited water availability in one of the adjacent channel segments.

Required by the methods:

Determine_Discharge_V1 Determine_Discharge_V5

Requires the factor sequences:

TimeStep WaterVolumeUpstream WaterVolumeDownstream

Updates the state sequence:

Discharge

Basic equations:
\[\begin{split}Q_{new} = \begin{cases} max(Q_{old}, \ 1000 \cdot max(V_u, \ 0) / \Delta &|\ Q_{old} > 0 \\ min(Q_{old}, \ -1000 \cdot max(V_d, \ 0) / \Delta &|\ Q_{old} < 0 \end{cases} \\ \\ \\ Q = Discharge \\ V_u = WaterVolumeUpstream \\ V_d = WaterVolumeDownstream \\ \Delta = TimeStep\end{split}\]

Examples:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> factors.timestep = 100.0
>>> factors.watervolumeupstream = 0.1
>>> factors.watervolumedownstream = 0.2

Update_Discharge_V1 must consider the upstream segment’s water volume for positive discharge values:

>>> states.discharge = 1.0
>>> model.update_discharge_v1()
>>> states.discharge
discharge(1.0)
>>> states.discharge = 2.0
>>> model.update_discharge_v1()
>>> states.discharge
discharge(1.0)

Instead, it must consider the downstream segment’s water volume for negative discharge values:

>>> states.discharge = -2.0
>>> model.update_discharge_v1()
>>> states.discharge
discharge(-2.0)
>>> states.discharge = -3.0
>>> model.update_discharge_v1()
>>> states.discharge
discharge(-2.0)
class hydpy.models.sw1d.sw1d_model.Update_Discharge_V2[source]

Bases: Method

Sluice-like discharge reduction with separate control for low and high flow protection.

Required by the method:

Determine_Discharge_V5

Requires the control parameters:

BottomLowWaterThreshold UpperLowWaterThreshold BottomHighWaterThreshold UpperHighWaterThreshold

Requires the derived parameter:

TOY

Requires the factor sequences:

WaterLevelUpstream WaterLevelDownstream

Updates the state sequence:

Discharge

Basic equations:
\[\begin{split}Q_{new} = Q_{new} \cdot \begin{cases} free &|\ h_u \leq h_d \\ free + sluice &|\ h_d < h_u \\ \end{cases} \\ \\ \\ closed = \begin{cases} 1 &|\ h_u \leq t_{bl} \\ 1 - \frac{h_u - t_{bl}}{t_{ul} - t_{bl}} &|\ t_{bl} < h_u < t_{ul} \\ 0 &|\ t_{ul} \leq h_u \end{cases} \\ \\ sluice = \begin{cases} 0 &|\ h_u \leq t_{bh} \\ \frac{h_u - t_{bh}}{t_{uh} - t_{bh}} &|\ t_{bh} < h_u < t_{uh} \\ 1 &|\ t_{uh} \leq h_u \end{cases} \\ \\ free = 1 - closed - sluice \\ \\ Q = Discharge \\ h_u = WaterLevelUpstream \\ h_d = WaterLevelDownstream \\ t_{bl} = BottomLowWaterThreshold \\ t_{ul} = UpperLowWaterThreshold \\ t_{bh} = BottomHighWaterThreshold \\ t_{uh} = UpperHighWaterThreshold\end{split}\]

Examples:

All involved control parameters are subclasses of SeasonalParameter, which allows the simulation of seasonal sluice control schemes. To show how this works, we first define a simulation period of four days:

>>> from hydpy import pub
>>> pub.timegrids = "2000-01-01", "2000-01-05", "1d"

We prepare a model and define different control schemes for four consecutive days:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> bottomlowwaterthreshold(_1_1_12=5.0, _1_2_12=2.0, _1_3_12=2.0, _1_4_12=2.0)
>>> upperlowwaterthreshold(_1_1_12=5.0, _1_2_12=8.0, _1_3_12=5.0, _1_4_12=6.0)
>>> bottomhighwaterthreshold(_1_1_12=5.0, _1_2_12=2.0, _1_3_12=5.0, _1_4_12=4.0)
>>> upperhighwaterthreshold(_1_1_12=5.0, _1_2_12=8.0, _1_3_12=8.0, _1_4_12=8.0)
>>> derived.toy.update()

We prepare a UnitTest object to demonstrate the dependency of Update_Discharge_V2 on the downstream water level:

>>> from hydpy import UnitTest
>>> test = UnitTest(model, model.update_discharge_v2, last_example=9,
...                 parseqs=(factors.waterlevelupstream, states.discharge))
>>> test.nexts.waterlevelupstream = 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0

We will discuss each day’s control scheme for a normal flow situation with a relatively low downstream water level and a reversed flow situation with a relatively high downstream water level.

For April 1, all threshold parameters have the same value of 5 m. So, gates are generally closed below an upstream water level of 5 m to prevent the source catchment from running dry during low flow periods (“closed gate”) and only allow normal flow above 5 m to maximise drainage during high flow periods (“sluice mode”):

>>> model.idx_sim = pub.timegrids.init["2000-01-01"]
>>> factors.waterleveldownstream = 0.0
>>> test.inits.discharge = 1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 |       0.0 |
|   4 |                4.0 |       0.0 |
|   5 |                5.0 |       1.0 |
|   6 |                6.0 |       1.0 |
|   7 |                7.0 |       1.0 |
|   8 |                8.0 |       1.0 |
|   9 |                9.0 |       1.0 |
>>> factors.waterleveldownstream = 10.0
>>> test.inits.discharge = -1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 |       0.0 |
|   4 |                4.0 |       0.0 |
|   5 |                5.0 |       0.0 |
|   6 |                6.0 |       0.0 |
|   7 |                7.0 |       0.0 |
|   8 |                8.0 |       0.0 |
|   9 |                9.0 |       0.0 |

In the following examples, he transitions between the low and high water control schemes are not sharp but gradual, which is often more realistic and numerically favourable. For April 2, the values of BottomLowWaterThreshold and BottomHighWaterThreshold and the values of UpperLowWaterThreshold and UpperHighWaterThreshold are equal. Hence, we see a linear-interpolation-like transition from the “closed gate” to the “sluice mode” control schemes:

>>> model.idx_sim = pub.timegrids.init["2000-01-02"]
>>> factors.waterleveldownstream = 0.0
>>> test.inits.discharge = 1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 |  0.166667 |
|   4 |                4.0 |  0.333333 |
|   5 |                5.0 |       0.5 |
|   6 |                6.0 |  0.666667 |
|   7 |                7.0 |  0.833333 |
|   8 |                8.0 |       1.0 |
|   9 |                9.0 |       1.0 |
>>> factors.waterleveldownstream = 10.0
>>> test.inits.discharge = -1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 |       0.0 |
|   4 |                4.0 |       0.0 |
|   5 |                5.0 |       0.0 |
|   6 |                6.0 |       0.0 |
|   7 |                7.0 |       0.0 |
|   8 |                8.0 |       0.0 |
|   9 |                9.0 |       0.0 |

For April 3, the values of UpperLowWaterThreshold and BottomHighWaterThreshold are equal. So, at this point, neither the “closed gate” nor the “sluice mode” control schemes apply, and the water can flow freely in both directions (“free discharge”):

>>> model.idx_sim = pub.timegrids.init["2000-01-03"]
>>> factors.waterleveldownstream = 0.0
>>> test.inits.discharge = 1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 |  0.333333 |
|   4 |                4.0 |  0.666667 |
|   5 |                5.0 |       1.0 |
|   6 |                6.0 |       1.0 |
|   7 |                7.0 |       1.0 |
|   8 |                8.0 |       1.0 |
|   9 |                9.0 |       1.0 |
>>> factors.waterleveldownstream = 10.0
>>> test.inits.discharge = -1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 | -0.333333 |
|   4 |                4.0 | -0.666667 |
|   5 |                5.0 |      -1.0 |
|   6 |                6.0 | -0.666667 |
|   7 |                7.0 | -0.333333 |
|   8 |                8.0 |       0.0 |
|   9 |                9.0 |       0.0 |

For April 4, the “closed gate” and “sluice mode” parameter ranges are partly overlapping, so reversed flow can occur but only with reduced intensity:

>>> model.idx_sim = pub.timegrids.init["2000-01-04"]
>>> factors.waterleveldownstream = 0.0
>>> test.inits.discharge = 1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 |      0.25 |
|   4 |                4.0 |       0.5 |
|   5 |                5.0 |      0.75 |
|   6 |                6.0 |       1.0 |
|   7 |                7.0 |       1.0 |
|   8 |                8.0 |       1.0 |
|   9 |                9.0 |       1.0 |
>>> factors.waterleveldownstream = 10.0
>>> test.inits.discharge = -1.0
>>> test()
| ex. | waterlevelupstream | discharge |
----------------------------------------
|   1 |                1.0 |       0.0 |
|   2 |                2.0 |       0.0 |
|   3 |                3.0 |     -0.25 |
|   4 |                4.0 |      -0.5 |
|   5 |                5.0 |      -0.5 |
|   6 |                6.0 |      -0.5 |
|   7 |                7.0 |     -0.25 |
|   8 |                8.0 |       0.0 |
|   9 |                9.0 |       0.0 |
class hydpy.models.sw1d.sw1d_model.Reset_DischargeVolume_V1[source]

Bases: Method

Reset the discharge volume to zero (at the beginning of an external simulation step).

Required by the methods:

Perform_Preprocessing_V2 Perform_Preprocessing_V5

Calculates the flux sequence:

DischargeVolume

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> fluxes.dischargevolume = 1.0
>>> model.reset_dischargevolume_v1()
>>> fluxes.dischargevolume
dischargevolume(0.0)
class hydpy.models.sw1d.sw1d_model.Update_DischargeVolume_V1[source]

Bases: Method

Update the total discharge volume of the current external simulation step.

Required by the methods:

Determine_Discharge_V1 Determine_Discharge_V3 Determine_Discharge_V5 Determine_Discharge_V6 Determine_Discharge_V7

Requires the factor sequence:

TimeStep

Requires the state sequence:

Discharge

Updates the flux sequence:

DischargeVolume

Basic equation:

\(DischargeVolume_{new} = DischargeVolume_{old} + TimeStep \cdot Discharge\)

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> fluxes.dischargevolume = 6.0
>>> factors.timestep = 60.0
>>> states.discharge = 0.2
>>> model.update_dischargevolume_v1()
>>> fluxes.dischargevolume
dischargevolume(18.0)
class hydpy.models.sw1d.sw1d_model.Calc_DischargeVolume_V1[source]

Bases: Method

Calculate the total discharge volume of a complete external simulation step at once.

Required by the method:

Perform_Postprocessing_V1

Requires the derived parameter:

Seconds

Requires the flux sequence:

Inflow

Updates the flux sequence:

DischargeVolume

Basic equation:

\(DischargeVolume = Seconds \cdot Inflow\)

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> derived.seconds(60.0)
>>> fluxes.inflow = 2.0
>>> model.calc_dischargevolume_v1()
>>> fluxes.dischargevolume
dischargevolume(120.0)
class hydpy.models.sw1d.sw1d_model.Calc_DischargeVolume_V2[source]

Bases: Method

Calculate the total discharge volume of a complete external simulation step at once.

Required by the method:

Perform_Postprocessing_V4

Requires the derived parameter:

Seconds

Requires the flux sequence:

Outflow

Updates the flux sequence:

DischargeVolume

Basic equation:

\(DischargeVolume = Seconds \cdot Outflow\)

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> derived.seconds(60.0)
>>> fluxes.outflow = 2.0
>>> model.calc_dischargevolume_v2()
>>> fluxes.dischargevolume
dischargevolume(120.0)
class hydpy.models.sw1d.sw1d_model.Calc_Discharges_V1[source]

Bases: Method

Let a network model order all routing submodels following the RoutingModel_V1, RoutingModel_V2, or RoutingModel_V3 interface to determine their individual discharge values.

Example:

>>> from hydpy.models.sw1d_channel import *
>>> parameterstep()
>>> nmbsegments(2)
>>> with model.add_routingmodel_v2("sw1d_lias", position=1, update=False) as r:
...     diffusionfactor(0.2)
...     stricklercoefficient(50.0)
...     derived.lengthmean(2.0)
...     factors.timestep = 100.0
...     factors.wettedarea = 6.0
...     factors.wettedperimeter = 8.0
...     factors.waterlevelupstream = 5.0
...     factors.waterleveldownstream = 3.0
...     states.discharge = 7.831208
...     fluxes.dischargeupstream = 7.831208
...     fluxes.dischargedownstream = 7.831208
>>> model.calc_discharges_v1()
>>> r.sequences.states.discharge
discharge(7.831208)
class hydpy.models.sw1d.sw1d_model.Calc_Discharges_V2[source]

Bases: Method

Query the discharge volume of the complete external simulation step from all submodels following the RoutingModel_V1, RoutingModel_V2, or RoutingModel_V3 interface and calculate the corresponding average discharges.

Requires the derived parameter:

Seconds

Calculates the flux sequence:

Discharges

Basic equation:

\(Discharges_i = DischargeVolume / Seconds\)

Examples:

>>> from hydpy.models.sw1d_channel import *
>>> parameterstep()
>>> nmbsegments(2)
>>> derived.seconds(60.0)
>>> with model.add_routingmodel_v2("sw1d_lias", position=1, update=False):
...     fluxes.dischargevolume = 120.0
>>> model.calc_discharges_v2()
>>> fluxes.discharges
discharges(0.0, 2.0, 0.0)
class hydpy.models.sw1d.sw1d_model.Calc_NetInflow_V1[source]

Bases: Method

Calculate the net flow into a channel segment.

Required by the method:

Update_Storage_V1

Requires the factor sequence:

TimeStep

Requires the flux sequence:

LateralFlow

Calculates the flux sequence:

NetInflow

Examples:

Without adjacent routing models, net inflow equals lateral inflow:

>>> from hydpy import Element, Node, prepare_model
>>> c = prepare_model("sw1d_channel")
>>> c.parameters.control.nmbsegments(1)
>>> with c.add_storagemodel_v1("sw1d_storage", position=0, update=False) as s:
...     factors.timestep = 100.0
...     fluxes.lateralflow = 1.0
>>> s.calc_netinflow_v1()
>>> s.sequences.fluxes.netinflow
netinflow(0.1)

With adjacent routing models, Calc_NetInflow_V1 adds the discharge from the upper one and subtracts the discharge from the lower one:

>>> n01, n12 = Node("n01", variable="LongQ"), Node("n12", variable="LongQ")
>>> e1 = Element("e1", inlets=n01, outlets=n12)
>>> e1.model = c
>>> e0a, e0b = Element("e0a", outlets=n01), Element("e0b", outlets=n01)
>>> e2a, e2b = Element("e2a", inlets=n12), Element("e2b", inlets=n12)
>>> for element, position, discharge in ((e0a, 1, 1.0), (e0b, 1, 2.0),
...                                      (e2a, 0, 2.0), (e2b, 0, 3.0)):
...     c = prepare_model("sw1d_channel")
...     element.model = c
...     c.parameters.control.nmbsegments(1)
...     with c.add_routingmodel_v2(
...             "sw1d_lias", position=position, update=False):
...         states.discharge = discharge
...     with c.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...         pass
>>> network = c.couple_models(
...     nodes=(n01, n12), elements=(e0a, e0b, e1, e2a, e2b))
>>> s.calc_netinflow_v1()
>>> s.sequences.fluxes.netinflow
netinflow(-0.1)
class hydpy.models.sw1d.sw1d_model.Update_WaterVolume_V1[source]

Bases: Method

Update the current water content of a channel segment.

Required by the method:

Update_Storage_V1

Requires the flux sequence:

NetInflow

Updates the state sequence:

WaterVolume

Example:

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> states.watervolume = 2.0
>>> fluxes.netinflow = 1.0
>>> model.update_watervolume_v1()
>>> states.watervolume
watervolume(3.0)
class hydpy.models.sw1d.sw1d_model.Update_Storages_V1[source]

Bases: Method

Let a network model order all storage submodels to update their storage contents and their dependent factors.

Example:

>>> from hydpy.models.sw1d_channel import *
>>> parameterstep()
>>> nmbsegments(1)
>>> with model.add_routingmodel_v2("sw1d_lias", position=0, update=False):
...     states.discharge = 50.0
>>> with model.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     length(2.0)
...     states.watervolume = 2.0
...     factors.timestep = 100.0
...     fluxes.lateralflow = 1.0
>>> with model.add_routingmodel_v2("sw1d_lias", position=1, update=False):
...     states.discharge = 60.0
>>> model.update_storages()
>>> model.storagemodels[0].sequences.states.watervolume
watervolume(1.1)
class hydpy.models.sw1d.sw1d_model.Query_WaterLevels_V1[source]

Bases: Method

Query the water levels from all submodels following the StorageModel_V1 interface.

Calculates the factor sequence:

WaterLevels

Example:

>>> from hydpy.models.sw1d_channel import *
>>> parameterstep()
>>> nmbsegments(2)
>>> with model.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     factors.waterlevel = 1.0
>>> with model.add_storagemodel_v1("sw1d_storage", position=1, update=False):
...     factors.waterlevel = -1.0
>>> model.query_waterlevels_v1()
>>> factors.waterlevels
waterlevels(1.0, -1.0)
class hydpy.models.sw1d.sw1d_model.Perform_Preprocessing_V1[source]

Bases: AutoMethod

Routing model interface method for preprocessing data that is invariant within each external simulation step.

Required submethod:

Pick_Inflow_V1

Requires the inlet sequence:

LongQ

Calculates the flux sequence:

Inflow

class hydpy.models.sw1d.sw1d_model.Perform_Preprocessing_V2[source]

Bases: AutoMethod

Routing model interface method for preprocessing data that is invariant within each external simulation step.

Required submethod:

Reset_DischargeVolume_V1

Calculates the flux sequence:

DischargeVolume

class hydpy.models.sw1d.sw1d_model.Perform_Preprocessing_V3[source]

Bases: AutoMethod

Storage model interface method for preprocessing data that is invariant within each external simulation step.

Required submethods:

Pick_LateralFlow_V1 Calc_WaterDepth_WaterLevel_V1

Requires the control parameter:

Length

Requires the inlet sequence:

LatQ

Requires the state sequence:

WaterVolume

Calculates the factor sequences:

WaterDepth WaterLevel

Calculates the flux sequence:

LateralFlow

class hydpy.models.sw1d.sw1d_model.Perform_Preprocessing_V4[source]

Bases: AutoMethod

Routing model interface method for preprocessing data that is invariant within each external simulation step.

Required submethod:

Pick_Outflow_V1

Requires the outlet sequence:

LongQ

Calculates the flux sequence:

Outflow

class hydpy.models.sw1d.sw1d_model.Perform_Preprocessing_V5[source]

Bases: AutoMethod

Routing model interface method for preprocessing data that is invariant within each external simulation step.

Required submethods:

Pick_WaterLevelDownstream_V1 Reset_DischargeVolume_V1

Requires the receiver sequence:

WaterLevel

Calculates the factor sequence:

WaterLevelDownstream

Calculates the flux sequence:

DischargeVolume

class hydpy.models.sw1d.sw1d_model.Perform_Postprocessing_V1[source]

Bases: AutoMethod

Routing model interface method for executing all tasks necessary at the end of each external simulation step.

Required submethod:

Calc_DischargeVolume_V1

Requires the derived parameter:

Seconds

Requires the flux sequence:

Inflow

Updates the flux sequence:

DischargeVolume

class hydpy.models.sw1d.sw1d_model.Perform_Postprocessing_V2[source]

Bases: AutoMethod

Routing model interface method for executing all tasks necessary at the end of each external simulation step.

Required submethod:

Pass_Discharge_V1

Requires the derived parameter:

Seconds

Requires the flux sequence:

DischargeVolume

Calculates the inlet sequence:

LongQ

Calculates the outlet sequence:

LongQ

class hydpy.models.sw1d.sw1d_model.Perform_Postprocessing_V3[source]

Bases: AutoMethod

Storage model interface method for executing all tasks necessary at the end of each external simulation step.

Required submethod:

Pass_WaterLevel_V1

Requires the factor sequence:

WaterLevel

Calculates the sender sequence:

WaterLevel

class hydpy.models.sw1d.sw1d_model.Perform_Postprocessing_V4[source]

Bases: AutoMethod

Routing model interface method for executing all tasks necessary at the end of each external simulation step.

Required submethod:

Calc_DischargeVolume_V2

Requires the derived parameter:

Seconds

Requires the flux sequence:

Outflow

Updates the flux sequence:

DischargeVolume

class hydpy.models.sw1d.sw1d_model.Determine_MaxTimeStep_V1[source]

Bases: AutoMethod

Interface method for determining the highest possible computation time step at a central location.

Required submethods:

Calc_WaterLevelUpstream_V1 Calc_WaterLevelDownstream_V1 Calc_WaterLevel_V1 Calc_WaterDepth_WettedArea_WettedPerimeter_V1 Calc_DischargeUpstream_V1 Calc_DischargeDownstream_V1 Calc_MaxTimeStep_V1

Requires the control parameter:

TimeStepFactor

Requires the derived parameters:

WeightUpstream LengthMin

Requires the fixed parameter:

GravitationalAcceleration

Requires the state sequence:

Discharge

Calculates the factor sequences:

WaterLevelUpstream WaterLevelDownstream WaterLevel WaterDepth WettedArea WettedPerimeter MaxTimeStep

Calculates the flux sequences:

DischargeUpstream DischargeDownstream

class hydpy.models.sw1d.sw1d_model.Determine_MaxTimeStep_V2[source]

Bases: AutoMethod

Interface method for determining the highest possible computation time step at an inflow location.

Required submethods:

Calc_WaterLevelDownstream_V1 Calc_WaterLevel_V2 Calc_WaterDepth_WettedArea_V1 Calc_MaxTimeStep_V2

Requires the control parameters:

LengthDownstream TimeStepFactor

Requires the flux sequence:

Inflow

Calculates the factor sequences:

WaterLevelDownstream WaterLevel WaterDepth WettedArea MaxTimeStep

class hydpy.models.sw1d.sw1d_model.Determine_MaxTimeStep_V3[source]

Bases: AutoMethod

Interface method for determining the highest possible computation time step at an outflow weir.

Required submethods:

Calc_WaterLevelUpstream_V1 Calc_WaterLevel_V3 Calc_MaxTimeStep_V3

Requires the control parameters:

CrestHeight FlowCoefficient TimeStepFactor LengthUpstream

Requires the fixed parameter:

GravitationalAcceleration

Calculates the factor sequences:

WaterLevelUpstream WaterLevel MaxTimeStep

class hydpy.models.sw1d.sw1d_model.Determine_MaxTimeStep_V4[source]

Bases: AutoMethod

Interface method for determining the highest possible computation time step at an outflow location.

Required submethods:

Calc_WaterLevelUpstream_V1 Calc_WaterLevel_V3 Calc_WaterDepth_WettedArea_V1 Calc_MaxTimeStep_V4

Requires the control parameters:

LengthUpstream TimeStepFactor

Requires the flux sequence:

Outflow

Calculates the factor sequences:

WaterLevelUpstream WaterLevel WaterDepth WettedArea MaxTimeStep

class hydpy.models.sw1d.sw1d_model.Determine_MaxTimeStep_V5[source]

Bases: AutoMethod

Interface method for determining the highest possible computation time step at an outflow gate.

Required submethods:

Calc_WaterLevelUpstream_V1 Calc_WaterLevel_V4 Calc_MaxTimeStep_V5

Requires the control parameters:

BottomLevel GateHeight FlowCoefficient LengthUpstream TimeStepFactor

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequence:

WaterLevelDownstream

Calculates the factor sequences:

WaterLevelUpstream WaterLevel MaxTimeStep

class hydpy.models.sw1d.sw1d_model.Determine_MaxTimeStep_V6[source]

Bases: AutoMethod

Interface method for determining the highest possible computation time step at an inflow and outflow location.

Required submethods:

Calc_WaterLevelUpstream_V1 Calc_WaterLevelDownstream_V1 Calc_WaterLevel_V1 Calc_WaterDepth_WettedArea_V1 Calc_MaxTimeStep_V6

Requires the control parameter:

TimeStepFactor

Requires the derived parameters:

LengthMin WeightUpstream

Requires the state sequence:

Discharge

Calculates the factor sequences:

WaterLevelDownstream WaterLevelUpstream WaterLevel WaterDepth WettedArea MaxTimeStep

class hydpy.models.sw1d.sw1d_model.Determine_Discharge_V1[source]

Bases: AutoMethod

Interface method for determining the discharge at a central location.

Required submethods:

Calc_WaterVolumeUpstream_V1 Calc_WaterVolumeDownstream_V1 Calc_Discharge_V1 Update_Discharge_V1 Update_DischargeVolume_V1

Requires the control parameters:

StricklerCoefficient DiffusionFactor

Requires the derived parameter:

LengthMean

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequences:

WaterLevelUpstream WaterLevelDownstream WettedArea WettedPerimeter TimeStep

Requires the flux sequences:

DischargeUpstream DischargeDownstream

Updates the flux sequence:

DischargeVolume

Updates the state sequence:

Discharge

Calculates the factor sequences:

WaterVolumeUpstream WaterVolumeDownstream

class hydpy.models.sw1d.sw1d_model.Determine_Discharge_V2[source]

Bases: Method

Interface method for determining the discharge at an inflow location.

Requires the flux sequence:

Inflow

Updates the state sequence:

Discharge

class hydpy.models.sw1d.sw1d_model.Determine_Discharge_V3[source]

Bases: AutoMethod

Interface method for determining the discharge at an outflow weir.

Required submethods:

Calc_Discharge_V2 Update_DischargeVolume_V1

Requires the control parameters:

CrestHeight CrestWidth FlowCoefficient

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequences:

WaterLevel TimeStep

Updates the flux sequence:

DischargeVolume

Updates the state sequence:

Discharge

class hydpy.models.sw1d.sw1d_model.Determine_Discharge_V4[source]

Bases: Method

Interface method for determining the discharge at an outflow location.

Requires the flux sequence:

Outflow

Updates the state sequence:

Discharge

class hydpy.models.sw1d.sw1d_model.Determine_Discharge_V5[source]

Bases: AutoMethod

Interface method for determining the sluice-modified discharge at a central location considering.

Required submethods:

Calc_WaterVolumeUpstream_V1 Calc_WaterVolumeDownstream_V1 Calc_Discharge_V1 Update_Discharge_V1 Update_Discharge_V2 Update_DischargeVolume_V1

Requires the control parameters:

StricklerCoefficient DiffusionFactor BottomLowWaterThreshold UpperLowWaterThreshold BottomHighWaterThreshold UpperHighWaterThreshold

Requires the derived parameters:

TOY LengthMean

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequences:

WaterLevelUpstream WaterLevelDownstream WettedArea WettedPerimeter TimeStep

Requires the flux sequences:

DischargeUpstream DischargeDownstream

Updates the flux sequence:

DischargeVolume

Updates the state sequence:

Discharge

Calculates the factor sequences:

WaterVolumeUpstream WaterVolumeDownstream

class hydpy.models.sw1d.sw1d_model.Determine_Discharge_V6[source]

Bases: AutoMethod

Interface method for determining the discharge at an outflow gate.

Required submethods:

Calc_Discharge_V3 Update_DischargeVolume_V1

Requires the control parameters:

BottomLevel GateHeight GateWidth FlowCoefficient DampingRadius

Requires the fixed parameter:

GravitationalAcceleration

Requires the factor sequences:

WaterLevel WaterLevelUpstream WaterLevelDownstream TimeStep

Updates the flux sequence:

DischargeVolume

Updates the state sequence:

Discharge

class hydpy.models.sw1d.sw1d_model.Determine_Discharge_V7[source]

Bases: AutoMethod

Interface method for determining the discharge at a pumping station.

Required submethods:

Calc_WaterLevel_V3 Calc_Discharge_V4 Update_DischargeVolume_V1

Requires the control parameters:

Gradient2PumpingRate TargetWaterLevel1 TargetWaterLevel2

Requires the factor sequences:

WaterLevelUpstream WaterLevelDownstream TimeStep

Updates the flux sequence:

DischargeVolume

Updates the state sequence:

Discharge

Calculates the factor sequence:

WaterLevel

class hydpy.models.sw1d.sw1d_model.Get_WaterVolume_V1[source]

Bases: Method

Interface method for querying the water volume in 1000 m³.

Requires the state sequence:

WaterVolume

class hydpy.models.sw1d.sw1d_model.Get_WaterLevel_V1[source]

Bases: Method

Interface method for querying the water level in m.

Requires the factor sequence:

WaterLevel

class hydpy.models.sw1d.sw1d_model.Get_Discharge_V1[source]

Bases: Method

Interface method for querying the discharge in m³/s.

Requires the state sequence:

Discharge

class hydpy.models.sw1d.sw1d_model.Get_DischargeVolume_V1[source]

Bases: Method

Interface method for querying the discharge in m³.

Requires the flux sequence:

DischargeVolume

class hydpy.models.sw1d.sw1d_model.Get_MaxTimeStep_V1[source]

Bases: Method

Interface method for querying the highest possible computation time step in s.

Requires the factor sequence:

MaxTimeStep

class hydpy.models.sw1d.sw1d_model.Set_TimeStep_V1[source]

Bases: Method

Interface method for setting the actual computation time step in s.

Calculates the factor sequence:

TimeStep

class hydpy.models.sw1d.sw1d_model.Get_PartialDischargeUpstream_V1[source]

Bases: Method

Return a partial discharge estimate suitable for a downstream model.

Requires the state sequence:

Discharge

Basic equation:

\(PartialDischargeUpstream = Discharge_{server} \cdot \frac{|Discharge_{client}|}{\Sigma_{i=1}^{n_{downstream}} |Discharge_i|}\)

Examples:

If the client model (which is currently asking for the partial discharge) is the only downstream model, Get_PartialDischargeUpstream_V1 returns the total discharge without modification:

>>> from hydpy import Element, Node, prepare_model, round_
>>> n01 = Node("n01", variable="LongQ")
>>> e0 = Element("e0", outlets=n01)
>>> e1a = Element("e1a", inlets=n01)
>>> c0 = prepare_model("sw1d_channel")
>>> e0.model = c0
>>> c0.parameters.control.nmbsegments(1)
>>> with c0.add_routingmodel_v2("sw1d_lias", position=0, update=False) as r0:
...     states.discharge = 5.0
>>> with c0.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> c1a = prepare_model("sw1d_channel")
>>> e1a.model = c1a
>>> c1a.parameters.control.nmbsegments(1)
>>> with c1a.add_routingmodel_v2("sw1d_lias", position=0, update=False) as r1a:
...     states.discharge = 3.0
>>> with c1a.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> network = c0.couple_models(nodes=[n01], elements=[e0, e1a])
>>> round_(r0.get_partialdischargeupstream_v1(3.0))
5.0

For multiple downstream models, it returns the discharge portion that it attributes to the current client model:

>>> e1b = Element("e1b", inlets=n01)
>>> c1b = prepare_model("sw1d_channel")
>>> e1b.model = c1b
>>> c1b.parameters.control.nmbsegments(1)
>>> with c1b.add_routingmodel_v2("sw1d_lias", position=0, update=False) as r1b:
...     states.discharge = 1.0
>>> with c1b.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> network = c0.couple_models(nodes=[n01], elements=[e0, e1a, e1b])
>>> round_(r0.get_partialdischargeupstream_v1(3.0))
3.75
>>> round_(r0.get_partialdischargeupstream_v1(1.0))
1.25

To prevent zero divisions, Get_PartialDischargeUpstream_V1 returns zero if all downstream models’ (total) discharge is also zero:

>>> r1a.sequences.states.discharge = 0.0
>>> r1b.sequences.states.discharge = 0.0
>>> round_(r0.get_partialdischargeupstream_v1(0.0))
0.0
class hydpy.models.sw1d.sw1d_model.Get_PartialDischargeDownstream_V1[source]

Bases: Method

Return a partial discharge estimate suitable for an upstream model.

Requires the state sequence:

Discharge

Basic equation:

\(PartialDischargeDownstream = Discharge_{server} \cdot \frac{|Discharge_{client}|}{\Sigma_{i=1}^{n_{upstream}} |Discharge_i|}\)

Examples:

If the client model (which is currently asking for the partial discharge) is the only upstream model, Get_PartialDischargeDownstream_V1 returns the total discharge without modification:

>>> from hydpy import Element, Node, prepare_model, round_
>>> n01 = Node("n01", variable="LongQ")
>>> e1 = Element("e1", inlets=n01)
>>> e0a = Element("e0a", outlets=n01)
>>> c1 = prepare_model("sw1d_channel")
>>> e1.model = c1
>>> c1.parameters.control.nmbsegments(1)
>>> with c1.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> with c1.add_routingmodel_v2("sw1d_lias", position=1, update=False) as r1:
...     states.discharge = 5.0
>>> c0a = prepare_model("sw1d_channel")
>>> e0a.model = c0a
>>> c0a.parameters.control.nmbsegments(1)
>>> with c0a.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> with c0a.add_routingmodel_v2("sw1d_lias", position=1, update=False) as r0a:
...     states.discharge = 3.0
>>> network = c1.couple_models(nodes=[n01], elements=[e1, e0a])
>>> round_(r1.get_partialdischargedownstream_v1(3.0))
5.0

For multiple upstream models, it returns the discharge portion that it attributes to the current client model:

>>> e0b = Element("e0b", outlets=n01)
>>> c0b = prepare_model("sw1d_channel")
>>> e0b.model = c0b
>>> c0b.parameters.control.nmbsegments(1)
>>> with c0b.add_storagemodel_v1("sw1d_storage", position=0, update=False):
...     pass
>>> with c0b.add_routingmodel_v2("sw1d_lias", position=1, update=False) as r0b:
...     states.discharge = 1.0
>>> network = c1.couple_models(nodes=[n01], elements=[e1, e0a, e0b])
>>> round_(r1.get_partialdischargedownstream_v1(3.0))
3.75
>>> round_(r1.get_partialdischargedownstream_v1(1.0))
1.25

To prevent zero divisions, Get_PartialDischargeDownstream_V1 returns zero if all upstream models’ (total) discharge is also zero:

>>> r0a.sequences.states.discharge = 0.0
>>> r0b.sequences.states.discharge = 0.0
>>> round_(r1.get_partialdischargedownstream_v1(0.0))
0.0
class hydpy.models.sw1d.sw1d_model.Update_Storage_V1[source]

Bases: AutoMethod

Interface method for updating the storage water content.

Required submethods:

Calc_NetInflow_V1 Update_WaterVolume_V1 Calc_WaterDepth_WaterLevel_V1

Requires the control parameter:

Length

Requires the factor sequence:

TimeStep

Requires the flux sequence:

LateralFlow

Updates the state sequence:

WaterVolume

Calculates the factor sequences:

WaterDepth WaterLevel

Calculates the flux sequence:

NetInflow

class hydpy.models.sw1d.sw1d_model.Main_CrossSectionModel_V2[source]

Bases: AdHocModel

Base class for HydPy-SW1D models that use submodels named crosssection and comply with the CrossSectionModel_V2 interface.

crosssection: SubmodelProperty[CrossSectionModel_V2]
crosssection_is_mainmodel
crosssection_typeid
add_crosssection_v2

Initialise the given submodel that follows the CrossSectionModel_V1 interface and is responsible for calculating discharge and related properties.

>>> from hydpy.models.sw1d_storage import *
>>> parameterstep()
>>> with model.add_crosssection_v2("wq_trapeze"):
...     nmbtrapezes(2)
...     bottomlevels(1.0, 3.0)
...     bottomwidths(2.0)
...     sideslopes(2.0, 4.0)
>>> model.crosssection.parameters.control.nmbtrapezes
nmbtrapezes(2)
>>> model.crosssection.parameters.control.bottomlevels
bottomlevels(1.0, 3.0)
REUSABLE_METHODS: ClassVar[tuple[type[ReusableMethod], ...]] = ()

Parameter Features

Control parameters

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

Bases: SubParameters

Control parameters of model sw1d.

The following classes are selected:
class hydpy.models.sw1d.sw1d_control.NmbSegments(subvars: SubParameters)[source]

Bases: Parameter

The number of channel segments [-].

NDIM: int = 0
TYPE

alias of int

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0, None)
name: str = 'nmbsegments'

Name of the variable in lowercase letters.

unit: str = '-'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.Length(subvars: SubParameters)[source]

Bases: Parameter

The length of a single channel segment [km].

Required by the methods:

Calc_WaterDepth_WaterLevel_CrossSectionModel_V2 Calc_WaterDepth_WaterLevel_V1 Perform_Preprocessing_V3 Update_Storage_V1

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'length'

Name of the variable in lowercase letters.

unit: str = 'km'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.LengthUpstream(subvars: SubParameters)[source]

Bases: Parameter

The upstream channel segment’s length [km].

Required by the methods:

Calc_MaxTimeStep_V3 Calc_MaxTimeStep_V4 Calc_MaxTimeStep_V5 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V5

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'lengthupstream'

Name of the variable in lowercase letters.

unit: str = 'km'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.LengthDownstream(subvars: SubParameters)[source]

Bases: Parameter

The downstream channel segment’s length [km].

Required by the methods:

Calc_MaxTimeStep_V2 Determine_MaxTimeStep_V2

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'lengthdownstream'

Name of the variable in lowercase letters.

unit: str = 'km'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.BottomLevel(subvars: SubParameters)[source]

Bases: Parameter

The channel bottom elevation [m].

Required by the methods:

Calc_Discharge_V3 Calc_MaxTimeStep_V5 Determine_Discharge_V6 Determine_MaxTimeStep_V5

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
name: str = 'bottomlevel'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.StricklerCoefficient(subvars: SubParameters)[source]

Bases: Parameter

The average Gauckler-Manning-Strickler coefficient [m^(1/3)/s].

Required by the methods:

Calc_Discharge_V1 Determine_Discharge_V1 Determine_Discharge_V5

The higher the coefficient’s value, the higher the calculated discharge. Typical values range from 20 to 80.

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'stricklercoefficient'

Name of the variable in lowercase letters.

unit: str = 'm^(1/3)/s'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.TimeStepFactor(subvars: SubParameters)[source]

Bases: Parameter

A factor for reducing the estimated computation time step to increase numerical stability [-].

Required by the methods:

Calc_MaxTimeStep_V1 Calc_MaxTimeStep_V2 Calc_MaxTimeStep_V3 Calc_MaxTimeStep_V4 Calc_MaxTimeStep_V5 Calc_MaxTimeStep_V6 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V5 Determine_MaxTimeStep_V6

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, 1.0)
name: str = 'timestepfactor'

Name of the variable in lowercase letters.

unit: str = '-'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.DiffusionFactor(subvars: SubParameters)[source]

Bases: Parameter

A factor for introducing numerical diffusion to increase numerical stability [-].

Required by the methods:

Calc_Discharge_V1 Determine_Discharge_V1 Determine_Discharge_V5

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, 1.0)
name: str = 'diffusionfactor'

Name of the variable in lowercase letters.

unit: str = '-'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.DampingRadius(subvars: SubParameters)[source]

Bases: Parameter

The radius of flow rate reductions around neuralgic water levels to prevent oscillations due to numerical inaccuracies [m].

Required by the methods:

Calc_Discharge_V3 Determine_Discharge_V6

For a value of zero, the radius of action is zero, with no modification of the target equation and, thus, no artificial damping.

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'dampingradius'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.CrestHeight(subvars: SubParameters)[source]

Bases: Parameter

The weir crest height [m].

Required by the methods:

Calc_Discharge_V2 Calc_MaxTimeStep_V3 Determine_Discharge_V3 Determine_MaxTimeStep_V3

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
name: str = 'crestheight'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.CrestWidth(subvars: SubParameters)[source]

Bases: Parameter

The weir crest width [m].

Required by the methods:

Calc_Discharge_V2 Determine_Discharge_V3

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'crestwidth'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.GateHeight(subvars: SubParameters)[source]

Bases: CallbackParameter

The gate lower edge’s height [m].

Required by the methods:

Calc_Discharge_V3 Calc_MaxTimeStep_V5 Determine_Discharge_V6 Determine_MaxTimeStep_V5

Parameter GateHeight offers the possibility of assigning a callback function for calculating variable gate heights instead of setting a fixed one. See the Calc_Discharge_V3 documentation for further information.

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
name: str = 'gateheight'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.GateWidth(subvars: SubParameters)[source]

Bases: Parameter

The gate width [m].

Required by the methods:

Calc_Discharge_V3 Determine_Discharge_V6

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'gatewidth'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.FlowCoefficient(subvars: SubParameters)[source]

Bases: Parameter

The weir flow coefficient [-].

Required by the methods:

Calc_Discharge_V2 Calc_Discharge_V3 Calc_MaxTimeStep_V3 Calc_MaxTimeStep_V5 Determine_Discharge_V3 Determine_Discharge_V6 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V5

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
INIT: int | float | bool | None = 0.62
name: str = 'flowcoefficient'

Name of the variable in lowercase letters.

unit: str = '-'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.TargetWaterLevel1(subvars: SubParameters)[source]

Bases: Parameter

The lower target water level [m].

Required by the methods:

Calc_Discharge_V4 Determine_Discharge_V7

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
trim(lower=None, upper=None) bool[source]

Trim TargetWaterLevel1 following \(TargetWaterLevel1 \leq TargetWaterLevel2\).

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> targetwaterlevel2(2.0)
>>> targetwaterlevel1(3.0)
>>> targetwaterlevel1
targetwaterlevel1(2.0)
name: str = 'targetwaterlevel1'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.TargetWaterLevel2(subvars: SubParameters)[source]

Bases: Parameter

The upper target water level [m].

Required by the methods:

Calc_Discharge_V4 Determine_Discharge_V7

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
trim(lower=None, upper=None) bool[source]

Trim TargetWaterLevel2 following \(TargetWaterLevel1 \leq TargetWaterLevel2\).

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> targetwaterlevel1(2.0)
>>> targetwaterlevel2(1.0)
>>> targetwaterlevel2
targetwaterlevel2(2.0)
name: str = 'targetwaterlevel2'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.BottomLowWaterThreshold(subvars)[source]

Bases: SeasonalParameter

Water level below which gates are fully closed to stop drainage during low flow periods [m].

Required by the methods:

Determine_Discharge_V5 Update_Discharge_V2

NDIM: int = 1
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
trim(lower=None, upper=None) bool[source]

Trim BottomLowWaterThreshold following \(BottomLowWaterThreshold \leq UpperLowWaterThreshold\) and \(BottomLowWaterThreshold \leq BottomHighWaterThreshold\) and \(BottomLowWaterThreshold \leq UpperHighWaterThreshold\).

>>> from hydpy import pub, round_
>>> pub.timegrids = "2000-01-01", "2000-01-06", "1d"
>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> bottomlowwaterthreshold(2.0)
>>> bottomlowwaterthreshold
bottomlowwaterthreshold(2.0)
>>> upperlowwaterthreshold.shape = 1
>>> upperlowwaterthreshold.values[:5] = 1.0, 2.0, 3.0, 4.0, 5.0
>>> bottomhighwaterthreshold.shape = 1
>>> bottomhighwaterthreshold.values[:5] = 5.0, 4.0, 3.0, 2.0, 1.0
>>> upperhighwaterthreshold.shape = 1
>>> upperhighwaterthreshold.values[:5] = 3.0, 2.0, 1.0, 2.0, 3.0
>>> bottomlowwaterthreshold(2.0)
>>> round_(bottomlowwaterthreshold.values[:5])
1.0, 2.0, 1.0, 2.0, 1.0
>>> from hydpy.core.testtools import warn_later
>>> with pub.options.warntrim(True), warn_later():
...     bottomlowwaterthreshold
bottomlowwaterthreshold(2.0)
UserWarning: The "background values" of parameter `bottomlowwaterthreshold` of element `?` have been trimmed but not its original time of year-specific values.  Using the latter without modification might result in inconsistencies.
name: str = 'bottomlowwaterthreshold'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.UpperLowWaterThreshold(subvars)[source]

Bases: SeasonalParameter

Water level below which gates are partly closed to reduce drainage during low flow periods [m].

Required by the methods:

Determine_Discharge_V5 Update_Discharge_V2

NDIM: int = 1
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
trim(lower=None, upper=None) bool[source]

Trim UpperLowWaterThreshold following \(UpperLowWaterThreshold \geq BottomLowWaterThreshold\) and \(UpperLowWaterThreshold \leq UpperHighWaterThreshold\).

>>> from hydpy import pub, round_
>>> pub.timegrids = "2000-01-01", "2000-01-06", "1d"
>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> upperlowwaterthreshold(4.0)
>>> upperlowwaterthreshold
upperlowwaterthreshold(4.0)
>>> bottomlowwaterthreshold.shape = 1
>>> bottomlowwaterthreshold.values[:5] = 1.0, 2.0, 3.0, 4.0, 5.0
>>> upperhighwaterthreshold.shape = 1
>>> upperhighwaterthreshold.values[:5] = 3.0, 4.0, 5.0, 6.0, 7.0
>>> upperlowwaterthreshold(4.0)
>>> round_(upperlowwaterthreshold.values[:5])
3.0, 4.0, 4.0, 4.0, 5.0
>>> from hydpy.core.testtools import warn_later
>>> with pub.options.warntrim(True), warn_later():
...     upperlowwaterthreshold
upperlowwaterthreshold(4.0)
UserWarning: The "background values" of parameter `upperlowwaterthreshold` of element `?` have been trimmed but not its original time of year-specific values.  Using the latter without modification might result in inconsistencies.
name: str = 'upperlowwaterthreshold'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.BottomHighWaterThreshold(subvars)[source]

Bases: SeasonalParameter

Water level above which gate operation is partly sluice-like to increase drainage during high flow periods [m].

Required by the methods:

Determine_Discharge_V5 Update_Discharge_V2

NDIM: int = 1
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
trim(lower=None, upper=None) bool[source]

Trim BottomHighWaterThreshold following \(BottomHighWaterThreshold \geq BottomLowWaterThreshold\) and \(BottomHighWaterThreshold \leq UpperHighWaterThreshold\).

>>> from hydpy import pub, round_
>>> pub.timegrids = "2000-01-01", "2000-01-06", "1d"
>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> bottomhighwaterthreshold(4.0)
>>> bottomhighwaterthreshold
bottomhighwaterthreshold(4.0)
>>> bottomlowwaterthreshold.shape = 1
>>> bottomlowwaterthreshold.values[:5] = 1.0, 2.0, 3.0, 4.0, 5.0
>>> upperhighwaterthreshold.shape = 1
>>> upperhighwaterthreshold.values[:5] = 3.0, 4.0, 5.0, 6.0, 7.0
>>> bottomhighwaterthreshold(4.0)
>>> round_(bottomhighwaterthreshold.values[:5])
3.0, 4.0, 4.0, 4.0, 5.0
>>> from hydpy.core.testtools import warn_later
>>> with pub.options.warntrim(True), warn_later():
...     bottomhighwaterthreshold
bottomhighwaterthreshold(4.0)
UserWarning: The "background values" of parameter `bottomhighwaterthreshold` of element `?` have been trimmed but not its original time of year-specific values.  Using the latter without modification might result in inconsistencies.
name: str = 'bottomhighwaterthreshold'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.UpperHighWaterThreshold(subvars)[source]

Bases: SeasonalParameter

Water level above which gate operation is fully sluice-like to maximise drainage during high flow periods [m].

Required by the methods:

Determine_Discharge_V5 Update_Discharge_V2

NDIM: int = 1
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
trim(lower=None, upper=None) bool[source]

Trim UpperHighWaterThreshold following \(UpperHighWaterThreshold \geq BottomLowWaterThreshold\) and \(UpperHighWaterThreshold \geq UpperLowWaterThreshold\) and \(UpperHighWaterThreshold \geq BottomHighWaterThreshold\).

>>> from hydpy import pub, round_
>>> pub.timegrids = "2000-01-01", "2000-01-06", "1d"
>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> upperhighwaterthreshold(4.0)
>>> upperhighwaterthreshold
upperhighwaterthreshold(4.0)
>>> bottomlowwaterthreshold.shape = 1
>>> bottomlowwaterthreshold.values[:5] = 1.0, 2.0, 3.0, 4.0, 5.0
>>> upperlowwaterthreshold.shape = 1
>>> upperlowwaterthreshold.values[:5] = 5.0, 4.0, 3.0, 2.0, 1.0
>>> bottomhighwaterthreshold.shape = 1
>>> bottomhighwaterthreshold.values[:5] = 3.0, 4.0, 5.0, 4.0, 3.0
>>> upperhighwaterthreshold(4.0)
>>> round_(upperhighwaterthreshold.values[:5])
5.0, 4.0, 5.0, 4.0, 5.0
>>> from hydpy.core.testtools import warn_later
>>> with pub.options.warntrim(True), warn_later():
...     upperhighwaterthreshold
upperhighwaterthreshold(4.0)
UserWarning: The "background values" of parameter `upperhighwaterthreshold` of element `?` have been trimmed but not its original time of year-specific values.  Using the latter without modification might result in inconsistencies.
name: str = 'upperhighwaterthreshold'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_control.Gradient2PumpingRate(subvars: SubParameters)[source]

Bases: SimpleInterpolator

An interpolation function describing the relationship between the water level height to be overcome and the maximum possible pumping rate [-].

Required by the methods:

Calc_Discharge_V4 Determine_Discharge_V7

XLABEL = 'water level gradient [m]'
YLABEL = 'maximum pumping rate [m³/s]'
name: str = 'gradient2pumpingrate'

Class name in lowercase letters.

Derived parameters

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

Bases: SubParameters

Derived parameters of model sw1d.

The following classes are selected:
  • Seconds() The length of the actual simulation step size in seconds [s].

  • TOY() References the timeofyear index array provided by the instance of class Indexer available in module pub [-].

  • WeightUpstream() A weighting coefficient for interpolating the water level from the centroids of two adjacent segments to their shared edge [-].

  • LengthMin() The minimum length of the segments upstream and downstream of the relevant routing model [km].

  • LengthMean() The mean length of the segments upstream and downstream of the relevant routing model [km].

class hydpy.models.sw1d.sw1d_derived.Seconds(subvars: SubParameters)[source]

Bases: SecondsParameter

The length of the actual simulation step size in seconds [s].

Required by the methods:

Calc_DischargeVolume_V1 Calc_DischargeVolume_V2 Calc_Discharges_V2 Pass_Discharge_V1 Perform_Postprocessing_V1 Perform_Postprocessing_V2 Perform_Postprocessing_V4

name: str = 'seconds'

Name of the variable in lowercase letters.

unit: str = 's'

Unit of the variable.

class hydpy.models.sw1d.sw1d_derived.TOY(subvars: SubParameters)[source]

Bases: TOYParameter

References the timeofyear index array provided by the instance of class Indexer available in module pub [-].

Required by the methods:

Determine_Discharge_V5 Update_Discharge_V2

name: str = 'toy'

Name of the variable in lowercase letters.

unit: str = '-'

Unit of the variable.

class hydpy.models.sw1d.sw1d_derived.WeightUpstream(subvars: SubParameters)[source]

Bases: Parameter

A weighting coefficient for interpolating the water level from the centroids of two adjacent segments to their shared edge [-].

Required by the methods:

Calc_WaterLevel_V1 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V6

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, 1.0)
update() None[source]

Update the value according to \(WeightUpstream = LengthDownstream / (LengthUpstream + LengthDownstream)\).

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> lengthupstream(1.0)
>>> lengthdownstream(3.0)
>>> derived.weightupstream.update()
>>> derived.weightupstream
weightupstream(0.75)
name: str = 'weightupstream'

Name of the variable in lowercase letters.

unit: str = '-'

Unit of the variable.

class hydpy.models.sw1d.sw1d_derived.LengthMin(subvars: SubParameters)[source]

Bases: Parameter

The minimum length of the segments upstream and downstream of the relevant routing model [km].

Required by the methods:

Calc_MaxTimeStep_V1 Calc_MaxTimeStep_V6 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V6

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
update() None[source]

Take the minimum of LengthUpstream and LengthDownstream.

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> lengthupstream(2.0)
>>> lengthdownstream(4.0)
>>> derived.lengthmin.update()
>>> derived.lengthmin
lengthmin(2.0)
name: str = 'lengthmin'

Name of the variable in lowercase letters.

unit: str = 'km'

Unit of the variable.

class hydpy.models.sw1d.sw1d_derived.LengthMean(subvars: SubParameters)[source]

Bases: Parameter

The mean length of the segments upstream and downstream of the relevant routing model [km].

Required by the methods:

Calc_Discharge_V1 Determine_Discharge_V1 Determine_Discharge_V5

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
update() None[source]

Take the mean of LengthUpstream and LengthDownstream.

>>> from hydpy.models.sw1d import *
>>> parameterstep()
>>> lengthupstream(2.0)
>>> lengthdownstream(4.0)
>>> derived.lengthmean.update()
>>> derived.lengthmean
lengthmean(3.0)
name: str = 'lengthmean'

Name of the variable in lowercase letters.

unit: str = 'km'

Unit of the variable.

Fixed parameters

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

Bases: SubParameters

Fixed parameters of model sw1d.

The following classes are selected:
class hydpy.models.sw1d.sw1d_fixed.GravitationalAcceleration(subvars: SubParameters)[source]

Bases: FixedParameter

Gravitational acceleration [m/s²].

Required by the methods:

Calc_Discharge_V1 Calc_Discharge_V2 Calc_Discharge_V3 Calc_MaxTimeStep_V1 Calc_MaxTimeStep_V3 Calc_MaxTimeStep_V5 Determine_Discharge_V1 Determine_Discharge_V3 Determine_Discharge_V5 Determine_Discharge_V6 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V5

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
INIT: int | float | bool = 9.81
name: str = 'gravitationalacceleration'

Name of the variable in lowercase letters.

unit: str = 'm/s²'

Unit of the variable.

Sequence Features

Factor sequences

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

Bases: FactorSequences

Factor sequences of model sw1d.

The following classes are selected:
class hydpy.models.sw1d.sw1d_factors.MaxTimeStep(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The highest possible computation time step according to local stability considerations [s].

Calculated by the methods:

Calc_MaxTimeStep_V1 Calc_MaxTimeStep_V2 Calc_MaxTimeStep_V3 Calc_MaxTimeStep_V4 Calc_MaxTimeStep_V5 Calc_MaxTimeStep_V6 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V5 Determine_MaxTimeStep_V6

Required by the method:

Get_MaxTimeStep_V1

NDIM: int = 0
NUMERIC: bool = False
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'maxtimestep'

Name of the variable in lowercase letters.

unit: str = 's'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.TimeStep(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The actual computation step according to global stability considerations [s].

Calculated by the methods:

Calc_TimeStep_V1 Set_TimeStep_V1

Required by the methods:

Calc_Discharge_V1 Calc_NetInflow_V1 Determine_Discharge_V1 Determine_Discharge_V3 Determine_Discharge_V5 Determine_Discharge_V6 Determine_Discharge_V7 Send_TimeStep_V1 Update_DischargeVolume_V1 Update_Discharge_V1 Update_Storage_V1

NDIM: int = 0
NUMERIC: bool = False
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'timestep'

Name of the variable in lowercase letters.

unit: str = 's'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WaterDepth(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

Water depth [m].

Calculated by the methods:

Calc_WaterDepth_WaterLevel_CrossSectionModel_V2 Calc_WaterDepth_WaterLevel_V1 Calc_WaterDepth_WettedArea_CrossSectionModel_V2 Calc_WaterDepth_WettedArea_V1 Calc_WaterDepth_WettedArea_WettedPerimeter_CrossSectionModel_V2 Calc_WaterDepth_WettedArea_WettedPerimeter_V1 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V6 Perform_Preprocessing_V3 Update_Storage_V1

Required by the method:

Calc_MaxTimeStep_V1

Difference between the elevations of the water surface and the channel bottom.

NDIM: int = 0
NUMERIC: bool = False
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'waterdepth'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WaterLevel(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

Water level [m].

Calculated by the methods:

Calc_WaterDepth_WaterLevel_CrossSectionModel_V2 Calc_WaterDepth_WaterLevel_V1 Calc_WaterLevel_V1 Calc_WaterLevel_V2 Calc_WaterLevel_V3 Calc_WaterLevel_V4 Determine_Discharge_V7 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V5 Determine_MaxTimeStep_V6 Perform_Preprocessing_V3 Update_Storage_V1

Required by the methods:

Calc_Discharge_V2 Calc_Discharge_V3 Calc_MaxTimeStep_V3 Calc_MaxTimeStep_V5 Calc_WaterDepth_WettedArea_CrossSectionModel_V2 Calc_WaterDepth_WettedArea_V1 Calc_WaterDepth_WettedArea_WettedPerimeter_CrossSectionModel_V2 Calc_WaterDepth_WettedArea_WettedPerimeter_V1 Determine_Discharge_V3 Determine_Discharge_V6 Get_WaterLevel_V1 Pass_WaterLevel_V1 Perform_Postprocessing_V3

The sum of the channel’s bottom elevation and water depth.

NDIM: int = 0
NUMERIC: bool = False
name: str = 'waterlevel'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WaterLevels(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The water level within all segments of a channel [m].

Calculated by the method:

Query_WaterLevels_V1

NDIM: int = 1
NUMERIC: bool = False
name: str = 'waterlevels'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WaterLevelUpstream(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The upstream channel segment’s water level [m].

Calculated by the methods:

Calc_WaterLevelUpstream_V1 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V3 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V5 Determine_MaxTimeStep_V6

Required by the methods:

Calc_Discharge_V1 Calc_Discharge_V3 Calc_Discharge_V4 Calc_MaxTimeStep_V5 Calc_WaterLevel_V1 Calc_WaterLevel_V3 Calc_WaterLevel_V4 Determine_Discharge_V1 Determine_Discharge_V5 Determine_Discharge_V6 Determine_Discharge_V7 Update_Discharge_V2

NDIM: int = 0
NUMERIC: bool = False
name: str = 'waterlevelupstream'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WaterLevelDownstream(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The downstream channel segment’s water level [m].

Calculated by the methods:

Calc_WaterLevelDownstream_V1 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V6 Perform_Preprocessing_V5 Pick_WaterLevelDownstream_V1

Required by the methods:

Calc_Discharge_V1 Calc_Discharge_V3 Calc_Discharge_V4 Calc_MaxTimeStep_V5 Calc_WaterLevel_V1 Calc_WaterLevel_V2 Calc_WaterLevel_V4 Determine_Discharge_V1 Determine_Discharge_V5 Determine_Discharge_V6 Determine_Discharge_V7 Determine_MaxTimeStep_V5 Update_Discharge_V2

NDIM: int = 0
NUMERIC: bool = False
name: str = 'waterleveldownstream'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WaterVolumeUpstream(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The upstream channel segment’s water volume [1000 m³].

Calculated by the methods:

Calc_WaterVolumeUpstream_V1 Determine_Discharge_V1 Determine_Discharge_V5

Required by the method:

Update_Discharge_V1

NDIM: int = 0
NUMERIC: bool = False
name: str = 'watervolumeupstream'

Name of the variable in lowercase letters.

unit: str = '1000 m³'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WaterVolumeDownstream(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The downstream channel segment’s water volume [1000 m³].

Calculated by the methods:

Calc_WaterVolumeDownstream_V1 Determine_Discharge_V1 Determine_Discharge_V5

Required by the method:

Update_Discharge_V1

NDIM: int = 0
NUMERIC: bool = False
name: str = 'watervolumedownstream'

Name of the variable in lowercase letters.

unit: str = '1000 m³'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WettedArea(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The channel wetted area [m²].

Calculated by the methods:

Calc_WaterDepth_WettedArea_CrossSectionModel_V2 Calc_WaterDepth_WettedArea_V1 Calc_WaterDepth_WettedArea_WettedPerimeter_CrossSectionModel_V2 Calc_WaterDepth_WettedArea_WettedPerimeter_V1 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V2 Determine_MaxTimeStep_V4 Determine_MaxTimeStep_V6

Required by the methods:

Calc_Discharge_V1 Calc_MaxTimeStep_V2 Calc_MaxTimeStep_V4 Calc_MaxTimeStep_V6 Determine_Discharge_V1 Determine_Discharge_V5

NDIM: int = 0
NUMERIC: bool = False
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'wettedarea'

Name of the variable in lowercase letters.

unit: str = 'm²'

Unit of the variable.

class hydpy.models.sw1d.sw1d_factors.WettedPerimeter(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FactorSequence

The channel wetted perimeter [m].

Calculated by the methods:

Calc_WaterDepth_WettedArea_WettedPerimeter_CrossSectionModel_V2 Calc_WaterDepth_WettedArea_WettedPerimeter_V1 Determine_MaxTimeStep_V1

Required by the methods:

Calc_Discharge_V1 Determine_Discharge_V1 Determine_Discharge_V5

NDIM: int = 0
NUMERIC: bool = False
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'wettedperimeter'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

Flux sequences

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

Bases: FluxSequences

Flux sequences of model sw1d.

The following classes are selected:
  • Inflow() Longitudinal flow into the first channel segment [m³/s].

  • Outflow() Longitudinal flow out of the last channel segment [m³/s].

  • LateralFlow() Lateral flow into the first channel segment [m³/s].

  • NetInflow() The net inflow into a channel segment [m³/T].

  • DischargeUpstream() The summed (partial) of all upstream routing models [m³/s].

  • DischargeDownstream() The summed (partial) of all downstream routing models [m³/s].

  • DischargeVolume() The total amount of discharge of a simulation step [m³/T].

  • Discharges() The discharges between all channel segments, including the flow into the first and out of the last one [m³/s].

class hydpy.models.sw1d.sw1d_fluxes.Inflow(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

Longitudinal flow into the first channel segment [m³/s].

Calculated by the methods:

Perform_Preprocessing_V1 Pick_Inflow_V1

Required by the methods:

Calc_DischargeVolume_V1 Calc_MaxTimeStep_V2 Determine_Discharge_V2 Determine_MaxTimeStep_V2 Perform_Postprocessing_V1

NDIM: int = 0
NUMERIC: bool = False
name: str = 'inflow'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

class hydpy.models.sw1d.sw1d_fluxes.Outflow(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

Longitudinal flow out of the last channel segment [m³/s].

Calculated by the methods:

Perform_Preprocessing_V4 Pick_Outflow_V1

Required by the methods:

Calc_DischargeVolume_V2 Calc_MaxTimeStep_V4 Determine_Discharge_V4 Determine_MaxTimeStep_V4 Perform_Postprocessing_V4

NDIM: int = 0
NUMERIC: bool = False
name: str = 'outflow'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

class hydpy.models.sw1d.sw1d_fluxes.LateralFlow(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

Lateral flow into the first channel segment [m³/s].

Calculated by the methods:

Perform_Preprocessing_V3 Pick_LateralFlow_V1

Required by the methods:

Calc_NetInflow_V1 Update_Storage_V1

NDIM: int = 0
NUMERIC: bool = False
name: str = 'lateralflow'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

class hydpy.models.sw1d.sw1d_fluxes.NetInflow(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

The net inflow into a channel segment [m³/T].

Calculated by the methods:

Calc_NetInflow_V1 Update_Storage_V1

Required by the method:

Update_WaterVolume_V1

NDIM: int = 0
NUMERIC: bool = False
name: str = 'netinflow'

Name of the variable in lowercase letters.

unit: str = 'm³/T'

Unit of the variable.

class hydpy.models.sw1d.sw1d_fluxes.DischargeUpstream(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

The summed (partial) of all upstream routing models [m³/s].

Calculated by the methods:

Calc_DischargeUpstream_V1 Determine_MaxTimeStep_V1

Required by the methods:

Calc_Discharge_V1 Determine_Discharge_V1 Determine_Discharge_V5

NDIM: int = 0
NUMERIC: bool = False
name: str = 'dischargeupstream'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

class hydpy.models.sw1d.sw1d_fluxes.DischargeDownstream(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

The summed (partial) of all downstream routing models [m³/s].

Calculated by the methods:

Calc_DischargeDownstream_V1 Determine_MaxTimeStep_V1

Required by the methods:

Calc_Discharge_V1 Determine_Discharge_V1 Determine_Discharge_V5

NDIM: int = 0
NUMERIC: bool = False
name: str = 'dischargedownstream'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

class hydpy.models.sw1d.sw1d_fluxes.DischargeVolume(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

The total amount of discharge of a simulation step [m³/T].

Calculated by the methods:

Perform_Preprocessing_V2 Perform_Preprocessing_V5 Reset_DischargeVolume_V1

Updated by the methods:

Calc_DischargeVolume_V1 Calc_DischargeVolume_V2 Determine_Discharge_V1 Determine_Discharge_V3 Determine_Discharge_V5 Determine_Discharge_V6 Determine_Discharge_V7 Perform_Postprocessing_V1 Perform_Postprocessing_V4 Update_DischargeVolume_V1

Required by the methods:

Get_DischargeVolume_V1 Pass_Discharge_V1 Perform_Postprocessing_V2

NDIM: int = 0
NUMERIC: bool = False
name: str = 'dischargevolume'

Name of the variable in lowercase letters.

unit: str = 'm³/T'

Unit of the variable.

class hydpy.models.sw1d.sw1d_fluxes.Discharges(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

The discharges between all channel segments, including the flow into the first and out of the last one [m³/s].

Calculated by the method:

Calc_Discharges_V2

NDIM: int = 1
NUMERIC: bool = False
PLUS = 1
name: str = 'discharges'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

State sequences

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

Bases: StateSequences

State sequences of model sw1d.

The following classes are selected:
class hydpy.models.sw1d.sw1d_states.WaterVolume(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: StateSequence

Water volume [1000 m³].

Updated by the methods:

Update_Storage_V1 Update_WaterVolume_V1

Required by the methods:

Calc_WaterDepth_WaterLevel_CrossSectionModel_V2 Calc_WaterDepth_WaterLevel_V1 Get_WaterVolume_V1 Perform_Preprocessing_V3

Note that the water volume stored in a channel segment might be slightly negative due to numerical inaccuracies (see ref:sw1d_channel_internal_negative_volumes) or even vastly negative due to erroneous data or configurations (see Excessive water withdrawal).

NDIM: int = 0
NUMERIC: bool = False
SPAN: tuple[int | float | bool | None, int | float | bool | None] = (None, None)
name: str = 'watervolume'

Name of the variable in lowercase letters.

unit: str = '1000 m³'

Unit of the variable.

class hydpy.models.sw1d.sw1d_states.Discharge(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: StateSequence

Discharge [m³/s].

Updated by the methods:

Calc_Discharge_V1 Calc_Discharge_V2 Calc_Discharge_V3 Calc_Discharge_V4 Determine_Discharge_V1 Determine_Discharge_V2 Determine_Discharge_V3 Determine_Discharge_V4 Determine_Discharge_V5 Determine_Discharge_V6 Determine_Discharge_V7 Update_Discharge_V1 Update_Discharge_V2

Required by the methods:

Calc_DischargeDownstream_V1 Calc_DischargeUpstream_V1 Calc_MaxTimeStep_V6 Determine_MaxTimeStep_V1 Determine_MaxTimeStep_V6 Get_Discharge_V1 Get_PartialDischargeDownstream_V1 Get_PartialDischargeUpstream_V1 Update_DischargeVolume_V1

NDIM: int = 0
NUMERIC: bool = False
name: str = 'discharge'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

Inlet sequences

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

Bases: InletSequences

Inlet sequences of model sw1d.

The following classes are selected:
  • LongQ() The longitudinal inflow into the first channel segment [m³/s].

  • LatQ() The lateral inflow into the first channel segment [m³/s].

class hydpy.models.sw1d.sw1d_inlets.LongQ(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: InletSequence

The longitudinal inflow into the first channel segment [m³/s].

Calculated by the methods:

Pass_Discharge_V1 Perform_Postprocessing_V2

Required by the methods:

Perform_Preprocessing_V1 Pick_Inflow_V1

NDIM: int = 1
NUMERIC: bool = False
name: str = 'longq'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

class hydpy.models.sw1d.sw1d_inlets.LatQ(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: InletSequence

The lateral inflow into the first channel segment [m³/s].

Required by the methods:

Perform_Preprocessing_V3 Pick_LateralFlow_V1

NDIM: int = 1
NUMERIC: bool = False
name: str = 'latq'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

Outlet sequences

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

Bases: OutletSequences

Outlet sequences of model sw1d.

The following classes are selected:
  • LongQ() The longitudinal outflow of the last channel segment [m³/s].

class hydpy.models.sw1d.sw1d_outlets.LongQ(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: OutletSequence

The longitudinal outflow of the last channel segment [m³/s].

Calculated by the methods:

Pass_Discharge_V1 Perform_Postprocessing_V2

Required by the methods:

Perform_Preprocessing_V4 Pick_Outflow_V1

NDIM: int = 1
NUMERIC: bool = False
name: str = 'longq'

Name of the variable in lowercase letters.

unit: str = 'm³/s'

Unit of the variable.

Receiver sequences

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

Bases: ReceiverSequences

Receiver sequences of model sw1d.

The following classes are selected:
class hydpy.models.sw1d.sw1d_receivers.WaterLevel(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: ReceiverSequence

Water level [m].

Required by the methods:

Perform_Preprocessing_V5 Pick_WaterLevelDownstream_V1

NDIM: int = 0
NUMERIC: bool = False
name: str = 'waterlevel'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

Sender sequences

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

Bases: SenderSequences

Sender sequences of model sw1d.

The following classes are selected:
  • WaterLevel() The water level within the first channel segment [m].

class hydpy.models.sw1d.sw1d_senders.WaterLevel(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: SenderSequence

The water level within the first channel segment [m].

Calculated by the methods:

Pass_WaterLevel_V1 Perform_Postprocessing_V3

NDIM: int = 1
NUMERIC: bool = False
name: str = 'waterlevel'

Name of the variable in lowercase letters.

unit: str = 'm'

Unit of the variable.

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

Bases: SubParameters

Control parameters of model sw1d.

The following classes are selected:
class hydpy.models.sw1d.DerivedParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Derived parameters of model sw1d.

The following classes are selected:
  • Seconds() The length of the actual simulation step size in seconds [s].

  • TOY() References the timeofyear index array provided by the instance of class Indexer available in module pub [-].

  • WeightUpstream() A weighting coefficient for interpolating the water level from the centroids of two adjacent segments to their shared edge [-].

  • LengthMin() The minimum length of the segments upstream and downstream of the relevant routing model [km].

  • LengthMean() The mean length of the segments upstream and downstream of the relevant routing model [km].

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

Bases: FactorSequences

Factor sequences of model sw1d.

The following classes are selected:
class hydpy.models.sw1d.FixedParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Fixed parameters of model sw1d.

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

Bases: FluxSequences

Flux sequences of model sw1d.

The following classes are selected:
  • Inflow() Longitudinal flow into the first channel segment [m³/s].

  • Outflow() Longitudinal flow out of the last channel segment [m³/s].

  • LateralFlow() Lateral flow into the first channel segment [m³/s].

  • NetInflow() The net inflow into a channel segment [m³/T].

  • DischargeUpstream() The summed (partial) of all upstream routing models [m³/s].

  • DischargeDownstream() The summed (partial) of all downstream routing models [m³/s].

  • DischargeVolume() The total amount of discharge of a simulation step [m³/T].

  • Discharges() The discharges between all channel segments, including the flow into the first and out of the last one [m³/s].

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

Bases: InletSequences

Inlet sequences of model sw1d.

The following classes are selected:
  • LongQ() The longitudinal inflow into the first channel segment [m³/s].

  • LatQ() The lateral inflow into the first channel segment [m³/s].

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

Bases: OutletSequences

Outlet sequences of model sw1d.

The following classes are selected:
  • LongQ() The longitudinal outflow of the last channel segment [m³/s].

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

Bases: ReceiverSequences

Receiver sequences of model sw1d.

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

Bases: SenderSequences

Sender sequences of model sw1d.

The following classes are selected:
  • WaterLevel() The water level within the first channel segment [m].

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

Bases: StateSequences

State sequences of model sw1d.

The following classes are selected: