32 INTEGER :: ndim,idim1,idim2,iupwind
33 INTEGER :: nrho,irho1,irho2,irhop,irhom
36 REAL (R8) :: rho(
solver%nrho)
38 REAL (R8) :: rho_derivn(
solver%nrho)
51 REAL (R8) :: u(
solver%ndim,2)
52 REAL (R8) :: v(
solver%ndim,2)
53 REAL (R8) :: w(
solver%ndim,2)
59 REAL (R8) :: h(
solver%nrho)
62 REAL (R8) :: ww(2,
solver%ndim)
90 rho_loop1:
DO irho1 = 1,nrho
91 rho(irho1) =
solver%RHO(irho1)
93 dim_loop1:
DO idim1 = 1,ndim
94 y(idim1,irho1) =
solver%Y(idim1,irho1)
95 ym(idim1,irho1) =
solver%YM(idim1,irho1)
96 dy(idim1,irho1) =
solver%DY(idim1,irho1)
98 a(idim1,irho1) =
solver%A(idim1,irho1)
99 b(idim1,irho1) =
solver%B(idim1,irho1)
100 c(idim1,irho1) =
solver%C(idim1,irho1)
101 d(idim1,irho1) =
solver%D(idim1,irho1)
102 e(idim1,irho1) =
solver%E(idim1,irho1)
103 f(idim1,irho1) =
solver%F(idim1,irho1)
104 g(idim1,irho1) =
solver%G(idim1,irho1)
106 dim_loop2:
DO idim2 = 1,ndim
107 cm1(idim1,idim2,irho1) =
solver%CM1(idim1,idim2,irho1)
110 u(idim1,1) =
solver%U(idim1,1)
111 v(idim1,1) =
solver%V(idim1,1)
112 w(idim1,1) =
solver%W(idim1,1)
113 u(idim1,2) =
solver%U(idim1,2)
114 v(idim1,2) =
solver%V(idim1,2)
115 w(idim1,2) =
solver%W(idim1,2)
126 ww(idim1,idim2) = w(idim2,idim1)
133 h(irhom) = rho(irho1)-rho(irhom)
138 f(idim2,irho1)=f(idim2,irho1)
143 uu(1,idim1,idim1) = - 0.5*v(idim1,1)/h(1)+0.5*u(idim1,1)
144 vv(1,idim1,idim1) = 0.5*v(idim1,1)/h(1)+0.5*u(idim1,1)
145 uu(2,idim1,idim1) = 0.5* v(idim1,2)/h(nrho-1)+0.5*u(idim1,2)
146 vv(2,idim1,idim1) = - 0.5*v(idim1,2)/h(nrho-1)+0.5*u(idim1,2)
151 h12 = 0.5*(h(irho1)+2.*h(irhom))
153 doloop2idim1 :
DO idim1 = 1,ndim
154 ff(irho1,idim1) = b(idim1,irho1)*ym(idim1,irho1)+f(idim1,irho1)*tau
155 aa(irho1,idim1,idim1) = -0.5/c(idim1,irho1)/h(irho1)/ h12 &
156 * (d(idim1,irhop)+d(idim1,irho1))
157 cc(irho1,idim1,idim1) = -0.5/c(idim1,irho1)/h(irhom)/ h12 &
159 bb(irho1,idim1,idim1) = -aa(irho1,idim1,idim1) -cc(irho1,idim1,idim1)
161 IF (iupwind.NE.1)
THEN
162 aa(irho1,idim1,idim1) = aa(irho1,idim1,idim1) &
163 + 0.25 /c(idim1,irho1)/h12 &
164 * (e(idim1,irhop)+e(idim1,irho1))
165 cc(irho1,idim1,idim1) = cc(irho1,idim1,idim1) &
166 - 0.5 /c(idim1,irho1)/h12 &
168 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
169 + 0.25 /c(idim1,irho1)/h12 &
171 * (e(idim1,irho1)+e(idim1,irhop)-2.*e(idim1,irhom))
173 IF (e(idim1,irho1).GE.0.)
THEN
174 cc(irho1,idim1,idim1) = cc(irho1,idim1,idim1) &
175 - e(idim1,irhom)/c(idim1,irho1)/h12
176 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
177 + e(idim1,irho1) / c(idim1,irho1)/h12
179 aa(irho1,idim1,idim1) = aa(irho1,idim1,idim1) &
180 + e(idim1,irhop)/c(idim1,irhop)/h12
181 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
182 + e(idim1,irho1) / c(idim1,irho1)/h12
187 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1)+g(idim1,irho1)
190 bb(irho1,idim1,idim2) = bb(irho1,idim1,idim2)
200 h12 = 0.5*(2.*h(irho1)+h(irhom))
202 doloop2idim2 :
DO idim1 = 1,ndim
203 ff(irho1,idim1) = b(idim1,irho1)*ym(idim1,irho1)+f(idim1,irho1)*tau
204 aa(irho1,idim1,idim1) = -0.5/c(idim1,irho1)/h(irho1)/ h12 &
206 cc(irho1,idim1,idim1) = -0.5/c(idim1,irho1)/h(irhom)/ h12 &
207 * (d(idim1,irho1)+ d(idim1,irhom))
208 bb(irho1,idim1,idim1) = -aa(irho1,idim1,idim1) -cc(irho1,idim1,idim1)
210 IF (iupwind.NE.1)
THEN
211 aa(irho1,idim1,idim1) = aa(irho1,idim1,idim1) &
212 + 0.5 /c(idim1,irho1)/h12 &
214 cc(irho1,idim1,idim1) = cc(irho1,idim1,idim1) &
215 - 0.25 /c(idim1,irho1)/h12 &
216 * (e(idim1,irho1)+e(idim1,irhom))
217 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
218 + 0.25 /c(idim1,irho1)/h12 &
219 * (2.*e(idim1,irhop)-e(idim1,irhom)-e(idim1,irho1))
221 IF (e(idim1,irho1).GE.0.)
THEN
222 cc(irho1,idim1,idim1) = cc(irho1,idim1,idim1) &
223 - e(idim1,irhom)/c(idim1,irho1)/h12
224 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
225 + e(idim1,irho1) / c(idim1,irho1)/h12
227 aa(irho1,idim1,idim1) = aa(irho1,idim1,idim1) &
228 + e(idim1,irhop)/c(idim1,irhop)/h12
229 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
230 + e(idim1,irho1) / c(idim1,irho1)/h12
235 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1)+g(idim1,irho1)
238 bb(irho1,idim1,idim2) = bb(irho1,idim1,idim2)
245 doloop1irho1:
DO irho1 = 3,nrho-2
248 h12 = 0.5*(h(irho1)+h(irhom))
250 doloop2idim3 :
DO idim1 = 1,ndim
251 ff(irho1,idim1) = b(idim1,irho1)*ym(idim1,irho1)+f(idim1,irho1)*tau
252 aa(irho1,idim1,idim1) = -0.5/c(idim1,irho1)/h(irho1)/ h12 &
253 * (d(idim1,irho1)+ d(idim1,irhop))
254 cc(irho1,idim1,idim1) = -0.5/c(idim1,irho1)/h(irhom)/ h12 &
255 * (d(idim1,irho1)+ d(idim1,irhom))
256 bb(irho1,idim1,idim1) = -aa(irho1,idim1,idim1) -cc(irho1,idim1,idim1)
258 IF (iupwind.NE.1)
THEN
259 aa(irho1,idim1,idim1) = aa(irho1,idim1,idim1) &
260 + 0.25 /c(idim1,irho1)/h12 &
261 * (e(idim1,irho1)+e(idim1,irhop))
262 cc(irho1,idim1,idim1) = cc(irho1,idim1,idim1) &
263 - 0.25 /c(idim1,irho1)/h12 &
264 * (e(idim1,irho1)+e(idim1,irhom))
265 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
266 + 0.25 /c(idim1,irho1)/h12 &
267 * (e(idim1,irhop)-e(idim1,irhom))
269 IF (e(idim1,irho1).GE.0.)
THEN
270 cc(irho1,idim1,idim1) = cc(irho1,idim1,idim1) &
271 - e(idim1,irhom)/c(idim1,irho1)/h12
272 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
273 + e(idim1,irho1) / c(idim1,irho1)/h12
275 aa(irho1,idim1,idim1) = aa(irho1,idim1,idim1) &
276 + e(idim1,irhop)/c(idim1,irhop)/h12
277 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1) &
278 + e(idim1,irho1) / c(idim1,irho1)/h12
283 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1)+g(idim1,irho1)
286 bb(irho1,idim1,idim2) = bb(irho1,idim1,idim2)
334 bb(irho1,idim1,idim1) = bb(irho1,idim1,idim1)+ a(idim1,irho1)
341 CALL
mprogonka_4(nrho,ndim,aa,bb,cc,ff,uu,vv,ww,yy)
347 y(idim1,irho1) = yy(irho1,idim1)*amix+y(idim1,irho1)*(1.e0_r8-amix)
354 rho_derivn(1) = rho(2) - ( rho(3) - rho(2) )
355 rho_derivn(nrho) = rho(nrho-1) + ( rho(nrho-1) - rho(nrho-2) )
359 CALL
derivn3_4(nrho,ndim,rho_derivn,y,dy)
362 dy(idim1,1)=0.5*(dy(idim1,2)+dy(idim1,1))
363 y(idim1,1)=0.5*(y(idim1,2)+y(idim1,1))
366 dy(idim1,nrho)=0.5*(dy(idim1,nrho)+dy(idim1,nrho-1))
367 y(idim1,nrho)=0.5*(y(idim1,nrho)+y(idim1,nrho-1))
372 solver%Y(idim1,irho1) = y(idim1,irho1)
373 solver%DY(idim1,irho1) = dy(idim1,irho1)
408 SUBROUTINE mprogonka_4 (NP,NDIM,A,B,C,F,U,V,W,Y) !AF, 14.Sep.2011
422 INTEGER,
INTENT(IN) :: np
424 INTEGER,
INTENT(IN) :: ndim
426 REAL(R8),
DIMENSION(NP,NDIM,NDIM),
INTENT(IN) :: a, b, c
428 REAL(R8),
DIMENSION(NP,NDIM),
INTENT(IN) :: f
430 REAL(R8),
DIMENSION(2,NDIM,NDIM),
INTENT(IN) :: u,v
432 REAL(R8),
DIMENSION(2,NDIM),
INTENT(IN) :: w
434 REAL(R8),
DIMENSION(NP,NDIM),
INTENT(OUT) :: y
438 REAL(R8),
DIMENSION(NP,NDIM,NDIM) :: alf
439 REAL(R8),
DIMENSION(NP,NDIM) :: bet
440 REAL(R8),
DIMENSION(NDIM,NDIM) :: temp1,temp2,temp3
441 REAL(R8),
DIMENSION(NP,NDIM) :: wekt1
442 REAL(R8),
DIMENSION(NDIM) :: wekt2
443 INTEGER :: i, j, j2, k, n, nn, n2
444 REAL(R8) :: stemp1,stemp2,det
451 alf(2,1,1) =-v(1,1,1)/u(1,1,1)
452 bet(2,1)= w(1,1)/u(1,1,1)
456 det=b(j,1,1)+alf(j,1,1)*c(j,1,1)
457 IF(abs(det).GT.1.e-30_r8)
THEN
458 alf(j2,1,1)=-a(j,1,1)/det
459 bet(j2,1)=(f(j,1)-bet(j,1)*c(j,1,1))/det
468 det=v(2,1,1)*alf(np,1,1)+u(2,1,1)
469 IF(abs(det).GT.1.e-30_r8) y(np,1)=(w(2,1)-bet(np,1)*v(2,1,1))/det
473 y(j,1)=alf(j2,1,1)*y(j2,1)+bet(j2,1)
491 alf(2,i,j)=alf(2,i,j)-temp2(i,k)*v(1,k,j)
493 bet(2,i)=bet(2,i)+temp2(i,j)*w(1,j)
503 temp1(i,j)=temp1(i,j)+c(n,i,k)*alf(n,k,j)
505 wekt1(n,i)=wekt1(n,i)-c(n,i,j)*bet(n,j)
516 alf(n2,i,j)=alf(n2,i,j)-temp2(i,k)*a(n,k,j)
518 bet(n2,i)=bet(n2,i)+temp2(i,j)*wekt1(n,j)
524 1001
FORMAT(1x,3i4,1
p,8e12.4)
533 temp1(i,j)=temp1(i,j)+v(2,i,k)*alf(np,k,j)
535 wekt2(i)=wekt2(i)-v(2,i,j)*bet(np,j)
543 y(np,i)=y(np,i)+temp2(i,j)*wekt2(j)
552 y(n,i)=y(n,i)+alf(n2,i,j)*y(n2,j)
597 INTEGER,
INTENT(IN) :: n
599 REAL(R8),
DIMENSION(n,n),
INTENT(IN) :: aa
602 REAL(R8),
DIMENSION(n,n),
INTENT(OUT) :: ainv
605 REAL(R8),
DIMENSION(n) :: scale
606 REAL(R8),
DIMENSION(n,n) :: b
607 REAL(R8),
DIMENSION(n,n) :: a
608 INTEGER,
DIMENSION(n) :: index
609 INTEGER :: i, j, k, jpivot, indexj
610 REAL(R8) :: scalemax, ratio, ratiomax, coeff, determ, sum
636 if( abs(a(i,j)) .gt. scalemax )
then
637 scalemax = abs(a(i,j))
649 ratio = abs(a(index(i),k))/scale(index(i))
650 if( ratio .gt. ratiomax )
then
657 if( jpivot .ne. k )
then
658 indexj = index(jpivot)
659 index(jpivot) = index(k)
664 coeff = a(index(i),k)/a(indexj,k)
666 a(index(i),j) = a(index(i),j) - coeff*a(indexj,j)
668 a(index(i),k) = coeff
670 b(index(i),j) = b(index(i),j) - a(index(i),k)*b(indexj,j)
678 ainv(n,k) = b(index(n),k)/a(index(n),n)
682 sum = sum - a(index(i),j)*ainv(j,k)
684 ainv(i,k) = sum/a(index(i),i)
708 SUBROUTINE derivn3_4(N,NFUN,X,FUN,DFUN) !AF, 14.Sep.2011
724 REAL (R8) :: h(n),dy2(n)
741 dy1(i) = ((y(i+1)-y(i))*h(i-1)/h(i)+(y(i)-y(i-1))*h(i)/h(i-1)) &
750 ddy = 2.e0_r8*((y(1)-y(2))/h(1)+(y(3)-y(2))/h(2))/(h(2)+h(1))
751 dy1(1) = dy1(2)-ddy*h(1)
752 ddy = 2.e0_r8*((y(n-2)-y(n-1))/h(n-2)+(y(n)-y(n-1))/h(n-1))/(h(n-1)+h(n-2))
753 dy1(n) = dy1(n-1)+ddy*h(n-1)
756 dfun(ifun,i) = dy1(i)
subroutine derivn3_4(N, NFUN, X, FUN, DFUN)
These subroutines calculate first and second derivatives, DY1 and DY2, of function Y respect to argum...
subroutine invmatrix_4(n, AA, Ainv)
Computes inverse of matrix Input AA - Matrix A (n by n) N - Dimension of matrix AA.
subroutine mprogonka_4(NP, NDIM, A, B, C, F, U, V, W, Y)
Finds Solution of discrete equation of the form A_i * Y_i+1 + B_i * Y_i +C_i * Y_i-1 = F_i where: Y_i...
subroutine solution4(SOLVER, ifail)
This subroutine solves transport equations using matrix PROGONKA method.
real(r8) function p(a, x, xr, xs, yr, ys, psi, psir, F_dia)