Skip to main content

HydroModel

Trait HydroModel 

Source
pub trait HydroModel: Send {
    type Params: Serialize + for<'de> Deserialize<'de> + Clone + Send;

    // Required methods
    fn new(params: Self::Params) -> Self;
    fn step(&mut self, forcing: &Forcing, dt_h: f64);
    fn discharge(&self) -> f64;
    fn state(&self) -> Value;
    fn reset(&mut self);
    fn name(&self) -> &'static str;
    fn params(&self) -> &Self::Params;
    fn params_mut(&mut self) -> &mut Self::Params;
}
Expand description

The core trait every distributed hydrological model implements.

Each model owns its parameter struct (associated type Params) and its internal state. The platform calls step once per time-step and reads discharge for the outlet hydrograph in m³/s. Implementations are expected to be deterministic given (params, state, forcing) so that calibration can rely on reproducibility.

Required Associated Types§

Source

type Params: Serialize + for<'de> Deserialize<'de> + Clone + Send

Model-specific parameters, serializable so calibrated configs can be persisted as JSON and overrides can be applied at runtime by the platform.

Required Methods§

Source

fn new(params: Self::Params) -> Self

Construct a model instance with the given parameters and default (cold-start) state.

Source

fn step(&mut self, forcing: &Forcing, dt_h: f64)

Advance the model by one time-step of length dt_h (hours), given the meteorological Forcing for that step. Updates internal state in place; the resulting outlet discharge is read via discharge.

Source

fn discharge(&self) -> f64

Current discharge at the basin outlet, in m³/s. Read after each step to assemble the hydrograph.

Source

fn state(&self) -> Value

Serialize the internal state (soil moisture, storages, …) as JSON for warm-restart across events or runs.

Source

fn reset(&mut self)

Reset internal state to its default cold-start values.

Source

fn name(&self) -> &'static str

Model display name (e.g. "新安江", "TOPMODEL") — see also ModelType::name.

Source

fn params(&self) -> &Self::Params

Read-only access to the parameter struct.

Source

fn params_mut(&mut self) -> &mut Self::Params

Mutable access to the parameter struct (used by calibrators to apply a new candidate vector between runs).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl HydroModel for ApicontModel

Source§

fn new(params: <ApicontModel as HydroModel>::Params) -> ApicontModel

Build a fresh model with an empty antecedent store (sm = 0) and zero outlet discharge.

Source§

fn step(&mut self, f: &Forcing, dt_h: f64)

Advance one step of length dt_h (hours).

Enforces strict mass balance P = ea + drain + Δsm: fill → ET (ea = min(PET, sm)) → exponential API drain (drain = (1 − k) · sm) → linear-reservoir routing (Q ← cs · Q + (1 − cs) · mm_to_m3s(drain, ...)).

Source§

fn discharge(&self) -> f64

Current outlet discharge (m³/s).

Source§

fn state(&self) -> Value

Snapshot of the internal state as { "sm": <mm> }.

Source§

fn reset(&mut self)

Reset the store and discharge to zero (a dry, pre-storm initial condition).

Source§

fn name(&self) -> &'static str

Static model name — "API-CONT".

Source§

fn params(&self) -> &<ApicontModel as HydroModel>::Params

Shared reference to the parameter struct.

Source§

fn params_mut(&mut self) -> &mut <ApicontModel as HydroModel>::Params

Exclusive reference to the parameter struct (for online updates).

Source§

type Params = ApicontParams

Source§

impl HydroModel for SwatModel

Source§

type Params = SwatParams

Source§

fn new(params: <SwatModel as HydroModel>::Params) -> SwatModel

Source§

fn step(&mut self, f: &Forcing, _dt_h: f64)

Source§

fn discharge(&self) -> f64

Source§

fn state(&self) -> Value

Source§

fn reset(&mut self)

Source§

fn name(&self) -> &'static str

Source§

fn params(&self) -> &<SwatModel as HydroModel>::Params

Source§

fn params_mut(&mut self) -> &mut <SwatModel as HydroModel>::Params

Source§

impl HydroModel for TopmodelModel

Source§

type Params = TopmodelParams

Source§

fn new(params: <TopmodelModel as HydroModel>::Params) -> TopmodelModel

Source§

fn step(&mut self, f: &Forcing, dt_h: f64)

Source§

fn discharge(&self) -> f64

Source§

fn state(&self) -> Value

Source§

fn reset(&mut self)

Source§

fn name(&self) -> &'static str

Source§

fn params(&self) -> &<TopmodelModel as HydroModel>::Params

Source§

fn params_mut(&mut self) -> &mut <TopmodelModel as HydroModel>::Params

Source§

impl HydroModel for XinanjiangModel

Source§

type Params = XinanjiangParams

Source§

fn new(params: <XinanjiangModel as HydroModel>::Params) -> XinanjiangModel

Source§

fn step(&mut self, f: &Forcing, dt_h: f64)

Source§

fn discharge(&self) -> f64

Source§

fn state(&self) -> Value

Source§

fn reset(&mut self)

Source§

fn name(&self) -> &'static str

Source§

fn params(&self) -> &<XinanjiangModel as HydroModel>::Params

Source§

fn params_mut(&mut self) -> &mut <XinanjiangModel as HydroModel>::Params

Implementors§