Trinh @ Bath

An example of a conceptual rainfall-runoff model

Here is an example implementation of the Probability Distributed Model.

  1. function [solution, hydrograph, obj] = simulate(obj, P, t_max, nt)
  2. % Calculate length of each time step
  3. dt = t_max / nt;
  4. % If precipitation is specified with a single value set precipitation
  5. % rate to be the same for all time steps
  6. if length(P) == 1
  7. P = P * ones(1, nt);
  8. end
  9. % Initialise structure to save store values (an extra entry is
  10. % included to store the initial values for each store)
  11. solution.C = zeros(1, nt+1); % soil moisture storage capacity
  12. solution.S = zeros(1, nt+1); % soil moisture storage value
  13. solution.Sf = zeros(1, nt+1); % fast storage value
  14. solution.Ss = zeros(1, nt+1); % slow storage value
  15. % Update stores in every time step
  16. for i = 1:nt+1
  17. % Calculate the soil mosisture value based on the current soil
  18. % moisture capacity
  19.  
  20. if obj.C < obj.par.c_max
  21. S = obj.par.S_max * (1 - (1 - obj.C / obj.par.c_max) .^ (obj.par.b + 1));
  22. else
  23. S = obj.par.S_max;
  24. end
  25. % Save store values (for i=1 initial value is saved)
  26. solution.C(i) = obj.C;
  27. solution.S(i) = S;
  28. solution.Sf(i) = obj.Sf;
  29. solution.Ss(i) = obj.Ss;
  30. % If the last step was reached end the simulation
  31. if i == nt + 1
  32. break
  33. end
  34. % Calculate the drainage function
  35. drainage = max(0, (S - obj.par.st) / obj.par.kg);
  36. % Calculate Pi (source term in ODE for the soil moisture storage)
  37. Pi = P(i) - drainage;
  38. % Save old value of c (for runoff calculation)
  39. C_old = obj.C;
  40. % Update value of soil moisture capacity, c
  41. obj.C = min(obj.C + Pi * dt, obj.par.c_max);
  42. % Calculate the volume of the surface runoff from the water balance
  43. runoff = Pi * dt - obj.par.S_max * ...
  44. ((1 - C_old / obj.par.c_max) ^ (obj.par.b + 1) - ...
  45. (1 - obj.C / obj.par.c_max) ^ (obj.par.b + 1));
  46. % Calculare the rate of runoff generation
  47. runoff = runoff / dt;
  48. % Calculate slow and fast flow
  49. flow_s = exp(obj.Ss / obj.par.ks);
  50. flow_f = obj.Sf / obj.par.kf;
  51. % Update values of the slow and fast storage
  52. obj.Sf = obj.Sf + (runoff - flow_f) * dt;
  53. obj.Ss = obj.Ss + (drainage - flow_s) * dt;
  54. end
  55. % For each time step calculate the corresponding time (t),
  56. % fast flow (Qf), slow flow (Qs) and total flow (Q_total)
  57. hydrograph.t = linspace(0, t_max, nt+1);
  58. hydrograph.Qf = solution.Sf / obj.par.kf;
  59. hydrograph.Qs = exp(solution.Ss / obj.par.ks);
  60. hydrograph.Q_total = hydrograph.Qs + hydrograph.Qf;
  61. end