MARRMOT_38

Implementation

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

  • Time step: daily

  • Backend: octave-cli + Octave optim

  • Calibrated parameters: 16

  • 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 1

0.5

p03

0 to 1

0.5

p04

0 to 1

0.5

p05

0 to 1

0.5

p06

0 to 1

0.5

p07

0 to 1

0.5

p08

0 to 1

0.5

p09

1 to 2000

1000.5

p10

0.01 to 0.99

0.5

p11

0.01 to 0.99

0.5

p12

0.01 to 0.99

0.5

p13

0 to 4

2.0

p14

0 to 4

2.0

p15

0.01 to 0.99

0.5

p16

0.01 to 0.99

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;
            a0 = theta(1);          % Time parameter for drainage 1>2 [d-1]
            b0 = theta(2);          % Time parameter for drainage 2>3 [d-1]
            c0 = theta(3);          % Time parameter for drainage 3>4 [d-1]
            a1 = theta(4);          % Time parameter for surface runoff 1 [d-1]
            k1 = theta(13);         % Base rate of capillary rise [mm/d]
            k2 = theta(14);         % Base rate of soil moisture exchange [mm/d]
            
            % auxiliary parameters
            aux_theta   = obj.aux_theta;
            sm1 = aux_theta(1);     % Size of primary soil moisture store, threshold before F12 starts [mm]
            t2  = aux_theta(2);     % Threshold before surface runoff Y2 starts [mm]
            t1  = aux_theta(3);     % Thresold before surface runoff Y1 starts [mm]
            sm2 = aux_theta(4);     % Size of secondary soil moisture store S5 [mm]
            t3  = aux_theta(5);     % Threshold before intermediate runoff starts [mm]
            t4  = aux_theta(6);     % Threshold before sub-base runoff starts [mm]
            a2  = aux_theta(7);     % Time parameter for surface runoff 2 [d-1]
            b1  = aux_theta(8);     % Time parameter for intermediate runoff 1 [d-1]
            c1  = aux_theta(9);     % Time parameter for sub-base runoff 1 [d-1]
            d1  = aux_theta(10);    % Time parameter for base runoff 1 [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_t1  = capillary_3(k1,sm1,S1,S2,delta_t);
            flux_t2  = exchange_2(k2,S1,sm1,S5,sm2);
            flux_y1  = interflow_8(S1,a1,t1);
            flux_y2  = interflow_8(S1,a2,t2);
            flux_y3  = interflow_8(S2,b1,t3);
            flux_y4  = interflow_8(S3,c1,t4);
            flux_y5  = baseflow_1(d1,S4);
            flux_e1  = evap_1(S1,Ep,delta_t);
            flux_e2  = evap_1(S2,max(0,Ep-flux_e1),delta_t);
            flux_e3  = evap_1(S3,max(0,Ep-flux_e1-flux_e2),delta_t);
            flux_e4  = evap_1(S4,max(0,Ep-flux_e1-flux_e2-flux_e3),delta_t);
            flux_f12 = interflow_8(S1,a0,sm1);
            flux_f23 = recharge_3(b0,S2);
            flux_f34 = recharge_3(c0,S3);
            
            % stores ODEs
            dS1 = P + flux_t1 - flux_t2 - flux_e1 - flux_f12 - flux_y1 - flux_y2;
            dS2 = flux_f12 - flux_t1 - flux_e2 - flux_f23 - flux_y3;    
            dS3 = flux_f23 - flux_e3 - flux_f34 - flux_y4;
            dS4 = flux_f34 - flux_e4 - flux_y5;
            dS5 = flux_t2;
 
            % outputs
            dS = [dS1 dS2 dS3 dS4 dS5];
            fluxes = [flux_t1,  flux_t2,...
                      flux_y1,  flux_y2,  flux_y3,  flux_y4, flux_y5,...
                      flux_e1,  flux_e2,  flux_e3,  flux_e4,... 
                      flux_f12, flux_f23, flux_f34];
        end
        
        % STEP runs at the end of every timestep.
function [out] = capillary_3(p1,p2,S1,S2,dt)
%capillary_3 capillary rise: linear relation

% 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:  Capillary rise scaled by receiving store's deficit up to a storage threshold
% Constraints:  f <= S2
% @(Inputs):    p1   - base capillary rise rate [mm/d]
%               p2   - threshold above which no capillary flow occurs [mm]
%               S1   - current storage in receiving store [mm]
%               S2   - current storage in supplying store [mm]
%               dt   - time step size [d]

out = min(S2/dt,p1*(1-S1/p2)*smoothThreshold_storage_logistic(S1,p2));

end
function [out] = exchange_2(p1,S1,S1max,S2,S2max)
%exchange_2 

% 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:  Water exchange based on relative storages
% Constraints:  -
% @(Inputs):    p1    - base exchange rate [mm/d]
%               S1    - current storage in S1 [mm]
%               S1max - maximum storage in S1 [mm]
%               S2    - current storage in S2 [mm]
%               S2max - maximum storage in S2 [mm]

out = p1*(S1/S1max - S2/S2max); 

end
function [out] = interflow_8(S,p1,p2)
%interflow_8 

% 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 interflow if storage exceeds a threshold
% Constraints:  f = 0 for S < p2
% @(Inputs):    S    - current storage [mm]
%               p1   - time coefficient [d-1]
%               p2   - storage threshold before flow occurs [mm]

out =  max(0,p1*(S-p2));

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