55 integer,
public,
protected ::
rho_
58 integer,
allocatable,
public,
protected ::
mom(:)
61 integer,
public,
protected ::
e_
64 integer,
public,
protected ::
p_
67 integer,
public,
protected ::
te_
72 integer,
public,
protected ::
q_
81 double precision,
protected :: small_e
90 double precision,
public,
protected ::
h_ion_fr=1d0
93 double precision,
public,
protected ::
he_ion_fr=1d0
100 double precision,
public,
protected ::
rr=1d0
107 double precision :: gamma_1, inv_gamma_1
112 function fun_kin_en(w, ixI^L, ixO^L, inv_rho)
result(ke)
114 integer,
intent(in) :: ixi^l, ixo^l
115 double precision,
intent(in) :: w(ixi^s, nw)
116 double precision :: ke(ixo^s)
117 double precision,
intent(in),
optional :: inv_rho(ixo^s)
118 end function fun_kin_en
146 subroutine ffhd_read_params(files)
149 character(len=*),
intent(in) :: files(:)
157 do n = 1,
size(files)
158 open(
unitpar, file=trim(files(n)), status=
"old")
159 read(
unitpar, ffhd_list,
end=111)
162 end subroutine ffhd_read_params
167 integer,
intent(in) :: fh
168 integer,
parameter :: n_par = 1
169 double precision :: values(n_par)
170 character(len=name_len) :: names(n_par)
171 integer,
dimension(MPI_STATUS_SIZE) :: st
174 call mpi_file_write(fh, n_par, 1, mpi_integer, st, er)
178 call mpi_file_write(fh, values, n_par, mpi_double_precision, st, er)
179 call mpi_file_write(fh, names, n_par * name_len, mpi_character, st, er)
199 if(
mype==0)
write(*,*)
'WARNING: set ffhd_thermal_conduction=F when ffhd_energy=F'
203 if(
mype==0)
write(*,*)
'WARNING: set ffhd_hyperbolic_thermal_conduction=F when ffhd_energy=F'
207 if(
mype==0)
write(*,*)
'WARNING: set ffhd_radiative_cooling=F when ffhd_energy=F'
211 if(
mype==0)
write(*,*)
'WARNING: set ffhd_trac=F when ffhd_energy=F'
215 if(
mype==0)
write(*,*)
'WARNING: set ffhd_partial_ionization=F when ffhd_energy=F'
221 if(
mype==0)
write(*,*)
'WARNING: set ffhd_partial_ionization=F when eq_state_units=F'
227 if(
mype==0)
write(*,*)
'WARNING: turn off parabolic TC when using hyperbolic TC'
230 physics_type =
"ffhd"
232 phys_internal_e=.false.
244 if(
mype==0)
write(*,*)
'WARNING: reset ffhd_trac_type=1 for 1D simulation'
249 if(
mype==0)
write(*,*)
'WARNING: set ffhd_trac_mask==bigdouble for global TRAC method'
253 allocate(start_indices(number_species),stop_indices(number_species))
260 mom(:) = var_set_momentum(1)
264 e_ = var_set_energy()
282 stop_indices(1)=nwflux
289 te_ = var_set_auxvar(
'Te',
'Te')
310 if(.not.
allocated(flux_type))
then
311 allocate(flux_type(
ndir, nwflux))
312 flux_type = flux_default
313 else if(any(shape(flux_type) /= [
ndir, nwflux]))
then
314 call mpistop(
"phys_check error: flux_type has wrong shape")
372 call mpistop(
"thermal conduction needs ffhd_energy=T")
375 call mpistop(
"hyperbolic thermal conduction needs ffhd_energy=T")
378 call mpistop(
"radiative cooling needs ffhd_energy=T")
383 phys_req_diagonal = .true.
407 rc_fl%get_var_Rfactor => ffhd_get_rfactor
410 rc_fl%has_equi = .false.
415 te_fl_ffhd%get_var_Rfactor => ffhd_get_rfactor
437 case(
'EIvtiCCmpi',
'EIvtuCCmpi')
439 case(
'ESvtiCCmpi',
'ESvtuCCmpi')
441 case(
'SIvtiCCmpi',
'SIvtuCCmpi')
443 case(
'WIvtiCCmpi',
'WIvtuCCmpi')
446 call mpistop(
"Error in synthesize emission: Unknown convert_type")
455 integer,
intent(in) :: ixI^L, ixO^L, igrid, nflux
456 double precision,
intent(in) :: x(ixI^S,1:ndim)
457 double precision,
intent(inout) :: wres(ixI^S,1:nw), w(ixI^S,1:nw)
458 double precision,
intent(in) :: my_dt
459 logical,
intent(in) :: fix_conserve_at_step
470 integer,
intent(in) :: ixi^
l, ixo^
l
471 double precision,
intent(in) ::
dx^
d, x(ixi^s,1:
ndim)
472 double precision,
intent(in) :: w(ixi^s,1:nw)
473 double precision :: dtnew
481 integer,
intent(in) :: ixI^L,ixO^L
482 double precision,
intent(inout) :: w(ixI^S,1:nw)
483 double precision,
intent(in) :: x(ixI^S,1:ndim)
484 integer,
intent(in) :: step
485 character(len=140) :: error_msg
487 write(error_msg,
"(a,i3)")
"Thermal conduction step ", step
493 type(tc_fluid),
intent(inout) :: fl
496 logical :: tc_saturate=.false.
497 double precision :: tc_k_para=0d0
498 character(len=std_len) :: tc_slope_limiter=
"MC"
500 namelist /tc_list/ tc_saturate, tc_slope_limiter, tc_k_para
504 read(
unitpar, tc_list,
end=111)
508 fl%tc_saturate = tc_saturate
509 fl%tc_k_para = tc_k_para
510 select case(tc_slope_limiter)
512 fl%tc_slope_limiter = 0
515 fl%tc_slope_limiter = 1
518 fl%tc_slope_limiter = 2
521 fl%tc_slope_limiter = 3
524 fl%tc_slope_limiter = 4
526 call mpistop(
"Unknown tc_slope_limiter, choose MC, minmod")
533 type(rc_fluid),
intent(inout) :: fl
535 integer :: ncool = 4000
536 double precision :: cfrac=0.1d0
539 character(len=std_len) :: coolcurve=
'JCcorona'
542 character(len=std_len) :: coolmethod=
'exact'
545 logical :: Tfix=.false.
551 logical :: rc_split=.false.
552 logical :: rad_cut=.false.
553 double precision :: rad_cut_hgt=0.5d0
554 double precision :: rad_cut_dey=0.15d0
556 namelist /rc_list/ coolcurve, coolmethod, ncool, cfrac, tlow, tfix, rc_split, rad_cut, rad_cut_hgt, rad_cut_dey
560 read(
unitpar, rc_list,
end=111)
565 fl%coolcurve=coolcurve
566 fl%coolmethod=coolmethod
572 fl%rad_cut_hgt=rad_cut_hgt
573 fl%rad_cut_dey=rad_cut_dey
583 if (
ffhd_gamma <= 0.0d0)
call mpistop (
"Error: ffhd_gamma <= 0")
584 if (
ffhd_adiab < 0.0d0)
call mpistop (
"Error: ffhd_adiab < 0")
588 call mpistop (
"Error: ffhd_gamma <= 0 or ffhd_gamma == 1")
589 inv_gamma_1=1.d0/gamma_1
594 call mpistop(
"usr_set_equi_vars has to be implemented in the user file")
600 double precision :: mp,kB
601 double precision :: a,b
648 logical,
intent(in) :: primitive
649 integer,
intent(in) :: ixI^L, ixO^L
650 double precision,
intent(in) :: w(ixI^S,nw)
651 double precision :: tmp(ixI^S)
652 logical,
intent(inout) :: flag(ixI^S,1:nw)
662 where(tmp(ixo^s) < small_e) flag(ixo^s,
e_) = .true.
669 integer,
intent(in) :: ixI^L, ixO^L
670 double precision,
intent(inout) :: w(ixI^S, nw)
671 double precision,
intent(in) :: x(ixI^S, 1:ndim)
672 double precision :: inv_gamma2(ixO^S)
676 w(ixo^s,
e_)=w(ixo^s,
p_)*inv_gamma_1+half*w(ixo^s,
mom(1))**2*w(ixo^s,
rho_)
683 integer,
intent(in) :: ixI^L, ixO^L
684 double precision,
intent(inout) :: w(ixI^S, nw)
685 double precision,
intent(in) :: x(ixI^S, 1:ndim)
686 double precision :: inv_rho(ixO^S), gamma2(ixO^S)
690 call ffhd_handle_small_values(.false., w, x, ixi^l, ixo^l,
'ffhd_to_primitive_origin')
693 w(ixo^s,
mom(1)) = w(ixo^s,
mom(1))/w(ixo^s,
rho_)
695 w(ixo^s,
p_)=gamma_1*(w(ixo^s,
e_)-half*w(ixo^s,
rho_)*w(ixo^s,
mom(1))**2)
701 integer,
intent(in) :: ixi^
l, ixo^
l
702 double precision,
intent(inout) :: w(ixi^s, nw)
703 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
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)
723 logical,
intent(in) :: primitive
724 integer,
intent(in) :: ixI^L,ixO^L
725 double precision,
intent(inout) :: w(ixI^S,1:nw)
726 double precision,
intent(in) :: x(ixI^S,1:ndim)
727 character(len=*),
intent(in) :: subname
729 logical :: flag(ixI^S,1:nw)
730 double precision :: tmp2(ixI^S)
732 call phys_check_w(primitive, ixi^l, ixi^l, w, flag)
739 where(flag(ixo^s,
rho_)) w(ixo^s,
mom(1)) = 0.0d0
745 where(flag(ixo^s,
e_))
762 if(.not.primitive)
then
775 integer,
intent(in) :: ixI^L, ixO^L
776 double precision,
intent(in) :: w(ixI^S,nw), x(ixI^S,1:ndim)
777 double precision,
intent(out) :: v(ixI^S,ndir)
778 double precision :: rho(ixI^S)
782 rho(ixo^s)=1.d0/rho(ixo^s)
784 v(ixo^s,ndir) = w(ixo^s,
mom(1))*
block%B0(ixo^s,idir,0)*rho(ixo^s)
790 integer,
intent(in) :: ixi^
l, ixo^
l, idim
791 double precision,
intent(in) :: w(ixi^s,nw), x(ixi^s,1:
ndim)
792 double precision,
intent(out) :: v(ixi^s)
793 double precision :: rho(ixi^s)
796 v(ixo^s) = (w(ixo^s,
mom(1))*
block%B0(ixo^s,idim,0)) / rho(ixo^s)
801 integer,
intent(in) :: ixI^L, ixO^L, idim
803 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S,1:ndim)
804 double precision,
intent(inout) :: cmax(ixI^S)
811 cmax(ixo^s)=abs(w(ixo^s,
mom(1))*
block%B0(ixo^s,idim,0))+cmax(ixo^s)
817 integer,
intent(in) :: ixI^L, ixO^L
818 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S,1:ndim)
819 double precision,
intent(inout) :: cs2max
820 double precision :: cs2(ixI^S)
823 cs2max=maxval(cs2(ixo^s))
828 integer,
intent(in) :: ixI^L, ixO^L
829 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S,1:ndim)
830 double precision,
intent(inout) :: a2max(ndim)
831 double precision :: a2(ixI^S,ndim,nw)
832 integer :: gxO^L,hxO^L,jxO^L,kxO^L,i,j
837 hxo^l=ixo^l-
kr(i,^
d);
838 gxo^l=hxo^l-
kr(i,^
d);
839 jxo^l=ixo^l+
kr(i,^
d);
840 kxo^l=jxo^l+
kr(i,^
d);
841 a2(ixo^s,i,1:nw)=abs(-w(kxo^s,1:nw)+16.d0*w(jxo^s,1:nw)&
842 -30.d0*w(ixo^s,1:nw)+16.d0*w(hxo^s,1:nw)-w(gxo^s,1:nw))
843 a2max(i)=maxval(a2(ixo^s,i,1:nw))/12.d0/
dxlevel(i)**2
850 integer,
intent(in) :: ixI^L,ixO^L
851 double precision,
intent(in) :: x(ixI^S,1:ndim)
852 double precision,
intent(inout) :: w(ixI^S,1:nw)
853 double precision,
intent(out) :: Tco_local,Tmax_local
854 double precision,
parameter :: trac_delta=0.25d0
855 double precision :: tmp1(ixI^S),Te(ixI^S),lts(ixI^S)
856 double precision,
dimension(ixI^S,1:ndir) :: bunitvec
857 double precision,
dimension(ixI^S,1:ndim) :: gradT
858 double precision :: Bdir(ndim)
859 double precision :: ltrc,ltrp,altr(ixI^S)
860 integer :: idims,jxO^L,hxO^L,ixA^D,ixB^D
861 integer :: jxP^L,hxP^L,ixP^L,ixQ^L
862 logical :: lrlt(ixI^S)
866 tmax_local=maxval(te(ixo^s))
876 lts(ixo^s)=0.5d0*abs(te(jxo^s)-te(hxo^s))/te(ixo^s)
878 where(lts(ixo^s) > trac_delta)
881 if(any(lrlt(ixo^s)))
then
882 tco_local=maxval(te(ixo^s), mask=lrlt(ixo^s))
893 lts(ixp^s)=0.5d0*abs(te(jxp^s)-te(hxp^s))/te(ixp^s)
894 lts(ixp^s)=max(one, (exp(lts(ixp^s))/ltrc)**ltrp)
895 lts(ixo^s)=0.25d0*(lts(jxo^s)+two*lts(ixo^s)+lts(hxo^s))
896 block%wextra(ixo^s,
tcoff_)=te(ixo^s)*lts(ixo^s)**0.4d0
898 call mpistop(
"ffhd_trac_type not allowed for 1D simulation")
913 call gradient(te,ixi^l,ixo^l,idims,tmp1)
914 gradt(ixo^s,idims)=tmp1(ixo^s)
916 bunitvec(ixo^s,:)=
block%B0(ixo^s,:,0)
921 ixb^d=(ixomin^d+ixomax^d-1)/2+ixa^d;
922 bdir(1:ndim)=bdir(1:ndim)+bunitvec(ixb^d,1:ndim)
924 if(sum(bdir(:)**2) .gt. zero)
then
925 bdir(1:ndim)=bdir(1:ndim)/dsqrt(sum(bdir(:)**2))
927 block%special_values(3:ndim+2)=bdir(1:ndim)
929 tmp1(ixo^s)=dsqrt(sum(bunitvec(ixo^s,:)**2,dim=ndim+1))
930 where(tmp1(ixo^s)/=0.d0)
931 tmp1(ixo^s)=1.d0/tmp1(ixo^s)
933 tmp1(ixo^s)=bigdouble
937 bunitvec(ixo^s,idims)=bunitvec(ixo^s,idims)*tmp1(ixo^s)
940 lts(ixo^s)=abs(sum(gradt(ixo^s,1:ndim)*bunitvec(ixo^s,1:ndim),dim=ndim+1))/te(ixo^s)
942 if(slab_uniform)
then
943 lts(ixo^s)=minval(dxlevel)*lts(ixo^s)
945 lts(ixo^s)=minval(block%ds(ixo^s,:),dim=ndim+1)*lts(ixo^s)
948 where(lts(ixo^s) > trac_delta)
951 if(any(lrlt(ixo^s)))
then
952 block%special_values(1)=maxval(te(ixo^s), mask=lrlt(ixo^s))
954 block%special_values(1)=zero
956 block%special_values(2)=tmax_local
974 call gradient(te,ixi^l,ixq^l,idims,gradt(ixi^s,idims))
975 call gradientx(te,x,ixi^l,hxp^l,idims,gradt(ixi^s,idims),.false.)
976 call gradientq(te,x,ixi^l,jxp^l,idims,gradt(ixi^s,idims))
978 bunitvec(ixp^s,:)=block%B0(ixp^s,:,0)
979 lts(ixp^s)=abs(sum(gradt(ixp^s,1:ndim)*bunitvec(ixp^s,1:ndim),dim=ndim+1))/te(ixp^s)
980 if(slab_uniform)
then
981 lts(ixp^s)=minval(dxlevel)*lts(ixp^s)
983 lts(ixp^s)=minval(block%ds(ixp^s,:),dim=ndim+1)*lts(ixp^s)
985 lts(ixp^s)=max(one, (exp(lts(ixp^s))/ltrc)**ltrp)
990 hxo^l=ixp^l-kr(idims,^d);
991 jxo^l=ixp^l+kr(idims,^d);
992 altr(ixp^s)=altr(ixp^s)+0.25d0*(lts(hxo^s)+two*lts(ixp^s)+lts(jxo^s))*bunitvec(ixp^s,idims)**2
994 block%wextra(ixp^s,
tcoff_)=te(ixp^s)*altr(ixp^s)**0.4d0
998 call mpistop(
"unknown ffhd_trac_type")
1003 subroutine ffhd_get_cbounds(wLC,wRC,wLp,wRp,x,ixI^L,ixO^L,idim,Hspeed,cmax,cmin)
1005 integer,
intent(in) :: ixI^L, ixO^L, idim
1006 double precision,
intent(in) :: wLC(ixI^S, nw), wRC(ixI^S, nw)
1007 double precision,
intent(in) :: wLp(ixI^S, nw), wRp(ixI^S, nw)
1008 double precision,
intent(in) :: x(ixI^S,1:ndim)
1009 double precision,
intent(inout) :: cmax(ixI^S,1:number_species)
1010 double precision,
intent(inout),
optional :: cmin(ixI^S,1:number_species)
1011 double precision,
intent(in) :: Hspeed(ixI^S,1:number_species)
1012 double precision :: wmean(ixI^S,nw)
1013 double precision,
dimension(ixI^S) :: umean, dmean, csoundL, csoundR, tmp1,tmp2,tmp3
1020 tmp1(ixo^s)=sqrt(wlp(ixo^s,
rho_))
1021 tmp2(ixo^s)=sqrt(wrp(ixo^s,
rho_))
1022 tmp3(ixo^s)=1.d0/(tmp1(ixo^s)+tmp2(ixo^s))
1023 umean(ixo^s)=(wlp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim)*tmp1(ixo^s)&
1024 +wrp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim)*tmp2(ixo^s))*tmp3(ixo^s)
1027 dmean(ixo^s)=(tmp1(ixo^s)*csoundl(ixo^s)+tmp2(ixo^s)*csoundr(ixo^s)) * &
1028 tmp3(ixo^s) + 0.5d0*tmp1(ixo^s)*tmp2(ixo^s)*tmp3(ixo^s)**2 * &
1029 (wrp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim)-wlp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim))**2
1030 dmean(ixo^s)=dsqrt(dmean(ixo^s))
1031 if(
present(cmin))
then
1032 cmin(ixo^s,1)=umean(ixo^s)-dmean(ixo^s)
1033 cmax(ixo^s,1)=umean(ixo^s)+dmean(ixo^s)
1035 cmax(ixo^s,1)=abs(umean(ixo^s))+dmean(ixo^s)
1038 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
1039 tmp1(ixo^s)=wmean(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim)/wmean(ixo^s,
rho_)
1041 if(
present(cmin))
then
1042 cmax(ixo^s,1)=max(tmp1(ixo^s)+csoundr(ixo^s),zero)
1043 cmin(ixo^s,1)=min(tmp1(ixo^s)-csoundr(ixo^s),zero)
1045 cmax(ixo^s,1)=abs(tmp1(ixo^s))+csoundr(ixo^s)
1051 csoundl(ixo^s)=max(csoundl(ixo^s),csoundr(ixo^s))
1052 if(
present(cmin))
then
1053 cmin(ixo^s,1)=min(wlp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim),&
1054 wrp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim))-csoundl(ixo^s)
1055 cmax(ixo^s,1)=max(wlp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim),&
1056 wrp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim))+csoundl(ixo^s)
1058 cmax(ixo^s,1)=max(wlp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim),&
1059 wrp(ixo^s,
mom(1))*
block%B0(ixo^s,idim,idim))+csoundl(ixo^s)
1066 integer,
intent(in) :: ixI^L, ixO^L, idim
1067 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S,1:ndim)
1068 double precision,
intent(out):: csound(ixI^S)
1071 csound(ixo^s) = dsqrt(csound(ixo^s))*abs(
block%B0(ixo^s,idim,idim))
1078 integer,
intent(in) :: ixI^L, ixO^L, idim
1079 double precision,
intent(in) :: w(ixI^S, nw), x(ixI^S,1:ndim)
1080 double precision,
intent(out):: csound(ixI^S)
1087 csound(ixo^s) = dsqrt(csound(ixo^s))
1093 integer,
intent(in) :: ixI^L, ixO^L
1094 double precision,
intent(in) :: w(ixI^S,nw)
1095 double precision,
intent(in) :: x(ixI^S,1:ndim)
1096 double precision,
intent(out):: pth(ixI^S)
1105 integer,
intent(in) :: ixI^L, ixO^L
1106 double precision,
intent(in) :: w(ixI^S,nw)
1107 double precision,
intent(in) :: x(ixI^S,1:ndim)
1108 double precision,
intent(out):: pth(ixI^S)
1113 {
do ix^db= ixo^lim^db\}
1118 elseif(check_small_values)
then
1119 {
do ix^db= ixo^lim^db\}
1120 if(pth(ix^d)<small_pressure)
then
1121 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1122 " encountered when call ffhd_get_pthermal"
1123 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1124 write(*,*)
"Location: ", x(ix^d,:)
1125 write(*,*)
"Cell number: ", ix^d
1127 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1130 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1131 write(*,*)
"Saving status at the previous time step"
1140 integer,
intent(in) :: ixI^L, ixO^L
1141 double precision,
intent(in) :: w(ixI^S, 1:nw)
1142 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1143 double precision,
intent(out):: res(ixI^S)
1145 res(ixo^s) = w(ixo^s,
te_)
1150 integer,
intent(in) :: ixI^L, ixO^L
1151 double precision,
intent(in) :: w(ixI^S, 1:nw)
1152 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1153 double precision,
intent(out):: res(ixI^S)
1154 double precision :: R(ixI^S)
1156 call ffhd_get_rfactor(w,x,ixi^l,ixo^l,r)
1157 res(ixo^s) = gamma_1 * w(ixo^s,
e_)/(w(ixo^s,
rho_)*r(ixo^s))
1162 integer,
intent(in) :: ixI^L, ixO^L
1163 double precision,
intent(in) :: w(ixI^S, 1:nw)
1164 double precision,
intent(in) :: x(ixI^S, 1:ndim)
1165 double precision,
intent(out):: res(ixI^S)
1167 double precision :: R(ixI^S)
1169 call ffhd_get_rfactor(w,x,ixi^l,ixo^l,r)
1171 res(ixo^s)=res(ixo^s)/(r(ixo^s)*w(ixo^s,
rho_))
1176 integer,
intent(in) :: ixi^
l, ixo^
l
1177 double precision,
intent(in) :: w(ixi^s,nw)
1178 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1179 double precision,
intent(out) :: csound2(ixi^s)
1180 double precision :: rho(ixi^s)
1185 csound2(ixo^s)=
ffhd_gamma*csound2(ixo^s)/rho(ixo^s)
1194 integer,
intent(in) :: ixI^L, ixO^L, idim
1196 double precision,
intent(in) :: wC(ixI^S,nw)
1198 double precision,
intent(in) :: w(ixI^S,nw)
1199 double precision,
intent(in) :: x(ixI^S,1:ndim)
1200 double precision,
intent(out) :: f(ixI^S,nwflux)
1201 double precision :: ptotal(ixO^S)
1202 double precision :: tmp(ixI^S)
1203 integer :: idirmin, iw, idir, jdir, kdir
1204 double precision,
dimension(ixI^S) :: Te,tau,sigT
1209 ptotal(ixo^s)=w(ixo^s,
p_)
1215 f(ixo^s,
mom(1))=(wc(ixo^s,
mom(1))*w(ixo^s,
mom(1))+ptotal(ixo^s))*
block%B0(ixo^s,idim,idim)
1219 f(ixo^s,
e_)=w(ixo^s,
mom(1))*(wc(ixo^s,
e_)+ptotal(ixo^s))*
block%B0(ixo^s,idim,idim)
1221 f(ixo^s,
e_)=f(ixo^s,
e_)+w(ixo^s,
q_)*
block%B0(ixo^s,idim,idim)
1232 integer,
intent(in) :: ixI^L, ixO^L
1233 double precision,
intent(in) :: qdt,dtfactor
1234 double precision,
intent(in) :: wCT(ixI^S,1:nw),wCTprim(ixI^S,1:nw), x(ixI^S,1:ndim)
1235 double precision,
intent(inout) :: w(ixI^S,1:nw)
1236 logical,
intent(in) :: qsourcesplit
1237 logical,
intent(inout) :: active
1239 if (.not. qsourcesplit)
then
1241 call add_punitb(qdt,ixi^l,ixo^l,wct,w,x,wctprim)
1249 w,x,qsourcesplit,active,
rc_fl)
1264 if(.not.qsourcesplit)
then
1274 integer,
intent(in) :: ixI^L,ixO^L
1275 double precision,
intent(in) :: qdt
1276 double precision,
intent(in) :: wCT(ixI^S,1:nw),x(ixI^S,1:ndim)
1277 double precision,
intent(in) :: wCTprim(ixI^S,1:nw)
1278 double precision,
intent(inout) :: w(ixI^S,1:nw)
1280 integer :: idims,hxO^L
1281 double precision :: divb(ixI^S)
1286 hxo^l=ixo^l-
kr(idims,^
d);
1287 divb(ixo^s)=divb(ixo^s)+(
block%B0(ixo^s,idims,idims)-
block%B0(hxo^s,idims,idims))/
dxlevel(idims)
1292 w(ixo^s,
mom(1))=w(ixo^s,
mom(1))+qdt*wctprim(ixo^s,
p_)*divb(ixo^s)
1297 integer,
intent(in) :: ixi^
l, ixo^
l
1298 double precision,
intent(in) :: w(ixi^s,1:nw),x(ixi^s,1:
ndim)
1299 double precision,
intent(out) :: rho(ixi^s)
1301 rho(ixo^s) = w(ixo^s,
rho_)
1307 integer,
intent(in) :: ixI^L,ixO^L, ie
1308 double precision,
intent(inout) :: w(ixI^S,1:nw)
1309 double precision,
intent(in) :: x(ixI^S,1:ndim)
1310 character(len=*),
intent(in) :: subname
1312 logical :: flag(ixI^S,1:nw)
1313 double precision :: rho(ixI^S)
1316 where(w(ixo^s,ie)<small_e) flag(ixo^s,ie)=.true.
1317 if(any(flag(ixo^s,ie)))
then
1320 where(flag(ixo^s,ie)) w(ixo^s,ie)=small_e
1324 w(ixo^s,
e_)=w(ixo^s,
e_)*gamma_1
1326 w(ixo^s,
mom(1)) = w(ixo^s,
mom(1))/rho(ixo^s)
1335 integer,
intent(in) :: ixI^L, ixO^L
1336 double precision,
intent(in) :: wCT(ixI^S,1:nw), x(ixI^S,1:ndim)
1337 double precision,
intent(inout) :: w(ixI^S,1:nw)
1338 double precision :: iz_H(ixO^S),iz_He(ixO^S), pth(ixI^S)
1352 integer,
intent(in) :: ixI^L, ixO^L
1353 double precision,
intent(inout) :: dtnew
1354 double precision,
intent(in) :: dx^D
1355 double precision,
intent(in) :: w(ixI^S,1:nw)
1356 double precision,
intent(in) :: x(ixI^S,1:ndim)
1357 integer :: idirmin,idim
1358 double precision :: dxarr(ndim)
1359 double precision :: current(ixI^S,7-2*ndir:3),eta(ixI^S)
1490 integer,
intent(in) :: ixi^l, ixo^l
1491 double precision,
intent(in) :: w(ixi^s, nw)
1492 double precision :: ke(ixo^s)
1493 double precision,
intent(in),
optional :: inv_rho(ixo^s)
1495 if(
present(inv_rho))
then
1496 ke(ixo^s)=0.5d0*w(ixo^s,
mom(1))**2*inv_rho(ixo^s)
1498 ke(ixo^s)=0.5d0*w(ixo^s,
mom(1))**2/w(ixo^s,
rho_)
1505 integer,
intent(in) :: ixI^L, ixO^L
1506 double precision,
intent(in) :: w(ixI^S,1:nw)
1507 double precision,
intent(in) :: x(ixI^S,1:ndim)
1508 double precision,
intent(out):: Rfactor(ixI^S)
1509 double precision :: iz_H(ixO^S),iz_He(ixO^S)
1512 rfactor(ixo^s)=(1.d0+iz_h(ixo^s)+0.1d0*(1.d0+iz_he(ixo^s)*(1.d0+iz_he(ixo^s))))/(2.d0+3.d0*
he_abundance)
1517 integer,
intent(in) :: ixI^L, ixO^L
1518 double precision,
intent(in) :: w(ixI^S,1:nw)
1519 double precision,
intent(in) :: x(ixI^S,1:ndim)
1520 double precision,
intent(out):: Rfactor(ixI^S)
1527 integer,
intent(in) :: ixI^L, ixO^L
1528 double precision,
dimension(ixI^S,1:nw),
intent(in) :: w
1529 double precision,
dimension(ixI^S),
intent(in) :: Te
1530 double precision,
dimension(ixI^S),
intent(out) :: tau,sigT5
1532 double precision :: dxmin,taumin
1533 double precision,
dimension(ixI^S) :: sigT7,eint
1540 sigt7(ixo^s)=sigt5(ixo^s)*
block%wextra(ixo^s,
tcoff_)
1543 sigt7(ixo^s)=sigt5(ixo^s)*te(ixo^s)
1547 sigt7(ixo^s)=sigt5(ixo^s)*te(ixo^s)
1555 integer,
intent(in) :: ixI^L,ixO^L
1556 double precision,
intent(in) :: qdt
1557 double precision,
dimension(ixI^S,1:ndim),
intent(in) :: x
1558 double precision,
dimension(ixI^S,1:nw),
intent(in) :: wCT,wCTprim
1559 double precision,
dimension(ixI^S,1:nw),
intent(inout) :: w
1561 integer :: hxC^L,hxO^L,ixC^L,jxC^L,jxO^L,kxC^L
1562 double precision :: invdx
1563 double precision,
dimension(ixI^S) :: Te,tau,sigT,htc_qsrc,Tface
1564 double precision,
dimension(ixI^S) :: htc_esrc
1566 te(ixi^s)=wctprim(ixi^s,
p_)/wct(ixi^s,
rho_)
1567 call get_tau(ixi^l,ixo^l,wctprim,te,tau,sigt)
1572 ixcmin^
d=ixomin^
d-
kr(idims,^
d);ixcmax^
d=ixomax^
d;
1573 jxc^l=ixc^l+
kr(idims,^
d);
1574 kxc^l=jxc^l+
kr(idims,^
d);
1575 hxc^l=ixc^l-
kr(idims,^
d);
1576 hxo^l=ixo^l-
kr(idims,^
d);
1577 tface(ixc^s)=(7.d0*(te(ixc^s)+te(jxc^s))-(te(hxc^s)+te(kxc^s)))/12.d0
1578 htc_qsrc(ixo^s)=htc_qsrc(ixo^s)+sigt(ixo^s)*
block%B0(ixo^s,idims,0)*(tface(ixo^s)-tface(hxo^s))*invdx
1580 htc_qsrc(ixo^s)=(htc_qsrc(ixo^s)+wct(ixo^s,
q_))/tau(ixo^s)
1581 w(ixo^s,
q_)=w(ixo^s,
q_)-qdt*htc_qsrc(ixo^s)
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.
subroutine add_convert_method(phys_convert_vars, nwc, dataset_names, file_suffix)
Frozen-field hydrodynamics module.
integer, public, protected te_
Indices of temperature.
integer, public, protected ffhd_trac_type
Which TRAC method is used.
subroutine ffhd_get_cs2max(w, x, ixIL, ixOL, cs2max)
double precision, public hypertc_kappa
The thermal conductivity kappa in hyperbolic thermal conduction.
integer, public, protected e_
Index of the energy density (-1 if not present)
subroutine ffhd_handle_small_values_origin(primitive, w, x, ixIL, ixOL, subname)
double precision, public ffhd_gamma
The adiabatic index.
double precision function ffhd_get_tc_dt_ffhd(w, ixIL, ixOL, dxD, x)
logical, public, protected eq_state_units
subroutine ffhd_update_temperature(ixIL, ixOL, wCT, w, x)
subroutine ffhd_get_temperature_from_eint(w, x, ixIL, ixOL, res)
subroutine ffhd_get_dt(w, ixIL, ixOL, dtnew, dxD, x)
double precision, public ffhd_adiab
The adiabatic constant.
procedure(sub_get_pthermal), pointer, public ffhd_get_temperature
subroutine ffhd_get_temperature_from_etot(w, x, ixIL, ixOL, res)
subroutine rfactor_from_constant_ionization(w, x, ixIL, ixOL, Rfactor)
logical, public, protected ffhd_hyperbolic_thermal_conduction
Whether hyperbolic type thermal conduction is used.
subroutine, public ffhd_get_v_idim(w, x, ixIL, ixOL, idim, v)
type(rc_fluid), allocatable, public rc_fl
type of fluid for radiative cooling
subroutine ffhd_get_tcutoff(ixIL, ixOL, w, x, Tco_local, Tmax_local)
subroutine tc_params_read_ffhd(fl)
integer, public, protected rho_
Index of the density (in the w array)
integer, public, protected tcoff_
Index of the cutoff temperature for the TRAC method.
procedure(sub_get_pthermal), pointer, public ffhd_get_pthermal
subroutine ffhd_check_params
logical, public, protected ffhd_partial_ionization
Whether plasma is partially ionized.
procedure(sub_convert), pointer, public ffhd_to_conserved
integer, dimension(:), allocatable, public, protected mom
Indices of the momentum density.
subroutine ffhd_te_images
subroutine ffhd_to_conserved_origin(ixIL, ixOL, w, x)
double precision, public, protected h_ion_fr
Ionization fraction of H H_ion_fr = H+/(H+ + H)
procedure(fun_kin_en), pointer, public ffhd_kin_en
subroutine, public ffhd_phys_init()
subroutine ffhd_add_source(qdt, dtfactor, ixIL, ixOL, wCT, wCTprim, w, x, qsourcesplit, active)
procedure(sub_get_v), pointer, public ffhd_get_v
subroutine ffhd_get_a2max(w, x, ixIL, ixOL, a2max)
subroutine ffhd_write_info(fh)
Write this module's parameters to a snapsoht.
subroutine ffhd_to_primitive_origin(ixIL, ixOL, w, x)
subroutine ffhd_get_cbounds(wLC, wRC, wLp, wRp, x, ixIL, ixOL, idim, Hspeed, cmax, cmin)
logical, public, protected ffhd_energy
Whether an energy equation is used.
double precision, public, protected rr
type(tc_fluid), allocatable, public tc_fl
type of fluid for thermal conduction
subroutine ffhd_get_flux(wC, w, x, ixIL, ixOL, idim, f)
subroutine ffhd_physical_units()
subroutine, public ffhd_e_to_ei(ixIL, ixOL, w, x)
subroutine add_punitb(qdt, ixIL, ixOL, wCT, w, x, wCTprim)
subroutine ffhd_get_csound(w, x, ixIL, ixOL, idim, csound)
subroutine rfactor_from_temperature_ionization(w, x, ixIL, ixOL, Rfactor)
type(te_fluid), allocatable, public te_fl_ffhd
type of fluid for thermal emission synthesis
double precision, public, protected he_abundance
Helium abundance over Hydrogen.
subroutine ffhd_get_v_origin(w, x, ixIL, ixOL, v)
logical, public, protected ffhd_viscosity
Whether viscosity is added.
logical, public, protected ffhd_radiative_cooling
Whether radiative cooling is added.
subroutine ffhd_get_temperature_from_te(w, x, ixIL, ixOL, res)
subroutine rc_params_read(fl)
subroutine ffhd_handle_small_ei(w, x, ixIL, ixOL, ie, subname)
integer, public, protected q_
procedure(sub_convert), pointer, public ffhd_to_primitive
integer, public, protected tweight_
subroutine ffhd_get_cmax_origin(w, x, ixIL, ixOL, idim, cmax)
double precision, public, protected he_ion_fr2
Ratio of number He2+ / number He+ + He2+ He_ion_fr2 = He2+/(He2+ + He+)
logical, public, protected ffhd_trac
Whether TRAC method is used.
subroutine get_tau(ixIL, ixOL, w, Te, tau, sigT5)
subroutine ffhd_check_w_origin(primitive, ixIL, ixOL, w, flag)
subroutine ffhd_get_pthermal_origin(w, x, ixIL, ixOL, pth)
subroutine, public ffhd_ei_to_e(ixIL, ixOL, w, x)
subroutine ffhd_tc_handle_small_e(w, x, ixIL, ixOL, step)
logical, public, protected ffhd_thermal_conduction
Whether thermal conduction is used.
logical, public, protected ffhd_gravity
Whether gravity is added.
subroutine add_hypertc_source(qdt, ixIL, ixOL, wCT, w, x, wCTprim)
integer, public, protected p_
Index of the gas pressure (-1 if not present) should equal e_.
subroutine ffhd_get_pthermal_iso(w, x, ixIL, ixOL, pth)
subroutine ffhd_get_csound_prim(w, x, ixIL, ixOL, idim, csound)
Calculate fast magnetosonic wave speed.
double precision function, dimension(ixo^s) ffhd_kin_en_origin(w, ixIL, ixOL, inv_rho)
double precision, public, protected ffhd_trac_mask
Height of the mask used in the TRAC method.
double precision, public, protected he_ion_fr
Ionization fraction of He He_ion_fr = (He2+ + He+)/(He2+ + He+ + He)
subroutine, public ffhd_get_csound2(w, x, ixIL, ixOL, csound2)
subroutine, public ffhd_get_rho(w, x, ixIL, ixOL, rho)
integer, public, protected ffhd_trac_finegrid
Distance between two adjacent traced magnetic field lines (in finest cell size)
subroutine ffhd_sts_set_source_tc_ffhd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux)
Module for flux conservation near refinement boundaries.
Module with geometry-related routines (e.g., divergence, curl)
subroutine gradient(q, ixIL, ixOL, idir, gradq)
Calculate gradient of a scalar q within ixL in direction idir.
subroutine divvector(qvec, ixIL, ixOL, divq, fourthorder, sixthorder)
Calculate divergence of a vector qvec within ixL.
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 phys_trac_mask
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.
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
double precision dt
global time step
integer ndir
Number of spatial dimensions (components) for vector variables.
double precision unit_velocity
Physical scaling factor for velocity.
logical b0field
split magnetic field as background B0 field
logical need_global_cs2max
global value for csound speed
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
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
double precision cs2max_global
global largest cs2 for hyperbolic thermal conduction
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
double precision small_density
integer boundspeed
bound (left/min and right.max) speed of Riemann fan
integer phys_trac_finegrid
integer, parameter unitconvert
integer number_equi_vars
number of equilibrium set variables, besides the mag field
Module for including gravity in (magneto)hydrodynamics simulations.
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.
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.
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 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_ffhd(ixIL, ixOL, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux, fl)
anisotropic thermal conduction with slope limited symmetric scheme Sharma 2007 Journal of Computation...
subroutine tc_init_params(phys_gamma)
double precision function, public get_tc_dt_ffhd(w, ixIL, ixOL, dxD, x, fl)
Get the explicut timestep for the TC (ffhd implementation)
subroutine, public tc_get_ffhd_params(fl, read_ffhd_params)
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_equi_vars), pointer usr_set_equi_vars
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.