MARRMOT_31

Implementation

MARRMoT v2.1.1 rev eeb7e15 m_31_mopex3_8p_5s; standardized continuous structure, not original model

  • Time step: daily

  • Backend: octave-cli + Octave optim

  • Calibrated parameters: 8

  • Temperature required: yes

Inspect the exact implementation.

Parameters and initial configuration

Parameter

Supported calibration range

Default

p01

-3 to 3

0.0

p02

0 to 20

10.0

p03

1 to 2000

1000.5

p04

0 to 1

0.5

p05

0 to 1

0.5

p06

0.05 to 0.95

0.5

p07

1 to 2000

1000.5

p08

0 to 1

0.5

s01

Fixed initial/configuration value

0.0

s02

Fixed initial/configuration value

0.0

s03

Fixed initial/configuration value

0.0

s04

Fixed initial/configuration value

0.0

s05

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;
            tcrit = theta(1);     % Snowfall & snowmelt temperature [oC]
            ddf   = theta(2);     % Degree-day factor for snowmelt [mm/oC/d]
            s2max = theta(3);     % Maximum soil moisture storage [mm]
            tw    = theta(4);     % Groundwater leakage time [d-1]
            tu    = theta(5);     % Slow flow routing response time [d-1]
            se    = theta(6);     % Root zone storage capacity as fraction of s3max [-]
            s3max = theta(7);     % Maximum groundwater storage [mm]
            tc    = theta(8);     % Mean residence time [d-1]
            
            % delta_t
            delta_t = obj.delta_t;
            
            % 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_ps   = snowfall_1(P,T,tcrit);
            flux_pr   = rainfall_1(P,T,tcrit);
            flux_qn   = melt_1(ddf,tcrit,T,S1,delta_t);
            flux_et1  = evap_7(S2,s2max,Ep,delta_t);
            flux_q1f  = saturation_1(flux_pr+flux_qn,S2,s2max);
            flux_qw   = recharge_3(tw,S2);
            flux_et2  = evap_7(S3,se*s3max,Ep,delta_t);
            flux_q2f  = saturation_1(flux_qw,S3,s3max);
            flux_q2u  = baseflow_1(tu,S3);
            flux_qf   = baseflow_1(tc,S4);
            flux_qs   = baseflow_1(tc,S5);

            % stores ODEs
            dS1 = flux_ps - flux_qn;
            dS2 = flux_pr + flux_qn - flux_et1 - flux_q1f - flux_qw;
            dS3 = flux_qw - flux_et2 - flux_q2f - flux_q2u;
            dS4 = flux_q1f + flux_q2f - flux_qf;
            dS5 = flux_q2u - flux_qs;
            
            
            % outputs
            dS = [dS1 dS2 dS3 dS4 dS5];
            fluxes = [flux_ps, flux_pr, flux_qn, flux_et1,...
                      flux_q1f, flux_qw, flux_et2, flux_q2f,...
                      flux_q2u, flux_qf, flux_qs];
        end
        
        % STEP runs at the end of every timestep
function [out] = snowfall_1(In,T,p1,varargin)
%snowfall_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:  Snowfall based on temperature threshold
% Constraints:  -
% @(Inputs):    p1   - temperature threshold below which snowfall occurs [oC]
%               T    - current temperature [oC]
%               In   - incoming precipitation flux [mm/d]
%               varargin(1) - smoothing variable r (default 0.01)

if size(varargin,2) == 0
    out = In.*(smoothThreshold_temperature_logistic(T,p1));
elseif size(varargin,2) == 1
    out = In.*(smoothThreshold_temperature_logistic(T,p1,varargin(1)));   
end


end
function [out] = rainfall_1(In,T,p1,varargin)
%rainfall_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:  Rainfall based on temperature threshold
% Constraints:  -
% @(Inputs):    p1   - temperature threshold above which rainfall occurs [oC]
%               T    - current temperature [oC]
%               In   - incoming precipitation flux [mm/d]
%               varargin(1) - smoothing variable r (default 0.01)

if size(varargin,2) == 0
    out = In.*(1-smoothThreshold_temperature_logistic(T,p1));
elseif size(varargin,2) == 1
    out = In.*(1-smoothThreshold_temperature_logistic(T,p1,varargin(1)));    
end

end
function [out] = melt_1(p1,p2,T,S,dt)
%melt_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:  Snowmelt from degree-day-factor 
% Constraints:  f <= S/dt
% @(Inputs):    p1   - degree-day factor [mm/oC/d]
%               p2   - temperature threshold for snowmelt [oC]
%               T    - current temperature [oC]
%               S    - current storage [mm]
%               dt   - time step size [d]

out = max(min(p1*(T-p2),S/dt),0);

end
function [out] = evap_7(S,Smax,Ep,dt)
%evap_7 evaporation based on scaled current water storage, limited by
%potential rate.

% 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 scaled by relative storage
% Constraints:  f <= S/dt
% @(Inputs):    S    - current storage [mm]
%               Smax - maximum contributing storage [mm]
%               Ep   - potential evapotranspiration rate [mm/d]
%               dt   - time step size [d]

out = min(S./Smax.*Ep,S/dt);

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] = recharge_3(p1,S)
%recharge_3 

% 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:  Linear recharge
% Constraints:  -
% @(Inputs):    p1   - time coefficient [d-1]
%               S    - current storage [mm]

out = p1.*S;

end
function [out] = baseflow_1(p1,S)
% baseflow_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:  Outflow from a linear reservoir
% Constraints:  -
% @(Inputs):    p1   - time scale parameter [d-1]
%               S    - current storage [mm]

out = p1.*S;

end
function [out] = smoothThreshold_temperature_logistic(T,Tt,r)
%smoothThreshold_temperature_logistic Logisitic smoother for temperature 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:
%
%   Snowfall = { P, if T <  Tt
%              { 0, if T >= Tt
%
%   By transforming the equation above to Sf = f(P,T,Tt,r):
%   Sf = P * 1/ (1+exp((T-Tt)/r))
%
%   Inputs:
%   P       : current precipitation
%   T       : current temperature
%   Tt      : threshold temperature below which snowfall occurs
%   r       : [optional] smoothing parameter rho, default = 0.01
%
%   NOTE: this function only outputs the multiplier. This needs to be
%   applied to the proper flux utside of this function.

% 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 nargin == 2
    r = 0.01;
end

% Calculate multiplier
out = 1 ./ (1+exp((T-Tt)/(r)));

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_31").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.