MARRMOT_39
Implementation
MARRMoT v2.1.1 rev eeb7e15 m_39_mcrm_16p_5s; standardized continuous structure, not original model
Time step: daily
Backend: octave-cli + Octave optim
Calibrated parameters: 16
Temperature required: no
Parameters and initial configuration
Parameter |
Supported calibration range |
Default |
|---|---|---|
|
0 to 5 |
2.5 |
|
0.01 to 0.99 |
0.5 |
|
0.01 to 0.99 |
0.5 |
|
0 to 2 |
1.0 |
|
0 to 1 |
0.5 |
|
1 to 2000 |
1000.5 |
|
0 to 1 |
0.5 |
|
1 to 5 |
3.0 |
|
0 to 20 |
10.0 |
|
0 to 1 |
0.5 |
|
1 to 120 |
60.5 |
|
1 to 300 |
150.5 |
|
0 to 1 |
0.5 |
|
1 to 5 |
3.0 |
|
0 to 1 |
0.5 |
|
1 to 5 |
3.0 |
|
Fixed initial/configuration value |
0.0 |
|
Fixed initial/configuration value |
0.0 |
|
Fixed initial/configuration value |
0.0 |
|
Fixed initial/configuration value |
0.0 |
|
Fixed initial/configuration value |
0.0 |
Ranges/defaults are implementation contracts, not universal priors or a recommended basin calibration. Consult source comments for parameter units and coupling.
Governing equations
The following source is the exact model kernel used by this adapter. For MARRMoT it includes the state derivative and each referenced flux function; the solver and routing are described above. Original notices and source citations are retained in the files.
function [dS, fluxes] = model_fun(obj, S)
% parameters
theta = obj.theta;
smax = theta(1); % Maximum interception storage [mm]
cmax = theta(2); % Maximum fraction of area contributing to rapid runoff [-]
c1 = theta(4); % Shape parameter for rapid flow distribution [mm-1]
ce = theta(5); % Shape parameter for evaporation [mm-1]
dsurp = theta(6); % Threshold for direct runoff [mm]
kd = theta(7); % Direct runoff time parameter [d-1]
gamd = theta(8); % Direct runoff flow non-linearity [-]
qpmax = theta(9); % Maximum percolation rate [mm/d]
kg = theta(10); % Groundwater time parameter [d-1]
sbf = theta(12); % Maximum routing store depth [mm]
kcr = theta(13); % Channel flow time parameter [d-1]
gamcr = theta(14); % Channel flow non-linearity [-]
kor = theta(15); % Out-of-bank flow time parameter [d-1]
gamor = theta(16); % Out-of-bank flow non-linearity [-]
% auxiliary parameters
c0 = obj.aux_theta(1);
% delta_t
delta_t = obj.delta_t;
% unit hydrographs and still-to-flow vectors
uhs = obj.uhs;
uh = uhs{1};
% stores
S1 = S(1);
S2 = S(2);
S3 = S(3);
S4 = S(4);
S5 = S(5);
% climate input
t = obj.t; % this time step
climate_in = obj.input_climate(t,:); % climate at this step
P = climate_in(1);
Ep = climate_in(2);
T = climate_in(3);
% fluxes functions
flux_ec = evap_1(S1,Ep,delta_t);
flux_qt = interception_1(P,S1,smax);
flux_qr = saturation_10(cmax,c0,c1,S2,flux_qt);
flux_er = evap_17(ce,S2,Ep-flux_ec);
flux_qn = effective_1(flux_qt,flux_qr);
flux_qd = interflow_9(S2,kd,dsurp,gamd,delta_t);
flux_qp = percolation_6(qpmax,dsurp,S2,delta_t);
flux_qb = baseflow_7(kg,1.5,S3,delta_t);
flux_uib = route(flux_qr + flux_qd + flux_qb, uh);
flux_uob = saturation_1(flux_uib,S4,sbf);
flux_qic = routing_1(kcr,gamcr,3/4,S4,delta_t);
flux_qoc = routing_1(kor,gamor,3/4,S5,delta_t);
% stores ODEs
dS1 = P - flux_ec - flux_qt;
dS2 = flux_qn - flux_er - flux_qd - flux_qp;
dS3 = flux_qp - flux_qb;
dS4 = flux_uib - flux_uob - flux_qic;
dS5 = flux_uob - flux_qoc;
% outputs
dS = [dS1 dS2 dS3 dS4 dS5];
fluxes = [flux_ec, flux_qt, flux_qr, flux_er,...
flux_qn, flux_qd, flux_qp, flux_qb,...
flux_uib, flux_uob, flux_qic, flux_qoc];
end
% STEP runs at the end of every timestep, use it to update
% still-to-flow vectors from unit hydrographs
function [out] = evap_1(S,Ep,dt)
%evap_1
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Evaporation at the potential rate
% Constraints: f <= S/dt
% @(Inputs): S - current storage [mm]
% Ep - potential evaporation rate [mm/d]
% dt - time step size
out = min(S/dt,Ep);
end
function [out] = interception_1(In,S,Smax,varargin)
%interception_1
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Interception excess when maximum capacity is reached
% Constraints: -
% @(Inputs): In - incoming flux [mm/d]
% S - current storage [mm]
% Smax - maximum storage [mm]
% varargin(1) - smoothing variable r (default 0.01)
% varargin(2) - smoothing variable e (default 5.00)
if size(varargin,2) == 0
out = In.*(1-smoothThreshold_storage_logistic(S,Smax));
elseif size(varargin,2) == 1
out = In.*(1-smoothThreshold_storage_logistic(S,Smax,varargin(1)));
elseif size(varargin,2) == 2
out = In.*(1-smoothThreshold_storage_logistic(S,Smax,varargin(1),varargin(2)));
end
end
function [out] = saturation_10(p1,p2,p3,S,In)
%saturation_10
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Saturation excess flow from a store with different degrees
% of saturation (min-max exponential variant)
% Constraints: -
% @(Inputs): p1 - maximum contributing fraction area [-]
% p2 - minimum contributing fraction area [-]
% p3 - exponentia scaling parameter [-]
% S - current storage [mm]
% In - incoming flux [mm/d]
out = min(p1,p2+p2.*exp(p3.*S)).*In;
end
function [out] = evap_17(p1,S,Ep)
%evap_17
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Scaled evaporation from a store that allows negative values
% Constraints: -
% @(Inputs): p1 - linear scaling parameter [mm-1]
% S - current storage [mm]
% Ep - potential evapotranspiration rate [mm/d]
out = 1./(1+exp(-1.*p1.*S)).*Ep;
end
function [out] = effective_1(In1,In2)
%effective_1
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: General effective flow (returns flux [mm/d])
% Constraints: In1 > In2
% @(Inputs): In1 - first flux [mm/d]
% In2 - second flux [mm/d]
out = max(In1-In2,0);
end
function [out] = interflow_9(S,p1,p2,p3,dt)
%interflow_9
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Non-linear interflow if storage exceeds a threshold
% Constraints: f <= S-p2
% S-p2 >= 0 prevents numerical issues with complex numbers
% @(Inputs): p1 - time coefficient [d-1]
% p2 - storage threshold for flow generation [mm]
% p3 - exponential scaling parameter [-]
% S - current storage [mm]
% dt - time step size [d]
out = min(max((S-p2)/dt,0),(p1.*max(S-p2,0)).^p3);
end
function [out] = percolation_6(p1,p2,S,dt)
%percolation_6
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Threshold-based percolation from a store that can reach negative values
% Constraints: f <= S/dt
% @(Inputs): p1 - maximum percolation rate
% p2 - storage threshold for reduced percolation [mm]
% S - current storage [mm]
% dt - time step size [d]
out = min(max(0,S)/dt,p1.*min(1,max(0,S)./p2));
end
function [out] = baseflow_7(p1,p2,S,dt)
%baseflow_7
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Non-linear outflow from a reservoir
% Constraints: f <= S/dt
% S >= 0
% @(Inputs): p1 - time coefficient [d-1]
% p2 - exponential scaling parameter [-]
% S - current storage [mm]
% dt - time step size [d]
out = min(S/dt,p1.*max(0,S).^p2);
end
function [ flux_out ] = route(flux_in, uh)
% ROUTE calculates the output of a unit hydrograph at the current timestep
% after routing a flux through it.
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% In:
% flux_in - input flux [1x1]
% uh - unit hydrograph [nx2]
% uh's first row contains coeficients to splut flow at each
% of n timesteps forward, the second row contains
% still-to-flow values.
%
% Out:
% flux_out - flux routed through the uh at this step [1x1]
%
flux_out = uh(1,1) * flux_in + uh(2,1);
end
function [out] = saturation_1(In,S,Smax,varargin)
%saturation_1
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Saturation excess from a store that has reached maximum capacity
% Constraints: -
% @(Inputs): In - incoming flux [mm/d]
% S - current storage [mm]
% Smax - maximum storage [mm]
% varargin(1) - smoothing variable r (default 0.01)
% varargin(2) - smoothing variable e (default 5.00)
if size(varargin,2) == 0
out = In.*(1-smoothThreshold_storage_logistic(S,Smax));
elseif size(varargin,2) == 1
out = In.*(1-smoothThreshold_storage_logistic(S,Smax,varargin(1)));
elseif size(varargin,2) == 2
out = In.*(1-smoothThreshold_storage_logistic(S,Smax,varargin(1),varargin(2)));
end
end
function [out] = routing_1(p1,p2,p3,S,dt)
%routing_1 non-linear routing
% Copyright (C) 2019, 2021 Wouter J.M. Knoben, Luca Trotter
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Flux function
% ------------------
% Description: Threshold-based non-linear routing
% Constraints: f <= S/dt
% S >= 0 prevents complex numbers
% @(Inputs): p1 - linear scaling parameter [-]
% p2 - exponential scaling parameter [-]
% p3 - fractional release parameter [-]
% S - current storage [mm]
% dt - time step size [d]
out = min([S/dt,p1.*(max(S,0).^p2),p3.*S/dt]);
end
function [out] = smoothThreshold_storage_logistic(S,Smax,r,e)
%smoothThreshold_storage_logistic Logisitic smoother for storage threshold functions.
% Copyright (C) 2018 Wouter J.M. Knoben
% This file is part of the Modular Assessment of Rainfall-Runoff Models
% Toolbox (MARRMoT).
% MARRMoT is a free software (GNU GPL v3) and distributed WITHOUT ANY
% WARRANTY. See <https://www.gnu.org/licenses/> for details.
% Smooths the transition of threshold functions of the form:
%
% Q = { P, if S = Smax
% { 0, if S < Smax
%
% By transforming the equation above to Q = f(P,S,Smax,e,r):
% Q = P * 1/ (1+exp((S-Smax+r*e*Smax)/(r*Smax)))
%
% Inputs:
% S : current storage
% Smax : maximum storage
% r : [optional] smoothing parameter rho, default = 0.01
% e : [optional] smoothing parameter e, default 5
%
% NOTE: this function only outputs the multiplier. This needs to be
% applied to the proper flux utside of this function.
%
% NOTE: can be applied for temperature thresholds as well (i.e. snow
% modules). This simply means that S becomes T, and Smax T0.
% Check for inputs and use defaults if not provided
% NOTE: this is not very elegant, but it is more than a factor 10 faster then:
% if ~exist('r','var'); r = 0.01; end
% if ~exist('e','var'); e = 5.00; end
if nargin == 2
r = 0.01;
e = 5.00;
elseif nargin == 3
r = r{1};
e = 5.00;
elseif nargin == 4
r = r{1};
e = e{1};
end
% Calculate multiplier
Smax = max(Smax,0); % this avoids numerical instabilities when Smax<0
if r*Smax == 0
out = 1 ./ (1+exp((S-Smax+r*e*Smax)/(r)));
else
out = 1 ./ (1+exp((S-Smax+r*e*Smax)/(r*Smax)));
end
end
Note
This standardized MARRMoT structure is not identical to the original named model. p01... follow exact source order; s01... are fixed initial stores, defaulting to zero. Octave + optim are required. Solver behavior can differ across runtime versions.
Simulation
from basinforge import Basin, get_model
basin = Basin.from_csv("basin.csv", basin_id="A", area_km2=1200,
q_unit="m3/s", timestep="daily")
q_mm = get_model("MARRMOT_39").simulate(basin)
q_m3s = basin.to_m3s(q_mm)
Supply your actual data and catchment area; temperature-dependent models require a temperature column. For non-daily models, choose an appropriate warmup in model steps.
See calibration, input requirements, sources and verification limitations.