-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuvwstar.f90
executable file
·182 lines (143 loc) · 7.72 KB
/
uvwstar.f90
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
module mod_uvwstar
use mod_cons
use mod_var
use mod_global
use mod_conserve
!use mod_bou
implicit none
private
public uvwstar
contains
!
!
subroutine uvwstar
!
!implicit none
integer i,j,k
real :: convection_x,convection_y,convection_z
real :: diffusion_x,diffusion_y,diffusion_z
real :: surface_phi_x,surface_phi_y,surface_phi_z
real :: as,cd,sm
real :: body_x,body_y,body_z
do k=0,k1
do j=0,j1
do i=0,i1
!as= abs(PFM_phi(i,j,k)- Phi_c(i,j,k))
as= abs(PFM_phi(i,j,k)*(1.0- PFM_c(i,j,k)))
!debug5(i,j,k)=as
cd=rhol(i,j,k)/dt+visl(i,j,k)/dz2 !here use ziyang's creterion
au(i,j,k)=100000.0*cd*as**0.1/( (1-as)**8+1e-3 )
!debug6(i,j,k)=au(i,j,k)
enddo
enddo
enddo
!call m_rho
do k=1,kmax
do j=1,jmax
do i=1,imax
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! X direction
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Y direction, convection
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
! x component
convection_y= ( (m_x_rho(i,j,k)+m_x_rho(i,j+1,k))/2.0*(vnew(i,j,k)+vnew(i+1,j,k))/2.0 - &
(m_x_rho(i-1,j,k)+m_x_rho(i-1,j+1,k))/2.0*(vnew(i-1,j,k)+vnew(i,j,k))/2.0 &
)/dx
! y component
convection_y= convection_y + &
(m_y_rho(i,j+1,k)*vnew(i,j+1,k)-m_y_rho(i,j-1,k)*vnew(i,j-1,k))/2.0/dy
! z component
convection_y= convection_y + &
( (m_z_rho(i,j,k)+m_z_rho(i,j+1,k))/2.0*(vnew(i,j,k+1)+vnew(i,j,k))/2.0 - &
(m_z_rho(i,j,k-1)+m_z_rho(i,j+1,k-1))/2.0*(vnew(i,j,k)+vnew(i,j,k-1))/2.0 &
)/dz
!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&! Y dirction, diffusion
! x component
diffusion_y= ( (visl(i,j,k)+visl(i+1,j,k)+visl(i,j+1,k)+visl(i+1,j+1,k))/4.0*&
( (vnew(i+1,j,k)-vnew(i,j,k))/dx+(unew(i,j+1,k)-unew(i,j,k))/dy ) -&
(visl(i,j,k)+visl(i-1,j,k)+visl(i,j+1,k)+visl(i-1,j+1,k))/4.0*&
( (vnew(i,j,k)-vnew(i-1,j,k))/dx+(unew(i-1,j+1,k)-unew(i-1,j,k))/dy ) )/dx
! y component
diffusion_y= diffusion_y+&
( -2.0/3.0*( visl(i,j+1,k)*((unew(i,j+1,k)-unew(i-1,j+1,k))/dx + &
(vnew(i,j+1,k)-vnew(i,j,k))/dy+(wnew(i,j+1,k)-wnew(i,j+1,k-1))/dz) -&
visl(i,j,k)*((unew(i,j,k)-unew(i-1,j,k))/dx+(vnew(i,j,k)-vnew(i,j-1,k))/dy+&
(wnew(i,j,k)-wnew(i,j,k-1))/dz) )+&
2.0*visl(i,j+1,k)*(vnew(i,j+1,k)-vnew(i,j,k))/dy - 2.0*visl(i,j,k)*(vnew(i,j,k)-vnew(i,j-1,k))/dy )/dy
! z component
diffusion_y=diffusion_y+&
( (visl(i,j,k)+visl(i,j+1,k)+visl(i,j,k+1)+visl(i,j+1,k+1))/4.0*&
( (wnew(i,j+1,k)-wnew(i,j,k))/dy+(vnew(i,j,k+1)-vnew(i,j,k))/dz )-&
(visl(i,j,k)+visl(i,j+1,k)+visl(i,j,k-1)+visl(i,j+1,k-1))/4.0*&
( (wnew(i,j+1,k-1)-wnew(i,j,k-1))/dy+(vnew(i,j,k)-vnew(i,j,k-1))/dz ) )/dz
surface_phi_y=(PFM_c(i,j,k)+PFM_c(i,j+1,k))/2.0*&
!(chem_pot_old(i,j+1,k)+chem_pot_old(i,j,k))/2.0*(PFM_phi_old(i,j+1,k)-PFM_phi_old(i,j,k))/dy
(chem_pot(i,j+1,k)+chem_pot(i,j,k))/2.0*(PFM_phi(i,j+1,k)-PFM_phi(i,j,k))/dy
body_y=0.
RHS_y(i,j,k)=-convection_y+diffusion_y+body_y+surface_phi_y
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Z direction
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo convection term
! x component
convection_z= ( (m_x_rho(i,j,k)+m_x_rho(i,j,k))/2.0*(wnew(i,j,k)+wnew(i+1,j,k))/2.0 - &
(m_x_rho(i-1,j,k)+m_x_rho(i-1,j,k))/2.0*(wnew(i-1,j,k)+wnew(i,j,k))/2.0 &
)/dx
! y component
convection_z= convection_z + &
( (m_y_rho(i,j,k)+m_y_rho(i,j,k+1))/2.0*(wnew(i,j,k)+wnew(i,j+1,k))/2.0 - &
(m_y_rho(i,j-1,k)+m_y_rho(i,j-1,k+1))/2.0*(wnew(i,j-1,k)+wnew(i,j,k))/2.0 &
)/dy
! z component
convection_z= convection_z + &
( m_z_rho(i,j,k+1)*wnew(i,j,k+1)-m_z_rho(i,j,k-1)*wnew(i,j,k-1) )/2.0/dz
!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&! diffusion term
! x component
diffusion_z=( (visl(i,j,k)+visl(i+1,j,k)+visl(i,j,k+1)+visl(i+1,j,k+1))/4.0*&
( (unew(i,j,k+1)-unew(i,j,k))/dz + (wnew(i+1,j,k)-wnew(i,j,k))/dx )-&
(visl(i,j,k)+visl(i-1,j,k)+visl(i,j,k+1)+visl(i-1,j,k+1))/4.0*&
( (unew(i-1,j,k+1)-unew(i-1,j,k))/dz + (wnew(i,j,k)-wnew(i-1,j,k))/dx ) )/dx
! y component
diffusion_z=diffusion_z+&
( (visl(i,j,k)+visl(i,j+1,k)+visl(i,j,k+1)+visl(i,j+1,k+1))/4.0*&
( (wnew(i,j+1,k)-wnew(i,j,k))/dy + (vnew(i,j,k+1)-vnew(i,j,k))/dz )-&
(visl(i,j,k)+visl(i,j-1,k)+visl(i,j,k+1)+visl(i,j-1,k+1))/4.0*&
( (wnew(i,j,k)-wnew(i,j-1,k))/dy + (vnew(i,j-1,k+1)-vnew(i,j-1,k))/dz ) )/dy
! z component
diffusion_z=diffusion_z&
-2.0/3.0*( visl(i,j,k+1)*((unew(i,j,k+1)-unew(i-1,j,k+1))/dx+ &
(vnew(i,j,k+1)-vnew(i,j-1,k+1))/dy+(wnew(i,j,k+1)-wnew(i,j,k))/dz) -&
visl(i,j,k)*((unew(i,j,k)-unew(i-1,j,k))/dx+&
(vnew(i,j,k)-vnew(i,j-1,k))/dy+(wnew(i,j,k)-wnew(i,j,k-1))/dz) )/dz +&
( 2.0*visl(i,j,k+1)*(wnew(i,j,k+1)-wnew(i,j,k))/dz - 2.0*visl(i,j,k)*(wnew(i,j,k)-wnew(i,j,k-1))/dz )/dz
surface_phi_z=(PFM_c(i,j,k)+PFM_c(i,j,k+1))/2.0*&
!(chem_pot_old(i,j,k+1)+chem_pot_old(i,j,k))/2.0*(PFM_phi_old(i,j,k+1)-PFM_phi_old(i,j,k))/dz
(chem_pot(i,j,k+1)+chem_pot(i,j,k))/2.0*(PFM_phi(i,j,k+1)-PFM_phi(i,j,k))/dz
!body_z=g_z*(rhol(i,j,k+1)+rhol(i,j,k))/2.0
body_z=0.
RHS_z(i,j,k)=-convection_z+diffusion_z+body_z+surface_phi_z
enddo
enddo
enddo
! this can be incorporate into last loop
do k=1,kmax
do j=1,jmax
do i=1,imax
ustar(i,j,k)= 0.
vstar(i,j,k)= (RHS_y(i,j,k)*dt+(rholold(i,j,k)+rholold(i,j+1,k))/2.0*vold(i,j,k))/( (rhol(i,j,k)+rhol(i,j+1,k))/2.0 -&
(residual1(i,j,k)+residual1(i,j+1,k))/2.0*dt +&
(au(i,j,k)+au(i,j+1,k))/2.0*dt)
wstar(i,j,k)= (RHS_z(i,j,k)*dt+(rholold(i,j,k)+rholold(i,j,k+1))/2.0*wold(i,j,k))/( (rhol(i,j,k)+rhol(i,j,k+1))/2.0 -&
(residual1(i,j,k)+residual1(i,j,k+1))/2.0*dt +&
(au(i,j,k)+au(i,j,k+1))/2.0*dt)
enddo
enddo
enddo
return
end subroutine uvwstar
!
end module mod_uvwstar