exch¶
The HydPy-Exch base model provides features to implement helper models that enable other models to exchange data more freely.
Method Features¶
- class hydpy.models.exch.exch_model.Model[source]¶
Bases:
AdHocModel
HydPy-Exch base model.
- The following “receiver update methods” are called in the given sequence before performing a simulation step:
Pic_LoggedWaterLevel_V1
Pic the logged water level from a receiver node.
- The following “run methods” are called in the given sequence during each simulation step:
Update_WaterLevel_V1
Update the factor sequenceWaterLevel
.Calc_DeltaWaterLevel_V1
Calculate the effective difference of both water levels.Calc_PotentialExchange_V1
Calculate the potential exchange that strictly follows the weir formula without taking any other limitations into account.Calc_ActualExchange_V1
Calculate the actual exchange.
- The following “outlet update methods” are called in the given sequence at the end of each simulation step:
Pass_ActualExchange_V1
Pass the actual exchange to an outlet node.
- class hydpy.models.exch.exch_model.Pic_LoggedWaterLevel_V1[source]¶
Bases:
Method
Pic the logged water level from a receiver node.
- Requires the receiver sequence:
- Calculates the log sequence:
- Basic equation:
\(LoggedWaterLevel = L\)
- class hydpy.models.exch.exch_model.Update_WaterLevel_V1[source]¶
Bases:
Method
Update the factor sequence
WaterLevel
.- Requires the log sequence:
- Calculates the factor sequence:
- Basic equation:
\(WaterLevel = LoggedWaterLevel\)
Example:
>>> from hydpy.models.exch import * >>> parameterstep() >>> logs.loggedwaterlevel = 2.0, 4.0 >>> model.update_waterlevel_v1() >>> factors.waterlevel waterlevel(2.0, 4.0)
- class hydpy.models.exch.exch_model.Calc_DeltaWaterLevel_V1[source]¶
Bases:
Method
Calculate the effective difference of both water levels.
- Requires the control parameter:
- Requires the factor sequence:
- Calculates the factor sequence:
- Basic equation:
\(DeltaWaterLevel = max(WaterLevel_0, CrestHeight) - max(WaterLevel_1, CrestHeight)\)
Examples:
“Effective difference” means that only the height above the crest counts. The first example illustrates this for fixed water levels and a variable crest height:
>>> from hydpy.models.exch import * >>> parameterstep() >>> from hydpy import UnitTest >>> test = UnitTest(model=model, ... method=model.calc_deltawaterlevel_v1, ... last_example=5, ... parseqs=(control.crestheight, factors.deltawaterlevel)) >>> test.nexts.crestheight = 1.0, 2.0, 3.0, 4.0, 5.0 >>> factors.waterlevel = 4.0, 2.0 >>> test() | ex. | crestheight | deltawaterlevel | --------------------------------------- | 1 | 1.0 | 2.0 | | 2 | 2.0 | 2.0 | | 3 | 3.0 | 1.0 | | 4 | 4.0 | 0.0 | | 5 | 5.0 | 0.0 |
Method
Calc_DeltaWaterLevel_V1
modifies the basic equation given above to also work for an inverse gradient:>>> factors.waterlevel = 2.0, 4.0 >>> test() | ex. | crestheight | deltawaterlevel | --------------------------------------- | 1 | 1.0 | -2.0 | | 2 | 2.0 | -2.0 | | 3 | 3.0 | -1.0 | | 4 | 4.0 | 0.0 | | 5 | 5.0 | 0.0 |
- class hydpy.models.exch.exch_model.Calc_PotentialExchange_V1[source]¶
Bases:
Method
Calculate the potential exchange that strictly follows the weir formula without taking any other limitations into account.
- Requires the control parameters:
- Requires the factor sequence:
- Calculates the flux sequence:
- Basic equation:
\(PotentialExchange = FlowCoefficient \cdot CrestWidth \cdot DeltaWaterLevel ^ {FlowExponent}\)
Examples:
Method
Calc_PotentialExchange_V1
modifies the given basic equation to work for positive and negative gradients:>>> from hydpy.models.exch import * >>> parameterstep() >>> crestwidth(3.0) >>> flowcoefficient(0.5) >>> flowexponent(2.0) >>> factors.deltawaterlevel = 2.0 >>> model.calc_potentialexchange_v1() >>> fluxes.potentialexchange potentialexchange(6.0)
>>> factors.deltawaterlevel = -2.0 >>> model.calc_potentialexchange_v1() >>> fluxes.potentialexchange potentialexchange(-6.0)
- class hydpy.models.exch.exch_model.Calc_ActualExchange_V1[source]¶
Bases:
Method
Calculate the actual exchange.
- Requires the control parameter:
- Requires the flux sequence:
- Calculates the flux sequence:
- Basic equation:
\(ActualExchange = min(PotentialExchange, AllowedExchange)\)
Examples:
Method
Calc_ActualExchange_V1
modifies the given basic equation to work for positive and negative gradients:>>> from hydpy.models.exch import * >>> parameterstep() >>> allowedexchange(2.0) >>> fluxes.potentialexchange = 1.0 >>> model.calc_actualexchange_v1() >>> fluxes.actualexchange actualexchange(1.0)
>>> fluxes.potentialexchange = 3.0 >>> model.calc_actualexchange_v1() >>> fluxes.actualexchange actualexchange(2.0)
>>> fluxes.potentialexchange = -1.0 >>> model.calc_actualexchange_v1() >>> fluxes.actualexchange actualexchange(-1.0)
>>> fluxes.potentialexchange = -3.0 >>> model.calc_actualexchange_v1() >>> fluxes.actualexchange actualexchange(-2.0)
Parameter Features¶
Control parameters¶
- class hydpy.models.exch.ControlParameters(master: Parameters, cls_fastaccess: Type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)
Bases:
SubParameters
Control parameters of model exch.
- The following classes are selected:
CrestHeight()
Crest height [m].CrestWidth()
Crest width [m].FlowCoefficient()
Flow coefficient [-].FlowExponent()
Flow exponent [-].AllowedExchange()
The highest water exchange allowed [m³/s].
- class hydpy.models.exch.exch_control.CrestHeight(subvars: SubParameters)[source]¶
Bases:
Parameter
Crest height [m].
- Required by the method:
- class hydpy.models.exch.exch_control.CrestWidth(subvars: SubParameters)[source]¶
Bases:
Parameter
Crest width [m].
- Required by the method:
- class hydpy.models.exch.exch_control.FlowCoefficient(subvars: SubParameters)[source]¶
Bases:
Parameter
Flow coefficient [-].
- Required by the method:
- class hydpy.models.exch.exch_control.FlowExponent(subvars: SubParameters)[source]¶
Bases:
Parameter
Flow exponent [-].
- Required by the method:
- class hydpy.models.exch.exch_control.AllowedExchange(subvars: SubParameters)[source]¶
Bases:
Parameter
The highest water exchange allowed [m³/s].
- Required by the method:
Sequence Features¶
Factor sequences¶
- class hydpy.models.exch.FactorSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)
Bases:
FactorSequences
Factor sequences of model exch.
- The following classes are selected:
WaterLevel()
Water level [m].DeltaWaterLevel()
Effective difference of the two water levels [m].
- class hydpy.models.exch.exch_factors.WaterLevel(subvars: ModelSequences[ModelSequence, FastAccess])[source]¶
Bases:
MixinFixedShape
,FactorSequence
Water level [m].
- Calculated by the method:
- Required by the method:
After each simulation step, the value of
WaterLevel
corresponds to the value of theLoggedWaterLevel
of the previous simulation step.
- class hydpy.models.exch.exch_factors.DeltaWaterLevel(subvars: ModelSequences[ModelSequence, FastAccess])[source]¶
Bases:
FactorSequence
Effective difference of the two water levels [m].
- Calculated by the method:
- Required by the method:
After each simulation step, the value of
DeltaWaterLevel
corresponds to the value of theLoggedWaterLevel
of the previous simulation step.
Flux sequences¶
- class hydpy.models.exch.FluxSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)
Bases:
FluxSequences
Flux sequences of model exch.
- The following classes are selected:
PotentialExchange()
The potential bidirectional water exchange [m³/s].ActualExchange()
The actual bidirectional water exchange [m³/s].
- class hydpy.models.exch.exch_fluxes.PotentialExchange(subvars: ModelSequences[ModelSequence, FastAccess])[source]¶
Bases:
FluxSequence
The potential bidirectional water exchange [m³/s].
- Calculated by the method:
- Required by the method:
- class hydpy.models.exch.exch_fluxes.ActualExchange(subvars: ModelSequences[ModelSequence, FastAccess])[source]¶
Bases:
FluxSequence
The actual bidirectional water exchange [m³/s].
- Calculated by the method:
- Required by the method:
Log sequences¶
- class hydpy.models.exch.LogSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)
Bases:
LogSequences
Log sequences of model exch.
- The following classes are selected:
LoggedWaterLevel()
Logged water level [m].
- class hydpy.models.exch.exch_logs.LoggedWaterLevel(subvars: ModelSequences[ModelSequence, FastAccess])[source]¶
Bases:
LogSequenceFixed
Logged water level [m].
- Calculated by the method:
- Required by the method:
Outlet sequences¶
- class hydpy.models.exch.OutletSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)
Bases:
OutletSequences
Outlet sequences of model exch.
- The following classes are selected:
E()
Bidirectional water exchange [m³].
- class hydpy.models.exch.exch_outlets.E(subvars: ModelSequences[ModelSequence, FastAccess])[source]¶
Bases:
OutletSequence
Bidirectional water exchange [m³].
- Calculated by the method:
Receiver sequences¶
- class hydpy.models.exch.ReceiverSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)
Bases:
ReceiverSequences
Receiver sequences of model exch.
- The following classes are selected:
L()
Water level [m].
- class hydpy.models.exch.exch_receivers.L(subvars: ModelSequences[ModelSequence, FastAccess])[source]¶
Bases:
ReceiverSequence
Water level [m].
- Required by the method:
- class hydpy.models.exch.ControlParameters(master: Parameters, cls_fastaccess: Type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)¶
Bases:
SubParameters
Control parameters of model exch.
- The following classes are selected:
CrestHeight()
Crest height [m].CrestWidth()
Crest width [m].FlowCoefficient()
Flow coefficient [-].FlowExponent()
Flow exponent [-].AllowedExchange()
The highest water exchange allowed [m³/s].
- class hydpy.models.exch.FactorSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)¶
Bases:
FactorSequences
Factor sequences of model exch.
- The following classes are selected:
WaterLevel()
Water level [m].DeltaWaterLevel()
Effective difference of the two water levels [m].
- class hydpy.models.exch.FluxSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)¶
Bases:
FluxSequences
Flux sequences of model exch.
- The following classes are selected:
PotentialExchange()
The potential bidirectional water exchange [m³/s].ActualExchange()
The actual bidirectional water exchange [m³/s].
- class hydpy.models.exch.LogSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)¶
Bases:
LogSequences
Log sequences of model exch.
- The following classes are selected:
LoggedWaterLevel()
Logged water level [m].
- class hydpy.models.exch.OutletSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)¶
Bases:
OutletSequences
Outlet sequences of model exch.
- The following classes are selected:
E()
Bidirectional water exchange [m³].
- class hydpy.models.exch.ReceiverSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)¶
Bases:
ReceiverSequences
Receiver sequences of model exch.
- The following classes are selected:
L()
Water level [m].