-
Notifications
You must be signed in to change notification settings - Fork 0
/
ucoeff.asv
128 lines (103 loc) · 4.54 KB
/
ucoeff.asv
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
function [] = ucoeff()
% Purpose: To calculate the coefficients for the u equation.
% constants
global NPI NPJ Dt Cmu
% variables
global x x_u y y_v u p mu mueff SP Su F_u F_v d_u relax_u u_old rho Istart Iend ...
Jstart Jend b aE aW aN aS aP yplus uplus k dudx dvdx XMAX X_truck X_distance YMAX Y_truck
Istart = 3;
Iend = NPI+1;
Jstart = 2;
Jend = NPJ+1;
convect();
for I = Istart:Iend
i = I;
for J = Jstart:Jend
j = J;
% Geometrical parameters: Areas of the cell faces
AREAw = y_v(j+1) - y_v(j); % See fig. 6.3
AREAe = AREAw;
AREAs = x(I) - x(I-1);
AREAn = AREAs;
% eq. 6.9a-6.9d - the convective mass flux defined in eq. 5.8a
% note: F = rho*u but Fw = (rho*u)w = rho*u*AREAw per definition.
Fw = 0.5*(F_u(i,J) + F_u(i-1,J))*AREAw;
Fe = 0.5*(F_u(i+1,J) + F_u(i,J))*AREAe;
Fs = 0.5*(F_v(I,j) + F_v(I-1,j))*AREAs;
Fn = 0.5*(F_v(I,j+1) + F_v(I-1,j+1))*AREAn;
% eq. 6.9e-6.9h - the transport by diffusion defined in eq. 5.8b
% note: D = mu/Dx but Dw = (mu/Dx)*AREAw per definition
Dw = (mueff(I-1,J)/(x_u(i) - x_u(i-1)))*AREAw;
De = (mueff(I,J)/(x_u(i+1) - x_u(i)))*AREAe;
Ds = 0.25*(mueff(I-1,J) + mueff(I,J) + mueff(I-1,J-1) + mueff(I,J-1))/(y(J) - y(J-1))*AREAs;
Dn = 0.25*(mueff(I-1,J+1) + mueff(I,J+1) + mueff(I-1,J) + mueff(I,J))/(y(J+1) - y(J))*AREAn;
% The source terms
mus = 0.25*(mueff(I-1,J) + mueff(I,J) + mueff(I-1,J-1) + mueff(I,J-1));
mun = 0.25*(mueff(I-1,J+1) + mueff(I,J+1) + mueff(I-1,J) + mueff(I,J));
if J==2 || J==NPI+1
if yplus(I,J) < 11.63
SP(i,J) = -mu(I,J)*AREAs/(0.5*AREAw);
else
SP(i,J) = -rho(I,J) * Cmu^0.25 * k(I,J)^0.5 / uplus(I,J) *AREAs;
end
else
SP(i,J) = 0.;
end
Su(i,J) = (mueff(I,J)*dudx(I,J) - mueff(I-1,J)*dudx(I-1,J)) / (x(I) - x(I-1)) + ...
(mun*dvdx(i,j+1) - mus*dvdx(i,j)) / (y_v(j+1) - y_v(j)) - ...
2./3. * (rho(I,J)*k(I,J) - rho(I-1,J)*k(I-1,J))/(x(I) - x(I-1));
Su(i,J) = Su(i,J)*AREAw*AREAs;
% u can be fixed to zero by setting SP to a very large value at the
% baffle
NPI_truck=NPI*X_truck/XMAX;
NPI_dis=NPI*X_distance/XMAX;
NPI_height=NPI*Y_truck/YMAX;
for kk=5:(5+NPI_truck)
if (i == ceil(kk) && J < ceil(NPI_height))
SP(i,J) = -1e30;
end
end
for kk=(5+NPI_truck + NPI_dis):(5+2*NPI_truck + NPI_dis)
if (i == ceil(kk) && J < ceil(NPI_height))
SP(i,J) = -1e30;
end
end
% for kk=(5+2*NPI_truck+2*NPI_dis):(5+3*NPI_truck+2*NPI_dis)
% if (i == ceil(kk) && J < ceil(NPI_height))
% SP(i,J) = -1e30;
% end
% end
% The coefficients (hybrid differencing scheme)
aW(i,J) = max([ Fw, Dw + Fw/2, 0.]);
aE(i,J) = max([-Fe, De - Fe/2, 0.]);
if J==2
aS(i,J) = 0.;
else
aS(i,J) = max([ Fs, Ds + Fs/2, 0.]);
end
if J==NPJ+1
aN(i,J) = 0.;
else
aN(i,J) = max([-Fn, Dn - Fn/2, 0.]);
end
aPold = 0.5*(rho(I-1,J) + rho(I,J))*AREAe*AREAn/Dt;
% eq. 8.31 without time dependent terms (see also eq. 5.14):
aP(i,J) = aW(i,J) + aE(i,J) + aS(i,J) + aN(i,J) + Fe - Fw + Fn - Fs - SP(I,J) + aPold;
% Calculation of d(i)(J) = d_u(i)(J) defined in eq. 6.23 for use in the
% equation for pression correction (eq. 6.32). See subroutine pccoeff.
d_u(i,J) = AREAw*relax_u/aP(i,J);
% Putting the integrated pressure gradient into the source term b(i)(J)
% The reason is to get an equation on the generalised form
% (eq. 7.7 ) to be solved by the TDMA algorithm.
% note: In reality b = a0p*fiP + Su = 0.
b(i,J) = (p(I-1,J) - p(I,J))*AREAw + Su(I,J) + aPold*u_old(i,J);
% Introducing relaxation by eq. 6.36 . and putting also the last
% term on the right side into the source term b(i)(J)
aP(i,J) = aP(i,J)/relax_u;
b(i,J) = b(i,J) + (1.0 - relax_u)*aP(i,J)*u(i,J);
% now we have implemented eq. 6.36 in the form of eq. 7.7
% and the TDMA algorithm can be called to solve it. This is done
% in the next step of the main program.
end
end
end