MARRMOT_42

Implementation

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

  • Time step: daily

  • Backend: octave-cli + Octave optim

  • Calibrated parameters: 12

  • Temperature required: no

Inspect the exact implementation.

Parameters and initial configuration

Parameter

Supported calibration range

Default

p01

0 to 1

0.5

p02

0 to 5

2.5

p03

0 to 1

0.5

p04

0.01 to 0.99

0.5

p05

0 to 1

0.5

p06

1 to 2000

1000.5

p07

0.01 to 0.99

0.5

p08

1 to 2000

1000.5

p09

0 to 1

0.5

p10

1 to 5

3.0

p11

0 to 1

0.5

p12

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

s06

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;
            c       = theta(1);     % Fraction area that is channel [-]
            imax    = theta(2);     % Maximum total interception storage [mm]
            a       = theta(3);     % Fraction stem/trunk interception [-]
            fi2     = theta(4);     % Fraction of total interception that is trunk/stem interception [mm]
            kin     = theta(5);     % Infiltration runoff coefficient [d-1]
            d50     = theta(6);     % Soil depth where 50% of area contributes to effective flow [mm]
            fd16    = theta(7);     % Fraction of D50 that is D16 [-]
            sbc     = theta(8);     % Soil depth where evaporation rate starts to decline [mm]
            kb      = theta(9);     % Baseflow runoff coefficient [d-1]
            pb      = theta(10);    % Baseflow non-linearity [-]
            kh      = theta(11);    % Hillslope runoff coefficient [d-1]
            kc      = theta(12);    % Channel runoff coefficient [d-1]

            % auxiliary parameters
            aux_theta = obj.aux_theta;
            i1max   = aux_theta(1); % Maximum canopy interception [mm]
            i2max   = aux_theta(2); % Maximum trunk/stem interception [mm]
            d16     = aux_theta(3); % Soil depth where 16% of area contributes to effective flow [mm]
            
            % delta_t
            delta_t = obj.delta_t;
            
            % stores
            S1 = S(1);
            S2 = S(2);
            S3 = S(3);
            S4 = S(4);
            S5 = S(5);
            S6 = S(6);
            
            % 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_rc  = split_1(c,P);
            flux_rg  = split_1(1-c,P);
            flux_eic = evap_1(S1,(1-c)*Ep,delta_t);
            flux_qie = interception_1(flux_rg,S1,i1max);
            flux_qis = split_1(a,flux_qie);
            flux_rt  = split_1(1-a,flux_qie);
            flux_eis = evap_1(S2,(1-c)*Ep,delta_t);
            flux_rs  = interception_1(flux_qis,S2,i2max);
            flux_rn  = flux_rt + flux_rs;
            flux_esu = evap_1(S3,(1-c)*Ep,delta_t);
            flux_re  = saturation_13(d50,d16,S3,flux_rn);
            flux_qin = recharge_3(kin,S3);
            flux_esb = evap_3(1,S4,sbc,max(0,(1-c)*Ep-flux_esu),delta_t);
            flux_qb  = baseflow_7(kb,pb,S4,delta_t);
            flux_qh  = interflow_3(kh,5/3,S5,delta_t);
            flux_qc  = interflow_3(kc,5/3,S6,delta_t);
            flux_qt  = effective_1(flux_qb+flux_qh+flux_qc,c*Ep);
            flux_ec  = (flux_qb+flux_qh+flux_qc) - flux_qt;

            % stores ODEs
            dS1 = flux_rg  - flux_eic - flux_qie;
            dS2 = flux_qis - flux_eis - flux_rs;
            dS3 = flux_rn  - flux_re  - flux_esu - flux_qin;
            dS4 = flux_qin - flux_esb - flux_qb;
            dS5 = flux_re  - flux_qh;
            dS6 = flux_rc  - flux_qc;
            
            % outputs
            dS = [dS1 dS2 dS3 dS4 dS5 dS6];
            fluxes = [flux_rc,  flux_rg, flux_eic, flux_qie, flux_qis, flux_rt...
                      flux_eis, flux_rs, flux_rn,  flux_esu, flux_re,  flux_qin...
                      flux_esb, flux_qb, flux_qh,  flux_qc,  flux_ec,  flux_qt];
        end
        
        % STEP runs at the end of every timestep.
function [out] = split_1(p1,In)
%split_1 flow splitting

% 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:  Split flow (returns flux [mm/d])
% Constraints:  -
% @(Inputs):    p1   - fraction of flux to be diverted [-]
%               In   - incoming flux [mm/d]

out = p1.*In;

end
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_13(p1,p2,S,In)
%saturation_13 

% 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 (normal distribution variant)
% Constraints:  -
% @(Inputs):    p1   - soil depth where 50% of catchment contributes to overland flow [mm]
%               p2   - soil depth where 16% of catchment contributes to overland flow [mm]
%               S    - current storage [mm]
%               In   - incoming flux [mm/d]

out = In.*normcdf(log10(max(0,S)./p1)./log10(p1./p2));

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] = evap_3(p1,S,Smax,Ep,dt)
%evap_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:  Evaporation based on scaled current water storage and wilting point
% Constraints:  f <= Ep
%               f <= S/dt
% @(Inputs):    p1   - wilting point as fraction of Smax [-]
%               S    - current storage [mm]
%               Smax - maximum storage [mm]
%               Ep   - potential evapotranspiration rate [mm/d]
%               dt   - time step size [d]

out = min([S/(p1*Smax)*Ep,Ep,S/dt]);

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 [out] = interflow_3(p1,p2,S,dt)
%interflow_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:  Non-linear interflow (variant)
% Constraints:  f <= S
%               S >= 0  - this avoids numerical issues with complex numbers
% @(Inputs):    p1   - time delay [d-1]
%               p2   - exponential scaling parameter [-]
%               S    - current storage [mm]
%               dt   - time step size [d]

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

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] = 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_42").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.