-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRK3.f90
178 lines (127 loc) · 4.18 KB
/
RK3.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
subroutine RK3
include 'com.txt'
t = 0
count = 0
call set_bc
call TVB_Limiter_P2
!call div_free
call calculate_umax
call calculate_totaldiv
call calculate_pmin
!if (totaldiv > 1e-7) then
! call calculate_Az
! call div_free_Balsara
! call calculate_totaldiv
! call calculate_umax
!end if
print *,t," ",umax," ",totaldiv
open(unit = 1,file = 'Q1flash.txt')
open(unit = 2,file = 'Q2flash.txt')
open(unit = 3,file = 'Q3flash.txt')
open(unit = 4,file = 'Q4flash.txt')
open(unit = 5,file = 'Q5flash.txt')
open(unit = 6,file = 'Q6flash.txt')
open(unit = 7,file = 'Q7flash.txt')
open(unit = 8,file = 'Q8flash.txt')
open(unit = 9,file = 'T.txt')
if (flash == 1) then
do d = 1,dimPk
do j = 1,Ny
do i = 1,Nx
write(1,*) uh(i,j,d,1)
write(2,*) uh(i,j,d,2)
write(3,*) uh(i,j,d,3)
write(4,*) uh(i,j,d,4)
write(5,*) uh(i,j,d,5)
write(6,*) uh(i,j,d,6)
write(7,*) uh(i,j,d,7)
write(8,*) uh(i,j,d,8)
end do
end do
end do
write(9,*) t
end if
tt = tend/frameMAX
countf = 1
do while (t < tend)
call calculate_dt
if (t + dt >= tend) then
dt = tend - t
t = tend
else
t = t + dt
end if
if (dt < 1e-7) then
t = tend
end if
! Stage 1
call set_bc
call Lh
call LhEz
uI = uh + dt*du
BxI = Bx + dt*dEz1
ByI = By + dt*dEz2
uh0 = uh
Bx0 = Bx
By0 = By
uh = uI
Bx = BxI
By = ByI
call TVB_Limiter_P2
!call div_free
call set_bc
if (RKorder == 3) then
!Stage 2
call Lh
call LhEz
uh = uI + dt*du
Bx = BxI + dt*dEz1
By = ByI + dt*dEz2
uII = (3d0/4d0)*uh0 + (1d0/4d0)*uh
BxII = (3d0/4d0)*Bx0 + (1d0/4d0)*Bx
ByII = (3d0/4d0)*By0 + (1d0/4d0)*By
uh = uII
Bx = BxII
By = ByII
call TVB_Limiter_P2
!call div_free
!Stage 3
call set_bc
call Lh
call LhEz
Bx = BxII + dt*dEz1
By = ByII + dt*dEz2
uh = uII + dt*du
uh = (1d0/3d0)*uh0 + (2d0/3d0)*uh
Bx = (1d0/3d0)*Bx0 + (2d0/3d0)*Bx
By = (1d0/3d0)*By0 + (2d0/3d0)*By
call TVB_Limiter_P2
!call div_free
end if
count = count + 1
call calculate_umax
call calculate_totaldiv
call calculate_pmin
print *,t," ",umax," ",totaldiv
! save solution
if ((t > tt*countf .or. t == tend) .and. flash == 1) then
print *,"Đ´ČëĘýžÝ",t,tt*countf
do d = 1,dimPk
do j = 1,Ny
do i = 1,Nx
write(1,*) uh(i,j,d,1)
write(2,*) uh(i,j,d,2)
write(3,*) uh(i,j,d,3)
write(4,*) uh(i,j,d,4)
write(5,*) uh(i,j,d,5)
write(6,*) uh(i,j,d,6)
write(7,*) uh(i,j,d,7)
write(8,*) uh(i,j,d,8)
end do
end do
end do
write(9,*) t
countf = countf + 1
end if
end do
end subroutine RK3