16  integer, 
public,
protected              :: 
rho_ 
   17  integer, 
public,
protected              :: 
d_  
   20  integer, 
allocatable, 
public, 
protected :: 
mom(:)
 
   23  integer, 
allocatable, 
public, 
protected :: 
tracer(:)
 
   26  integer, 
public,
protected              :: 
e_ 
   28  integer, 
public,
protected              :: 
p_ 
   31  integer, 
public,
protected     :: 
lfac_ 
   34  integer, 
public,
protected     :: 
xi_ 
   54  double precision, 
public         :: 
tolernr   = 1.0d-9
 
   55  double precision, 
public         :: 
dmaxvel   = 1.0d-7
 
   74  subroutine srhd_read_params(files)
 
   76    character(len=*), 
intent(in) :: files(:)
 
   84       open(
unitpar, file=trim(files(n)), status=
"old")
 
   85       read(
unitpar, srhd_list, 
end=111)
 
   89  end subroutine srhd_read_params
 
   92  subroutine srhd_write_info(fh)
 
   94    integer, 
intent(in)                 :: fh
 
   95    integer, 
parameter                  :: n_par = 1
 
   96    double precision                    :: values(n_par)
 
   97    character(len=name_len)             :: names(n_par)
 
   98    integer, 
dimension(MPI_STATUS_SIZE) :: st
 
  101    call mpi_file_write(fh, n_par, 1, mpi_integer, st, er)
 
  105    call mpi_file_write(fh, values, n_par, mpi_double_precision, st, er)
 
  106    call mpi_file_write(fh, names, n_par * name_len, mpi_character, st, er)
 
  108  end subroutine srhd_write_info
 
  118    physics_type = 
"srhd" 
  120    phys_total_energy  = .true.
 
  124    phys_internal_e = .false.
 
  125    phys_partial_ionization=.false.
 
  131    allocate(start_indices(number_species),stop_indices(number_species))
 
  140    mom(:) = var_set_momentum(
ndir)
 
  143    e_ = var_set_energy()
 
  147    call srhd_physical_units()
 
  153       tracer(itr) = var_set_fluxvar(
"trc", 
"trp", itr, need_bc=.false.)
 
  158    xi_  = var_set_auxvar(
'xi',
'xi')
 
  159    lfac_= var_set_auxvar(
'lfac',
'lfac')
 
  165    stop_indices(1)=nwflux
 
  168    if (.not. 
allocated(flux_type)) 
then 
  169       allocate(flux_type(
ndir, nw))
 
  170       flux_type = flux_default
 
  171    else if (any(shape(flux_type) /= [
ndir, nw])) 
then 
  172       call mpistop(
"phys_check error: flux_type has wrong shape")
 
  176    allocate(iw_vector(nvector))
 
  177    iw_vector(1) = 
mom(1) - 1
 
  180    phys_add_source          => srhd_add_source
 
  181    phys_get_dt              => srhd_get_dt
 
  183    phys_get_a2max           => srhd_get_a2max
 
  188    phys_get_cmax            => srhd_get_cmax
 
  189    phys_get_cbounds         => srhd_get_cbounds
 
  190    phys_get_flux            => srhd_get_flux
 
  191    phys_add_source_geom     => srhd_add_source_geom
 
  198    phys_get_v               => srhd_get_v
 
  199    phys_write_info          => srhd_write_info
 
  200    phys_handle_small_values => srhd_handle_small_values
 
 
  213            call mpistop (
"Error: srhd_gamma <= 0 or srhd_gamma == 1")
 
  221    call srhd_get_smallvalues_eos
 
  224       write(*,*)
'------------------------------------------------------------' 
  225       write(*,*)
'Using EOS set via srhd_eos=',
srhd_eos 
  226       write(*,*)
'Maximal lorentz factor (via dmaxvel) is=',
lfacmax 
  230       write(*,*)
'------------------------------------------------------------' 
 
  235  subroutine srhd_physical_units
 
  237    double precision :: mp,kb
 
  250       call mpistop(
"Abort: must set positive values for unit length and numberdensity")
 
  260  end subroutine srhd_physical_units
 
  265    logical, 
intent(in)          :: primitive
 
  266    integer, 
intent(in)          :: ixi^
l, ixo^
l 
  267    double precision, 
intent(in) :: w(ixi^s, nw)
 
  268    logical, 
intent(inout)       :: flag(ixi^s,1:nw)
 
  278       where(w(ixo^s,
e_) < 
small_e) flag(ixo^s,
e_) = .true.
 
 
  284  subroutine srhd_check_w_aux(ixI^L, ixO^L, w, flag)
 
  286    integer, 
intent(in)          :: ixi^
l, ixo^
l 
  287    double precision, 
intent(in) :: w(ixi^s, nw)
 
  288    logical, 
intent(inout)       :: flag(ixi^s,1:nw)
 
  293    where(w(ixo^s,
lfac_) < one) flag(ixo^s,
lfac_) = .true.
 
  295    if(any(flag(ixo^s,
xi_)))
then 
  296       write(*,*)
'auxiliary xi too low: abort' 
  297       call mpistop(
'auxiliary  check failed')
 
  299    if(any(flag(ixo^s,
lfac_)))
then 
  300       write(*,*)
'auxiliary lfac too low: abort' 
  301       call mpistop(
'auxiliary  check failed')
 
  304  end subroutine srhd_check_w_aux
 
  310    integer, 
intent(in)                :: ixi^
l, ixo^
l 
  311    double precision, 
intent(inout)    :: w(ixi^s, nw)
 
  312    double precision, 
dimension(ixO^S) :: rho,rhoh,pth
 
  315    rho(ixo^s)    = sum(w(ixo^s, 
mom(:))**2, dim=
ndim+1)
 
  316    w(ixo^s,
lfac_) = dsqrt(1.0d0+rho(ixo^s))
 
  318    rho(ixo^s)=w(ixo^s,
rho_)
 
  319    pth(ixo^s)=w(ixo^s,
p_)
 
  324    w(ixo^s,
xi_) = w(ixo^s,
lfac_)**2.0d0*rhoh(ixo^s)
 
 
  334    integer, 
intent(in)             :: ixi^
l,ixo^
l 
  335    double precision, 
intent(inout) :: w(ixi^s, nw)
 
  336    double precision, 
intent(in)    :: x(ixi^s, 1:
ndim)
 
  338    integer                        :: ix^
d,ierror,idir
 
  339    integer                        :: flag_error(ixo^s)
 
  340    double precision               :: ssqr
 
  343      {
do ix^db=ixomin^db,ixomax^db\}
 
  347          ssqr= ssqr+w(ix^
d,
mom(idir))**2
 
  350           print *,
'entering con2prim with', w(ix^
d,
lfac_),w(ix^
d,
xi_), &
 
  351                    w(ix^
d,
d_),ssqr,w(ix^
d,
e_)
 
  352           print *,
'in position',ix^
d,x(ix^
d,1:
ndim)
 
  358           print *,
'entering con2prim with', w(ix^
d,
lfac_),w(ix^
d,
xi_), &
 
  359                    w(ix^
d,
d_),ssqr,w(ix^
d,
e_)
 
  360           print *,
'in position',ix^
d,x(ix^
d,1:
ndim)
 
  365        call con2prim_eos(w(ix^
d,
lfac_),w(ix^
d,
xi_), &
 
  366                    w(ix^
d,
d_),ssqr,w(ix^
d,
e_),ierror)
 
  367        flag_error(ix^
d) = ierror
 
  370      {
do ix^db=ixomin^db,ixomax^db\}
 
  374          ssqr= ssqr+w(ix^
d,
mom(idir))**2
 
  377           print *,
'entering con2prim with', w(ix^
d,
lfac_),w(ix^
d,
xi_), &
 
  378                    w(ix^
d,
d_),ssqr,w(ix^
d,
e_)
 
  379           print *,
'in position',ix^
d,x(ix^
d,1:
ndim)
 
  385           print *,
'entering con2prim with', w(ix^
d,
lfac_),w(ix^
d,
xi_), &
 
  386                    w(ix^
d,
d_),ssqr,w(ix^
d,
e_)
 
  387           print *,
'in position',ix^
d,x(ix^
d,1:
ndim)
 
  393                    w(ix^
d,
d_),ssqr,w(ix^
d,
e_),ierror)
 
  394        flag_error(ix^
d) = ierror
 
  399     if(any(flag_error(ixo^s)/=0))
then 
  400         print *,flag_error(ixo^s)
 
  401         call mpistop(
'Problem when getting auxiliaries')
 
 
  411    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  412    double precision, 
intent(inout) :: w(ixi^s, nw)
 
  413    double precision, 
intent(in)    :: x(ixi^s, 1:
ndim)
 
  415    double precision, 
dimension(ixO^S) :: rhoh,rho,pth
 
  419    rhoh(ixo^s)    = sum(w(ixo^s, 
mom(:))**2, dim=
ndim+1)
 
  420    w(ixo^s,
lfac_) = dsqrt(1.0d0+rhoh(ixo^s))
 
  422    rho(ixo^s)=w(ixo^s,
rho_)
 
  423    pth(ixo^s)=w(ixo^s,
p_)
 
  428    rhoh(ixo^s)= rhoh(ixo^s)*w(ixo^s,
lfac_)
 
  430    w(ixo^s,
xi_) = w(ixo^s,
lfac_)*rhoh(ixo^s)
 
  433    w(ixo^s,
d_)=w(ixo^s,
lfac_)*rho(ixo^s)
 
  437       w(ixo^s, 
mom(idir)) = rhoh(ixo^s)*w(ixo^s, 
mom(idir))
 
  441    w(ixo^s,
e_) = w(ixo^s,
xi_)-pth(ixo^s)-w(ixo^s,
d_)
 
 
  452    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  453    double precision, 
intent(inout) :: w(ixi^s, nw)
 
  454    double precision, 
intent(in)    :: x(ixi^s, 1:
ndim)
 
  456    double precision, 
dimension(ixO^S) :: rho,rhoh,e
 
  457    double precision, 
dimension(ixI^S) :: pth
 
  458    character(len=30)                  :: subname_loc
 
  464    rho(ixo^s) = w(ixo^s,
d_)/w(ixo^s,
lfac_)
 
  468    rhoh(ixo^s) = w(ixo^s,
xi_)/w(ixo^s,
lfac_)**2.0d0
 
  469    call srhd_get_pressure_eos(ixi^
l,ixo^
l,rho,rhoh,pth,e)
 
  471    w(ixo^s,
rho_)=rho(ixo^s)
 
  474      w(ixo^s,
mom(idir)) = w(ixo^s,
lfac_)*w(ixo^s,
mom(idir))&
 
  477    w(ixo^s,
p_)=pth(ixo^s)
 
  481                               /(rho(ixo^s)*w(ixo^s,
lfac_))
 
 
  487  subroutine srhd_get_v(w,x,ixI^L,ixO^L,v)
 
  489    integer, 
intent(in)           :: ixi^
l, ixo^
l 
  490    double precision, 
intent(in)  :: w(ixi^s, nw), x(ixi^s,1:
ndim)
 
  491    double precision, 
intent(out) :: v(ixi^s,1:
ndir)
 
  496      v(ixo^s,idir) = w(ixo^s, 
mom(idir))/w(ixo^s,
xi_)
 
  499  end subroutine srhd_get_v
 
  504  subroutine srhd_get_csound2_rhoh(w,x,ixI^L,ixO^L,rhoh,csound2)
 
  506    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  507    double precision, 
intent(in)    :: w(ixi^s,nw),rhoh(ixo^s)
 
  508    double precision, 
intent(in)    :: x(ixi^s,1:
ndim)
 
  509    double precision, 
intent(out)   :: csound2(ixo^s)
 
  511    double precision                :: rho(ixo^s)
 
  514    call srhd_get_csound2_eos(ixi^
l,ixo^
l,rho,rhoh,csound2)
 
  516  end subroutine srhd_get_csound2_rhoh
 
  523    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  524    double precision, 
intent(inout) :: w(ixi^s,nw)
 
  525    double precision, 
intent(in)    :: x(ixi^s,1:
ndim)
 
  526    double precision, 
intent(out)   :: csound2(ixo^s)
 
  528    double precision                :: rho(ixo^s),rhoh(ixo^s)
 
  533    rho  = w(ixo^s,
d_)/w(ixo^s,
lfac_)
 
  534    rhoh = w(ixo^s,
xi_)/w(ixo^s,
lfac_)**2.0d0
 
  535    call srhd_get_csound2_eos(ixi^
l,ixo^
l,rho,rhoh,csound2)
 
 
  545    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  546    double precision, 
intent(in)    :: w(ixi^s, nw)
 
  547    double precision, 
intent(in)    :: x(ixi^s, 1:
ndim)
 
  548    double precision, 
intent(out)   :: pth(ixi^s)
 
  551    double precision             :: rho(ixo^s),rhoh(ixo^s),e(ixo^s)
 
  554    rho  = w(ixo^s,
d_)/w(ixo^s,
lfac_)
 
  555    rhoh = w(ixo^s,
xi_)/w(ixo^s,
lfac_)**2.0d0
 
  556    call srhd_get_pressure_eos(ixi^
l,ixo^
l,rho,rhoh,pth,e)
 
 
  562  subroutine srhd_add_source(qdt,dtfactor,ixI^L,ixO^L,wCT,wCTprim,w,x,qsourcesplit,active)
 
  565    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  566    double precision, 
intent(in)    :: qdt,dtfactor
 
  567    double precision, 
intent(in)    :: wct(ixi^s, 1:nw),wctprim(ixi^s,1:nw), x(ixi^s, 1:
ndim)
 
  568    double precision, 
intent(inout) :: w(ixi^s, 1:nw)
 
  569    logical, 
intent(in)             :: qsourcesplit
 
  570    logical, 
intent(inout)          :: active
 
  572  end subroutine srhd_add_source
 
  575  subroutine srhd_get_dt(w, ixI^L, ixO^L, dtnew, dx^D, x)
 
  578    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  579    double precision, 
intent(in)    :: 
dx^
d, x(ixi^s, 1:^nd)
 
  580    double precision, 
intent(in)    :: w(ixi^s, 1:nw)
 
  581    double precision, 
intent(inout) :: dtnew
 
  585  end subroutine srhd_get_dt
 
  589  subroutine srhd_get_cmax(w, x, ixI^L, ixO^L, idim, cmax)
 
  592    integer, 
intent(in)                       :: ixi^
l, ixo^
l, idim
 
  593    double precision, 
intent(in)              :: w(ixi^s, nw), x(ixi^s, 1:
ndim)
 
  594    double precision, 
intent(inout)           :: cmax(ixi^s)
 
  596    double precision :: wc(ixi^s,nw)
 
  597    double precision, 
dimension(ixO^S)        :: csound2,tmp1,tmp2,v2
 
  598    double precision, 
dimension(ixI^S)        :: vidim, cmin
 
  600    logical       :: flag(ixi^s,1:nw)
 
  608    tmp1(ixo^s)=wc(ixo^s,
xi_)/wc(ixo^s,
lfac_)**2.0d0
 
  609    v2(ixo^s)=1.0d0-1.0d0/wc(ixo^s,
lfac_)**2
 
  610    call srhd_get_csound2_rhoh(wc,x,ixi^
l,ixo^
l,tmp1,csound2)
 
  611    vidim(ixo^s) = wc(ixo^s, 
mom(idim))/wc(ixo^s, 
xi_)
 
  612    tmp2(ixo^s)=vidim(ixo^s)**2.0d0
 
  613    tmp1(ixo^s)=1.0d0-v2(ixo^s)*csound2(ixo^s) &
 
  614                        -tmp2(ixo^s)*(1.0d0-csound2(ixo^s))
 
  615    tmp2(ixo^s)=dsqrt(csound2(ixo^s)*(one-v2(ixo^s))*tmp1(ixo^s))
 
  616    tmp1(ixo^s)=vidim(ixo^s)*(one-csound2(ixo^s))
 
  617    cmax(ixo^s)=(tmp1(ixo^s)+tmp2(ixo^s))/(one-v2(ixo^s)*csound2(ixo^s))
 
  618    cmin(ixo^s)=(tmp1(ixo^s)-tmp2(ixo^s))/(one-v2(ixo^s)*csound2(ixo^s))
 
  620    cmin(ixo^s) = max(cmin(ixo^s), - 1.0d0)
 
  621    cmin(ixo^s) = min(cmin(ixo^s),   1.0d0)
 
  622    cmax(ixo^s) = max(cmax(ixo^s), - 1.0d0)
 
  623    cmax(ixo^s) = min(cmax(ixo^s),   1.0d0)
 
  625    cmax(ixo^s) = max(dabs(cmax(ixo^s)),dabs(cmin(ixo^s)))
 
  627  end subroutine srhd_get_cmax
 
  629  subroutine srhd_get_a2max(w,x,ixI^L,ixO^L,a2max)
 
  632    integer, 
intent(in)          :: ixi^
l, ixo^
l 
  633    double precision, 
intent(in) :: w(ixi^s, nw), x(ixi^s,1:
ndim)
 
  634    double precision, 
intent(inout) :: a2max(
ndim)
 
  635    double precision :: a2(ixi^s,
ndim,nw)
 
  636    integer :: gxo^
l,hxo^
l,jxo^
l,kxo^
l,i
 
  641      hxo^
l=ixo^
l-
kr(i,^
d);
 
  642      gxo^
l=hxo^
l-
kr(i,^
d);
 
  643      jxo^
l=ixo^
l+
kr(i,^
d);
 
  644      kxo^
l=jxo^
l+
kr(i,^
d);
 
  645      a2(ixo^s,i,1:nwflux)=dabs(-w(kxo^s,1:nwflux)+16.d0*w(jxo^s,1:nwflux)&
 
  646        -30.d0*w(ixo^s,1:nwflux)+16.d0*w(hxo^s,1:nwflux)-w(gxo^s,1:nwflux))
 
  647      a2max(i)=maxval(a2(ixo^s,i,1:nwflux))/12.d0/
dxlevel(i)**2
 
  650  end subroutine srhd_get_a2max
 
  653  subroutine srhd_get_cmax_loc(ixI^L,ixO^L,vidim,csound2,v2,cmax,cmin)
 
  655    integer, 
intent(in)          :: ixi^
l, ixo^
l 
  656    double precision, 
intent(in)             :: vidim(ixi^s)
 
  657    double precision, 
intent(in), 
dimension(ixO^S) :: csound2
 
  658    double precision, 
intent(in)             :: v2(ixi^s)
 
  659    double precision, 
intent(out)          :: cmax(ixi^s)
 
  660    double precision, 
intent(out)          :: cmin(ixi^s)
 
  662    double precision, 
dimension(ixI^S):: tmp1,tmp2
 
  664    tmp2(ixo^s)=vidim(ixo^s)**2.0d0
 
  665    tmp1(ixo^s)=1.0d0-v2(ixo^s)*csound2(ixo^s) &
 
  666                        -tmp2(ixo^s)*(1.0d0-csound2(ixo^s))
 
  667    tmp2(ixo^s)=dsqrt(csound2(ixo^s)*(one-v2(ixo^s))*tmp1(ixo^s))
 
  668    tmp1(ixo^s)=vidim(ixo^s)*(one-csound2(ixo^s))
 
  669    cmax(ixo^s)=(tmp1(ixo^s)+tmp2(ixo^s))/(one-v2(ixo^s)*csound2(ixo^s))
 
  671    cmax(ixo^s) = max(cmax(ixo^s), - 1.0d0)
 
  672    cmax(ixo^s) = min(cmax(ixo^s),   1.0d0)
 
  673    cmin(ixo^s)=(tmp1(ixo^s)-tmp2(ixo^s))/(one-v2(ixo^s)*csound2(ixo^s))
 
  675    cmin(ixo^s) = max(cmin(ixo^s), - 1.0d0)
 
  676    cmin(ixo^s) = min(cmin(ixo^s),   1.0d0)
 
  678  end subroutine srhd_get_cmax_loc
 
  682  subroutine srhd_get_cbounds(wLC,wRC,wLp,wRp,x,ixI^L,ixO^L,idim,Hspeed,cmax,cmin)
 
  686    integer, 
intent(in)             :: ixi^
l, ixo^
l, idim
 
  688    double precision, 
intent(in)    :: wlc(ixi^s, 
nw), wrc(ixi^s, 
nw)
 
  690    double precision, 
intent(in)    :: wlp(ixi^s, 
nw), wrp(ixi^s, 
nw)
 
  691    double precision, 
intent(in)    :: x(ixi^s, 1:
ndim)
 
  693    double precision, 
intent(inout), 
optional :: cmin(ixi^s,1:
number_species)
 
  696    double precision :: wmean(ixi^s,
nw)
 
  697    double precision, 
dimension(ixO^S) :: csound2,tmp1,tmp2,tmp3
 
  698    double precision, 
dimension(ixI^S) :: vidim,cmaxl,cmaxr,cminl,cminr,v2
 
  700    logical       :: flag(ixi^s,1:
nw)
 
  707      tmp2=wlp(ixo^s,
xi_)/wlp(ixo^s,
lfac_)**2.0d0
 
  709      call srhd_get_csound2_prim_eos(ixo^
l,tmp1,tmp2,tmp3,csound2)
 
  710      vidim(ixo^s) = wlp(ixo^s, 
mom(idim))/wlp(ixo^s, 
lfac_)
 
  711      v2(ixo^s) = 1.0d0-1.0d0/wlp(ixo^s,
lfac_)**2
 
  712      call srhd_get_cmax_loc(ixi^
l,ixo^
l,vidim,csound2,v2,cmaxl,cminl)
 
  717      tmp2=wrp(ixo^s,
xi_)/wrp(ixo^s,
lfac_)**2.0d0
 
  719      call srhd_get_csound2_prim_eos(ixo^
l,tmp1,tmp2,tmp3,csound2)
 
  720      vidim(ixo^s) = wrp(ixo^s, 
mom(idim))/wrp(ixo^s, 
lfac_)
 
  721      v2(ixo^s) = 1.0d0-1.0d0/wrp(ixo^s,
lfac_)**2
 
  722      call srhd_get_cmax_loc(ixi^
l,ixo^
l,vidim,csound2,v2,cmaxr,cminr)
 
  724      if(
present(cmin))
then 
  726        cmax(ixo^s,1)=max(cmaxl(ixo^s),cmaxr(ixo^s))
 
  727        cmin(ixo^s,1)=min(cminl(ixo^s),cminr(ixo^s))
 
  730        cmaxl(ixo^s)=max(cmaxl(ixo^s),dabs(cminl(ixo^s)))
 
  731        cmaxr(ixo^s)=max(cmaxr(ixo^s),dabs(cminr(ixo^s)))
 
  732        cmax(ixo^s,1)=max(cmaxl(ixo^s),cmaxr(ixo^s))
 
  740      tmp1=wmean(ixo^s,
xi_)/wmean(ixo^s,
lfac_)**2.0d0
 
  741      call srhd_get_csound2_rhoh(wmean,x,ixi^
l,ixo^
l,tmp1,csound2)
 
  742      vidim(ixo^s) = wmean(ixo^s, 
mom(idim))/wmean(ixo^s, 
xi_)
 
  743      v2(ixo^s)=1.0d0-1.0d0/wmean(ixo^s,
lfac_)**2
 
  744      call srhd_get_cmax_loc(ixi^
l,ixo^
l,vidim,csound2,v2,cmaxl,cminl)
 
  745      if(
present(cmin)) 
then 
  746        cmax(ixo^s,1)=cmaxl(ixo^s)
 
  747        cmin(ixo^s,1)=cminl(ixo^s)
 
  749        cmax(ixo^s,1)=max(cmaxl(ixo^s),dabs(cminl(ixo^s)))
 
  757      tmp1=wmean(ixo^s,
rho_)
 
  758      tmp2=wmean(ixo^s,
xi_)/wmean(ixo^s,
lfac_)**2.0d0
 
  760      call srhd_get_csound2_prim_eos(ixo^
l,tmp1,tmp2,tmp3,csound2)
 
  761      vidim(ixo^s) = wmean(ixo^s, 
mom(idim))/wmean(ixo^s, 
lfac_)
 
  762      v2(ixo^s) = 1.0d0-1.0d0/wmean(ixo^s,
lfac_)**2
 
  763      call srhd_get_cmax_loc(ixi^
l,ixo^
l,vidim,csound2,v2,cmaxl,cminl)
 
  764      if(
present(cmin)) 
then 
  765        cmax(ixo^s,1)=cmaxl(ixo^s)
 
  766        cmin(ixo^s,1)=cminl(ixo^s)
 
  768        cmax(ixo^s,1)=max(cmaxl(ixo^s),dabs(cminl(ixo^s)))
 
  772  end subroutine srhd_get_cbounds
 
  775  subroutine srhd_get_flux(wC,wP,x,ixI^L,ixO^L,idim,f)
 
  777    integer, 
intent(in)          :: ixi^
l, ixo^
l, idim
 
  779    double precision, 
intent(in) :: wc(ixi^s,nw)
 
  781    double precision, 
intent(in) :: wp(ixi^s,nw)
 
  782    double precision, 
intent(in) :: x(ixi^s,1:
ndim)
 
  783    double precision,
intent(out) :: f(ixi^s,nwflux)
 
  785    double precision             :: pth(ixi^s)
 
  786    double precision             :: v(ixi^s,1:
ndir)
 
  789    pth(ixo^s)=wp(ixo^s,
p_)
 
  791      v(ixo^s,idir) = wp(ixo^s, 
mom(idir))/wp(ixo^s,
lfac_)
 
  795    f(ixo^s,
d_)=v(ixo^s,idim)*wc(ixo^s,
rho_)
 
  805      f(ixo^s,
mom(idir))= v(ixo^s,idim)*wc(ixo^s,
mom(idir))
 
  807    f(ixo^s,
mom(idim))=pth(ixo^s)+f(ixo^s,
mom(idim))
 
  811    f(ixo^s,
e_)=v(ixo^s,idim)*(wc(ixo^s,
e_) + pth(ixo^s))
 
  813  end subroutine srhd_get_flux
 
  816  subroutine srhd_add_source_geom(qdt, dtfactor, ixI^L, ixO^L, wCT, wprim, w, x)
 
  820    integer, 
intent(in)             :: ixi^
l, ixo^
l 
  821    double precision, 
intent(in)    :: qdt, dtfactor, x(ixi^s, 1:
ndim)
 
  822    double precision, 
intent(inout) :: wct(ixi^s, 1:nw), wprim(ixi^s, 1:nw), w(ixi^s, 1:nw)
 
  824    double precision :: pth(ixi^s), 
source(ixi^s), v(ixi^s,1:
ndir)
 
  825    integer                         :: idir, h1x^
l{^nooned, h2x^
l}
 
  827    double precision :: exp_factor(ixi^s), del_exp_factor(ixi^s), exp_factor_primitive(ixi^s)
 
  838      source(ixo^s) = 
source(ixo^s)*del_exp_factor(ixo^s)/exp_factor(ixo^s)
 
  849             w(ixo^s, mr_) = w(ixo^s, mr_) + qdt * 
source(ixo^s) / x(ixo^s, 
r_)
 
  850             source(ixo^s) = -wct(ixo^s, mphi_) * wprim(ixo^s,
mom(
r_))
 
  851             w(ixo^s, mphi_) = w(ixo^s, mphi_) + qdt * 
source(ixo^s) / x(ixo^s, 
r_)
 
  853             w(ixo^s, mr_) = w(ixo^s, mr_) + qdt * 
source(ixo^s) / x(ixo^s, 
r_)
 
  858       h1x^
l=ixo^
l-
kr(1,^
d); {^nooned h2x^
l=ixo^
l-
kr(2,^
d);}
 
  863       source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
 
  864            *(
block%surfaceC(ixo^s, 1) - 
block%surfaceC(h1x^s, 1)) &
 
  865            /
block%dvolume(ixo^s)
 
  871       w(ixo^s, mr_) = w(ixo^s, mr_) + qdt * 
source(ixo^s) / x(ixo^s, 1)
 
  875       source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
 
  876            * (
block%surfaceC(ixo^s, 2) - 
block%surfaceC(h2x^s, 2)) &
 
  877            / 
block%dvolume(ixo^s)
 
  882       w(ixo^s, 
mom(2)) = w(ixo^s, 
mom(2)) + qdt * 
source(ixo^s) / x(ixo^s, 1)
 
  886         source(ixo^s) = -(wct(ixo^s, 
mom(3)) * wprim(ixo^s, 
mom(1))) &
 
  887                        - (wct(ixo^s, 
mom(3)) * wprim(ixo^s, 
mom(2))) / dtan(x(ixo^s, 2))
 
  888         w(ixo^s, 
mom(3)) = w(ixo^s, 
mom(3)) + qdt * 
source(ixo^s) / x(ixo^s, 1)
 
  893  end subroutine srhd_add_source_geom
 
  896  subroutine srhd_handle_small_values(primitive, w, x, ixI^L, ixO^L, subname)
 
  899    logical, 
intent(in)             :: primitive
 
  900    integer, 
intent(in)             :: ixi^
l,ixo^
l 
  901    double precision, 
intent(inout) :: w(ixi^s,1:nw)
 
  902    double precision, 
intent(in)    :: x(ixi^s,1:
ndim)
 
  903    character(len=*), 
intent(in)    :: subname
 
  906    logical :: flag(ixi^s,1:nw),flagall(ixi^s)
 
  914        flagall(ixo^s)=(flag(ixo^s,
rho_).or.flag(ixo^s,
e_)) 
 
  916        where(flagall(ixo^s))
 
  928            where(flagall(ixo^s)) w(ixo^s, 
e_) = 
small_e  
  948        if(.not.primitive) 
then 
  950          write(*,*) 
"handle_small_values default: note reporting conservatives!" 
  956  end subroutine srhd_handle_small_values
 
  966    integer, 
intent(in)                :: ixi^
l,ixo^
l 
  967    double precision, 
intent(in)       :: w(ixi^s, 1:nw)
 
  968    logical, 
intent(in)                :: varconserve
 
  969    double precision, 
intent(out)      :: geff(ixi^s)
 
  971    double precision, 
dimension(ixO^S) :: pth,rho,e_th,e
 
  974      if (varconserve) 
then 
  975        pth(ixo^s)=w(ixo^s,
xi_)-w(ixo^s,
e_)-w(ixo^s,
d_)
 
  976        rho(ixo^s)=w(ixo^s,
d_)/w(ixo^s,
lfac_)
 
  978        e    = e_th+dsqrt(e_th**2+rho**2)
 
  980                             (one-(rho(ixo^s)/e(ixo^s))**2)
 
  984        e    = e_th+dsqrt(e_th**2+w(ixo^s,
rho_)**2)
 
  986                             (one-(w(ixo^s,
rho_)/e(ixo^s))**2)
 
 
  995  subroutine srhd_get_smallvalues_eos
 
  999    double precision :: lsmalle,lsmallp,lsmallrho
 
 1006       call mpistop(
"must set finite values small-density/pressure for small value treatments")
 
 1016                      gamma_1*lsmallrho*(lsmallrho/lsmalle))
 
 1025  end subroutine srhd_get_smallvalues_eos
 
 1030    integer, 
intent(in)                :: ixo^
l 
 1031    double precision, 
intent(in)       :: rho(ixo^s),p(ixo^s)
 
 1032    double precision, 
intent(out)      :: rhoh(ixo^s)
 
 1034    double precision, 
dimension(ixO^S) :: e_th,e
 
 1039     e    = e_th+dsqrt(e_th**2+rho**2)
 
 1048      {
do ix^db= ixo^lim^db\}
 
 1050           write(*,*) 
"local pressure and density",p(ix^
d),rho(ix^
d)
 
 1051           write(*,*) 
"Error: small value of enthalpy rho*h=",rhoh(ix^
d),&
 
 1052                " encountered when call srhd_get_enthalpy_eos" 
 1053           call mpistop(
'enthalpy below small_xi: stop (may need to turn on fixes)')
 
 1059      {
do ix^db= ixo^lim^db\}
 
 
 1070  subroutine srhd_get_pressure_eos(ixI^L,ixO^L,rho,rhoh,p,E)
 
 1072    integer, 
intent(in)            :: ixi^
l, ixo^
l 
 1073    double precision, 
intent(in)   :: rho(ixo^s),rhoh(ixo^s)
 
 1074    double precision, 
intent(out)  :: p(ixi^s)
 
 1075    double precision, 
intent(out)  :: e(ixo^s)
 
 1079     e = (rhoh+dsqrt(rhoh**2+(
srhd_gamma**2-one)*rho**2)) &
 
 1081     p(ixo^s) = half*
gamma_1* (e-rho*(rho/e))
 
 1087      {
do ix^db= ixo^lim^db\}
 
 1089           write(*,*) 
"local enthalpy rho*h and density rho",rhoh(ix^
d),rho(ix^
d)
 
 1090           if(
srhd_eos) 
write(*,*) 
'E, rho^2/E, difference', &
 
 1091                       e(ix^
d),rho(ix^
d)**2/e(ix^
d),e(ix^
d)-rho(ix^
d)**2/e(ix^
d)
 
 1092           write(*,*) 
"Error: small value of gas pressure",p(ix^
d),&
 
 1093                " encountered when call srhd_get_pressure_eos" 
 1094           call mpistop(
'pressure below small_pressure: stop (may need to turn on fixes)')
 
 1100      {
do ix^db= ixo^lim^db\}
 
 1108  end subroutine srhd_get_pressure_eos
 
 1112  subroutine srhd_get_csound2_eos(ixI^L,ixO^L,rho,rhoh,csound2)
 
 1114    integer, 
intent(in)             :: ixi^
l, ixo^
l 
 1115    double precision, 
intent(in)    :: rho(ixo^s),rhoh(ixo^s)
 
 1116    double precision, 
intent(out)   :: csound2(ixo^s)
 
 1118    double precision                :: p(ixi^s)
 
 1119    double precision                :: e(ixo^s)
 
 1122    call srhd_get_pressure_eos(ixi^
l,ixo^
l,rho,rhoh,p,e)
 
 1125                          +
gamma_1*(rho(ixo^s)/e(ixo^s))**2))&
 
 1126                      /(2.0d0*rhoh(ixo^s))
 
 1128       csound2(ixo^s)=
srhd_gamma*p(ixo^s)/rhoh(ixo^s)
 
 1132      {
do ix^db= ixo^lim^db\}
 
 1133         if(csound2(ix^
d)>=1.0d0.or.csound2(ix^
d)<=0.0d0) 
then 
 1134           write(*,*) 
"sound speed error with p - rho - rhoh",p(ix^
d),rhoh(ix^
d),rho(ix^
d)
 
 1135           if(
srhd_eos) 
write(*,*) 
'and E', e(ix^
d)
 
 1136           write(*,*) 
"Error: value of csound2",csound2(ix^
d),&
 
 1137                " encountered when call srhd_get_csound2_eos" 
 1138           call mpistop(
'sound speed stop (may need to turn on fixes)')
 
 1144      {
do ix^db= ixo^lim^db\}
 
 1145         if(csound2(ix^
d)>=1.0d0) 
then 
 1146            csound2(ix^
d)=1.0d0-1.0d0/
lfacmax**2
 
 1148         if(csound2(ix^
d)<=0.0d0) 
then 
 1154  end subroutine srhd_get_csound2_eos
 
 1158  subroutine srhd_get_csound2_prim_eos(ixO^L,rho,rhoh,p,csound2)
 
 1160    integer, 
intent(in)             :: ixo^
l 
 1161    double precision, 
intent(in)    :: rho(ixo^s),rhoh(ixo^s),p(ixo^s)
 
 1162    double precision, 
intent(out)   :: csound2(ixo^s)
 
 1164    double precision                :: e(ixo^s)
 
 1178      {
do ix^db= ixo^lim^db\}
 
 1179         if(csound2(ix^
d)>=1.0d0.or.csound2(ix^
d)<=0.0d0) 
then 
 1180           write(*,*) 
"sound speed error with p - rho - rhoh",p(ix^
d),rhoh(ix^
d),rho(ix^
d)
 
 1181           if(
srhd_eos) 
write(*,*) 
'and E', e(ix^
d)
 
 1182           write(*,*) 
"Error: value of csound2",csound2(ix^
d),&
 
 1183                " encountered when call srhd_get_csound2_prim_eos" 
 1184           call mpistop(
'sound speed stop (may need to turn on fixes)')
 
 1190      {
do ix^db= ixo^lim^db\}
 
 1191         if(csound2(ix^
d)>=1.0d0) 
then 
 1192            csound2(ix^
d)=1.0d0-1.0d0/
lfacmax**2
 
 1194         if(csound2(ix^
d)<=0.0d0) 
then 
 1200  end subroutine srhd_get_csound2_prim_eos
 
 1203  subroutine con2prim_eos(lfac,xi,myd,myssqr,mytau,ierror)
 
 1206    double precision, 
intent(in)    :: myd, myssqr, mytau
 
 1207    double precision, 
intent(inout) :: lfac, xi
 
 1208    integer, 
intent(inout)          :: ierror
 
 1211    double precision:: f,df,lfacl
 
 1215    d = myd; 
ssqr = myssqr; 
tau = mytau; 
 
 1221    call funcd_eos(xi,f,df,lfacl,
d,
ssqr,
tau,ierror)
 
 1222    if (ierror == 0 .and. dabs(f/df)<
absaccnr) 
then 
 1230      write(*,*)
'entering con2prim_eos with xi=',xi
 
 1239    call con2primhydro_eos(lfac,xi,
d,
ssqr,
tau,ierror)
 
 1241  end subroutine con2prim_eos
 
 1243  subroutine funcd_eos(xi,f,df,mylfac,d,ssqr,tau,ierror)
 
 1244    double precision, 
intent(in)  :: xi,d,ssqr,tau
 
 1245    double precision, 
intent(out) :: f,df,mylfac
 
 1246    integer, 
intent(inout)        :: ierror
 
 1249    double precision  :: dlfac
 
 1250    double precision  :: vsqr,p,dpdxi
 
 1256       mylfac = one/dsqrt(one-vsqr)
 
 1257       dlfac = -mylfac**3*ssqr/(xi**3)
 
 1259       call funcpressure_eos(xi,mylfac,d,dlfac,p,dpdxi)
 
 1270  end subroutine funcd_eos
 
 1273  subroutine con2primhydro_eos(lfac,xi,d,sqrs,tau,ierror)
 
 1274    double precision, 
intent(out) :: xi,lfac
 
 1275    double precision, 
intent(in)  :: d,sqrs,tau
 
 1276    integer,
intent(inout)         :: ierror
 
 1279    integer          :: ni,niiter,nit,n2it,ni3
 
 1280    double precision :: pcurrent,pnew
 
 1281    double precision :: er,er1,ff,df,dp,v2
 
 1282    double precision :: pmin,lfac2inv,plabs,prabs,pprev
 
 1283    double precision :: s2overcubeg2rh
 
 1284    double precision :: xicurrent,h,dhdp
 
 1285    double precision :: oldff1,oldff2,nff
 
 1286    double precision :: pleft,pright
 
 1301    pmin=dsqrt(sqrs)/(one-
dmaxvel)-tau-d
 
 1302    plabs=max(
minp,pmin)
 
 1321          pcurrent=half*(pcurrent+pprev)
 
 1329       xicurrent=tau+d+pcurrent
 
 1341       v2=sqrs/xicurrent**2
 
 1343       if(lfac2inv>zero) 
then 
 1344          lfac=one/dsqrt(lfac2inv)
 
 1356       s2overcubeg2rh=sqrs/(xicurrent**3)
 
 1358       call funcenthalpy_eos(pcurrent,lfac2inv,d,sqrs,xicurrent,&
 
 1359                          s2overcubeg2rh,h,dhdp)
 
 1361       ff=-xicurrent*lfac2inv + h
 
 1362       df=- two*sqrs/xicurrent**2  + dhdp - lfac2inv
 
 1364       if (ff*df==zero) 
then 
 1374          if (ff*df>zero) 
then 
 1377             pnew=max(pnew,plabs)
 
 1381             pnew=min(pnew,prabs)
 
 1387       er=two*dabs(dp)/(pnew+pcurrent)
 
 1393       if((dabs(oldff2-ff) < 1.0d-8 .or. niiter >= 
maxitnr-
maxitnr/20).and.&
 
 1394            ff * oldff1 < zero    .and.  dabs(ff)>
absaccnr)
then 
 1397          if(n2it<=3) pcurrent=half*(pnew+pcurrent)
 
 1401             pcurrent=half*(pleft+pright)
 
 1404                xicurrent=tau+d+pcurrent
 
 1405                v2=sqrs/xicurrent**2
 
 1408                if(lfac2inv>zero)
then 
 1409                   lfac=one/dsqrt(lfac2inv)
 
 1417                call bisection_enthalpy_eos(pnew,lfac2inv,d,xicurrent,h)
 
 1418                nff=-xicurrent*lfac2inv + h
 
 1421                if(ff * nff < zero)
then 
 1427                pcurrent=half*(pleft+pright)
 
 1431                if(2.0d0*dabs(pleft-pright)/(pleft+pright)< 
absaccnr &
 
 1465    if(pcurrent<
minp) 
then 
 1472    v2=sqrs/xicurrent**2
 
 1474    if(lfac2inv>zero) 
then 
 1475       lfac=one/dsqrt(lfac2inv)
 
 1481  end subroutine con2primhydro_eos
 
 1485  subroutine funcpressure_eos(xicurrent,lfac,d,dlfacdxi,p,dpdxi)
 
 1487    double precision, 
intent(in)         :: xicurrent,lfac,d,dlfacdxi
 
 1488    double precision, 
intent(out)        :: p,dpdxi
 
 1490    double precision                     :: rho,h,e,dhdxi,rhotoe
 
 1491    double precision                     :: dpdchi,dedxi
 
 1494    h=xicurrent/(lfac**2)
 
 1496    e = (h+dsqrt(h**2+(
srhd_gamma**2-one)*rho**2)) &
 
 1500    p = half*
gamma_1*(e-rho*rhotoe)
 
 1502    dhdxi = one/(lfac**2)-2.0d0*xicurrent/(lfac**2)*dlfacdxi/lfac
 
 1504    dedxi=(dhdxi+(h*dhdxi-(
srhd_gamma**2-one)*rho**2*dlfacdxi/lfac)&
 
 1509    dpdxi=half*
gamma_1*(2.0d0*rho*rhotoe*dlfacdxi/lfac+&
 
 1510          (one+rhotoe**2)*dedxi)
 
 1512  end subroutine funcpressure_eos
 
 1516  subroutine funcenthalpy_eos(pcurrent,lfac2inv,d,sqrs,xicurrent,dv2d2p,h,dhdp)
 
 1518    double precision, 
intent(in) :: pcurrent,lfac2inv,d,sqrs,xicurrent,dv2d2p
 
 1519    double precision, 
intent(out):: h,dhdp
 
 1522    double precision:: rho,e_th,e,de_thdp,dedp
 
 1524    rho=d*dsqrt(lfac2inv)
 
 1526    e = (e_th + dsqrt(e_th**2+rho**2))
 
 1532    dedp = de_thdp * (one+e_th/dsqrt(e_th**2+rho**2))&
 
 1533              +  d**2*dv2d2p/dsqrt(e_th**2+rho**2)
 
 1536              gamma_1*(rho*(rho/e))*(-2.0d0*dv2d2p/lfac2inv+dedp/e))
 
 1537  end subroutine funcenthalpy_eos
 
 1541  subroutine bisection_enthalpy_eos(pcurrent,lfac2inv,d,xicurrent,h)
 
 1543    double precision, 
intent(in) :: pcurrent,lfac2inv,d,xicurrent
 
 1544    double precision, 
intent(out):: h
 
 1547    double precision:: rho,e_th,e
 
 1549    rho=d*dsqrt(lfac2inv)
 
 1551    e = (e_th + dsqrt(e_th**2+rho**2))
 
 1556  end subroutine bisection_enthalpy_eos
 
 1559  subroutine con2prim(lfac,xi,myd,myssqr,mytau,ierror)
 
 1562    double precision, 
intent(in)    :: myd, myssqr, mytau
 
 1563    double precision, 
intent(inout) :: lfac, xi
 
 1564    integer, 
intent(inout)          :: ierror
 
 1567    double precision:: f,df,lfacl
 
 1571    d = myd; 
ssqr = myssqr; 
tau = mytau; 
 
 1577    call funcd(xi,f,df,lfacl,
d,
ssqr,
tau,ierror)
 
 1578    if (ierror == 0 .and. dabs(f/df)<
absaccnr) 
then 
 1586       write(*,*) 
'entering con2prim with xi=',xi
 
 1595    call con2primhydro(lfac,xi,
d,
ssqr,
tau,ierror)
 
 1597  end subroutine con2prim
 
 1599  subroutine funcd(xi,f,df,mylfac,d,ssqr,tau,ierror)
 
 1600    double precision, 
intent(in)  :: xi,d,ssqr,tau
 
 1601    double precision, 
intent(out) :: f,df,mylfac
 
 1602    integer, 
intent(inout)        :: ierror
 
 1605    double precision  :: dlfac
 
 1606    double precision  :: vsqr,p,dpdxi
 
 1612       mylfac = one/dsqrt(one-vsqr)
 
 1613       dlfac = -mylfac**3*ssqr/(xi**3)
 
 1615       call funcpressure(xi,mylfac,d,dlfac,p,dpdxi)
 
 1626  end subroutine funcd
 
 1629  subroutine con2primhydro(lfac,xi,d,sqrs,tau,ierror)
 
 1630    double precision, 
intent(out) :: xi,lfac
 
 1631    double precision, 
intent(in)  :: d,sqrs,tau
 
 1632    integer,
intent(inout)         :: ierror
 
 1635    integer          :: ni,niiter,nit,n2it,ni3
 
 1636    double precision :: pcurrent,pnew
 
 1637    double precision :: er,er1,ff,df,dp,v2
 
 1638    double precision :: pmin,lfac2inv,plabs,prabs,pprev
 
 1639    double precision :: s2overcubeg2rh
 
 1640    double precision :: xicurrent,h,dhdp
 
 1641    double precision :: oldff1,oldff2,nff
 
 1642    double precision :: pleft,pright
 
 1657    pmin=dsqrt(sqrs)/(one-
dmaxvel)-tau-d
 
 1658    plabs=max(
minp,pmin)
 
 1677          pcurrent=half*(pcurrent+pprev)
 
 1685       xicurrent=tau+d+pcurrent
 
 1697       v2=sqrs/xicurrent**2
 
 1699       if(lfac2inv>zero) 
then 
 1700          lfac=one/dsqrt(lfac2inv)
 
 1712       s2overcubeg2rh=sqrs/(xicurrent**3)
 
 1714       call funcenthalpy(pcurrent,lfac2inv,d,sqrs,xicurrent,&
 
 1715                          s2overcubeg2rh,h,dhdp)
 
 1717       ff=-xicurrent*lfac2inv + h
 
 1718       df=- two*sqrs/xicurrent**2  + dhdp - lfac2inv
 
 1720       if (ff*df==zero) 
then 
 1730          if (ff*df>zero) 
then 
 1733             pnew=max(pnew,plabs)
 
 1737             pnew=min(pnew,prabs)
 
 1743       er=two*dabs(dp)/(pnew+pcurrent)
 
 1749       if((dabs(oldff2-ff) < 1.0d-8 .or. niiter >= 
maxitnr-
maxitnr/20).and.&
 
 1750            ff * oldff1 < zero    .and.  dabs(ff)>
absaccnr)
then 
 1753          if(n2it<=3) pcurrent=half*(pnew+pcurrent)
 
 1757             pcurrent=half*(pleft+pright)
 
 1760                xicurrent=tau+d+pcurrent
 
 1761                v2=sqrs/xicurrent**2
 
 1764                if(lfac2inv>zero)
then 
 1765                   lfac=one/dsqrt(lfac2inv)
 
 1773                call bisection_enthalpy(pnew,lfac2inv,d,xicurrent,h)
 
 1774                nff=-xicurrent*lfac2inv + h
 
 1777                if(ff * nff < zero)
then 
 1783                pcurrent=half*(pleft+pright)
 
 1787                if(2.0d0*dabs(pleft-pright)/(pleft+pright)< 
absaccnr &
 
 1821    if(pcurrent<
minp) 
then 
 1828    v2=sqrs/xicurrent**2
 
 1830    if(lfac2inv>zero) 
then 
 1831       lfac=one/dsqrt(lfac2inv)
 
 1837  end subroutine con2primhydro
 
 1841  subroutine funcpressure(xicurrent,lfac,d,dlfacdxi,p,dpdxi)
 
 1843    double precision, 
intent(in)         :: xicurrent,lfac,d,dlfacdxi
 
 1844    double precision, 
intent(out)        :: p,dpdxi
 
 1846    double precision                     :: rho,h,e,dhdxi,rhotoe
 
 1847    double precision                     :: dpdchi,dedxi
 
 1850    h=xicurrent/(lfac**2)
 
 1855    dpdxi = dpdchi * one/lfac**2
 
 1857    if (dlfacdxi /= 0.0d0) &
 
 1858          dpdxi = dpdxi  + dpdchi * ((d*lfac-2.0d0*xicurrent)/lfac**3) * dlfacdxi
 
 1860  end subroutine funcpressure
 
 1864  subroutine funcenthalpy(pcurrent,lfac2inv,d,sqrs,xicurrent,dv2d2p,h,dhdp)
 
 1866    double precision, 
intent(in) :: pcurrent,lfac2inv,d,sqrs,xicurrent,dv2d2p
 
 1867    double precision, 
intent(out):: h,dhdp
 
 1870    double precision:: rho,e_th,e,de_thdp,dedp
 
 1872    rho=d*dsqrt(lfac2inv)
 
 1875  end subroutine funcenthalpy
 
 1879  subroutine bisection_enthalpy(pcurrent,lfac2inv,d,xicurrent,h)
 
 1881    double precision, 
intent(in) :: pcurrent,lfac2inv,d,xicurrent
 
 1882    double precision, 
intent(out):: h
 
 1885    double precision:: rho,e_th,e
 
 1887    rho=d*dsqrt(lfac2inv)
 
 1891  end subroutine bisection_enthalpy
 
Calculate w(iw)=w(iw)+qdt*SOURCE[wCT,qtC,x] within ixO for all indices iw=iwmin......
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
Module for physical and numeric constants.
Module with geometry-related routines (e.g., divergence, curl)
integer, parameter spherical
integer, parameter cylindrical
integer, parameter cartesian_expansion
This module contains definitions of global parameters and variables and some generic functions/subrou...
type(state), pointer block
Block pointer for using one block and its previous state.
double precision small_pressure
double precision unit_time
Physical scaling factor for time.
double precision unit_density
Physical scaling factor for density.
integer, parameter unitpar
file handle for IO
double precision unit_mass
Physical scaling factor for mass.
integer, dimension(3, 3) kr
Kronecker delta tensor.
double precision unit_numberdensity
Physical scaling factor for number density.
double precision unit_pressure
Physical scaling factor for pressure.
integer, parameter ndim
Number of spatial dimensions for grid variables.
double precision unit_length
Physical scaling factor for length.
logical use_particles
Use particles module or not.
character(len=std_len), dimension(:), allocatable par_files
Which par files are used as input.
integer mype
The rank of the current MPI task.
double precision, dimension(:), allocatable, parameter d
integer ndir
Number of spatial dimensions (components) for vector variables.
double precision unit_velocity
Physical scaling factor for velocity.
double precision unit_temperature
Physical scaling factor for temperature.
logical si_unit
Use SI units (.true.) or use cgs units (.false.)
double precision, dimension(:,:), allocatable dx
spatial steps for all dimensions at all levels
logical phys_trac
Use TRAC for MHD or 1D HD.
logical fix_small_values
fix small values with average or replace methods
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
double precision small_density
integer r_
Indices for cylindrical coordinates FOR TESTS, negative value when not used:
integer boundspeed
bound (left/min and right.max) speed of Riemann fan
logical check_small_values
check and optionally fix unphysical small values (density, gas pressure)
Module containing all the particle routines.
subroutine particles_init()
Initialize particle data and parameters.
This module defines the procedures of a physics module. It contains function pointers for the various...
Module for handling problematic values in simulations, such as negative pressures.
subroutine, public small_values_average(ixil, ixol, w, x, w_flag, windex)
logical, public trace_small_values
trace small values in the source file using traceback flag of compiler
subroutine, public small_values_error(wprim, x, ixil, ixol, w_flag, subname)
character(len=20), public small_values_method
How to handle small values.
Special Relativistic Hydrodynamics (with EOS) physics module.
subroutine, public srhd_get_auxiliary(ixil, ixol, w, x)
Compute auxiliary variables lfac and xi from a conservative state using srhd_con2prim to calculate en...
double precision, public tolernr
integer, public, protected srhd_n_tracer
Number of tracer species.
double precision, public inv_gamma_1
subroutine, public srhd_get_geff_eos(w, ixil, ixol, varconserve, geff)
calculate effective gamma
integer, dimension(:), allocatable, public, protected tracer
Indices of the tracers.
double precision, public absaccnr
double precision, public small_e
The smallest allowed energy.
integer, public, protected lfac_
Index of the Lorentz factor.
subroutine, public srhd_get_enthalpy_eos(ixol, rho, p, rhoh)
Compute the enthalpy rho*h from rho and pressure p.
subroutine, public srhd_get_auxiliary_prim(ixil, ixol, w)
Set auxiliary variables lfac and xi from a primitive state only used when handle_small_values average...
double precision, public gamma_to_gamma_1
integer, public maxitnr
parameters for NR in con2prim
subroutine, public srhd_phys_init()
Initialize the module.
double precision, public gamma_1
double precision, public, protected he_abundance
Helium abundance over Hydrogen.
double precision, public small_xi
The smallest allowed inertia.
integer, dimension(:), allocatable, public, protected mom
Indices of the momentum density.
subroutine, public srhd_get_pthermal(w, x, ixil, ixol, pth)
Calculate thermal pressure p within ixO^L must follow after update conservative with auxiliaries.
double precision, public minp
logical, public srhd_eos
Whether synge eos is used.
double precision, public lfacmax
integer, public, protected d_
subroutine, public srhd_check_w(primitive, ixil, ixol, w, flag)
Returns logical argument flag T where values are not ok.
subroutine, public srhd_to_conserved(ixil, ixol, w, x)
Transform primitive variables into conservative ones.
subroutine, public srhd_check_params
integer, public, protected p_
Index of the gas pressure should equal e_.
subroutine, public srhd_to_primitive(ixil, ixol, w, x)
Transform conservative variables into primitive ones.
logical, public, protected srhd_particles
Whether particles module is added.
double precision, public smalltau
double precision, public dmaxvel
integer, public, protected e_
Index of the energy density.
double precision, public minrho
double precision, public smallxi
integer, public, protected xi_
Index of the inertia.
double precision, public srhd_gamma
The adiabatic index and derived values.
integer, public, protected rho_
Index of the density (in the w array)
subroutine, public srhd_get_csound2(w, x, ixil, ixol, csound2)
Calculate the square of the thermal sound speed csound2 within ixO^L. here computed from conservative...
Module with all the methods that users can customize in AMRVAC.
procedure(set_surface), pointer usr_set_surface
integer nw
Total number of variables.
integer number_species
number of species: each species has different characterictic speeds and should be used accordingly in...
integer nwflux
Number of flux variables.