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.

use_waterlevel(waterlevel: float, /) None[source]

Set the water level in m and use it to calculate all other properties.

get_wettedarea() float[source]

Get the wetted area in m².

get_surfacewidth() float[source]

Get the surface width in m.

get_discharge() float[source]

Get the discharge in m³/s.

get_celerity() float[source]

Get the wave celerity in m/s.

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.

use_wettedarea(wettedarea: float, /) None[source]

Set the wetted area in m² and use it to calculate all other properties.

get_waterdepth() float[source]

Get the water depth in m.

get_waterlevel() float[source]

Get the water level in m.

get_wettedarea() float[source]

Get the wetted area in m².

get_wettedperimeter() float[source]

Get the wetted perimeter in m.

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, or RoutingModel_V3 must call perform_preprocessing() at the beginning of each external simulation step, call determine_maxtimestep(), set_timestep(), and determine_discharge() in the mentioned order during each internal simulation step, and call perform_postprocessing() at the end of each simulation step. Before determine_discharge() is called, methods get_discharge(), get_partialdischargeupstream(), and get_partialdischargedownstream() (if implemented) must return the “old” discharge previously calculated or read from condition files.

typeid: ClassVar[int]

Type identifier for the respective routing submodels.

perform_preprocessing() None[source]

Preprocess all data that is invariant during each external simulation step.

perform_postprocessing() None[source]

Execute all tasks necessary at the end of each external simulation step.

determine_maxtimestep() None[source]

Determine the highest possible computation time step.

get_maxtimestep() float[source]

Get the highest possible computation time step in s.

set_timestep(timestep: float) None[source]

Set the actual computation time step in s.

determine_discharge() None[source]

Determine the discharge.

get_discharge() float[source]

Get the simulated total discharge in m³/s.

get_dischargevolume() float[source]

Get the simulated total discharge in m.

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 for RoutingModel_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 for RoutingModel_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.

perform_postprocessing() None[source]

Execute all tasks necessary at the end of each external simulation step.

set_timestep(timestep: float) None[source]

Set the actual computation time step in s.

update_storage() None[source]

Update the stored water content.

get_watervolume() float[source]

Get the current water volume in 1000 m³.

get_waterlevel() float[source]

Get the current water level in m.

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. See sw1d_channel as an example, which usually delegates simulations to sw1d_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.