10 integer,
parameter :: fastRW_ = 3,fastlw_=4,slowrw_=5,slowlw_=6
11 integer,
parameter :: entroW_ = 8,diverw_=7,alfvrw_=1,alfvlw_=2
30 case(fastrw_,fastlw_,slowrw_,slowlw_)
50 integer,
intent(in) :: ix^L, idim
51 double precision,
intent(in) :: wL(ixG^T, nw), wR(ixG^T, nw)
52 double precision,
intent(inout) :: wroe(ixG^T, nw)
53 double precision,
intent(inout) :: workroe(ixG^T, nworkroe)
54 double precision,
intent(in) :: x(ixG^T, 1:^ND)
56 call average2(wl,wr,x,ix^l,idim,wroe,workroe(ixg^t,1),workroe(ixg^t,2), &
57 workroe(ixg^t,3),workroe(ixg^t,4),workroe(ixg^t,5),workroe(ixg^t,6), &
58 workroe(ixg^t,7),workroe(ixg^t,8))
68 subroutine average2(wL,wR,x,ix^L,idim,wroe,cfast,cslow,afast,aslow,csound2,dp, &
72 integer :: ix^L,idim,idir,jdir,iw
73 double precision,
dimension(ixG^T,nw) :: wL,wR,wroe
74 double precision,
intent(in) :: x(ixG^T,1:ndim)
75 double precision,
dimension(ixG^T) :: cfast,cslow,afast,aslow,csound2,dp, &
78 if (
ndir==1)
call mpistop(
"MHD with d=11 is the same as HD")
83 wroe(ix^s,
mom(idir))=half*(wl(ix^s,
mom(idir))/wl(ix^s,
rho_)+wr(ix^s,
mom(idir))/wr(ix^s,
rho_))
84 wroe(ix^s,
mag(idir))=half*(wl(ix^s,
mag(idir))+wr(ix^s,
mag(idir)))
91 wroe(ix^s,
e_)=half*(afast(ix^s)+aslow(ix^s))
93 dp(ix^s)=aslow(ix^s)-afast(ix^s)
95 dp(ix^s)=aslow(ix^s)-afast(ix^s)
99 rhodv(ix^s)=wr(ix^s,
mom(idim))-wl(ix^s,
mom(idim))-&
112 cfast(ix^s)=sum(wroe(ix^s,
mag(:))**2,dim=ndim+1)/wroe(ix^s,
rho_)+csound2(ix^s)
115 cslow(ix^s)=half*(cfast(ix^s)-dsqrt(cfast(ix^s)**2-&
116 4d0*csound2(ix^s)*wroe(ix^s,
mag(idim))**2/wroe(ix^s,
rho_)))
119 cfast(ix^s)=cfast(ix^s)-cslow(ix^s)
122 afast(ix^s)=(csound2(ix^s)-cslow(ix^s))/(cfast(ix^s)-cslow(ix^s))
123 afast(ix^s)=min(one,max(afast(ix^s),zero))
126 aslow(ix^s)=dsqrt(one-afast(ix^s))
129 afast(ix^s)=dsqrt(afast(ix^s))
132 cfast(ix^s)=dsqrt(cfast(ix^s))
135 cslow(ix^s)=dsqrt(cslow(ix^s))
139 wroe(ix^s,
rho_)=dsqrt(wroe(ix^s,
rho_))
142 where(dabs(wroe(ix^s,
mag(idim)))<smalldouble)&
143 wroe(ix^s,
mag(idim))=smalldouble
147 where(wroe(ix^s,
mag(idir))>=zero)
148 wroe(ix^s,
mag(idir))=one
150 wroe(ix^s,
mag(idir))=-one
155 tmp(ix^s)=dsqrt(wroe(ix^s,
mag(idir))**2+wroe(ix^s,
mag(jdir))**2)
156 where(tmp(ix^s)>smalldouble)
157 wroe(ix^s,
mag(idir))=wroe(ix^s,
mag(idir))/tmp(ix^s)
158 wroe(ix^s,
mag(jdir))=wroe(ix^s,
mag(jdir))/tmp(ix^s)
160 wroe(ix^s,
mag(idir))=dsqrt(half)
161 wroe(ix^s,
mag(jdir))=dsqrt(half)
177 subroutine mhd_get_eigenjump(wL,wR,wroe,x,ix^L,il,idim,smalla,a,jump,workroe)
180 integer,
intent(in) :: ix^L,il,idim
181 double precision,
dimension(ixG^T,nw) :: wL,wR,wroe
182 double precision,
intent(in) :: x(ixG^T,1:ndim)
183 double precision,
dimension(ixG^T) :: smalla,a,jump
184 double precision,
dimension(ixG^T,nworkroe) :: workroe
186 call geteigenjump2(wl,wr,wroe,x,ix^l,il,idim,smalla,a,jump, &
187 workroe(ixg^t,1),workroe(ixg^t,2), &
188 workroe(ixg^t,3),workroe(ixg^t,4),workroe(ixg^t,5),workroe(ixg^t,6), &
189 workroe(ixg^t,7),workroe(ixg^t,8),workroe(ixg^t,9),workroe(ixg^t,10), &
190 workroe(ixg^t,11),workroe(ixg^t,12),workroe(ixg^t,13))
204 subroutine geteigenjump2(wL,wR,wroe,x,ix^L,il,idim,smalla,a,jump, &
205 cfast,cslow,afast,aslow,csound2,dp,rhodv,bdv,bdb,cs2L,cs2R,cs2ca2L,cs2ca2R)
209 integer :: ix^L,il,idim,idir,jdir
210 double precision,
dimension(ixG^T,nw) :: wL,wR,wroe
211 double precision,
intent(in) :: x(ixG^T,1:ndim)
212 double precision,
dimension(ixG^T) :: smalla,a,jump
213 double precision,
dimension(ixG^T) :: cfast,cslow,afast,aslow,csound2,dp,rhodv
214 double precision,
dimension(ixG^T) :: bdv,bdb
215 double precision,
dimension(ixG^T) :: aL,aR,cs2L,cs2R,cs2ca2L,cs2ca2R
223 bdv(ix^s)=wroe(ix^s,
mag(idir))* &
224 (wr(ix^s,
mom(idir))/wr(ix^s,
rho_)-wl(ix^s,
mom(idir))/wl(ix^s,
rho_))
225 if(
ndir==3)bdv(ix^s)=bdv(ix^s)+wroe(ix^s,
mag(jdir))* &
226 (wr(ix^s,
mom(jdir))/wr(ix^s,
rho_)-wl(ix^s,
mom(jdir))/wl(ix^s,
rho_))
227 bdv(ix^s)=bdv(ix^s)*sign(wroe(ix^s,
rho_)**2,wroe(ix^s,
mag(idim)))
229 bdb(ix^s)=wroe(ix^s,
mag(idir))*(wr(ix^s,
mag(idir))-wl(ix^s,
mag(idir)))
230 if(
ndir==3)bdb(ix^s)=bdb(ix^s)+&
231 wroe(ix^s,
mag(jdir))*(wr(ix^s,
mag(jdir))-wl(ix^s,
mag(jdir)))
232 bdb(ix^s)=bdb(ix^s)*dsqrt(csound2(ix^s))*wroe(ix^s,
rho_)
238 bdv(ix^s)=wroe(ix^s,
mag(jdir))* &
239 (wr(ix^s,
mom(idir))/wr(ix^s,
rho_)-wl(ix^s,
mom(idir))/wl(ix^s,
rho_)) &
240 -wroe(ix^s,
mag(idir))* &
241 (wr(ix^s,
mom(jdir))/wr(ix^s,
rho_)-wl(ix^s,
mom(jdir))/wl(ix^s,
rho_))
242 bdb(ix^s)=wroe(ix^s,
mag(jdir))*(wr(ix^s,
mag(idir))-wl(ix^s,
mag(idir))) &
243 -wroe(ix^s,
mag(idir))*(wr(ix^s,
mag(jdir))-wl(ix^s,
mag(jdir)))
244 bdv(ix^s)=bdv(ix^s)*half*wroe(ix^s,
rho_)**2
245 bdb(ix^s)=bdb(ix^s)*half*sign(wroe(ix^s,
rho_),wroe(ix^s,
mag(idim)))
250 a(ix^s)=wroe(ix^s,
mom(idim))+cfast(ix^s)
251 jump(ix^s)=half/csound2(ix^s)*(&
252 afast(ix^s)*(+cfast(ix^s)*rhodv(ix^s)+dp(ix^s))&
253 +aslow(ix^s)*(-cslow(ix^s)*bdv(ix^s)+bdb(ix^s)))
255 a(ix^s)=wroe(ix^s,
mom(idim))-cfast(ix^s)
256 jump(ix^s)=half/csound2(ix^s)*(&
257 afast(ix^s)*(-cfast(ix^s)*rhodv(ix^s)+dp(ix^s))&
258 +aslow(ix^s)*(+cslow(ix^s)*bdv(ix^s)+bdb(ix^s)))
260 a(ix^s)=wroe(ix^s,
mom(idim))+cslow(ix^s)
261 jump(ix^s)=half/csound2(ix^s)*(&
262 aslow(ix^s)*(+cslow(ix^s)*rhodv(ix^s)+dp(ix^s))&
263 +afast(ix^s)*(+cfast(ix^s)*bdv(ix^s)-bdb(ix^s)))
265 a(ix^s)=wroe(ix^s,
mom(idim))-cslow(ix^s)
266 jump(ix^s)=half/csound2(ix^s)*(&
267 aslow(ix^s)*(-cslow(ix^s)*rhodv(ix^s)+dp(ix^s))&
268 +afast(ix^s)*(-cfast(ix^s)*bdv(ix^s)-bdb(ix^s)))
270 a(ix^s)=wroe(ix^s,
mom(idim))
271 jump(ix^s)=wr(ix^s,
rho_)-wl(ix^s,
rho_)-dp(ix^s)/csound2(ix^s)
274 a(ix^s)=wroe(ix^s,
mom(idim))
275 jump(ix^s)=wr(ix^s,
mag(idim))-wl(ix^s,
mag(idim))
281 a(ix^s)=wroe(ix^s,
mom(idim))+dabs(wroe(ix^s,
mag(idim)))/wroe(ix^s,
rho_)
282 jump(ix^s)=+bdv(ix^s)-bdb(ix^s)
284 a(ix^s)=wroe(ix^s,
mom(idim))-dabs(wroe(ix^s,
mag(idim)))/wroe(ix^s,
rho_)
285 jump(ix^s)=-bdv(ix^s)-bdb(ix^s)
294 case(
'harten',
'powell',
'ratio')
297 al(ix^s)= wl(ix^s,
mom(idim))/wl(ix^s,
rho_)
298 ar(ix^s)= wr(ix^s,
mom(idim))/wr(ix^s,
rho_)
308 cs2ca2l(ix^s)=cs2l(ix^s)+sum(wl(ix^s,
mag(:))**2,dim=ndim+1)/wl(ix^s,
rho_)
309 cs2ca2r(ix^s)=cs2r(ix^s)+sum(wr(ix^s,
mag(:))**2,dim=ndim+1)/wr(ix^s,
rho_)
312 dsqrt(cs2ca2l(ix^s)**2-4d0*cs2l(ix^s)*wl(ix^s,
mag(idim))**2/wl(ix^s,
rho_))
314 dsqrt(cs2ca2r(ix^s)**2-4d0*cs2r(ix^s)*wr(ix^s,
mag(idim))**2/wr(ix^s,
rho_))
317 al(ix^s)=al(ix^s) + dsqrt(half*(cs2ca2l(ix^s) + cs2l(ix^s)))
318 ar(ix^s)=ar(ix^s) + dsqrt(half*(cs2ca2r(ix^s) + cs2r(ix^s)))
320 al(ix^s)=al(ix^s) - dsqrt(half*(cs2ca2l(ix^s) + cs2l(ix^s)))
321 ar(ix^s)=ar(ix^s) - dsqrt(half*(cs2ca2r(ix^s) + cs2r(ix^s)))
323 al(ix^s)=al(ix^s) + dsqrt(half*(cs2ca2l(ix^s) - cs2l(ix^s)))
324 ar(ix^s)=ar(ix^s) + dsqrt(half*(cs2ca2r(ix^s) - cs2r(ix^s)))
326 al(ix^s)=al(ix^s) - dsqrt(half*(cs2ca2l(ix^s) - cs2l(ix^s)))
327 ar(ix^s)=ar(ix^s) - dsqrt(half*(cs2ca2r(ix^s) - cs2r(ix^s)))
328 case(entrow_,diverw_)
332 cs2ca2l(ix^s)=dabs(wl(ix^s,
mag(idim)))/dsqrt(wl(ix^s,
rho_))
333 cs2ca2r(ix^s)=dabs(wr(ix^s,
mag(idim)))/dsqrt(wr(ix^s,
rho_))
335 al(ix^s)=al(ix^s) + cs2ca2l(ix^s)
336 ar(ix^s)=ar(ix^s) + cs2ca2r(ix^s)
338 al(ix^s)=al(ix^s) - cs2ca2l(ix^s)
339 ar(ix^s)=ar(ix^s) - cs2ca2r(ix^s)
351 integer,
intent(in) :: ix^L, iw, il, idim
352 double precision,
intent(in) :: w(ixG^T, nw), q(ixG^T)
353 double precision,
intent(inout) :: rq(ixG^T)
354 double precision,
intent(inout) :: workroe(ixG^T, nworkroe)
356 call rtimes2(q,w,ix^l,iw,il,idim,rq,&
357 workroe(ixg^t,1),workroe(ixg^t,2), &
358 workroe(ixg^t,3),workroe(ixg^t,4),workroe(ixg^t,5),workroe(ixg^t,6), &
359 workroe(ixg^t,7),workroe(ixg^t,14),workroe(ixg^t,15))
364 subroutine rtimes2(q,wroe,ix^L,iw,il,idim,rq, &
365 cfast,cslow,afast,aslow,csound2,dp,rhodv,bv,v2a2)
368 integer :: ix^L,iw,il,idim,idir,jdir
369 double precision :: wroe(ixG^T,nw)
370 double precision,
dimension(ixG^T) :: q,rq
371 double precision,
dimension(ixG^T) :: cfast,cslow,afast,aslow,csound2,dp,rhodv
372 double precision,
dimension(ixG^T) :: bv,v2a2
379 case(fastrw_,fastlw_)
380 rq(ix^s)=q(ix^s)*afast(ix^s)
381 case(slowrw_,slowlw_)
382 rq(ix^s)=q(ix^s)*aslow(ix^s)
385 case(diverw_,alfvrw_,alfvlw_)
388 else if(iw ==
e_)
then
391 v2a2(ix^s)=half*sum(wroe(ix^s,
mom(:))**2,dim=
ndim+1)+ &
394 bv(ix^s)=wroe(ix^s,
mag(idir))*wroe(ix^s,
mom(idir))
395 if(
ndir==3)bv(ix^s)=bv(ix^s)+wroe(ix^s,
mag(jdir))*wroe(ix^s,
mom(jdir))
396 bv(ix^s)=bv(ix^s)*sign(one,wroe(ix^s,
mag(idim)))
397 else if(il==alfvrw_)
then
399 bv(ix^s)=(wroe(ix^s,
mag(jdir))*wroe(ix^s,
mom(idir))-&
400 wroe(ix^s,
mag(idir))*wroe(ix^s,
mom(jdir)))
405 rq(ix^s)=q(ix^s)*(-aslow(ix^s)*cslow(ix^s)*bv(ix^s)+afast(ix^s)*&
406 (v2a2(ix^s)+cfast(ix^s)*(cfast(ix^s)+wroe(ix^s,
mom(idim)))))
408 rq(ix^s)=q(ix^s)*(+aslow(ix^s)*cslow(ix^s)*bv(ix^s)+afast(ix^s)*&
409 (v2a2(ix^s)+cfast(ix^s)*(cfast(ix^s)-wroe(ix^s,
mom(idim)))))
411 rq(ix^s)=q(ix^s)*(+afast(ix^s)*cfast(ix^s)*bv(ix^s)+aslow(ix^s)*&
412 (v2a2(ix^s)+cslow(ix^s)*(cslow(ix^s)+wroe(ix^s,
mom(idim)))))
414 rq(ix^s)=q(ix^s)*(-afast(ix^s)*cfast(ix^s)*bv(ix^s)+aslow(ix^s)*&
415 (v2a2(ix^s)+cslow(ix^s)*(cslow(ix^s)-wroe(ix^s,
mom(idim)))))
417 rq(ix^s)= q(ix^s)*half*sum(wroe(ix^s,
mom(:))**2,dim=
ndim+1)
420 rq(ix^s)= q(ix^s)*wroe(ix^s,
mag(idim))
425 rq(ix^s)=+q(ix^s)*bv(ix^s)
427 rq(ix^s)=-q(ix^s)*bv(ix^s)
429 else if(any(
mom(:)==iw))
then
430 if(iw==
mom(idim))
then
433 rq(ix^s)=q(ix^s)*afast(ix^s)*(wroe(ix^s,iw)+cfast(ix^s))
435 rq(ix^s)=q(ix^s)*afast(ix^s)*(wroe(ix^s,iw)-cfast(ix^s))
437 rq(ix^s)=q(ix^s)*aslow(ix^s)*(wroe(ix^s,iw)+cslow(ix^s))
439 rq(ix^s)=q(ix^s)*aslow(ix^s)*(wroe(ix^s,iw)-cslow(ix^s))
441 rq(ix^s)=q(ix^s)*wroe(ix^s,iw)
442 case(diverw_,alfvlw_,alfvrw_)
448 rq(ix^s)=q(ix^s)*(afast(ix^s)*wroe(ix^s,iw)-aslow(ix^s)*&
449 cslow(ix^s)*wroe(ix^s,
mag(1)-
mom(1)+iw)*sign(one,wroe(ix^s,
mag(idim))))
451 rq(ix^s)=q(ix^s)*(afast(ix^s)*wroe(ix^s,iw)+aslow(ix^s)*&
452 cslow(ix^s)*wroe(ix^s,
mag(1)-
mom(1)+iw)*sign(one,wroe(ix^s,
mag(idim))))
454 rq(ix^s)=q(ix^s)*(aslow(ix^s)*wroe(ix^s,iw)+afast(ix^s)*&
455 cfast(ix^s)*wroe(ix^s,
mag(1)-
mom(1)+iw)*sign(one,wroe(ix^s,
mag(idim))))
457 rq(ix^s)=q(ix^s)*(aslow(ix^s)*wroe(ix^s,iw)-afast(ix^s)*&
458 cfast(ix^s)*wroe(ix^s,
mag(1)-
mom(1)+iw)*sign(one,wroe(ix^s,
mag(idim))))
460 rq(ix^s)=q(ix^s)*wroe(ix^s,iw)
464 if(iw==
mom(idir))
then
465 rq(ix^s)=+q(ix^s)*wroe(ix^s,
mag(jdir))
467 rq(ix^s)=-q(ix^s)*wroe(ix^s,
mag(idir))
470 if(iw==
mom(idir))
then
471 rq(ix^s)=-q(ix^s)*wroe(ix^s,
mag(jdir))
473 rq(ix^s)=+q(ix^s)*wroe(ix^s,
mag(idir))
477 else if(any(
mag(:)==iw))
then
478 if(iw==
mag(idim))
then
486 case(fastrw_,fastlw_)
487 rq(ix^s)=+q(ix^s)*aslow(ix^s)*dsqrt(csound2(ix^s))*wroe(ix^s,iw)&
489 case(slowrw_,slowlw_)
490 rq(ix^s)=-q(ix^s)*afast(ix^s)*dsqrt(csound2(ix^s))*wroe(ix^s,iw)&
492 case(entrow_,diverw_)
494 case(alfvrw_,alfvlw_)
495 if(iw==
mag(idir))
then
496 rq(ix^s)=-q(ix^s)*wroe(ix^s,
mag(jdir))&
497 /sign(wroe(ix^s,
rho_),wroe(ix^s,
mag(idim)))
499 rq(ix^s)=+q(ix^s)*wroe(ix^s,
mag(idir))&
500 /sign(wroe(ix^s,
rho_),wroe(ix^s,
mag(idim)))
integer, dimension(:), allocatable, public mag
Indices of the magnetic field.
This module contains definitions of global parameters and variables and some generic functions/subrou...
character(len=std_len), dimension(:), allocatable typeentropy
Which type of entropy fix to use with Riemann-type solvers.
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer ndir
Number of spatial dimensions (components) for vector variables.
double precision, dimension(:), allocatable entropycoef
Magneto-hydrodynamics module.
integer, dimension(:), allocatable, public, protected mom
Indices of the momentum density.
double precision, public mhd_adiab
The adiabatic constant.
double precision, public mhd_gamma
The adiabatic index.
logical, public, protected mhd_energy
Whether an energy equation is used.
logical, public divbwave
Add divB wave in Roe solver.
integer, public, protected p_
Index of the gas pressure (-1 if not present) should equal e_.
integer, public, protected rho_
Index of the density (in the w array)
procedure(sub_get_pthermal), pointer, public mhd_get_pthermal
integer, public, protected e_
Index of the energy density (-1 if not present)
Subroutines for Roe-type Riemann solver for MHD.
subroutine average2(wL, wR, x, ixL, idim, wroe, cfast, cslow, afast, aslow, csound2, dp, rhodv, tmp)
subroutine mhd_get_eigenjump(wL, wR, wroe, x, ixL, il, idim, smalla, a, jump, workroe)
subroutine, public mhd_roe_init()
subroutine rtimes2(q, wroe, ixL, iw, il, idim, rq, cfast, cslow, afast, aslow, csound2, dp, rhodv, bv, v2a2)
subroutine mhd_average(wL, wR, x, ixL, idim, wroe, workroe)
subroutine geteigenjump2(wL, wR, wroe, x, ixL, il, idim, smalla, a, jump, cfast, cslow, afast, aslow, csound2, dp, rhodv, bdv, bdb, cs2L, cs2R, cs2ca2L, cs2ca2R)
subroutine mhd_rtimes(q, w, ixL, iw, il, idim, rq, workroe)
procedure(sub_rtimes), pointer phys_rtimes
procedure(sub_get_eigenjump), pointer phys_get_eigenjump
procedure(sub_average), pointer phys_average
Subroutines for TVD-MUSCL schemes.
subroutine, public entropyfix(ixL, il, aL, aR, a, smalla)