-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathf_calds.m
77 lines (63 loc) · 2.15 KB
/
f_calds.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% This function calculates soil water balance
% Input
% s1: soil volumetric moisture in the top layer, unitless
% s2: soil volumetric moisture in the bottom layer, unitless
% PP: precipitation, m/s
% F1: soil-root flux in the top layer, m/s
% F2: soil-root flux in the bottom layer, m/s
% EVmax: potential soil evaporation, m/s
% Soil: soil properties
% Const: constants
% Output
% ds1: change in s1, unitless
% ds1: change in s1, unitless
% F1: modified soil-root flux in the top layer considering sh, m/s
% F2: modified soil-root flux in the bottom layer considering sh, m/s
% V1: soil evaporation from the top layer, m/s
% L2: leakage from the bottom layer, m/s
% RT: water flux between the two soil layers, m/s
% Q: surface runoff due to saturation excess, m/s
function [ds1,ds2,F1,F2,V1,L2,RT,Q] = f_calds(s1,s2,PP,F1,F2,EVmax,Soil,Const)
[psis1,K1] = SoilHydro(Soil.pct1,s1,Soil.SID1);
[psis2,K2] = SoilHydro(Soil.pct2,s2,Soil.SID2);
K = (Soil.Zr1+Soil.Zr2)/(Soil.Zr1/K1+Soil.Zr2/K2); % resistance in series
RT = K*((psis1-psis2).*1e6/Const.rhow/Const.g)/((Soil.Zr1+Soil.Zr2)/2);
if s1>Soil.sfc1
V1 = EVmax;
elseif s1<Soil.sw1
V1 = 0;
else
V1 = (s1-Soil.sw1)/(Soil.sfc1-Soil.sw1)*EVmax;
end
Loss1 = (F1+V1+RT); % m/s
dt = 3600;
ds1 = (PP-Loss1)/(Soil.n1*Soil.Zr1.*1)*dt;
if s2 > Soil.sfc2
[~,Ksat2] = SoilHydro(Soil.pct2,1,Soil.SID2);
beta = 2*(Soil.b2)+4;
L2 = Ksat2/(exp(beta*(1-Soil.sfc2))-1)*(exp(beta*(s2-Soil.sfc2))-1); % deep percolation
else
L2 = 0;
end
V2 = 0;
Loss2 = (F2+V2+L2);
dt = 3600; % time step in seconds
ds2 = (RT-Loss2)/(Soil.n2*Soil.Zr2.*1)*dt;
ss1 = s1+ds1;
ss2 = s2+ds2;
Q = 0;
if ss1>Soil.sfc1
ds1 = Soil.sfc1-s1;
Q = (ss1-Soil.sfc1)*Soil.n1*Soil.Zr1/dt; % saturated excess
elseif ss1<Soil.sh1
ds1 = Soil.sh1-s1;
F1 = 0;
RT = 0;
V1 = 0;
end
if ss2>Soil.sfc2
ds2 = Soil.sfc2-s2;
elseif ss2<Soil.sh2
ds2 = Soil.sh2-s1;
end
end