hydrobricks
Loading...
Searching...
No Matches
Reach Class Reference

#include <Reach.h>

Classes

struct  RoutingState
 

Public Types

enum class  Scheme { None , Lag , Muskingum , MuskingumCunge }
 

Public Member Functions

 Reach (Subbasin *subbasin)
 
void Initialize ()
 
void SetChannelRouting (const ChannelRoutingSettings &settings)
 
double RouteUpstream (double inflowVolume, double timeStepInDays)
 
double RouteLocal (double localVolume, double timeStepInDays)
 
bool RoutesLocalRunoff () const
 
void Reset ()
 
void SaveAsInitialState ()
 
Subbasin * GetSubbasin () const
 
Scheme GetScheme () const
 
double GetLength () const
 
double GetSlope () const
 
double GetWidth () const
 
double GetManning () const
 
double GetCelerity () const
 
double GetCelerityForDischarge (double dischargeM3s) const
 
double GetMuskingumX () const
 
double GetTravelTimeInDays () const
 
int GetSubreachCount () const
 
double GetInflow () const
 
double GetOutflow () const
 
double GetStorage () const
 

Static Public Member Functions

static Scheme SchemeFromString (const string &name)
 
static string SchemeToString (Scheme scheme)
 

Protected Attributes

Subbasin * _subbasin
 
Scheme _scheme = Scheme::None
 
bool _routeLocal = false
 
double _length = 0
 
double _slope = 0
 
const float * _celerity = nullptr
 
const float * _celerityExponent = nullptr
 
const float * _referenceDischarge = nullptr
 
const float * _x = nullptr
 
const float * _width = nullptr
 
const float * _manning = nullptr
 
double _celerityOverride = NAN_D
 
double _xOverride = NAN_D
 
double _widthOverride = NAN_D
 
double _manningOverride = NAN_D
 
double _inflow = 0
 
double _outflow = 0
 
RoutingState _main
 
RoutingState _local
 

Detailed Description

The channel reach of a subbasin: the main channel from the point where the upstream subbasins enter to the subbasin outlet. It routes the volume arriving from upstream (m3 per time step) to the outlet, where the subbasin's own runoff joins it.

Four routing schemes exist: instantaneous (the inflow leaves the reach in the same step), a pure translation (lag), the Muskingum method and Muskingum-Cunge. The first three use a celerity: the model-wide parameter (which a subbasin property may override reach by reach), optionally varying with the discharge through a power law. Muskingum-Cunge instead derives the celerity and the weighting factor from the channel geometry (length, slope, width and Manning roughness) and the discharge of the step, so its parameters are measured rather than calibrated. A Muskingum-Cunge reach is also divided into sub reaches short enough for the wave to be resolved (the Ponce and Theurer criterion), the sub reaches being routed in series.

The subbasin's own runoff joins at the outlet by default. With 'route_local_runoff' it is routed too, through half the reach: generated uniformly along the reach, it travels half of it on average.

Member Enumeration Documentation

◆ Scheme

enum class Reach::Scheme
strong

The routing schemes: how the inflow of a time step is spread over the following ones.

Constructor & Destructor Documentation

◆ Reach()

Reach::Reach ( Subbasin * subbasin)
explicit

Create the reach of a subbasin.

Parameters
subbasinThe subbasin the reach belongs to (its outlet is the reach outlet).

Member Function Documentation

◆ GetCelerity()

double Reach::GetCelerity ( ) const
nodiscard

Get the celerity of this reach at the reference discharge [m/s]: the subbasin property when present, else the model-wide parameter, else 1.

Returns
the reference celerity.

◆ GetCelerityForDischarge()

double Reach::GetCelerityForDischarge ( double dischargeM3s) const
nodiscard

Get the celerity of this reach at a given discharge [m/s].

With the Muskingum-Cunge scheme it comes from the Manning relation for a wide channel: the kinematic celerity is 5/3 of the flow velocity. With the other schemes it is the reference celerity scaled by the discharge ratio raised to 'celerity_exponent' (0, the default, keeps it constant). The result is clamped to a plausible range for a river so that a vanishing discharge cannot give an unbounded travel time.

Parameters
dischargeM3sThe discharge [m3/s]; a non-positive value returns the reference celerity.
Returns
the celerity.

◆ GetInflow()

double Reach::GetInflow ( ) const
inlinenodiscard

Get the volume that entered the reach in the current time step [m3]: the upstream inflow, plus the sub basin's own runoff when it is routed.

Returns
the inflow volume.

◆ GetLength()

double Reach::GetLength ( ) const
inlinenodiscard

Get the reach length [m] (0 when the subbasin has no 'length' property).

Returns
the reach length.

◆ GetManning()

double Reach::GetManning ( ) const
nodiscard

Get the Manning roughness in use for this reach [s/m^(1/3)]: the subbasin property when present, else the model-wide parameter. Used by the Muskingum-Cunge scheme only.

Returns
the Manning roughness.

◆ GetMuskingumX()

double Reach::GetMuskingumX ( ) const
nodiscard

Get the Muskingum weighting factor in use for this reach [-]: the subbasin property when present, else the model-wide parameter, else 0.2. The Muskingum-Cunge scheme computes its own instead.

Returns
the weighting factor.

◆ GetOutflow()

double Reach::GetOutflow ( ) const
inlinenodiscard

Get the volume that left the reach in the current time step [m3].

Returns
the outflow volume.

◆ GetScheme()

Scheme Reach::GetScheme ( ) const
inlinenodiscard

Get the routing scheme.

Returns
the routing scheme.

◆ GetSlope()

double Reach::GetSlope ( ) const
inlinenodiscard

Get the reach slope [m/m] (0 when the subbasin has no 'slope' property).

Returns
the reach slope.

◆ GetStorage()

double Reach::GetStorage ( ) const
inlinenodiscard

Get the volume in transit in the reach [m3], in both the main channel and the local-runoff branch.

Returns
the storage.

◆ GetSubbasin()

Subbasin * Reach::GetSubbasin ( ) const
inlinenodiscard

Get the subbasin the reach belongs to.

Returns
the subbasin.

◆ GetSubreachCount()

int Reach::GetSubreachCount ( ) const
inlinenodiscard

Get the number of sub reaches the main channel is divided into for the routing. Always 1 except with the Muskingum-Cunge scheme, and only once the first time step has fixed it.

Returns
the number of sub reaches.

◆ GetTravelTimeInDays()

double Reach::GetTravelTimeInDays ( ) const
nodiscard

Get the travel time of the reach at the reference discharge [days]: length / celerity (0 without a length). With Muskingum-Cunge the celerity is the one the geometry gives at that discharge; with the other schemes it is the celerity parameter, which is defined at that same discharge.

Returns
the travel time.

◆ GetWidth()

double Reach::GetWidth ( ) const
nodiscard

Get the channel width in use for this reach [m]: the subbasin property when present, else the model-wide parameter. Used by the Muskingum-Cunge scheme only.

Returns
the channel width.

◆ Initialize()

void Reach::Initialize ( )

Read the reach geometry from the subbasin properties ('length' [m], 'slope' [-], 'width' [m] and 'manning' [s/m^(1/3)]) when present, as well as the reach-specific routing parameters ('celerity' [m/s] and 'muskingum_x' [-]) overriding the model-wide ones.

◆ Reset()

void Reach::Reset ( )

Reset the reach to its initial state (nothing in transit, or the saved initial state).

◆ RouteLocal()

double Reach::RouteLocal ( double localVolume,
double timeStepInDays )

Route the subbasin's own runoff, for the current time step. Called once per step, after the subbasin is processed. Without 'route_local_runoff' the runoff is returned unchanged (it joins at the outlet); with it, the runoff travels half the reach.

Parameters
localVolumeThe subbasin's own runoff [m3 per time step].
timeStepInDaysThe time step [days].
Returns
the volume of that runoff reaching the outlet [m3 per time step].

◆ RoutesLocalRunoff()

bool Reach::RoutesLocalRunoff ( ) const
inlinenodiscard

Check whether the subbasin's own runoff is routed through (half) the reach.

Returns
true when the local runoff is routed.

◆ RouteUpstream()

double Reach::RouteUpstream ( double inflowVolume,
double timeStepInDays )

Route the volume arriving from the upstream subbasins through the reach, for the current time step. Called once per step, before the subbasin is processed.

Parameters
inflowVolumeThe volume entering the reach from upstream [m3 per time step].
timeStepInDaysThe time step [days].
Returns
the volume leaving the reach at the subbasin outlet [m3 per time step].

◆ SaveAsInitialState()

void Reach::SaveAsInitialState ( )

Save the current state as the initial state restored by Reset().

◆ SchemeFromString()

Reach::Scheme Reach::SchemeFromString ( const string & name)
static

Parse a routing scheme name.

Parameters
nameThe name of the scheme ('none', 'lag', 'muskingum' or 'muskingum_cunge').
Returns
the scheme.

◆ SchemeToString()

string Reach::SchemeToString ( Scheme scheme)
static

Get the canonical name of a routing scheme.

Parameters
schemeThe scheme.
Returns
its name ('none', 'lag', 'muskingum' or 'muskingum_cunge').

◆ SetChannelRouting()

void Reach::SetChannelRouting ( const ChannelRoutingSettings & settings)

Set the channel routing scheme and bind the model-wide routing parameters.

Parameters
settingsThe channel routing settings of the model.

The documentation for this class was generated from the following files: