wknoben / MARRMoT

Modular Assessment of Rainfall-Runoff Models Toolbox - Matlab code for 47 conceptual hydrologic models
GNU General Public License v3.0
110 stars 54 forks source link

bugfix: ensure no percolation if store is in deficit mode #62

Closed wknoben closed 1 month ago

wknoben commented 3 months ago

Closes #61

Added an extra constraint to ensure flux only returns values with non-negative deficits (i.e., water surplus):

Included test against known solution: the piece-wise function described in #61:

% function inputs
D = linspace(-1,1,201);
delta_t = 1;

% specify parameters as used in the Q0.05 pyMARRMoT comparison runs
dsurp   = 100.95;   % theta(6)
qpmax   = 1;        % theta(9)

% true solution
qp_true = zeros(1,length(D));
for i = 1:length(D)
    d = D(i);
    if d >= dsurp
        out = min(d/delta_t,qpmax);
    elseif d < 0
        out = 0;
    else
        out = min(d/delta_t,qpmax*d/dsurp);
    end
    qp_true(i) = out;
end

image