-
Notifications
You must be signed in to change notification settings - Fork 0
/
V5.m
executable file
·146 lines (127 loc) · 4.58 KB
/
V5.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
function f = V5(DIM, i, h, h_old, phi, phi_old, k, k_old, PARAMS)
% Normal interior node
n = DIM.n;
% find which index we want from the re-arranged matrix
<<<<<<< HEAD
point = (DIM.r == i);
east = (DIM.r == i+1);
west = (DIM.r == i-1);
north = (DIM.r == i+n);
south = (DIM.r == i-n);
=======
point = find((DIM.r == i));
east = find((DIM.r == i+1));
west = find((DIM.r == i-1));
north = find((DIM.r == i+n));
south = find((DIM.r == i-n));
>>>>>>> master
% get the dx and dz values
DELTA = DIM.DELTA(point, :);
dx = DELTA(1:2);
dz = DELTA(3:4);
ST = DIM.ST(point, :);
% get the K values
K_xx = DIM.K_xx;
K_zz = DIM.K_zz;
% get total cell volume
cell_volume = DIM.VOL(point, 5);
dt = PARAMS.dt;
theta = PARAMS.theta;
sigma = PARAMS.sigma;
source = 0;
if PARAMS.PUMPS == 1
if DIM.XZ(point, 1) == 450 && DIM.XZ(point, 2) == 10 && phi(point) > 0.2
source = -PARAMS.town_rate / DIM.WIDTH; % -5e-8 * 60*60*24;
elseif DIM.XZ(point, 1) == 100 && DIM.XZ(point, 2) == 50
% source = -PARAMS.bore_rate / DIM.WIDTH;
end
end
% calculate k
if h(point) >= h(east)
k_e_up = k(point);
k_e_down = k(east);
else
k_e_up = k(east);
k_e_down = k(point);
end
if h(point) >= h(west)
k_w_up = k(point);
k_w_down = k(west);
else
k_w_up = k(west);
k_w_down = k(point);
end
if h(point) >= h(north) + dz(2)
k_n_up = k(point);
k_n_down = k(north);
else
k_n_up = k(north);
k_n_down = k(point);
end
if h(point) >= h(south) - dz(1)
k_s_up = k(point);
k_s_down = k(south);
else
k_s_up = k(north);
k_s_down = k(south);
end
k_e = k_e_up + sigma / 2 * (k_e_down - k_e_up);
k_n = k_n_up + sigma / 2 * (k_n_down - k_n_up);
k_w = k_w_up + sigma / 2 * (k_w_down - k_w_up);
k_s = k_s_up + sigma / 2 * (k_s_down - k_s_up);
if h_old(point) >= h_old(east)
k_e_up_old = k_old(point);
k_e_down_old = k_old(east);
else
k_e_up_old = k_old(east);
k_e_down_old = k_old(point);
end
if h_old(point) >= h_old(west)
k_w_up_old = k_old(point);
k_w_down_old = k_old(west);
else
k_w_up_old = k_old(west);
k_w_down_old = k_old(point);
end
if h_old(point) >= h_old(north) + dz(2)
k_n_up_old = k_old(point);
k_n_down_old = k_old(north);
else
k_n_up_old = k_old(north);
k_n_down_old = k_old(point);
end
if h_old(point) >= h_old(south) - dz(1)
k_s_up_old = k_old(point);
k_s_down_old = k_old(south);
else
k_s_up_old = k_old(south);
k_s_down_old = k_old(point);
end
k_e_old = k_e_up_old + sigma / 2 * (k_e_down_old - k_e_up_old);
k_n_old = k_n_up_old + sigma / 2 * (k_n_down_old - k_n_up_old);
k_w_old = k_w_up_old + sigma / 2 * (k_w_down_old - k_w_up_old);
k_s_old = k_s_up_old + sigma / 2 * (k_s_down_old - k_s_up_old);
% calculate line integrals
gamma_1 = -k_e * K_xx(ST(1)) * dz(2) / 2 * ((h(east) - h(point))/dx(2));
gamma_2 = -k_n * K_zz(ST(1)) * dx(2) / 2 * ((h(north) - h(point))/dz(2) + 1);
gamma_3 = -k_n * K_zz(ST(2)) * dx(1) / 2 * ((h(north) - h(point))/dz(2) + 1);
gamma_4 = -k_w * K_xx(ST(2)) * dz(2) / 2 * ((h(west) - h(point))/dx(1));
gamma_5 = -k_w * K_xx(ST(3)) * dz(1) / 2 * ((h(west) - h(point))/dx(1));
gamma_6 = -k_s * K_zz(ST(3)) * dx(1) / 2 * ((h(south) - h(point))/dz(1) - 1);
gamma_7 = -k_s * K_zz(ST(4)) * dx(2) / 2 * ((h(south) - h(point))/dz(1) - 1);
gamma_8 = -k_e * K_xx(ST(4)) * dz(1) / 2 * ((h(east) - h(point))/dx(2));
gamma_1_old = -k_e_old * K_xx(ST(1)) * dz(2) / 2 * ((h_old(east) - h_old(point))/dx(2));
gamma_2_old = -k_n_old * K_zz(ST(1)) * dx(2) / 2 * ((h_old(north) - h_old(point))/dz(2) + 1);
gamma_3_old = -k_n_old * K_zz(ST(2)) * dx(1) / 2 * ((h_old(north) - h_old(point))/dz(2) + 1);
gamma_4_old = -k_w_old * K_xx(ST(2)) * dz(2) / 2 * ((h_old(west) - h_old(point))/dx(1));
gamma_5_old = -k_w_old * K_xx(ST(3)) * dz(1) / 2 * ((h_old(west) - h_old(point))/dx(1));
gamma_6_old = -k_s_old * K_zz(ST(3)) * dx(1) / 2 * ((h_old(south) - h_old(point))/dz(1) - 1);
gamma_7_old = -k_s_old * K_zz(ST(4)) * dx(2) / 2 * ((h_old(south) - h_old(point))/dz(1) - 1);
gamma_8_old = -k_e_old * K_xx(ST(4)) * dz(1) / 2 * ((h_old(east) - h_old(point))/dx(2));
% evaluate f function
f = phi(point) - phi_old(point) - dt * (theta * source + (1 - theta) * source) ...
+ dt/cell_volume * (theta * ...
(gamma_1 + gamma_2 + gamma_3 + gamma_4 + gamma_5 + gamma_6 + gamma_7 + gamma_8) ...
+ (1 - theta) * ( ...
gamma_1_old + gamma_2_old + gamma_3_old + gamma_4_old + gamma_5_old + gamma_6_old + gamma_7_old + gamma_8_old));
end