routinginterfaces¶
This module defines submodel interfaces for calculating 1-dimensional water flows.
Module routinginterfaces
implements the following members:
CrossSectionModel_V1
Interface for calculating the discharge and related properties at a channel cross-section.
CrossSectionModel_V2
Interface for calculating discharge-related properties at a channel cross-section.
RoutingModelBase
Base interface for routing models at inflow, central, and outflow locations.
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.
StorageModel_V1
Interface for calculating the water amount stored in a single channel segment.
ChannelModel_V1
Interface for handling routing and storage submodels.
- class hydpy.interfaces.routinginterfaces.CrossSectionModel_V1[source]¶
Bases:
SubmodelInterface
Interface for calculating the discharge and related properties at a channel cross-section.
- typeid: ClassVar[Literal[1]] = 1¶
Type identifier for
CrossSectionModel_V1
submodels.
- prepare_bottomslope(bottomslope: int) None [source]¶
Set the bottom’s slope (in the longitudinal direction) [-].
- use_waterdepth(waterdepth: float, /) None [source]¶
Set the water depth in m and use it to calculate all other properties.
- class hydpy.interfaces.routinginterfaces.CrossSectionModel_V2[source]¶
Bases:
SubmodelInterface
Interface for calculating discharge-related properties at a channel cross-section.
- typeid: ClassVar[Literal[2]] = 2¶
Type identifier for
CrossSectionModel_V2
submodels.
- use_waterdepth(waterdepth: float, /) None [source]¶
Set the water depth in m and use it to calculate all other properties.
- use_waterlevel(waterlevel: float, /) None [source]¶
Set the water level in m and use it to calculate all other properties.
- class hydpy.interfaces.routinginterfaces.RoutingModelBase[source]¶
Bases:
SubmodelInterface
Base interface for routing models at inflow, central, and outflow locations.
An essential note for model developers: All main models using submodels that follow the interface
RoutingModel_V1
,RoutingModel_V2
, orRoutingModel_V3
must callperform_preprocessing()
at the beginning of each external simulation step, calldetermine_maxtimestep()
,set_timestep()
, anddetermine_discharge()
in the mentioned order during each internal simulation step, and callperform_postprocessing()
at the end of each simulation step. Beforedetermine_discharge()
is called, methodsget_discharge()
,get_partialdischargeupstream()
, andget_partialdischargedownstream()
(if implemented) must return the “old” discharge previously calculated or read from condition files.- perform_preprocessing() None [source]¶
Preprocess all data that is invariant during each external simulation step.
- class hydpy.interfaces.routinginterfaces.RoutingModel_V1[source]¶
Bases:
RoutingModelBase
Interface for calculating the inflow into a channel.
- typeid: ClassVar[Literal[1]] = 1¶
Type identifier for
RoutingModel_V1
submodels.
- routingmodelsdownstream: modeltools.SubmodelsProperty[RoutingModel_V2 | RoutingModel_V3]¶
References to the neighbour routing models lying downstream.
- storagemodeldownstream: modeltools.SubmodelProperty[StorageModel_V1]¶
Required reference to the neighbour storage model downstream.
- get_partialdischargeupstream(clientdischarge: float) float [source]¶
Get the simulated partial discharge in m³/s.
For multiple downstream models,
get_partialdischargeupstream()
returns the discharge portion that it attributes to the client model.
- class hydpy.interfaces.routinginterfaces.RoutingModel_V2[source]¶
Bases:
RoutingModelBase
Interface for calculating the discharge between two channel segments.
The usage instructions described for the
RoutingModel_V1
interface also apply forRoutingModel_V2
.- typeid: ClassVar[Literal[2]] = 2¶
Type identifier for
RoutingModel_V2
submodels.
- routingmodelsupstream: modeltools.SubmodelsProperty[RoutingModel_V1 | RoutingModel_V2]¶
References to the neighbour routing models lying upstream.
- routingmodelsdownstream: modeltools.SubmodelsProperty[RoutingModel_V2 | RoutingModel_V3]¶
References to the neighbour routing models lying downstream.
- storagemodelupstream: modeltools.SubmodelProperty[StorageModel_V1]¶
Required reference to the neighbour storage model upstream.
- storagemodeldownstream: modeltools.SubmodelProperty[StorageModel_V1]¶
Required reference to the neighbour storage model downstream.
- get_partialdischargeupstream(clientdischarge: float) float [source]¶
Get the simulated partial discharge in m³/s.
For multiple downstream models,
get_partialdischargeupstream()
returns the discharge portion that it attributes to the client model.
- get_partialdischargedownstream(clientdischarge: float) float [source]¶
Get the simulated partial discharge in m³/s.
For multiple upstream models,
get_partialdischargedownstream()
returns the discharge portion that it attributes to the client model.
- class hydpy.interfaces.routinginterfaces.RoutingModel_V3[source]¶
Bases:
RoutingModelBase
Interface for calculating the outflow of a channel.
The usage instructions described for the
RoutingModel_V1
interface also apply forRoutingModel_V2
.- typeid: ClassVar[Literal[3]] = 3¶
Type identifier for
RoutingModel_V3
submodels.
- routingmodelsupstream: modeltools.SubmodelsProperty[RoutingModel_V1 | RoutingModel_V2]¶
References to the neighbour routing models lying upstream.
- storagemodelupstream: modeltools.SubmodelProperty[StorageModel_V1]¶
Required reference to the neighbour storage model upstream.
- get_partialdischargedownstream(clientdischarge: float) float [source]¶
Get the simulated partial discharge in m³/s.
For multiple upstream models,
get_partialdischargedownstream()
returns the discharge portion that it attributes to the client model.
- class hydpy.interfaces.routinginterfaces.StorageModel_V1[source]¶
Bases:
SubmodelInterface
Interface for calculating the water amount stored in a single channel segment.
- typeid: ClassVar[Literal[1]] = 1¶
Type identifier for
StorageModel_V1
submodels.
- routingmodelsupstream: modeltools.SubmodelsProperty[RoutingModel_V1 | RoutingModel_V2 | RoutingModel_V3]¶
Optional reference to the neighbour routing model upstream.
- routingmodelsdownstream: modeltools.SubmodelsProperty[RoutingModel_V1 | RoutingModel_V2 | RoutingModel_V3]¶
Optional reference to the neighbour routing model downstream.
- perform_preprocessing() None [source]¶
Preprocess all data that is invariant during each external simulation step.
- class hydpy.interfaces.routinginterfaces.ChannelModel_V1[source]¶
Bases:
SubmodelInterface
Interface for handling routing and storage submodels.
The purpose of any model that follows the
ChannelModel_V1
interface is to collect and connect the routing and storage submodels required to simulate the water flow through a single channel (without confluences or branches). It can but must not be able to perform the actual simulation itself. Seesw1d_channel
as an example, which usually delegates simulations tosw1d_network
.- typeid: ClassVar[Literal[1]] = 1¶
Type identifier for
ChannelModel_V1
submodels.
- storagemodels: modeltools.SubmodelsProperty[StorageModel_V1]¶
References to the storage submodels.
There must be one storage model for each channel segment.
- routingmodels: modeltools.SubmodelsProperty[RoutingModel_V1 | RoutingModel_V2 | RoutingModel_V3]¶
References to the routing submodels.
There must be one routing model for each interface between two channel segments. Additionally, one routing model can be at the first position for simulating “longitudinal inflow” into the channel. And there can be one routing model at the last position for calculating “longitudinal outflow”.
Note that “inflow” and “outflow” here only refer to the location but not necessarily to water increases or decreases in the channel’s water amount, as both might be positive or negative, depending on the selected submodel.
If neither the upstream channel model defines a routing model for its last position nor the corresponding downstream channel model for its first position, both channels cannot become connected. If both channel models define routing models for the mentioned positions, it is unclear which is relevant. We suggest the following convention. Of course, add routing submodels that handle “external longitudinal inflow” (e.g.
sw1d_q_in
) at the first position and routing submodels that handle “external longitudinal outflow” (e.g.sw1d_weir_out
) at the last position. Add routing submodels that handle “internal longitudinal flow” (e.g.sw1d_lias
) at the last position for places with confluences or without tributaries. For branches, add them to the first position.