24 logical,
public,
protected ::
hd_dust = .false.
48 integer,
public,
protected ::
rho_
51 integer,
allocatable,
public,
protected ::
mom(:)
54 integer,
allocatable,
public,
protected ::
tracer(:)
57 integer,
public,
protected ::
e_
60 integer,
public,
protected ::
p_
63 integer,
public,
protected ::
te_
69 double precision,
public ::
hd_gamma = 5.d0/3.0d0
75 double precision,
protected :: small_e
78 logical,
public,
protected ::
hd_trac = .false.
88 double precision,
public,
protected ::
h_ion_fr=1d0
91 double precision,
public,
protected ::
he_ion_fr=1d0
98 double precision,
public,
protected ::
rr=1d0
118 subroutine hd_read_params(files)
120 character(len=*),
intent(in) :: files(:)
129 do n = 1,
size(files)
130 open(
unitpar, file=trim(files(n)), status=
"old")
131 read(
unitpar, hd_list,
end=111)
135 end subroutine hd_read_params
140 integer,
intent(in) :: fh
141 integer,
parameter :: n_par = 1
142 double precision :: values(n_par)
143 character(len=name_len) :: names(n_par)
144 integer,
dimension(MPI_STATUS_SIZE) :: st
147 call mpi_file_write(fh, n_par, 1, mpi_integer, st, er)
151 call mpi_file_write(fh, values, n_par, mpi_double_precision, st, er)
152 call mpi_file_write(fh, names, n_par * name_len, mpi_character, st, er)
178 phys_internal_e = .false.
187 if(
mype==0)
write(*,*)
'WARNING: set hd_trac_type=1'
192 if(
mype==0)
write(*,*)
'WARNING: set hd_trac=F when ndim>=2'
200 if(
mype==0)
write(*,*)
'WARNING: set hd_thermal_conduction=F when hd_energy=F'
204 if(
mype==0)
write(*,*)
'WARNING: set hd_radiative_cooling=F when hd_energy=F'
210 if(
mype==0)
write(*,*)
'WARNING: set hd_partial_ionization=F when eq_state_units=F'
215 allocate(start_indices(number_species),stop_indices(number_species))
223 mom(:) = var_set_momentum(
ndir)
227 e_ = var_set_energy()
253 phys_req_diagonal = .false.
265 phys_req_diagonal = .true.
272 tracer(itr) = var_set_fluxvar(
"trc",
"trp", itr, need_bc=.false.)
279 stop_indices(1)=nwflux
283 te_ = var_set_auxvar(
'Te',
'Te')
308 call mpistop(
"thermal conduction needs hd_energy=T")
309 phys_req_diagonal = .true.
328 call mpistop(
"radiative cooling needs hd_energy=T")
334 rc_fl%get_var_Rfactor => hd_get_rfactor
341 te_fl_hd%get_var_Rfactor => hd_get_rfactor
360 phys_req_diagonal = .true.
364 if (.not.
allocated(flux_type))
then
365 allocate(flux_type(
ndir, nw))
366 flux_type = flux_default
367 else if (any(shape(flux_type) /= [
ndir, nw]))
then
368 call mpistop(
"phys_check error: flux_type has wrong shape")
372 allocate(iw_vector(nvector))
373 iw_vector(1) =
mom(1) - 1
384 case(
'EIvtiCCmpi',
'EIvtuCCmpi')
386 case(
'ESvtiCCmpi',
'ESvtuCCmpi')
388 case(
'SIvtiCCmpi',
'SIvtuCCmpi')
390 case(
'WIvtiCCmpi',
'WIvtuCCmpi')
393 call mpistop(
"Error in synthesize emission: Unknown convert_type")
404 integer,
intent(in) :: ixI^L, ixO^L, igrid, nflux
405 double precision,
intent(in) :: x(ixI^S,1:ndim)
406 double precision,
intent(inout) :: wres(ixI^S,1:nw), w(ixI^S,1:nw)
407 double precision,
intent(in) :: my_dt
408 logical,
intent(in) :: fix_conserve_at_step
419 integer,
intent(in) :: ixi^
l, ixo^
l
420 double precision,
intent(in) ::
dx^
d, x(ixi^s,1:
ndim)
421 double precision,
intent(in) :: w(ixi^s,1:nw)
422 double precision :: dtnew
432 integer,
intent(in) :: ixI^L,ixO^L
433 double precision,
intent(inout) :: w(ixI^S,1:nw)
434 double precision,
intent(in) :: x(ixI^S,1:ndim)
435 integer,
intent(in) :: step
438 logical :: flag(ixI^S,1:nw)
439 character(len=140) :: error_msg
442 where(w(ixo^s,
e_)<small_e) flag(ixo^s,
e_)=.true.
443 if(any(flag(ixo^s,
e_)))
then
446 where(flag(ixo^s,
e_)) w(ixo^s,
e_)=small_e
453 w(ixo^s, iw_mom(idir)) = w(ixo^s, iw_mom(idir))/w(ixo^s,
rho_)
455 write(error_msg,
"(a,i3)")
"Thermal conduction step ", step
464 type(tc_fluid),
intent(inout) :: fl
466 logical :: tc_saturate=.false.
467 double precision :: tc_k_para=0d0
469 namelist /tc_list/ tc_saturate, tc_k_para
473 read(
unitpar, tc_list,
end=111)
476 fl%tc_saturate = tc_saturate
477 fl%tc_k_para = tc_k_para
483 integer,
intent(in) :: ixI^L, ixO^L
484 double precision,
intent(in) :: w(ixI^S,1:nw),x(ixI^S,1:ndim)
485 double precision,
intent(out) :: rho(ixI^S)
487 rho(ixo^s) = w(ixo^s,
rho_)
497 type(rc_fluid),
intent(inout) :: fl
500 integer :: ncool = 4000
501 double precision :: cfrac=0.1d0
504 character(len=std_len) :: coolcurve=
'JCcorona'
507 character(len=std_len) :: coolmethod=
'exact'
510 logical :: Tfix=.false.
516 logical :: rc_split=.false.
519 namelist /rc_list/ coolcurve, coolmethod, ncool, cfrac, tlow, tfix, rc_split
523 read(
unitpar, rc_list,
end=111)
528 fl%coolcurve=coolcurve
529 fl%coolmethod=coolmethod
542 if (
hd_gamma <= 0.0d0)
call mpistop (
"Error: hd_gamma <= 0")
543 if (
hd_adiab < 0.0d0)
call mpistop (
"Error: hd_adiab < 0")
547 call mpistop (
"Error: hd_gamma <= 0 or hd_gamma == 1.0")
562 double precision :: mp,kB
563 double precision :: a,b
617 logical,
intent(in) :: primitive
618 integer,
intent(in) :: ixi^
l, ixo^
l
619 double precision,
intent(in) :: w(ixi^s, nw)
620 logical,
intent(inout) :: flag(ixi^s,1:nw)
621 double precision :: tmp(ixi^s)
629 tmp(ixo^s) = (
hd_gamma - 1.0d0)*(w(ixo^s,
e_) - &
645 integer,
intent(in) :: ixi^
l, ixo^
l
646 double precision,
intent(inout) :: w(ixi^s, nw)
647 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
648 double precision :: invgam
658 w(ixo^s,
e_) = w(ixo^s,
e_) * invgam + &
659 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) * w(ixo^s,
rho_)
664 w(ixo^s,
mom(idir)) = w(ixo^s,
rho_) * w(ixo^s,
mom(idir))
677 integer,
intent(in) :: ixi^
l, ixo^
l
678 double precision,
intent(inout) :: w(ixi^s, nw)
679 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
681 double precision :: inv_rho(ixo^s)
687 inv_rho = 1.0d0 / w(ixo^s,
rho_)
697 w(ixo^s,
mom(idir)) = w(ixo^s,
mom(idir)) * inv_rho
710 integer,
intent(in) :: ixI^L, ixO^L
711 double precision,
intent(inout) :: w(ixI^S, nw)
712 double precision,
intent(in) :: x(ixI^S, 1:ndim)
715 w(ixo^s,
e_)=w(ixo^s,
e_)&
723 integer,
intent(in) :: ixI^L, ixO^L
724 double precision,
intent(inout) :: w(ixI^S, nw)
725 double precision,
intent(in) :: x(ixI^S, 1:ndim)
728 w(ixo^s,
e_)=w(ixo^s,
e_)&
736 integer,
intent(in) :: ixI^L, ixO^L
737 double precision :: w(ixI^S, nw)
738 double precision,
intent(in) :: x(ixI^S, 1:ndim)
744 call mpistop(
"energy from entropy can not be used with -eos = iso !")
751 integer,
intent(in) :: ixI^L, ixO^L
752 double precision :: w(ixI^S, nw)
753 double precision,
intent(in) :: x(ixI^S, 1:ndim)
759 call mpistop(
"entropy from energy can not be used with -eos = iso !")
766 integer,
intent(in) :: ixI^L, ixO^L, idim
767 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S, 1:ndim)
768 double precision,
intent(out) :: v(ixI^S)
770 v(ixo^s) = w(ixo^s,
mom(idim)) / w(ixo^s,
rho_)
777 integer,
intent(in) :: ixI^L, ixO^L
778 double precision,
intent(in) :: w(ixI^S,nw), x(ixI^S,1:^ND)
779 double precision,
intent(out) :: v(ixI^S,1:ndir)
784 v(ixo^s,idir) = w(ixo^s,
mom(idir)) / w(ixo^s,
rho_)
795 integer,
intent(in) :: ixI^L, ixO^L, idim
797 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S, 1:ndim)
798 double precision,
intent(inout) :: cmax(ixI^S)
808 cmax(ixo^s)=dabs(w(ixo^s,
mom(idim)))+dsqrt(
hd_gamma*cmax(ixo^s)/w(ixo^s,
rho_))
819 integer,
intent(in) :: ixI^L, ixO^L
820 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S,1:ndim)
821 double precision,
intent(inout) :: a2max(ndim)
822 double precision :: a2(ixI^S,ndim,nw)
823 integer :: gxO^L,hxO^L,jxO^L,kxO^L,i,j
828 hxo^l=ixo^l-
kr(i,^
d);
829 gxo^l=hxo^l-
kr(i,^
d);
830 jxo^l=ixo^l+
kr(i,^
d);
831 kxo^l=jxo^l+
kr(i,^
d);
832 a2(ixo^s,i,1:nw)=dabs(-w(kxo^s,1:nw)+16.d0*w(jxo^s,1:nw)&
833 -30.d0*w(ixo^s,1:nw)+16.d0*w(hxo^s,1:nw)-w(gxo^s,1:nw))
834 a2max(i)=maxval(a2(ixo^s,i,1:nw))/12.d0/
dxlevel(i)**2
841 integer,
intent(in) :: ixI^L,ixO^L
842 double precision,
intent(in) :: x(ixI^S,1:ndim)
844 double precision,
intent(inout) :: w(ixI^S,1:nw)
845 double precision,
intent(out) :: tco_local, Tmax_local
847 double precision,
parameter :: trac_delta=0.25d0
848 double precision :: tmp1(ixI^S),Te(ixI^S),lts(ixI^S)
849 double precision :: ltr(ixI^S),ltrc,ltrp,tcoff(ixI^S)
850 integer :: jxO^L,hxO^L
851 integer :: jxP^L,hxP^L,ixP^L
852 logical :: lrlt(ixI^S)
855 call hd_get_rfactor(w,x,ixi^l,ixi^l,te)
856 te(ixi^s)=w(ixi^s,
p_)/(te(ixi^s)*w(ixi^s,
rho_))
859 tmax_local=maxval(te(ixo^s))
866 lts(ixo^s)=0.5d0*dabs(te(jxo^s)-te(hxo^s))/te(ixo^s)
868 where(lts(ixo^s) > trac_delta)
871 if(any(lrlt(ixo^s)))
then
872 tco_local=maxval(te(ixo^s), mask=lrlt(ixo^s))
883 lts(ixp^s)=0.5d0*abs(te(jxp^s)-te(hxp^s))/te(ixp^s)
884 ltr(ixp^s)=max(one, (exp(lts(ixp^s))/ltrc)**ltrp)
885 w(ixo^s,
tcoff_)=te(ixo^s)*&
886 (0.25*(ltr(jxo^s)+two*ltr(ixo^s)+ltr(hxo^s)))**0.4d0
888 call mpistop(
"mhd_trac_type not allowed for 1D simulation")
894 subroutine hd_get_cbounds(wLC, wRC, wLp, wRp, x, ixI^L, ixO^L, idim,Hspeed,cmax, cmin)
899 integer,
intent(in) :: ixI^L, ixO^L, idim
901 double precision,
intent(in) :: wLC(ixI^S, nw), wRC(ixI^S, nw)
903 double precision,
intent(in) :: wLp(ixI^S, nw), wRp(ixI^S, nw)
904 double precision,
intent(in) :: x(ixI^S, 1:ndim)
905 double precision,
intent(inout) :: cmax(ixI^S,1:number_species)
906 double precision,
intent(inout),
optional :: cmin(ixI^S,1:number_species)
907 double precision,
intent(in) :: Hspeed(ixI^S,1:number_species)
909 double precision :: wmean(ixI^S,nw)
910 double precision,
dimension(ixI^S) :: umean, dmean, csoundL, csoundR, tmp1,tmp2,tmp3
918 tmp1(ixo^s)=dsqrt(wlp(ixo^s,
rho_))
919 tmp2(ixo^s)=dsqrt(wrp(ixo^s,
rho_))
920 tmp3(ixo^s)=1.d0/(dsqrt(wlp(ixo^s,
rho_))+dsqrt(wrp(ixo^s,
rho_)))
921 umean(ixo^s)=(wlp(ixo^s,
mom(idim))*tmp1(ixo^s)+wrp(ixo^s,
mom(idim))*tmp2(ixo^s))*tmp3(ixo^s)
931 dmean(ixo^s) = (tmp1(ixo^s)*csoundl(ixo^s)+tmp2(ixo^s)*csoundr(ixo^s)) * &
932 tmp3(ixo^s) + 0.5d0*tmp1(ixo^s)*tmp2(ixo^s)*tmp3(ixo^s)**2 * &
933 (wrp(ixo^s,
mom(idim))-wlp(ixo^s,
mom(idim)))**2
935 dmean(ixo^s)=dsqrt(dmean(ixo^s))
936 if(
present(cmin))
then
937 cmin(ixo^s,1)=umean(ixo^s)-dmean(ixo^s)
938 cmax(ixo^s,1)=umean(ixo^s)+dmean(ixo^s)
940 {
do ix^db=ixomin^db,ixomax^db\}
941 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
942 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
946 cmax(ixo^s,1)=dabs(umean(ixo^s))+dmean(ixo^s)
950 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
951 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
955 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
956 tmp1(ixo^s)=wmean(ixo^s,
mom(idim))/wmean(ixo^s,
rho_)
958 csoundr(ixo^s) = dsqrt(csoundr(ixo^s))
960 if(
present(cmin))
then
961 cmax(ixo^s,1)=max(tmp1(ixo^s)+csoundr(ixo^s),zero)
962 cmin(ixo^s,1)=min(tmp1(ixo^s)-csoundr(ixo^s),zero)
963 if(h_correction)
then
964 {
do ix^db=ixomin^db,ixomax^db\}
965 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
966 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
970 cmax(ixo^s,1)=dabs(tmp1(ixo^s))+csoundr(ixo^s)
974 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
985 csoundl(ixo^s)=max(dsqrt(csoundl(ixo^s)),dsqrt(csoundr(ixo^s)))
986 if(
present(cmin))
then
987 cmin(ixo^s,1)=min(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))-csoundl(ixo^s)
988 cmax(ixo^s,1)=max(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))+csoundl(ixo^s)
989 if(h_correction)
then
990 {
do ix^db=ixomin^db,ixomax^db\}
991 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
992 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
996 cmax(ixo^s,1)=max(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))+csoundl(ixo^s)
999 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
1000 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
1010 integer,
intent(in) :: ixi^
l, ixo^
l
1011 double precision,
intent(in) :: w(ixi^s,nw)
1012 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1013 double precision,
intent(out) :: csound2(ixi^s)
1026 integer,
intent(in) :: ixi^
l, ixo^
l
1027 double precision,
intent(in) :: w(ixi^s, 1:nw)
1028 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1029 double precision,
intent(out):: pth(ixi^s)
1033 pth(ixo^s) = (
hd_gamma - 1.0d0) * (w(ixo^s,
e_) - &
1044 {
do ix^db= ixo^lim^db\}
1050 {
do ix^db= ixo^lim^db\}
1052 write(*,*)
"Error: small value of gas pressure",pth(ix^
d),&
1053 " encountered when call hd_get_pthermal"
1055 write(*,*)
"Location: ", x(ix^
d,:)
1056 write(*,*)
"Cell number: ", ix^
d
1058 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^
d,iw)
1062 write(*,*)
"Saving status at the previous time step"
1073 integer,
intent(in) :: ixI^L, ixO^L
1074 double precision,
intent(in) :: w(ixI^S, 1:nw)
1075 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1076 double precision,
intent(out):: res(ixI^S)
1078 double precision :: R(ixI^S)
1080 call hd_get_rfactor(w,x,ixi^l,ixo^l,r)
1082 res(ixo^s)=res(ixo^s)/(r(ixo^s)*w(ixo^s,
rho_))
1088 integer,
intent(in) :: ixI^L, ixO^L
1089 double precision,
intent(in) :: w(ixI^S, 1:nw)
1090 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1091 double precision,
intent(out):: res(ixI^S)
1093 double precision :: R(ixI^S)
1095 call hd_get_rfactor(w,x,ixi^l,ixo^l,r)
1096 res(ixo^s) = (
hd_gamma - 1.0d0) * w(ixo^s,
e_)/(w(ixo^s,
rho_)*r(ixo^s))
1104 integer,
intent(in) :: ixI^L, ixO^L, idim
1105 double precision,
intent(in) :: w(ixI^S, 1:nw), x(ixI^S, 1:ndim)
1106 double precision,
intent(out) :: f(ixI^S, nwflux)
1107 double precision :: pth(ixI^S), v(ixI^S),frame_vel(ixI^S)
1108 integer :: idir, itr
1113 f(ixo^s,
rho_) = v(ixo^s) * w(ixo^s,
rho_)
1117 f(ixo^s,
mom(idir)) = v(ixo^s) * w(ixo^s,
mom(idir))
1120 f(ixo^s,
mom(idim)) = f(ixo^s,
mom(idim)) + pth(ixo^s)
1124 f(ixo^s,
e_) = v(ixo^s) * (w(ixo^s,
e_) + pth(ixo^s))
1128 f(ixo^s,
tracer(itr)) = v(ixo^s) * w(ixo^s,
tracer(itr))
1144 integer,
intent(in) :: ixI^L, ixO^L, idim
1146 double precision,
intent(in) :: wC(ixI^S, 1:nw)
1148 double precision,
intent(in) :: w(ixI^S, 1:nw)
1149 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1150 double precision,
intent(out) :: f(ixI^S, nwflux)
1151 double precision :: pth(ixI^S),frame_vel(ixI^S)
1152 integer :: idir, itr
1155 pth(ixo^s) = w(ixo^s,
p_)
1160 f(ixo^s,
rho_) = w(ixo^s,
mom(idim)) * w(ixo^s,
rho_)
1164 f(ixo^s,
mom(idir)) = w(ixo^s,
mom(idim)) * wc(ixo^s,
mom(idir))
1167 f(ixo^s,
mom(idim)) = f(ixo^s,
mom(idim)) + pth(ixo^s)
1171 f(ixo^s,
e_) = w(ixo^s,
mom(idim)) * (wc(ixo^s,
e_) + w(ixo^s,
p_))
1204 integer,
intent(in) :: ixI^L, ixO^L
1205 double precision,
intent(in) :: qdt, dtfactor, x(ixI^S, 1:ndim)
1206 double precision,
intent(inout) :: wCT(ixI^S, 1:nw), wprim(ixI^S,1:nw),w(ixI^S, 1:nw)
1210 double precision :: pth(ixI^S), source(ixI^S), minrho
1211 integer :: iw,idir, h1x^L{^NOONED, h2x^L}
1212 integer :: mr_,mphi_
1213 integer :: irho, ifluid, n_fluids
1214 double precision :: exp_factor(ixI^S), del_exp_factor(ixI^S), exp_factor_primitive(ixI^S)
1236 source(ixo^s) =
source(ixo^s)*del_exp_factor(ixo^s)/exp_factor(ixo^s)
1240 do ifluid = 0, n_fluids-1
1242 if (ifluid == 0)
then
1266 where (wct(ixo^s, irho) > minrho)
1267 source(ixo^s) =
source(ixo^s) + wct(ixo^s,mphi_)*wprim(ixo^s,mphi_)
1268 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt*
source(ixo^s)/x(ixo^s,
r_)
1271 where (wct(ixo^s, irho) > minrho)
1272 source(ixo^s) = -wct(ixo^s, mphi_) * wprim(ixo^s, mr_)
1273 w(ixo^s, mphi_) = w(ixo^s, mphi_) + qdt *
source(ixo^s) / x(ixo^s,
r_)
1277 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt *
source(ixo^s) / x(ixo^s,
r_)
1282 call mpistop(
"Dust geom source terms not implemented yet with spherical geometries")
1286 h1x^l=ixo^l-
kr(1,^
d); {^nooned h2x^l=ixo^l-
kr(2,^
d);}
1288 pth(ixo^s)=wprim(ixo^s,
p_)
1297 source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
1298 *(
block%surfaceC(ixo^s, 1) -
block%surfaceC(h1x^s, 1)) &
1299 /
block%dvolume(ixo^s)
1303 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt *
source(ixo^s) / x(ixo^s, 1)
1307 source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
1308 * (
block%surfaceC(ixo^s, 2) -
block%surfaceC(h2x^s, 2)) &
1309 /
block%dvolume(ixo^s)
1311 source(ixo^s) =
source(ixo^s) + (wprim(ixo^s,
mom(3))**2 * wprim(ixo^s,
rho_)) / tan(x(ixo^s, 2))
1313 source(ixo^s) =
source(ixo^s) - (wprim(ixo^s,
mom(2)) * wprim(ixo^s, mr_)) * wprim(ixo^s,
rho_)
1314 w(ixo^s,
mom(2)) = w(ixo^s,
mom(2)) + qdt *
source(ixo^s) / x(ixo^s, 1)
1318 source(ixo^s) = -(wprim(ixo^s,
mom(3)) * wprim(ixo^s, mr_)) * wprim(ixo^s,
rho_)&
1319 - (wprim(ixo^s,
mom(2)) * wprim(ixo^s,
mom(3))) * wprim(ixo^s,
rho_) / tan(x(ixo^s, 2))
1320 w(ixo^s,
mom(3)) = w(ixo^s,
mom(3)) + qdt *
source(ixo^s) / x(ixo^s, 1)
1329 call mpistop(
"Rotating frame not implemented yet with dust")
1338 subroutine hd_add_source(qdt,dtfactor, ixI^L,ixO^L,wCT,wCTprim,w,x,qsourcesplit,active)
1347 integer,
intent(in) :: ixI^L, ixO^L
1348 double precision,
intent(in) :: qdt, dtfactor
1349 double precision,
intent(in) :: wCT(ixI^S, 1:nw),wCTprim(ixI^S,1:nw), x(ixI^S, 1:ndim)
1350 double precision,
intent(inout) :: w(ixI^S, 1:nw)
1351 logical,
intent(in) :: qsourcesplit
1352 logical,
intent(inout) :: active
1354 double precision :: gravity_field(ixI^S, 1:ndim)
1355 integer :: idust, idim
1363 qsourcesplit,active,
rc_fl)
1378 call usr_gravity(ixi^l, ixo^l, wct, x, gravity_field)
1382 + qdt * gravity_field(ixo^s, idim) * wct(ixo^s,
dust_rho(idust))
1393 if(.not.qsourcesplit)
then
1409 integer,
intent(in) :: ixI^L, ixO^L
1410 double precision,
intent(in) :: dx^D, x(ixI^S, 1:^ND)
1411 double precision,
intent(in) :: w(ixI^S, 1:nw)
1412 double precision,
intent(inout) :: dtnew
1440 integer,
intent(in) :: ixi^l, ixo^l
1441 double precision,
intent(in) :: w(ixi^s, nw)
1442 double precision :: ke(ixo^s)
1443 double precision,
intent(in),
optional :: inv_rho(ixo^s)
1445 if (
present(inv_rho))
then
1446 ke = 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) * inv_rho
1448 ke = 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) / w(ixo^s,
rho_)
1454 integer,
intent(in) :: ixi^l, ixo^l
1455 double precision,
intent(in) :: w(ixi^s, nw)
1456 double precision :: inv_rho(ixo^s)
1459 inv_rho = 1.0d0 / w(ixo^s,
rho_)
1469 logical,
intent(in) :: primitive
1470 integer,
intent(in) :: ixI^L,ixO^L
1471 double precision,
intent(inout) :: w(ixI^S,1:nw)
1472 double precision,
intent(in) :: x(ixI^S,1:ndim)
1473 character(len=*),
intent(in) :: subname
1476 logical :: flag(ixI^S,1:nw)
1478 call hd_check_w(primitive, ixi^l, ixo^l, w, flag)
1486 where(flag(ixo^s,
rho_)) w(ixo^s,
mom(idir)) = 0.0d0
1494 where(flag(ixo^s,
rho_)) w(ixo^s,
e_) = small_e +
hd_kin_en(w,ixi^l,ixo^l)
1503 where(flag(ixo^s,
e_))
1528 -0.5d0*sum(w(ixi^s,
mom(:))**2, dim=ndim+1)/w(ixi^s,
rho_))
1531 +0.5d0*sum(w(ixi^s,
mom(:))**2, dim=ndim+1)/w(ixi^s,
rho_)
1543 if(.not.primitive)
then
1551 w(ixo^s,
mom(idir)) = w(ixo^s,
mom(idir))/w(ixo^s,
rho_)
1563 integer,
intent(in) :: ixI^L, ixO^L
1564 double precision,
intent(in) :: w(ixI^S,1:nw)
1565 double precision,
intent(in) :: x(ixI^S,1:ndim)
1566 double precision,
intent(out):: Rfactor(ixI^S)
1568 double precision :: iz_H(ixO^S),iz_He(ixO^S)
1572 rfactor(ixo^s)=(1.d0+iz_h(ixo^s)+0.1d0*(1.d0+iz_he(ixo^s)*(1.d0+iz_he(ixo^s))))/2.3d0
1578 integer,
intent(in) :: ixI^L, ixO^L
1579 double precision,
intent(in) :: w(ixI^S,1:nw)
1580 double precision,
intent(in) :: x(ixI^S,1:ndim)
1581 double precision,
intent(out):: Rfactor(ixI^S)
1591 integer,
intent(in) :: ixI^L, ixO^L
1592 double precision,
intent(in) :: wCT(ixI^S,1:nw), x(ixI^S,1:ndim)
1593 double precision,
intent(inout) :: w(ixI^S,1:nw)
1595 double precision :: iz_H(ixO^S),iz_He(ixO^S), pth(ixI^S)
Calculate w(iw)=w(iw)+qdt*SOURCE[wCT,qtC,x] within ixO for all indices iw=iwmin......
Module with basic data types used in amrvac.
integer, parameter std_len
Default length for strings.
Module to include CAK radiation line force in (magneto)hydrodynamic models Computes both the force fr...
subroutine cak_get_dt(w, ixIL, ixOL, dtnew, dxD, x)
Check time step for total radiation contribution.
subroutine cak_init(phys_gamma)
Initialize the module.
subroutine cak_add_source(qdt, ixIL, ixOL, wCT, w, x, energy, qsourcesplit, active)
w[iw]=w[iw]+qdt*S[wCT,qtC,x] where S is the source based on wCT within ixO
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
Module for physical and numeric constants.
double precision, parameter bigdouble
A very large real number.
Module for including dust species, which interact with the gas through a drag force.
subroutine, public dust_check_w(ixIL, ixOL, w, flag)
subroutine, public dust_get_flux(w, x, ixIL, ixOL, idim, f)
subroutine, public dust_implicit_update(dtfactor, qdt, qtC, psb, psa)
Implicit solve of psb=psa+dtfactor*dt*F_im(psb)
subroutine, public dust_get_dt(w, ixIL, ixOL, dtnew, dxD, x)
Get dt related to dust and gas stopping time (Laibe 2011)
subroutine, public dust_add_source(qdt, ixIL, ixOL, wCT, w, x, qsourcesplit, active)
w[iw]= w[iw]+qdt*S[wCT, x] where S is the source based on wCT within ixO
subroutine, public dust_to_primitive(ixIL, ixOL, w, x)
integer, dimension(:, :), allocatable, public, protected dust_mom
Indices of the dust momentum densities.
subroutine, public dust_get_cmax(w, x, ixIL, ixOL, idim, cmax, cmin)
integer, public, protected dust_n_species
The number of dust species.
integer, dimension(:), allocatable, public, protected dust_rho
Indices of the dust densities.
subroutine, public dust_get_flux_prim(w, x, ixIL, ixOL, idim, f)
subroutine, public dust_check_params()
subroutine, public dust_evaluate_implicit(qtC, psa)
inplace update of psa==>F_im(psa)
subroutine, public dust_init(g_rho, g_mom, g_energy)
subroutine, public dust_get_cmax_prim(w, x, ixIL, ixOL, idim, cmax, cmin)
subroutine, public dust_to_conserved(ixIL, ixOL, w, x)
Module for flux conservation near refinement boundaries.
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.
logical h_correction
If true, do H-correction to fix the carbuncle problem at grid-aligned shocks.
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 global_time
The global simulation time.
double precision unit_mass
Physical scaling factor for mass.
logical use_imex_scheme
whether IMEX in use or not
integer, dimension(3, 3) kr
Kronecker delta tensor.
integer it
Number of time steps taken.
double precision unit_numberdensity
Physical scaling factor for number density.
character(len=std_len) convert_type
Which format to use when converting.
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
logical phys_trac
Use TRAC for MHD or 1D HD.
logical fix_small_values
fix small values with average or replace methods
logical crash
Save a snapshot before crash a run met unphysical values.
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
integer, parameter unitconvert
logical check_small_values
check and optionally fix unphysical small values (density, gas pressure)
Module for including gravity in (magneto)hydrodynamics simulations.
logical grav_split
source split or not
subroutine gravity_get_dt(w, ixIL, ixOL, dtnew, dxD, x)
subroutine gravity_add_source(qdt, ixIL, ixOL, wCT, wCTprim, w, x, energy, rhov, qsourcesplit, active)
w[iw]=w[iw]+qdt*S[wCT,qtC,x] where S is the source based on wCT within ixO
subroutine gravity_init()
Initialize the module.
Hydrodynamics physics module.
subroutine, public hd_check_params
logical, public, protected hd_energy
Whether an energy equation is used.
logical, public, protected hd_dust
Whether dust is added.
subroutine rfactor_from_temperature_ionization(w, x, ixIL, ixOL, Rfactor)
integer, public, protected e_
Index of the energy density (-1 if not present)
logical, public, protected hd_radiative_cooling
Whether radiative cooling is added.
double precision, public, protected rr
subroutine hd_get_flux(wC, w, x, ixIL, ixOL, idim, f)
double precision, public hd_gamma
The adiabatic index.
subroutine rhos_to_e(ixIL, ixOL, w, x)
subroutine hd_get_a2max(w, x, ixIL, ixOL, a2max)
integer, public, protected hd_trac_type
subroutine hd_get_flux_cons(w, x, ixIL, ixOL, idim, f)
logical, public, protected hd_particles
Whether particles module is added.
type(tc_fluid), allocatable, public tc_fl
logical, public, protected hd_viscosity
Whether viscosity is added.
subroutine rc_params_read(fl)
subroutine hd_get_rho(w, x, ixIL, ixOL, rho)
subroutine, public hd_check_w(primitive, ixIL, ixOL, w, flag)
Returns logical argument flag where values are ok.
integer, public, protected tcoff_
Index of the cutoff temperature for the TRAC method.
subroutine hd_e_to_ei(ixIL, ixOL, w, x)
Transform total energy to internal energy.
double precision, public, protected he_ion_fr2
Ratio of number He2+ / number He+ + He2+ He_ion_fr2 = He2+/(He2+ + He+)
subroutine hd_sts_set_source_tc_hd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux)
subroutine hd_ei_to_e(ixIL, ixOL, w, x)
Transform internal energy to total energy.
subroutine hd_add_source(qdt, dtfactor, ixIL, ixOL, wCT, wCTprim, w, x, qsourcesplit, active)
subroutine hd_write_info(fh)
Write this module's parameters to a snapsoht.
integer, public, protected te_
Indices of temperature.
integer, dimension(:), allocatable, public, protected mom
Indices of the momentum density.
subroutine hd_get_dt(w, ixIL, ixOL, dtnew, dxD, x)
double precision function hd_get_tc_dt_hd(w, ixIL, ixOL, dxD, x)
double precision, public, protected h_ion_fr
Ionization fraction of H H_ion_fr = H+/(H+ + H)
logical, public, protected hd_cak_force
Whether CAK radiation line force is activated.
subroutine hd_get_cbounds(wLC, wRC, wLp, wRp, x, ixIL, ixOL, idim, Hspeed, cmax, cmin)
Calculate cmax_idim = csound + abs(v_idim) within ixO^L.
subroutine, public hd_phys_init()
Initialize the module.
subroutine hd_get_temperature_from_eint(w, x, ixIL, ixOL, res)
Calculate temperature=p/rho when in e_ the internal energy is stored.
integer, dimension(:), allocatable, public, protected tracer
Indices of the tracers.
logical, public, protected hd_thermal_conduction
Whether thermal conduction is added.
logical, public, protected eq_state_units
logical, public, protected hd_force_diagonal
Allows overruling default corner filling (for debug mode, since otherwise corner primitives fail)
subroutine, public hd_get_pthermal(w, x, ixIL, ixOL, pth)
Calculate thermal pressure=(gamma-1)*(e-0.5*m**2/rho) within ixO^L.
double precision, public hd_adiab
The adiabatic constant.
subroutine hd_get_tcutoff(ixIL, ixOL, w, x, tco_local, Tmax_local)
get adaptive cutoff temperature for TRAC (Johnston 2019 ApJL, 873, L22)
integer, public, protected rho_
Index of the density (in the w array)
subroutine tc_params_read_hd(fl)
subroutine hd_get_v_idim(w, x, ixIL, ixOL, idim, v)
Calculate v_i = m_i / rho within ixO^L.
logical, public, protected hd_partial_ionization
Whether plasma is partially ionized.
double precision, public, protected he_ion_fr
Ionization fraction of He He_ion_fr = (He2+ + He+)/(He2+ + He+ + He)
double precision, public, protected he_abundance
Helium abundance over Hydrogen.
logical, public, protected hd_gravity
Whether gravity is added.
subroutine hd_physical_units
subroutine rfactor_from_constant_ionization(w, x, ixIL, ixOL, Rfactor)
subroutine, public hd_to_conserved(ixIL, ixOL, w, x)
Transform primitive variables into conservative ones.
subroutine hd_add_source_geom(qdt, dtfactor, ixIL, ixOL, wCT, wprim, w, x)
Add geometrical source terms to w.
type(rc_fluid), allocatable, public rc_fl
subroutine, public hd_to_primitive(ixIL, ixOL, w, x)
Transform conservative variables into primitive ones.
logical, public, protected hd_trac
Whether TRAC method is used.
integer, public, protected hd_n_tracer
Number of tracer species.
type(te_fluid), allocatable, public te_fl_hd
subroutine e_to_rhos(ixIL, ixOL, w, x)
subroutine hd_get_cmax(w, x, ixIL, ixOL, idim, cmax)
Calculate cmax_idim = csound + abs(v_idim) within ixO^L.
logical, public, protected hd_rotating_frame
Whether rotating frame is activated.
subroutine hd_get_v(w, x, ixIL, ixOL, v)
Calculate velocity vector v_i = m_i / rho within ixO^L.
double precision function, dimension(ixo^s), public hd_kin_en(w, ixIL, ixOL, inv_rho)
subroutine hd_update_temperature(ixIL, ixOL, wCT, w, x)
integer, public, protected p_
Index of the gas pressure (-1 if not present) should equal e_.
subroutine hd_tc_handle_small_e(w, x, ixIL, ixOL, step)
subroutine hd_get_temperature_from_etot(w, x, ixIL, ixOL, res)
Calculate temperature=p/rho when in e_ the total energy is stored.
subroutine hd_handle_small_values(primitive, w, x, ixIL, ixOL, subname)
subroutine, public hd_get_csound2(w, x, ixIL, ixOL, csound2)
Calculate the square of the thermal sound speed csound2 within ixO^L. csound2=gamma*p/rho.
double precision function, dimension(ixo^s) hd_inv_rho(w, ixIL, ixOL)
module ionization degree - get ionization degree for given temperature
subroutine ionization_degree_init()
subroutine ionization_degree_from_temperature(ixIL, ixOL, Te, iz_H, iz_He)
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 radiative cooling – add optically thin radiative cooling for HD and MHD
subroutine radiative_cooling_init(fl, read_params)
subroutine cooling_get_dt(w, ixIL, ixOL, dtnew, dxD, x, fl)
subroutine radiative_cooling_init_params(phys_gamma, He_abund)
Radiative cooling initialization.
subroutine radiative_cooling_add_source(qdt, ixIL, ixOL, wCT, wCTprim, w, x, qsourcesplit, active, fl)
Module for including rotating frame in (magneto)hydrodynamics simulations The rotation vector is assu...
subroutine rotating_frame_add_source(qdt, dtfactor, ixIL, ixOL, wCT, w, x)
w[iw]=w[iw]+qdt*S[wCT,qtC,x] where S is the source based on wCT within ixO
subroutine rotating_frame_init()
Initialize the module.
Module for handling problematic values in simulations, such as negative pressures.
logical, public trace_small_values
trace small values in the source file using traceback flag of compiler
subroutine, public small_values_average(ixIL, ixOL, w, x, w_flag, windex)
logical, dimension(:), allocatable, public small_values_fix_iw
Whether to apply small value fixes to certain variables.
subroutine, public small_values_error(wprim, x, ixIL, ixOL, w_flag, subname)
character(len=20), public small_values_method
How to handle small values.
Generic supertimestepping method 1) in amrvac.par in sts_list set the following parameters which have...
subroutine, public add_sts_method(sts_getdt, sts_set_sources, startVar, nflux, startwbc, nwbc, evolve_B)
subroutine which added programatically a term to be calculated using STS Params: sts_getdt function c...
subroutine, public set_conversion_methods_to_head(sts_before_first_cycle, sts_after_last_cycle)
Set the hooks called before the first cycle and after the last cycle in the STS update This method sh...
subroutine, public set_error_handling_to_head(sts_error_handling)
Set the hook of error handling in the STS update. This method is called before updating the BC....
subroutine, public sts_init()
Initialize sts module.
Thermal conduction for HD and MHD or RHD and RMHD or twofl (plasma-neutral) module Adaptation of mod_...
subroutine, public sts_set_source_tc_hd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux, fl)
subroutine, public tc_get_hd_params(fl, read_hd_params)
Init TC coefficients: HD case.
subroutine tc_init_params(phys_gamma)
double precision function, public get_tc_dt_hd(w, ixIL, ixOL, dxD, x, fl)
Get the explicit timestep for the TC (hd implementation)
subroutine get_euv_image(qunit, fl)
subroutine get_sxr_image(qunit, fl)
subroutine get_euv_spectrum(qunit, fl)
subroutine get_whitelight_image(qunit, fl)
Module with all the methods that users can customize in AMRVAC.
procedure(rfactor), pointer usr_rfactor
procedure(set_surface), pointer usr_set_surface
procedure(phys_gravity), pointer usr_gravity
procedure(hd_pthermal), pointer usr_set_pthermal
The module add viscous source terms and check time step.
subroutine viscosity_get_dt(w, ixIL, ixOL, dtnew, dxD, x)
subroutine viscosity_add_source(qdt, ixIL, ixOL, wCT, w, x, energy, qsourcesplit, active)
subroutine viscosity_init(phys_wider_stencil, phys_req_diagonal)
Initialize the module.
subroutine visc_add_source_geom(qdt, ixIL, ixOL, wCT, w, x)
subroutine, public visc_get_flux_prim(w, x, ixIL, ixOL, idim, f, energy)