22 logical,
public,
protected ::
hd_dust = .false.
43 integer,
public,
protected ::
rho_
46 integer,
allocatable,
public,
protected ::
mom(:)
49 integer,
allocatable,
public,
protected ::
tracer(:)
52 integer,
public,
protected ::
e_
55 integer,
public,
protected ::
p_
61 double precision,
public ::
hd_gamma = 5.d0/3.0d0
67 double precision,
protected :: small_e
70 logical,
public,
protected ::
hd_trac = .false.
92 subroutine hd_read_params(files)
94 character(len=*),
intent(in) :: files(:)
102 do n = 1,
size(files)
103 open(
unitpar, file=trim(files(n)), status=
"old")
104 read(
unitpar, hd_list,
end=111)
108 end subroutine hd_read_params
113 integer,
intent(in) :: fh
114 integer,
parameter :: n_par = 1
115 double precision :: values(n_par)
116 character(len=name_len) :: names(n_par)
117 integer,
dimension(MPI_STATUS_SIZE) :: st
120 call mpi_file_write(fh, n_par, 1, mpi_integer, st, er)
124 call mpi_file_write(fh, values, n_par, mpi_double_precision, st, er)
125 call mpi_file_write(fh, names, n_par * name_len, mpi_character, st, er)
133 double precision,
intent(in) :: x(ixI^S,1:ndim)
134 double precision,
intent(inout) :: fC(ixI^S,1:nwflux,1:ndim), wnew(ixI^S,1:nw)
135 integer,
intent(in) :: ixI^L, ixO^L
136 integer,
intent(in) :: idim
137 integer :: hxO^L, kxC^L, iw
138 double precision :: inv_volume(ixI^S)
143 hxo^l=ixo^l-
kr(idim,^
d);
148 inv_volume(ixo^s) = 1.0d0/
block%dvolume(ixo^s)
153 isangmom = (iw==iw_mom(
phi_))
156 if (idim==
r_ .and. isangmom)
then
157 fc(kxc^s,iw,idim)= fc(kxc^s,iw,idim)*(x(kxc^s,
r_)+half*
block%dx(kxc^s,idim))
158 wnew(ixo^s,iw)=wnew(ixo^s,iw) + (fc(ixo^s,iw,idim)-fc(hxo^s,iw,idim)) * &
159 (inv_volume(ixo^s)/x(ixo^s,idim))
161 wnew(ixo^s,iw)=wnew(ixo^s,iw) + (fc(ixo^s,iw,idim)-fc(hxo^s,iw,idim)) * &
167 call mpistop(
"Error: hd_angmomfix is not implemented &\\
168 &with dust and coordinate=='spherical'")
170 if (idim==
r_ .and. (iw==iw_mom(2) .or. iw==iw_mom(
phi_)))
then
171 fc(kxc^s,iw,idim)= fc(kxc^s,iw,idim)*(x(kxc^s,idim)+half*
block%dx(kxc^s,idim))
172 wnew(ixo^s,iw)=wnew(ixo^s,iw) + (fc(ixo^s,iw,idim)-fc(hxo^s,iw,idim)) * &
173 (inv_volume(ixo^s)/x(ixo^s,idim))
174 elseif (idim==2 .and. iw==iw_mom(
phi_))
then
175 fc(kxc^s,iw,idim)=fc(kxc^s,iw,idim)*sin(x(kxc^s,idim)+half*
block%dx(kxc^s,idim))
176 wnew(ixo^s,iw)=wnew(ixo^s,iw) + (fc(ixo^s,iw,idim)-fc(hxo^s,iw,idim)) * &
177 (inv_volume(ixo^s)/sin(x(ixo^s,idim)))
179 wnew(ixo^s,iw)=wnew(ixo^s,iw) + (fc(ixo^s,iw,idim)-fc(hxo^s,iw,idim)) * &
217 if(
mype==0)
write(*,*)
'WARNING: set hd_trac_type=1'
222 if(
mype==0)
write(*,*)
'WARNING: set hd_trac=F when ndim>=2'
230 if(
mype==0)
write(*,*)
'WARNING: set hd_thermal_conduction=F when hd_energy=F'
234 if(
mype==0)
write(*,*)
'WARNING: set hd_radiative_cooling=F when hd_energy=F'
239 allocate(start_indices(number_species),stop_indices(number_species))
247 mom(:) = var_set_momentum(
ndir)
251 e_ = var_set_energy()
298 tracer(itr) = var_set_fluxvar(
"trc",
"trp", itr, need_bc=.false.)
305 stop_indices(1)=nwflux
317 call mpistop(
"thermal conduction needs hd_energy=T")
337 call mpistop(
"radiative cooling needs hd_energy=T")
376 call mpistop(
"phys_check error: flux_type has wrong shape")
380 allocate(iw_vector(nvector))
381 iw_vector(1) =
mom(1) - 1
390 case(
'EIvtiCCmpi',
'EIvtuCCmpi')
392 case(
'ESvtiCCmpi',
'ESvtuCCmpi')
394 case(
'SIvtiCCmpi',
'SIvtuCCmpi')
397 call mpistop(
"Error in synthesize emission: Unknown convert_type")
408 integer,
intent(in) :: ixI^L, ixO^L, igrid, nflux
409 double precision,
intent(in) :: x(ixI^S,1:ndim)
410 double precision,
intent(inout) :: wres(ixI^S,1:nw), w(ixI^S,1:nw)
411 double precision,
intent(in) :: my_dt
412 logical,
intent(in) :: fix_conserve_at_step
424 integer,
intent(in) :: ixi^
l, ixo^
l
425 double precision,
intent(in) ::
dx^
d, x(ixi^s,1:
ndim)
426 double precision,
intent(in) :: w(ixi^s,1:nw)
427 double precision :: dtnew
438 integer,
intent(in) :: ixI^L,ixO^L
439 double precision,
intent(inout) :: w(ixI^S,1:nw)
440 double precision,
intent(in) :: x(ixI^S,1:ndim)
441 integer,
intent(in) :: step
444 logical :: flag(ixI^S,1:nw)
445 character(len=140) :: error_msg
448 where(w(ixo^s,
e_)<small_e) flag(ixo^s,
e_)=.true.
449 if(any(flag(ixo^s,
e_)))
then
452 where(flag(ixo^s,
e_)) w(ixo^s,
e_)=small_e
459 w(ixo^s, iw_mom(idir)) = w(ixo^s, iw_mom(idir))/w(ixo^s,
rho_)
461 write(error_msg,
"(a,i3)")
"Thermal conduction step ", step
471 type(tc_fluid),
intent(inout) :: fl
473 logical :: tc_saturate=.false.
474 double precision :: tc_k_para=0d0
476 namelist /tc_list/ tc_saturate, tc_k_para
478 do n = 1,
size(par_files)
479 open(
unitpar, file=trim(par_files(n)), status=
"old")
480 read(
unitpar, tc_list,
end=111)
483 fl%tc_saturate = tc_saturate
484 fl%tc_k_para = tc_k_para
490 integer,
intent(in) :: ixI^L, ixO^L
491 double precision,
intent(in) :: w(ixI^S,1:nw),x(ixI^S,1:ndim)
492 double precision,
intent(out) :: rho(ixI^S)
494 rho(ixo^s) = w(ixo^s,
rho_)
504 type(rc_fluid),
intent(inout) :: fl
507 integer :: ncool = 4000
508 double precision :: cfrac=0.1d0
511 character(len=std_len) :: coolcurve=
'JCcorona'
514 character(len=std_len) :: coolmethod=
'exact'
517 logical :: Tfix=.false.
523 logical :: rc_split=.false.
526 namelist /rc_list/ coolcurve, coolmethod, ncool, cfrac, tlow, tfix, rc_split
530 read(
unitpar, rc_list,
end=111)
535 fl%coolcurve=coolcurve
536 fl%coolmethod=coolmethod
555 call mpistop (
"Error: hd_gamma <= 0 or hd_gamma == 1.0")
570 double precision :: mp,kB
611 logical,
intent(in) :: primitive
612 integer,
intent(in) :: ixi^
l, ixo^
l
613 double precision,
intent(in) :: w(ixi^s, nw)
614 logical,
intent(inout) :: flag(ixi^s,1:nw)
615 double precision :: tmp(ixi^s)
623 tmp(ixo^s) = (
hd_gamma - 1.0d0)*(w(ixo^s,
e_) - &
639 integer,
intent(in) :: ixi^
l, ixo^
l
640 double precision,
intent(inout) :: w(ixi^s, nw)
641 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
642 double precision :: invgam
652 w(ixo^s,
e_) = w(ixo^s,
e_) * invgam + &
653 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) * w(ixo^s,
rho_)
658 w(ixo^s,
mom(idir)) = w(ixo^s,
rho_) * w(ixo^s,
mom(idir))
671 integer,
intent(in) :: ixi^
l, ixo^
l
672 double precision,
intent(inout) :: w(ixi^s, nw)
673 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
675 double precision :: inv_rho(ixo^s)
681 inv_rho = 1.0d0 / w(ixo^s,
rho_)
691 w(ixo^s,
mom(idir)) = w(ixo^s,
mom(idir)) * inv_rho
704 integer,
intent(in) :: ixI^L, ixO^L
705 double precision,
intent(inout) :: w(ixI^S, nw)
706 double precision,
intent(in) :: x(ixI^S, 1:ndim)
709 w(ixo^s,
e_)=w(ixo^s,
e_)&
717 integer,
intent(in) :: ixI^L, ixO^L
718 double precision,
intent(inout) :: w(ixI^S, nw)
719 double precision,
intent(in) :: x(ixI^S, 1:ndim)
722 w(ixo^s,
e_)=w(ixo^s,
e_)&
730 integer,
intent(in) :: ixI^L, ixO^L
731 double precision :: w(ixI^S, nw)
732 double precision,
intent(in) :: x(ixI^S, 1:ndim)
738 call mpistop(
"energy from entropy can not be used with -eos = iso !")
745 integer,
intent(in) :: ixI^L, ixO^L
746 double precision :: w(ixI^S, nw)
747 double precision,
intent(in) :: x(ixI^S, 1:ndim)
753 call mpistop(
"entropy from energy can not be used with -eos = iso !")
760 integer,
intent(in) :: ixI^L, ixO^L, idim
761 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S, 1:ndim)
762 double precision,
intent(out) :: v(ixI^S)
764 v(ixo^s) = w(ixo^s,
mom(idim)) / w(ixo^s,
rho_)
771 integer,
intent(in) :: ixI^L, ixO^L
772 double precision,
intent(in) :: w(ixI^S,nw), x(ixI^S,1:^ND)
773 double precision,
intent(out) :: v(ixI^S,1:ndir)
778 v(ixo^s,idir) = w(ixo^s,
mom(idir)) / w(ixo^s,
rho_)
788 integer,
intent(in) :: ixI^L, ixO^L, idim
789 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S, 1:ndim)
790 double precision,
intent(inout) :: cmax(ixI^S)
791 double precision :: csound(ixI^S)
792 double precision :: v(ixI^S)
796 csound(ixo^s) = dsqrt(csound(ixo^s))
798 cmax(ixo^s) = dabs(v(ixo^s))+csound(ixo^s)
808 integer,
intent(in) :: ixI^L, ixO^L
809 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S,1:ndim)
810 double precision,
intent(inout) :: a2max(ndim)
811 double precision :: a2(ixI^S,ndim,nw)
812 integer :: gxO^L,hxO^L,jxO^L,kxO^L,i,j
817 hxo^l=ixo^l-
kr(i,^
d);
818 gxo^l=hxo^l-
kr(i,^
d);
819 jxo^l=ixo^l+
kr(i,^
d);
820 kxo^l=jxo^l+
kr(i,^
d);
821 a2(ixo^s,i,1:nw)=dabs(-w(kxo^s,1:nw)+16.d0*w(jxo^s,1:nw)&
822 -30.d0*w(ixo^s,1:nw)+16.d0*w(hxo^s,1:nw)-w(gxo^s,1:nw))
823 a2max(i)=maxval(a2(ixo^s,i,1:nw))/12.d0/
dxlevel(i)**2
830 integer,
intent(in) :: ixI^L,ixO^L
831 double precision,
intent(in) :: x(ixI^S,1:ndim)
832 double precision,
intent(inout) :: w(ixI^S,1:nw)
833 double precision,
intent(out) :: tco_local, Tmax_local
835 double precision,
parameter :: trac_delta=0.25d0
836 double precision :: tmp1(ixI^S),Te(ixI^S),lts(ixI^S)
837 double precision :: ltr(ixI^S),ltrc,ltrp,tcoff(ixI^S)
838 integer :: jxO^L,hxO^L
839 integer :: jxP^L,hxP^L,ixP^L
840 logical :: lrlt(ixI^S)
843 tmp1(ixi^s)=w(ixi^s,
e_)-0.5d0*sum(w(ixi^s,iw_mom(:))**2,dim=ndim+1)/w(ixi^s,
rho_)
847 tmax_local=maxval(te(ixo^s))
854 lts(ixo^s)=0.5d0*dabs(te(jxo^s)-te(hxo^s))/te(ixo^s)
856 where(lts(ixo^s) > trac_delta)
859 if(any(lrlt(ixo^s)))
then
860 tco_local=maxval(te(ixo^s), mask=lrlt(ixo^s))
871 lts(ixp^s)=0.5d0*abs(te(jxp^s)-te(hxp^s))/te(ixp^s)
872 ltr(ixp^s)=max(one, (exp(lts(ixp^s))/ltrc)**ltrp)
873 w(ixo^s,
tcoff_)=te(ixo^s)*&
874 (0.25*(ltr(jxo^s)+two*ltr(ixo^s)+ltr(hxo^s)))**0.4d0
876 call mpistop(
"mhd_trac_type not allowed for 1D simulation")
882 subroutine hd_get_cbounds(wLC, wRC, wLp, wRp, x, ixI^L, ixO^L, idim,Hspeed,cmax, cmin)
887 integer,
intent(in) :: ixI^L, ixO^L, idim
889 double precision,
intent(in) :: wLC(ixI^S, nw), wRC(ixI^S, nw)
891 double precision,
intent(in) :: wLp(ixI^S, nw), wRp(ixI^S, nw)
892 double precision,
intent(in) :: x(ixI^S, 1:ndim)
893 double precision,
intent(inout) :: cmax(ixI^S,1:number_species)
894 double precision,
intent(inout),
optional :: cmin(ixI^S,1:number_species)
895 double precision,
intent(in) :: Hspeed(ixI^S,1:number_species)
897 double precision :: wmean(ixI^S,nw)
898 double precision,
dimension(ixI^S) :: umean, dmean, csoundL, csoundR, tmp1,tmp2,tmp3
906 tmp1(ixo^s)=dsqrt(wlp(ixo^s,
rho_))
907 tmp2(ixo^s)=dsqrt(wrp(ixo^s,
rho_))
908 tmp3(ixo^s)=1.d0/(dsqrt(wlp(ixo^s,
rho_))+dsqrt(wrp(ixo^s,
rho_)))
909 umean(ixo^s)=(wlp(ixo^s,
mom(idim))*tmp1(ixo^s)+wrp(ixo^s,
mom(idim))*tmp2(ixo^s))*tmp3(ixo^s)
919 dmean(ixo^s) = (tmp1(ixo^s)*csoundl(ixo^s)+tmp2(ixo^s)*csoundr(ixo^s)) * &
920 tmp3(ixo^s) + 0.5d0*tmp1(ixo^s)*tmp2(ixo^s)*tmp3(ixo^s)**2 * &
921 (wrp(ixo^s,
mom(idim))-wlp(ixo^s,
mom(idim)))**2
923 dmean(ixo^s)=dsqrt(dmean(ixo^s))
924 if(
present(cmin))
then
925 cmin(ixo^s,1)=umean(ixo^s)-dmean(ixo^s)
926 cmax(ixo^s,1)=umean(ixo^s)+dmean(ixo^s)
928 {
do ix^db=ixomin^db,ixomax^db\}
929 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
930 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
934 cmax(ixo^s,1)=dabs(umean(ixo^s))+dmean(ixo^s)
938 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
939 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
943 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
944 tmp1(ixo^s)=wmean(ixo^s,
mom(idim))/wmean(ixo^s,
rho_)
946 csoundr(ixo^s) = dsqrt(csoundr(ixo^s))
948 if(
present(cmin))
then
949 cmax(ixo^s,1)=max(tmp1(ixo^s)+csoundr(ixo^s),zero)
950 cmin(ixo^s,1)=min(tmp1(ixo^s)-csoundr(ixo^s),zero)
951 if(h_correction)
then
952 {
do ix^db=ixomin^db,ixomax^db\}
953 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
954 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
958 cmax(ixo^s,1)=dabs(tmp1(ixo^s))+csoundr(ixo^s)
962 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
973 csoundl(ixo^s)=max(dsqrt(csoundl(ixo^s)),dsqrt(csoundr(ixo^s)))
974 if(
present(cmin))
then
975 cmin(ixo^s,1)=min(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))-csoundl(ixo^s)
976 cmax(ixo^s,1)=max(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))+csoundl(ixo^s)
977 if(h_correction)
then
978 {
do ix^db=ixomin^db,ixomax^db\}
979 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
980 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
984 cmax(ixo^s,1)=max(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))+csoundl(ixo^s)
987 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
988 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
998 integer,
intent(in) :: ixi^
l, ixo^
l
999 double precision,
intent(in) :: w(ixi^s,nw)
1000 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1001 double precision,
intent(out) :: csound2(ixi^s)
1014 integer,
intent(in) :: ixi^
l, ixo^
l
1015 double precision,
intent(in) :: w(ixi^s, 1:nw)
1016 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1017 double precision,
intent(out):: pth(ixi^s)
1021 pth(ixo^s) = (
hd_gamma - 1.0d0) * (w(ixo^s,
e_) - &
1032 {
do ix^db= ixo^lim^db\}
1034 write(*,*)
"Error: small value of gas pressure",pth(ix^
d),&
1035 " encountered when call hd_get_pthermal"
1037 write(*,*)
"Location: ", x(ix^
d,:)
1038 write(*,*)
"Cell number: ", ix^
d
1040 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^
d,iw)
1044 write(*,*)
"Saving status at the previous time step"
1051 {
do ix^db= ixo^lim^db\}
1063 integer,
intent(in) :: ixI^L, ixO^L
1064 double precision,
intent(in) :: w(ixI^S, 1:nw)
1065 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1066 double precision,
intent(out):: res(ixI^S)
1069 res(ixo^s)=res(ixo^s)/w(ixo^s,
rho_)
1076 integer,
intent(in) :: ixI^L, ixO^L
1077 double precision,
intent(in) :: w(ixI^S, 1:nw)
1078 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1079 double precision,
intent(out):: res(ixI^S)
1087 integer,
intent(in) :: ixI^L, ixO^L
1088 double precision,
intent(inout) :: w(ixI^S, nw)
1089 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1092 w(ixo^s,
e_)=w(ixo^s,
e_)&
1101 integer,
intent(in) :: ixI^L, ixO^L
1102 double precision,
intent(inout) :: w(ixI^S, nw)
1103 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1106 w(ixo^s,
e_)=w(ixo^s,
e_)&
1117 integer,
intent(in) :: ixI^L, ixO^L, idim
1118 double precision,
intent(in) :: w(ixI^S, 1:nw), x(ixI^S, 1:ndim)
1119 double precision,
intent(out) :: f(ixI^S, nwflux)
1120 double precision :: pth(ixI^S), v(ixI^S),frame_vel(ixI^S)
1121 integer :: idir, itr
1126 f(ixo^s,
rho_) = v(ixo^s) * w(ixo^s,
rho_)
1130 f(ixo^s,
mom(idir)) = v(ixo^s) * w(ixo^s,
mom(idir))
1133 f(ixo^s,
mom(idir)) = f(ixo^s,
mom(idir)) + v(ixo^s) * frame_vel(ixo^s)*w(ixo^s,
rho_)
1137 f(ixo^s,
mom(idim)) = f(ixo^s,
mom(idim)) + pth(ixo^s)
1141 f(ixo^s,
e_) = v(ixo^s) * (w(ixo^s,
e_) + pth(ixo^s))
1145 f(ixo^s,
tracer(itr)) = v(ixo^s) * w(ixo^s,
tracer(itr))
1162 integer,
intent(in) :: ixI^L, ixO^L, idim
1164 double precision,
intent(in) :: wC(ixI^S, 1:nw)
1166 double precision,
intent(in) :: w(ixI^S, 1:nw)
1167 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1168 double precision,
intent(out) :: f(ixI^S, nwflux)
1169 double precision :: pth(ixI^S),frame_vel(ixI^S)
1170 integer :: idir, itr
1173 pth(ixo^s) = w(ixo^s,
p_)
1178 f(ixo^s,
rho_) = w(ixo^s,
mom(idim)) * w(ixo^s,
rho_)
1182 f(ixo^s,
mom(idir)) = w(ixo^s,
mom(idim)) * wc(ixo^s,
mom(idir))
1184 call mpistop(
"hd_rotating_frame not implemented yet with angmomfix")
1187 f(ixo^s,
mom(idir)) = f(ixo^s,
mom(idir)) + w(ixo^s,
mom(idim))* wc(ixo^s,
rho_) * frame_vel(ixo^s)
1191 f(ixo^s,
mom(idim)) = f(ixo^s,
mom(idim)) + pth(ixo^s)
1195 f(ixo^s,
e_) = w(ixo^s,
mom(idim)) * (wc(ixo^s,
e_) + w(ixo^s,
p_))
1228 integer,
intent(in) :: ixI^L, ixO^L
1229 double precision,
intent(in) :: qdt, x(ixI^S, 1:ndim)
1230 double precision,
intent(inout) :: wCT(ixI^S, 1:nw), w(ixI^S, 1:nw)
1234 double precision :: pth(ixI^S), source(ixI^S), minrho
1235 integer :: iw,idir, h1x^L{^NOONED, h2x^L}
1236 integer :: mr_,mphi_
1237 integer :: irho, ifluid, n_fluids
1238 double precision :: exp_factor(ixI^S), del_exp_factor(ixI^S), exp_factor_primitive(ixI^S)
1252 source(ixo^s) =
source(ixo^s)*del_exp_factor(ixo^s)/exp_factor(ixo^s)
1256 do ifluid = 0, n_fluids-1
1258 if (ifluid == 0)
then
1274 where (wct(ixo^s, irho) > minrho)
1275 source(ixo^s) =
source(ixo^s) + wct(ixo^s, mphi_)**2 / wct(ixo^s, irho)
1276 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt *
source(ixo^s) / x(ixo^s,
r_)
1280 where (wct(ixo^s, irho) > minrho)
1281 source(ixo^s) = -wct(ixo^s, mphi_) * wct(ixo^s, mr_) / wct(ixo^s, irho)
1282 w(ixo^s, mphi_) = w(ixo^s, mphi_) + qdt *
source(ixo^s) / x(ixo^s,
r_)
1287 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt *
source(ixo^s) / x(ixo^s,
r_)
1292 call mpistop(
"Dust geom source terms not implemented yet with spherical geometries")
1296 h1x^l=ixo^l-
kr(1,^
d); {^nooned h2x^l=ixo^l-
kr(2,^
d);}
1299 source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
1300 *(
block%surfaceC(ixo^s, 1) -
block%surfaceC(h1x^s, 1)) &
1301 /
block%dvolume(ixo^s)
1307 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt *
source(ixo^s) / x(ixo^s, 1)
1311 source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
1312 * (
block%surfaceC(ixo^s, 2) -
block%surfaceC(h2x^s, 2)) &
1313 /
block%dvolume(ixo^s)
1315 source(ixo^s) =
source(ixo^s) + (wct(ixo^s,
mom(3))**2 / wct(ixo^s,
rho_)) / tan(x(ixo^s, 2))
1320 w(ixo^s,
mom(2)) = w(ixo^s,
mom(2)) + qdt *
source(ixo^s) / x(ixo^s, 1)
1325 source(ixo^s) = -(wct(ixo^s,
mom(3)) * wct(ixo^s, mr_)) / wct(ixo^s,
rho_)&
1326 - (wct(ixo^s,
mom(2)) * wct(ixo^s,
mom(3))) / wct(ixo^s,
rho_) / tan(x(ixo^s, 2))
1327 w(ixo^s,
mom(3)) = w(ixo^s,
mom(3)) + qdt *
source(ixo^s) / x(ixo^s, 1)
1337 call mpistop(
"Rotating frame not implemented yet with dust")
1355 integer,
intent(in) :: ixI^L, ixO^L
1356 double precision,
intent(in) :: qdt
1357 double precision,
intent(in) :: wCT(ixI^S, 1:nw), x(ixI^S, 1:ndim)
1358 double precision,
intent(inout) :: w(ixI^S, 1:nw)
1359 logical,
intent(in) :: qsourcesplit
1360 logical,
intent(inout) :: active
1361 double precision,
intent(in),
optional :: wCTprim(ixI^S, 1:nw)
1363 double precision :: gravity_field(ixI^S, 1:ndim)
1364 integer :: idust, idim
1372 qsourcesplit,active,
rc_fl)
1387 call usr_gravity(ixi^l, ixo^l, wct, x, gravity_field)
1391 + qdt * gravity_field(ixo^s, idim) * wct(ixo^s,
dust_rho(idust))
1411 integer,
intent(in) :: ixI^L, ixO^L
1412 double precision,
intent(in) :: dx^D, x(ixI^S, 1:^ND)
1413 double precision,
intent(in) :: w(ixI^S, 1:nw)
1414 double precision,
intent(inout) :: dtnew
1442 integer,
intent(in) :: ixi^l, ixo^l
1443 double precision,
intent(in) :: w(ixi^s, nw)
1444 double precision :: ke(ixo^s)
1445 double precision,
intent(in),
optional :: inv_rho(ixo^s)
1447 if (
present(inv_rho))
then
1448 ke = 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) * inv_rho
1450 ke = 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) / w(ixo^s,
rho_)
1456 integer,
intent(in) :: ixi^l, ixo^l
1457 double precision,
intent(in) :: w(ixi^s, nw)
1458 double precision :: inv_rho(ixo^s)
1461 inv_rho = 1.0d0 / w(ixo^s,
rho_)
1471 logical,
intent(in) :: primitive
1472 integer,
intent(in) :: ixI^L,ixO^L
1473 double precision,
intent(inout) :: w(ixI^S,1:nw)
1474 double precision,
intent(in) :: x(ixI^S,1:ndim)
1475 character(len=*),
intent(in) :: subname
1478 logical :: flag(ixI^S,1:nw)
1482 call hd_check_w(primitive, ixi^l, ixo^l, w, flag)
1490 where(flag(ixo^s,
rho_)) w(ixo^s,
mom(idir)) = 0.0d0
1498 where(flag(ixo^s,
rho_)) w(ixo^s,
e_) = small_e +
hd_kin_en(w,ixi^l,ixo^l)
1507 where(flag(ixo^s,
e_))
1532 -0.5d0*sum(w(ixi^s,
mom(:))**2, dim=ndim+1)/w(ixi^s,
rho_))
1535 +0.5d0*sum(w(ixi^s,
mom(:))**2, dim=ndim+1)/w(ixi^s,
rho_)
1547 if(.not.primitive)
then
1555 w(ixo^s,
mom(idir)) = w(ixo^s,
mom(idir))/w(ixo^s,
rho_)
subroutine mpistop(message)
Exit MPI-AMRVAC with an error message.
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
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_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.
logical angmomfix
Enable to strictly conserve the angular momentum (works both in cylindrical and spherical coordinates...
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.
integer, 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 (Johnston 2019 ApJL, 873, L22) for MHD or 1D HD.
logical crash
Save a snapshot before crash a run met unphysical values.
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
double precision, dimension(ndim) dxlevel
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, 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 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 hd_angmomfix(fC, x, wnew, ixIL, ixOL, idim)
Add fluxes in an angular momentum conserving way.
integer, public, protected e_
Index of the energy density (-1 if not present)
logical, public, protected hd_radiative_cooling
Whether radiative cooling is added.
subroutine hd_get_flux(wC, w, x, ixIL, ixOL, idim, f)
double precision, public hd_gamma
The adiabatic index.
subroutine hd_add_source(qdt, ixIL, ixOL, wCT, w, x, qsourcesplit, active, wCTprim)
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.
subroutine hd_ei_to_e1(ixIL, ixOL, w, x)
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.
subroutine hd_sts_set_source_tc_hd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux)
subroutine hd_add_source_geom(qdt, ixIL, ixOL, wCT, w, x)
Add geometrical source terms to w.
subroutine hd_ei_to_e(ixIL, ixOL, w, x)
Transform internal energy to total energy.
subroutine hd_write_info(fh)
Write this module's parameters to a snapsoht.
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)
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 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.
subroutine hd_e_to_ei1(ixIL, ixOL, w, x)
Transform total energy to internal energy.
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.
double precision, public, protected he_abundance
Helium abundance over Hydrogen.
logical, public, protected hd_gravity
Whether gravity is added.
subroutine hd_physical_units
subroutine, public hd_to_conserved(ixIL, ixOL, w, x)
Transform primitive variables into conservative ones.
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)
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 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...
procedure(sub_get_a2max), pointer phys_get_a2max
procedure(sub_convert), pointer phys_to_primitive
procedure(sub_small_values), pointer phys_handle_small_values
procedure(sub_write_info), pointer phys_write_info
procedure(sub_get_flux), pointer phys_get_flux
procedure(sub_evaluate_implicit), pointer phys_evaluate_implicit
logical phys_req_diagonal
Whether the physics routines require diagonal ghost cells, for example for computing a curl.
procedure(sub_get_cbounds), pointer phys_get_cbounds
procedure(sub_check_params), pointer phys_te_images
procedure(sub_get_dt), pointer phys_get_dt
logical phys_total_energy
Solve total energy equation or not.
procedure(sub_get_pthermal), pointer phys_get_pthermal
procedure(sub_get_tcutoff), pointer phys_get_tcutoff
procedure(sub_add_source_geom), pointer phys_add_source_geom
procedure(sub_check_params), pointer phys_check_params
integer, parameter flux_default
Indicates a normal flux.
integer, dimension(:, :), allocatable flux_type
Array per direction per variable, which can be used to specify that certain fluxes have to be treated...
integer phys_wider_stencil
To use wider stencils in flux calculations. A value of 1 will extend it by one cell in both direction...
procedure(sub_convert), pointer phys_to_conserved
character(len=name_len) physics_type
String describing the physics type of the simulation.
procedure(sub_check_w), pointer phys_check_w
procedure(sub_implicit_update), pointer phys_implicit_update
double precision phys_gamma
procedure(sub_add_source), pointer phys_add_source
procedure(sub_angmomfix), pointer phys_angmomfix
procedure(sub_get_cmax), pointer phys_get_cmax
procedure(sub_get_v), pointer phys_get_v
logical phys_energy
Solve energy equation or not.
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_add_source(qdt, ixIL, ixOL, wCT, w, x, qsourcesplit, active, fl)
subroutine radiative_cooling_init_params(phys_gamma, He_abund)
Radiative cooling initialization.
Module for including rotating frame in hydrodynamics simulations The rotation vector is assumed to be...
subroutine rotating_frame_add_source(qdt, 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.
subroutine rotating_frame_velocity(x, ixIL, ixOL, frame_vel)
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 Adaptation of mod_thermal_conduction for the mod_supertimestepping ...
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)
Read tc module parameters from par file: MHD case.
subroutine tc_init_params(phys_gamma)
double precision function, public get_tc_dt_hd(w, ixIL, ixOL, dxD, x, fl)
subroutine get_euv_image(qunit, fl)
subroutine get_sxr_image(qunit, fl)
subroutine get_euv_spectrum(qunit, fl)
Module with all the methods that users can customize in AMRVAC.
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)