10 integer :: soundRW_ = -1
11 integer :: soundLW_ = -1
12 integer :: entropW_ = -1
13 integer :: shearW0_ = -1
50 if (iw == soundrw_ .or. iw == soundlw_)
then
62 subroutine hd_average(wL,wR,x,ix^L,idim,wroe,workroe)
64 integer,
intent(in) :: ix^
l, idim
65 double precision,
intent(in) :: wl(ixg^t, nw), wr(ixg^t, nw)
66 double precision,
intent(inout) :: wroe(ixg^t, nw)
67 double precision,
intent(inout) :: workroe(ixg^t,
nworkroe)
68 double precision,
intent(in) :: x(ixg^t, 1:^nd)
72 workroe(ix^s, 1) = sqrt(wl(ix^s,
rho_))
73 workroe(ix^s, 2) = sqrt(wr(ix^s,
rho_))
76 wroe(ix^s,
rho_) = workroe(ix^s, 1)*workroe(ix^s, 2)
79 workroe(ix^s, 1) = workroe(ix^s, 1)/workroe(ix^s, 2)
83 wroe(ix^s,
mom(idir)) = (wl(ix^s,
mom(idir))/wl(ix^s,
rho_) * workroe(ix^s, 1)+&
84 wr(ix^s,
mom(idir))/wr(ix^s,
rho_))/(one+workroe(ix^s, 1))
88 call eos%get_thermal_pressure(wl,x,ixg^
ll,ix^
l, workroe(ixg^t, 2))
90 wroe(ix^s,
e_) = (workroe(ix^s, 2)+wl(ix^s,
e_))/wl(ix^s,
rho_)
92 call eos%get_thermal_pressure(wr,x,ixg^
ll,ix^
l, workroe(ixg^t, 2))
94 workroe(ix^s, 2) = (workroe(ix^s, 2)+wr(ix^s,
e_))/wr(ix^s,
rho_)
95 wroe(ix^s,
e_) = (wroe(ix^s,
e_)*workroe(ix^s, 1) + workroe(ix^s, 2))/(one+workroe(ix^s, 1))
96 end subroutine hd_average
98 subroutine average2(wL,wR,x,ix^L,idim,wroe,tmp,tmp2)
105 integer :: ix^
l,idim,idir
106 double precision,
dimension(ixG^T,nw) :: wl,wr,wroe
107 double precision,
dimension(ixG^T,ndim),
intent(in) :: x
108 double precision,
dimension(ixG^T) :: tmp,tmp2
112 end subroutine average2
118 subroutine hd_get_eigenjump(wL,wR,wroe,x,ix^L,il,idim,smalla,a,jump,workroe)
121 integer,
intent(in) :: ix^
l,il,idim
122 double precision,
dimension(ixG^T,nw):: wl,wr,wroe
123 double precision,
dimension(ixG^T,ndim),
intent(in) :: x
124 double precision,
dimension(ixG^T) :: smalla,a,jump
125 double precision,
dimension(ixG^T,nworkroe) :: workroe
127 call geteigenjump2(wl,wr,wroe,x,ix^
l,il,idim,smalla,a,jump, &
128 workroe(ixg^t,1),workroe(ixg^t,2),workroe(ixg^t,3))
130 end subroutine hd_get_eigenjump
132 subroutine geteigenjump2(wL,wR,wroe,x,ix^L,il,idim,smalla,a,jump,&
133 csound,dpperc2,dvperc)
143 integer :: ix^
l,il,idim,idir
144 double precision,
dimension(ixG^T,nw) :: wl,wr,wroe
145 double precision,
dimension(ixG^T,ndim),
intent(in) :: x
146 double precision,
dimension(ixG^T) :: smalla,a,jump,tmp,tmp2
147 double precision,
dimension(ixG^T) :: csound,dpperc2,dvperc
148 double precision :: kin_en(ixg^t)
152 kin_en(ix^s) = 0.5d0 * sum(wroe(ix^s,
mom(:))**2, dim=^nd+1)
153 csound(ix^s)=(eos%gamma-one)*(wroe(ix^s,
e_) - kin_en(ix^s))
155 csound(ix^s)=max(eos%gamma*smalldouble/wroe(ix^s,
rho_),csound(ix^s))
159 call eos%get_thermal_pressure(wl,x,ixg^
ll,ix^
l,tmp)
160 call eos%get_thermal_pressure(wr,x,ixg^
ll,ix^
l,tmp2)
161 dpperc2(ix^s)=(tmp2(ix^s)-tmp(ix^s))/csound(ix^s)
164 csound(ix^s)=sqrt(csound(ix^s))
167 dvperc(ix^s)=(wr(ix^s,
mom(idim))/wr(ix^s,
rho_)-&
168 wl(ix^s,
mom(idim))/wl(ix^s,
rho_))/csound(ix^s)
172 if (il == soundrw_)
then
173 a(ix^s)=wroe(ix^s,
mom(idim))+csound(ix^s)
174 jump(ix^s)=half*(dpperc2(ix^s)+wroe(ix^s,
rho_)*dvperc(ix^s))
175 else if (il == soundlw_)
then
176 a(ix^s)=wroe(ix^s,
mom(idim))-csound(ix^s)
177 jump(ix^s)=half*(dpperc2(ix^s)-wroe(ix^s,
rho_)*dvperc(ix^s))
178 else if (il == entropw_)
then
179 a(ix^s)=wroe(ix^s,
mom(idim))
180 jump(ix^s)=-dpperc2(ix^s)+wr(ix^s,
rho_)-wl(ix^s,
rho_)
183 idir=il-shearw0_;
if(idir>=idim)idir=idir+1
184 a(ix^s)=wroe(ix^s,
mom(idim))
185 jump(ix^s)=wroe(ix^s,
rho_)*&
186 (wr(ix^s,
mom(idir))/wr(ix^s,
rho_)-wl(ix^s,
mom(idir))/wl(ix^s,
rho_))
197 case(
'harten',
'powell')
199 if (il == soundrw_)
then
200 call eos%get_thermal_pressure(wl,x,ixg^
ll,ix^
l,tmp)
201 tmp(ix^s)=wl(ix^s,
mom(idim))/wl(ix^s,
rho_)&
202 + sqrt(eos%gamma*tmp(ix^s)/wl(ix^s,
rho_))
203 call eos%get_thermal_pressure(wr,x,ixg^
ll,ix^
l,tmp2)
204 tmp2(ix^s)=wr(ix^s,
mom(idim))/wr(ix^s,
rho_)&
205 + sqrt(eos%gamma*tmp2(ix^s)/wr(ix^s,
rho_))
206 else if (il == soundlw_)
then
207 call eos%get_thermal_pressure(wl,x,ixg^
ll,ix^
l,tmp)
208 tmp(ix^s)=wl(ix^s,
mom(idim))/wl(ix^s,
rho_)&
209 - sqrt(eos%gamma*tmp(ix^s)/wl(ix^s,
rho_))
210 call eos%get_thermal_pressure(wr,x,ixg^
ll,ix^
l,tmp2)
211 tmp2(ix^s)=wr(ix^s,
mom(idim))/wr(ix^s,
rho_)&
212 - sqrt(eos%gamma*tmp2(ix^s)/wr(ix^s,
rho_))
214 tmp(ix^s) =wl(ix^s,
mom(idim))/wl(ix^s,
rho_)
215 tmp2(ix^s)=wr(ix^s,
mom(idim))/wr(ix^s,
rho_)
221 end subroutine geteigenjump2
224 subroutine hd_rtimes(q,wroe,ix^L,iw,il,idim,rq,workroe)
227 integer,
intent(in) :: ix^
l,iw,il,idim
228 double precision,
intent(in) :: wroe(ixg^t,nw)
229 double precision,
intent(in) :: q(ixg^t)
230 double precision,
intent(inout) :: rq(ixg^t)
231 double precision,
intent(inout) :: workroe(ixg^t,
nworkroe)
233 call rtimes2(q,wroe,ix^
l,iw,il,idim,rq,workroe(ixg^t,1))
234 end subroutine hd_rtimes
236 subroutine rtimes2(q,wroe,ix^L,iw,il,idim,rq,csound)
242 integer :: ix^
l,iw,il,idim,idir
243 double precision :: wroe(ixg^t,nw)
244 double precision,
dimension(ixG^T) :: q,rq,csound
247 shearwave=il>shearw0_
251 idir=il-shearw0_;
if(idir>=idim)idir=idir+1
260 else if (iw ==
e_)
then
261 if (il == soundrw_)
then
262 rq(ix^s)=q(ix^s)*(wroe(ix^s,
e_)+wroe(ix^s,
mom(idim))*csound(ix^s))
263 else if (il == soundlw_)
then
264 rq(ix^s)=q(ix^s)*(wroe(ix^s,
e_)-wroe(ix^s,
mom(idim))*csound(ix^s))
265 else if (il == entropw_)
then
266 rq(ix^s)=q(ix^s) * 0.5d0 * sum(wroe(ix^s,
mom(:))**2, dim=^nd+1)
268 rq(ix^s)=q(ix^s)*wroe(ix^s,
mom(idir))
271 if(iw==
mom(idim))
then
272 if (il == soundrw_)
then
273 rq(ix^s)=q(ix^s)*(wroe(ix^s,
mom(idim))+csound(ix^s))
274 else if (il == soundlw_)
then
275 rq(ix^s)=q(ix^s)*(wroe(ix^s,
mom(idim))-csound(ix^s))
276 else if (il == entropw_)
then
277 rq(ix^s)=q(ix^s)*wroe(ix^s,
mom(idim))
283 if(iw==
mom(idir))
then
289 rq(ix^s)=q(ix^s)*wroe(ix^s,iw)
294 end subroutine rtimes2
296 subroutine hd_average_iso(wL,wR,x,ix^L,idim,wroe,workroe)
302 integer,
intent(in) :: ix^
l, idim
303 double precision,
intent(in) :: wl(ixg^t, nw), wr(ixg^t, nw)
304 double precision,
intent(inout) :: wroe(ixg^t, nw)
305 double precision,
intent(inout) :: workroe(ixg^t,
nworkroe)
306 double precision,
intent(in) :: x(ixg^t, 1:^nd)
308 call average2_iso(wl,wr,x,ix^
l,idim,wroe,workroe(ixg^t,1))
310 end subroutine hd_average_iso
312 subroutine average2_iso(wL,wR,x,ix^L,idim,wroe,tmp)
319 integer:: ix^
l,idim,idir
320 double precision,
dimension(ixG^T,nw):: wl,wr,wroe
321 double precision,
intent(in) :: x(ixg^t,1:
ndim)
322 double precision,
dimension(ixG^T):: tmp
330 wroe(ix^s,
mom(idir)) = half * (wl(ix^s,
mom(idir))/wl(ix^s,
rho_) + &
331 wr(ix^s,
mom(idir))/wr(ix^s,
rho_))
333 case (
'roe',
'default')
337 tmp(ix^s)=sqrt(wl(ix^s,
rho_)/wr(ix^s,
rho_))
339 wroe(ix^s,
mom(idir))=(wl(ix^s,
mom(idir))/wl(ix^s,
rho_)*tmp(ix^s)+&
340 wr(ix^s,
mom(idir))/wr(ix^s,
rho_))/(one+tmp(ix^s))
344 end subroutine average2_iso
346 subroutine hd_get_eigenjump_iso(wL,wR,wroe,x,ix^L,il,idim,smalla,a,jump,workroe)
355 integer,
intent(in) :: ix^
l,il,idim
356 double precision,
dimension(ixG^T,nw):: wl,wr,wroe
357 double precision,
intent(in) :: x(ixg^t,1:
ndim)
358 double precision,
dimension(ixG^T) :: smalla,a,jump
359 double precision,
dimension(ixG^T,nworkroe) :: workroe
361 call geteigenjump2_iso(wl,wr,wroe,x,ix^
l,il,idim,smalla,a,jump,workroe(ixg^t,1))
363 end subroutine hd_get_eigenjump_iso
365 subroutine geteigenjump2_iso(wL,wR,wroe,x,ix^L,il,idim,smalla,a,jump,csound)
375 integer:: ix^
l,il,idim,idir
376 double precision,
dimension(ixG^T,nw):: wl,wr,wroe
377 double precision,
intent(in) :: x(ixg^t,1:
ndim)
378 double precision,
dimension(ixG^T) :: smalla,a,jump,tmp,tmp2
379 double precision,
dimension(ixG^T) :: csound
380 DOUBLE PRECISION,
PARAMETER:: qsmall=1.
d-6
385 call eos%get_thermal_pressure(wroe,x,ixg^
ll,ix^
l,csound)
386 csound(ix^s) = sqrt(eos%gamma*csound(ix^s)/wroe(ix^s,
rho_))
388 if (il == soundrw_)
then
389 a(ix^s)=wroe(ix^s,
mom(idim))+csound(ix^s)
390 jump(ix^s)=half*((one-wroe(ix^s,
mom(idim))/csound(ix^s))*&
392 +(wr(ix^s,
mom(idim))-wl(ix^s,
mom(idim)))/csound(ix^s))
393 else if (il == soundlw_)
then
394 a(ix^s)=wroe(ix^s,
mom(idim))-csound(ix^s)
395 jump(ix^s)=half*((one+wroe(ix^s,
mom(idim))/csound(ix^s))*&
397 -(wr(ix^s,
mom(idim))-wl(ix^s,
mom(idim)))/csound(ix^s))
400 idir=il-shearw0_;
if(idir>=idim)idir=idir+1
401 a(ix^s)=wroe(ix^s,
mom(idim))
402 jump(ix^s)=-wroe(ix^s,
mom(idir))*(wr(ix^s,
rho_)-wl(ix^s,
rho_))&
403 +(wr(ix^s,
mom(idir))-wl(ix^s,
mom(idir)))
405 case (
'roe',
'default')
406 call eos%get_thermal_pressure(wroe,x,ixg^
ll,ix^
l,csound)
407 call eos%get_thermal_pressure(wl,x,ixg^
ll,ix^
l,tmp)
408 call eos%get_thermal_pressure(wr,x,ixg^
ll,ix^
l,tmp2)
409 where(abs(wl(ix^s,
rho_)-wr(ix^s,
rho_))<=qsmall*(wl(ix^s,
rho_)+wr(ix^s,
rho_)))
410 csound(ix^s) = sqrt(eos%gamma*csound(ix^s)/wroe(ix^s,
rho_))
412 csound(ix^s) = sqrt(eos%gamma*(tmp2(ix^s)-tmp(ix^s))/&
417 if (il == soundrw_)
then
418 a(ix^s)=wroe(ix^s,
mom(idim))+csound(ix^s)
419 jump(ix^s)=half*((wr(ix^s,
rho_)-wl(ix^s,
rho_))+&
420 wroe(ix^s,
rho_)/csound(ix^s)*(wr(ix^s,
mom(idim))/wr(ix^s,
rho_)-&
421 wl(ix^s,
mom(idim))/wl(ix^s,
rho_)))
422 else if (il == soundlw_)
then
423 a(ix^s)=wroe(ix^s,
mom(idim))-csound(ix^s)
424 jump(ix^s)=half*((wr(ix^s,
rho_)-wl(ix^s,
rho_))-&
425 wroe(ix^s,
rho_)/csound(ix^s)*(wr(ix^s,
mom(idim))/wr(ix^s,
rho_)-&
426 wl(ix^s,
mom(idim))/wl(ix^s,
rho_)))
429 idir=il-shearw0_;
if(idir>=idim)idir=idir+1
430 a(ix^s)=wroe(ix^s,
mom(idim))
431 jump(ix^s)=wroe(ix^s,
rho_)*(wr(ix^s,
mom(idir))/wr(ix^s,
rho_)-&
432 wl(ix^s,
mom(idir))/wl(ix^s,
rho_))
442 case(
'harten',
'powell')
444 if (il == soundrw_)
then
445 call eos%get_thermal_pressure(wl,x,ixg^
ll,ix^
l,tmp)
446 tmp(ix^s) =wl(ix^s,
mom(idim))/wl(ix^s,
rho_)&
447 + sqrt(eos%gamma*tmp(ix^s)/wl(ix^s,
rho_))
448 call eos%get_thermal_pressure(wr,x,ixg^
ll,ix^
l,tmp2)
449 tmp2(ix^s)=wr(ix^s,
mom(idim))/wr(ix^s,
rho_)&
450 + sqrt(eos%gamma*tmp2(ix^s)/wr(ix^s,
rho_))
451 else if (il == soundlw_)
then
452 call eos%get_thermal_pressure(wl,x,ixg^
ll,ix^
l,tmp)
453 tmp(ix^s) =wl(ix^s,
mom(idim))/wl(ix^s,
rho_)&
454 - sqrt(eos%gamma*tmp(ix^s)/wl(ix^s,
rho_))
455 call eos%get_thermal_pressure(wr,x,ixg^
ll,ix^
l,tmp2)
456 tmp2(ix^s)=wr(ix^s,
mom(idim))/wr(ix^s,
rho_)&
457 - sqrt(eos%gamma*tmp2(ix^s)/wr(ix^s,
rho_))
459 tmp(ix^s) =wl(ix^s,
mom(idim))/wl(ix^s,
rho_)
460 tmp2(ix^s)=wr(ix^s,
mom(idim))/wr(ix^s,
rho_)
466 end subroutine geteigenjump2_iso
468 subroutine hd_rtimes_iso(q,wroe,ix^L,iw,il,idim,rq,workroe)
474 integer,
intent(in) :: ix^
l,iw,il,idim
475 double precision,
intent(in) :: wroe(ixg^t,nw)
476 double precision,
intent(in) :: q(ixg^t)
477 double precision,
intent(inout) :: rq(ixg^t)
478 double precision,
intent(inout) :: workroe(ixg^t,
nworkroe)
481 call rtimes2_iso(q,wroe,ix^
l,iw,il,idim,rq,workroe(ixg^t,1))
483 end subroutine hd_rtimes_iso
485 subroutine rtimes2_iso(q,wroe,ix^L,iw,il,idim,rq,csound)
491 integer:: ix^
l,iw,il,idim,idir
492 double precision:: wroe(ixg^t,nw)
493 double precision,
dimension(ixG^T):: q,rq,csound
496 if (il == soundrw_ .or. il == soundlw_)
then
501 else if(iw==
mom(idim))
then
502 if (il == soundrw_)
then
503 rq(ix^s)=q(ix^s)*(wroe(ix^s,
mom(idim))+csound(ix^s))
504 else if (il == soundlw_)
then
505 rq(ix^s)=q(ix^s)*(wroe(ix^s,
mom(idim))-csound(ix^s))
510 if (il == soundrw_ .or. il == soundlw_)
then
511 rq(ix^s)=q(ix^s)*wroe(ix^s,iw)
514 idir=il-shearw0_;
if(idir>=idim)idir=idir+1
515 if(iw==
mom(idir))
then
523 end subroutine rtimes2_iso
Equation of state for AMRVAC, handled through a single eos_container object.
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, parameter d
double precision, dimension(:), allocatable entropycoef
character(len=std_len) typeaverage
Hydrodynamics physics module.
logical, public, protected hd_energy
Whether an energy equation is used.
integer, public, protected e_
Index of the energy density (-1 if not present)
integer, dimension(:), allocatable, public, protected mom
Indices of the momentum density.
integer, public, protected rho_
Whether plasma is partially ionized.
Module with Roe-type Riemann solver for hydrodynamics.
subroutine, public hd_roe_init()
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)