35 logical,
public,
protected ::
hd_dust = .false.
67 integer,
public,
protected ::
rho_
70 integer,
allocatable,
public,
protected ::
mom(:)
73 integer,
public,
protected :: ^
c&m^C_
76 integer,
allocatable,
public,
protected ::
tracer(:)
79 integer,
public,
protected ::
e_
82 integer,
public,
protected ::
p_
85 integer,
public,
protected ::
ne_
88 integer,
public,
protected ::
r_e
91 integer,
public,
protected ::
te_
94 integer,
public,
protected ::
fip_ = -1
97 logical,
public,
protected ::
hd_fip = .false.
103 integer,
public,
protected ::
q_
179 logical,
public,
protected ::
hd_trac = .false.
195 double precision,
public,
protected ::
h_ion_fr=1d0
205 double precision,
public,
protected ::
rr=1d0
236 subroutine hd_read_params(files)
238 character(len=*),
intent(in) :: files(:)
254 do n = 1,
size(files)
255 open(
unitpar, file=trim(files(n)), status=
"old")
256 read(
unitpar, hd_list,
end=111)
260 end subroutine hd_read_params
263 subroutine hd_write_info(fh)
265 integer,
intent(in) :: fh
266 integer,
parameter :: n_par = 1
267 double precision :: values(n_par)
268 character(len=name_len) :: names(n_par)
269 integer,
dimension(MPI_STATUS_SIZE) :: st
272 call mpi_file_write(fh, n_par, 1, mpi_integer, st, er)
275 values(1) = eos%gamma
276 call mpi_file_write(fh, values, n_par, mpi_double_precision, st, er)
277 call mpi_file_write(fh, names, n_par * name_len, mpi_character, st, er)
278 end subroutine hd_write_info
304 phys_internal_e = .false.
305 phys_gamma = eos%gamma
312 if(
mype==0)
write(*,*)
'WARNING: set hd_trac_type=1'
316 call mpistop(
"hd_trac_type=7 requires usr_get_heating to be set in mod_usr.t")
327 call mpistop(
"hd_trac_type=7 requires usr_get_heating to be set in mod_usr.t")
332 if(
mype==0)
write(*,*)
'WARNING: hd_trac disabled for ndim>=2 (only trac_type=7 supported)'
341 if(
mype==0)
write(*,*)
'WARNING: set hd_thermal_conduction=F when hd_energy=F'
345 if(
mype==0)
write(*,*)
'WARNING: set hd_hyperbolic_thermal_conduction=F when hd_energy=F'
349 if(
mype==0)
write(*,*)
'WARNING: set hd_radiative_cooling=F when hd_energy=F'
354 allocate(start_indices(number_species),stop_indices(number_species))
362 mom(:) = var_set_momentum(
ndir)
367 e_ = var_set_energy()
393 fip_ = var_set_fluxvar(
'rho_fip',
'fip', need_bc=.false.)
402 tracer(itr) = var_set_fluxvar(
"trc",
"trp", itr, need_bc=.false.)
405 if (eos%eos_type ==
'LTE')
then
408 else if (eos%eos_type ==
'PI')
then
419 if(.not.
hd_energy)
call mpistop(
"radiative transfer needs hd_energy=T")
420 call rt_sc_activate()
426 write(*,*)
'Warning: CAK force addition together with FLD radiation'
431 write(*,*)
'Warning: Optically thin cooling together with FLD radiation'
435 call mpistop(
'implicit dust addition not compatible with FLD radiation')
438 call mpistop(
'using FLD implies the use of an energy equation, set hd_energy=T')
441 r_e = var_set_radiation_energy()
446 call fld_init(eos%eos_type, eos%ionE, eos%pi_table)
450 phys_implicit_update => hd_fld_implicit_update
451 phys_evaluate_implicit => hd_fld_evaluate_implicit
458 phys_get_dt => hd_get_dt
459 phys_get_cmax => hd_get_cmax
460 phys_get_tcutoff => hd_get_tcutoff
461 phys_get_cbounds => hd_get_cbounds
462 phys_get_flux => hd_get_flux
463 phys_add_source_geom => hd_add_source_geom
464 phys_add_source => hd_add_source
465 phys_modify_wlr => hd_modify_wlr
469 phys_get_v => hd_get_v
471 phys_write_info => hd_write_info
475 phys_get_ei => hd_get_ei
478 call hd_physical_units()
508 if (iw_ne > 0) nwgc = max(nwgc, iw_ne)
509 if (iw_te > 0) nwgc = max(nwgc, iw_te)
512 stop_indices(1)=nwflux
523 iw_log_nh = var_set_wextra()
531 call mpistop(
"thermal conduction needs hd_energy=T")
539 if (iw_log_nh > 0)
then
562 call mpistop(
"radiative cooling needs hd_energy=T")
570 if (
rc_fl%rad_escape_prob)
then
580 phys_te_images => hd_te_images
592 if(
mype==0)
write(*,*)
'WARNING: set hd_well_balanced=F (requires hd_gravity=T)'
594 phys_wb_transform => hd_wb_transform
595 phys_wb_inverse => hd_wb_inverse
596 phys_wb_prolong => hd_wb_prolong
599 if (eos%ionE .and. eos%p2eint_method /=
'bisect')
then
600 eos%p2eint_method =
'bisect'
601 if(
mype==0)
write(*,*)
'WB + ionE: forcing p2eint_method = bisect'
603 if(
mype==0)
write(*,*)
'Well-balanced reconstruction enabled'
615 if (.not.
allocated(flux_type))
then
616 allocate(flux_type(
ndir, nw))
617 flux_type = flux_default
618 else if (any(shape(flux_type) /= [
ndir, nw]))
then
619 call mpistop(
"phys_check error: flux_type has wrong shape")
623 allocate(iw_vector(nvector))
624 iw_vector(1) =
mom(1) - 1
632 subroutine hd_modify_wlr(ixI^L,ixO^L,qt,wLC,wRC,wLp,wRp,s,idir)
635 integer,
intent(in) :: ixi^
l, ixo^
l, idir
636 double precision,
intent(in) :: qt
637 double precision,
intent(inout) :: wlc(ixi^s,1:nw), wrc(ixi^s,1:nw)
638 double precision,
intent(inout) :: wlp(ixi^s,1:nw), wrp(ixi^s,1:nw)
643 end subroutine hd_modify_wlr
646 subroutine hd_te_images
650 case(
'EIvtiCCmpi',
'EIvtuCCmpi')
652 case(
'ESvtiCCmpi',
'ESvtuCCmpi')
654 case(
'SIvtiCCmpi',
'SIvtuCCmpi')
656 case(
'WIvtiCCmpi',
'WIvtuCCmpi')
659 call mpistop(
"Error in synthesize emission: Unknown convert_type")
661 end subroutine hd_te_images
666 subroutine hd_sts_set_source_tc_hd(ixI^L,ixO^L,w,x,wres,fix_conserve_at_step,my_dt,igrid,nflux)
670 integer,
intent(in) :: ixi^
l, ixo^
l, igrid, nflux
671 double precision,
intent(in) :: x(ixi^s,1:
ndim)
672 double precision,
intent(inout) :: wres(ixi^s,1:nw), w(ixi^s,1:nw)
673 double precision,
intent(in) :: my_dt
674 logical,
intent(in) :: fix_conserve_at_step
676 end subroutine hd_sts_set_source_tc_hd
678 function hd_get_tc_dt_hd(w,ixI^L,ixO^L,dx^D,x)
result(dtnew)
684 integer,
intent(in) :: ixi^
l, ixo^
l
685 double precision,
intent(in) ::
dx^
d, x(ixi^s,1:
ndim)
686 double precision,
intent(in) :: w(ixi^s,1:nw)
687 double precision :: dtnew
690 end function hd_get_tc_dt_hd
692 subroutine hd_tc_handle_small_e(w, x, ixI^L, ixO^L, step)
697 integer,
intent(in) :: ixi^
l,ixo^
l
698 double precision,
intent(inout) :: w(ixi^s,1:nw)
699 double precision,
intent(in) :: x(ixi^s,1:
ndim)
700 integer,
intent(in) :: step
703 logical :: flag(ixi^s,1:nw)
704 character(len=140) :: error_msg
708 if(any(flag(ixo^s,
e_)))
then
716 w(ixo^s,
e_)=w(ixo^s,
e_)*(eos%gamma - 1.0d0)
718 w(ixo^s, iw_mom(idir)) = w(ixo^s, iw_mom(idir))/w(ixo^s,
rho_)
720 write(error_msg,
"(a,i3)")
"Thermal conduction step ", step
724 end subroutine hd_tc_handle_small_e
727 subroutine tc_params_read_hd(fl)
729 type(tc_fluid),
intent(inout) :: fl
731 logical :: tc_saturate=.false.
732 logical :: tc_patch_eint=.false.
733 logical :: tc_frozen_ion=.true.
734 double precision :: tc_k_para=0d0
735 double precision :: trac_t_floor=0.d0
736 double precision :: tc_sat_coef=-1.d0
738 namelist /tc_list/ tc_saturate, tc_k_para, trac_t_floor, tc_patch_eint, tc_frozen_ion, tc_sat_coef
742 read(
unitpar, tc_list,
end=111)
745 fl%tc_saturate = tc_saturate
746 fl%tc_sat_coef = tc_sat_coef
747 fl%tc_patch_eint = tc_patch_eint
748 fl%frozen_ion = tc_frozen_ion
749 fl%tc_k_para = tc_k_para
750 fl%trac_T_floor = trac_t_floor / unit_temperature
752 end subroutine tc_params_read_hd
766 subroutine rc_params_read(fl)
770 type(rc_fluid),
intent(inout) :: fl
773 integer :: ncool = 4000
776 character(len=std_len) :: coolcurve=
'JCcorona'
779 logical :: tfix=.false.
785 logical :: rc_split=.false.
788 double precision :: cfrac=0.1d0
791 logical :: rad_modify=.false.
793 logical :: rad_modify_sym=.false.
795 double precision :: rad_cut_hgt=0.0d0
797 double precision :: rad_cut_dey=0.15d0
799 double precision :: rad_taper_rho=
bigdouble
801 double precision :: rad_taper_dey=0.0d0
804 double precision :: rad_suppress_temp=0.0d0
806 logical :: rad_escape_prob=.false.
808 double precision :: rad_kappa_eff=0.0d0
810 double precision :: rad_kappa_tcutoff=0.0d0
812 double precision :: rad_kappa_alpha=4.0d0
814 character(len=10) :: rad_escape_type=
'slab'
816 double precision :: rad_escape_tau_cutoff=0.0d0
818 double precision :: rad_escape_height=0.0d0
820 character(len=8) :: rc_y_mod_quadrature=
'boole'
821 integer :: rc_y_mod_n_sub=16
823 logical :: rad_damp=.false.
824 double precision :: rad_damp_height=0.5d0
825 double precision :: rad_damp_scale=0.15d0
827 logical :: rad_newton=.false.
828 double precision :: rad_newton_trad=0.006d0
829 double precision :: rad_newton_rhosurf=1.d4
830 double precision :: rad_newton_pthick=25.d0
832 namelist /rc_list/ coolcurve, ncool, cfrac, tlow, tfix, rc_split, &
833 rad_modify, rad_modify_sym, rad_suppress_temp, &
834 rad_cut_hgt, rad_cut_dey, rad_taper_rho, rad_taper_dey, &
835 rad_escape_prob, rad_kappa_eff, rad_kappa_tcutoff, rad_kappa_alpha, &
836 rad_escape_type, rad_escape_tau_cutoff, rad_escape_height, &
837 rc_y_mod_quadrature, rc_y_mod_n_sub, &
838 rad_damp, rad_damp_height, rad_damp_scale, &
839 rad_newton, rad_newton_trad, rad_newton_rhosurf, rad_newton_pthick
843 read(
unitpar, rc_list,
end=111)
848 fl%coolcurve=coolcurve
853 fl%rad_modify=rad_modify
854 fl%rad_modify_sym=rad_modify_sym
855 fl%rad_suppress_temp=rad_suppress_temp
856 fl%rad_cut_hgt=rad_cut_hgt
857 fl%rad_cut_dey=rad_cut_dey
858 fl%rad_taper_rho=rad_taper_rho
859 fl%rad_taper_dey=rad_taper_dey
860 fl%rad_escape_prob=rad_escape_prob
861 fl%rad_kappa_eff=rad_kappa_eff
862 fl%rad_kappa_Tcutoff=rad_kappa_tcutoff/unit_temperature
863 fl%rad_kappa_alpha=rad_kappa_alpha
864 fl%rad_escape_type=rad_escape_type
865 fl%rad_escape_tau_cutoff=rad_escape_tau_cutoff
866 fl%rad_escape_height=rad_escape_height/unit_length
867 fl%Y_mod_quadrature=rc_y_mod_quadrature
868 fl%Y_mod_N_sub=rc_y_mod_n_sub
869 fl%rad_damp = rad_damp
870 fl%rad_damp_height = rad_damp_height
871 fl%rad_damp_scale = rad_damp_scale
872 fl%rad_newton = rad_newton
873 fl%rad_newton_trad = rad_newton_trad
874 fl%rad_newton_rhosurf = rad_newton_rhosurf
875 fl%rad_newton_pthick = rad_newton_pthick
876 end subroutine rc_params_read
884 use mod_particles,
only: npayload,nusrpayload,ngridvars,num_particles,physics_type_particles
887 double precision :: a,b,xfrac,yfrac
897 if (eos%gamma <= 0.0d0)
call mpistop (
"Error: eos%gamma <= 0")
898 if (
hd_adiab < 0.0d0)
call mpistop (
"Error: hd_adiab < 0")
901 if (eos%gamma <= 0.0d0 .or. eos%gamma == 1.0d0) &
902 call mpistop (
"Error: eos%gamma <= 0 or eos%gamma == 1.0")
914 call mpistop(
'select IMEX scheme for implicit dust update')
926 call mpistop(
"hd_hyperbolic_thermal_conduction is implemented for ndim=1 only;" // &
927 " for ndim>1 use mod_ffhd or parabolic mod_thermal_conduction.")
930 call mpistop(
"hd_hyperbolic_thermal_conduction and hd_thermal_conduction are mutually exclusive;" // &
931 " choose one TC implementation.")
936 call mpistop(
'select IMEX scheme for FLD radiation use')
939 call phys_set_mg_bounds()
941 if(.not.
fld_no_mg)
call mpistop(
'multigrid must have BCs for IMEX and FLD radiation use')
944 write(*,*)
'==FLD SETUP======================'
945 write(*,*)
'Using FLD with settings:'
949 write(*,*)
'Using FLD with settings: fld_bound_diff=',
fld_bound_diff
952 write(*,*)
'Using FLD with settings: fld_kappa0=',
fld_kappa0
953 write(*,*)
'Using FLD with settings: fld_opal_table=',
fld_opal_table
955 write(*,*)
'Using FLD with settings: fld_bisect_tol=',
fld_bisect_tol
956 write(*,*)
'Using FLD with settings: fld_diff_tol=',
fld_diff_tol
959 write(*,*)
' FLD has fld_no_mg=',
fld_no_mg
961 print *,
'WARNING: cheating with FLD diffusion ***********************'
962 print *,
'WARNING: No MG-diffusion for radiative energy at all!!!!!!!'
963 print *,
'WARNING: cheating with FLD diffusion ***********************'
966 print *,
'NORMALIZED arad_norm=',
arad_norm
967 print *,
'NORMALIZED c_norm=',
c_norm
969 print *,
'WARNING: cheating with c_norm ***********************'
970 print *,
'WARNING: c_norm reset to=',
fld_cnorm
972 print *,
'WARNING: cheating with c_norm ***********************'
980 print *,
'physical fld_kappa (in cgs or SI) =',
fld_kappa0
983 write(*,*)
'===FLD SETUP====================='
987 write(*,*)
'====HD run with settings===================='
988 write(*,*)
'Using mod_hd_phys with settings:'
990 write(*,*)
'Dimensionality :',
ndim
991 write(*,*)
'vector components:',
ndir
993 write(*,*)
'number of variables nw=',nw
994 write(*,*)
' start index iwstart=',iwstart
995 write(*,*)
'number of vector variables=',nvector
996 write(*,*)
'number of stagger variables nws=',nws
997 write(*,*)
'number of variables with BCs=',nwgc
998 write(*,*)
'number of vars with fluxes=',nwflux
999 write(*,*)
'number of vars with flux + BC=',nwfluxbc
1000 write(*,*)
'number of auxiliary variables=',nwaux
1001 write(*,*)
'number of extra vars without flux=',nwextra
1002 write(*,*)
'number of extra vars for wextra=',nw_extra
1003 write(*,*)
'number of auxiliary I/O variables=',
nwauxio
1018 write(*,*)
'*****Using particles: npayload,ngridvars :', npayload,ngridvars
1019 write(*,*)
'*****Using particles: nusrpayload :', nusrpayload
1020 write(*,*)
'*****Using particles: num_particles :', num_particles
1021 write(*,*)
'*****Using particles: physics_type_particles=',physics_type_particles
1024 write(*,*)
'number due to phys_wider_stencil=',phys_wider_stencil
1025 write(*,*)
'==========================================='
1026 print *,
'========EOS and UNITS==========='
1028 print *,
'gamma=',eos%gamma
1029 print *,
'He_abundance =',eos%He_abundance
1031 print *,
'========EOS and UNITS==========='
1047 print *,
' compare this to ',mp_si*(1.d0+4.d0*eos%He_abundance)
1049 print *,
' compare this to ',mp_cgs*(1.d0+4.d0*eos%He_abundance)
1053 print *,
' compare this to ',kb_si*(2.d0+3.d0*eos%He_abundance)
1057 print *,
' compare this to ',kb_cgs*(2.d0+3.d0*eos%He_abundance)
1061 if(eos%eos_type /=
'LTE')
then
1062 print *,
'mean molecular weight mu is =',a/b,
' = ', (1.d0+4.d0*eos%He_abundance)/(2.d0+3.d0*eos%He_abundance)
1064 yfrac=4.d0*eos%He_abundance/(1.d0+4.d0*eos%He_abundance)
1065 print *,
'mass fraction hydrogen X is =',1/a,
' and this equals ', 1.d0/(1.d0+4.d0*eos%He_abundance)
1066 print *,
'mass fraction helium Y is =',yfrac
1067 print *,
' check that 1/mu', b/a,
' is equal to 2X+3Y/4=',2.d0*xfrac+3.d0*yfrac/4.d0
1068 print *,
' ratio n_e/n_p=',1.d0+2.0d0*eos%He_abundance
1070 print *,
'========UNITS==========='
1075 subroutine hd_physical_units
1077 double precision :: mp,kb,c_lightspeed,xfrac,sigma_telectron
1078 double precision :: a,b
1085 sigma_telectron=sigma_te_si
1090 c_lightspeed=const_c
1091 sigma_telectron=sigma_te_cgs
1096 if (eos%eos_type ==
'LTE')
then
1100 eos%nH2rhoFactor = 1d0+4d0*eos%He_abundance
1101 rr=(2d0+3d0*eos%He_abundance) / (1d0+4d0*eos%He_abundance)
1102 xfrac=1.d0/(1.d0+4.d0*eos%He_abundance)
1106 a=1d0+4d0*eos%He_abundance
1107 if(eos%eos_type==
'PI')
then
1110 b=2d0+3d0*eos%He_abundance
1196 end subroutine hd_physical_units
1203 logical,
intent(in) :: primitive
1204 integer,
intent(in) :: ixi^
l, ixo^
l
1205 double precision,
intent(in) :: w(ixi^s, nw)
1206 logical,
intent(inout) :: flag(ixi^s,1:nw)
1208 double precision :: tmp(ixi^s)
1209 double precision :: x(ixi^s, 1:
ndim)
1220 tmp(ixo^s)=(eos%gamma-1.0d0)*(w(ixo^s,
e_)-&
1221 half*(^
c&w(ixo^s,
m^
c_)**2+)/w(ixo^s,
rho_))
1235 subroutine hd_bound_fip(primitive, ixI^L, ixO^L, w)
1237 logical,
intent(in) :: primitive
1238 integer,
intent(in) :: ixi^
l, ixo^
l
1239 double precision,
intent(inout) :: w(ixi^s,1:nw)
1241 double precision :: rho_safe(ixi^s), fip_prim(ixi^s)
1249 fip_prim(ixo^s) = w(ixo^s,
fip_) / rho_safe(ixo^s)
1250 fip_prim(ixo^s) = min(
maxfip, max(
minfip, fip_prim(ixo^s)))
1251 w(ixo^s,
fip_) = rho_safe(ixo^s) * fip_prim(ixo^s)
1253 end subroutine hd_bound_fip
1318 integer,
intent(in) :: ixi^
l, ixo^
l
1319 double precision,
intent(inout) :: w(ixi^s, nw)
1320 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1323 w(ixo^s,
e_)=w(ixo^s,
e_)+half*(^
c&w(ixo^s,
m^
c_)**2+)/w(ixo^s,
rho_)
1330 integer,
intent(in) :: ixi^
l, ixo^
l
1331 double precision,
intent(inout) :: w(ixi^s, nw)
1332 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1335 w(ixo^s,
e_)=w(ixo^s,
e_)-half*(^
c&w(ixo^s,
m^
c_)**2+)/w(ixo^s,
rho_)
1342 subroutine hd_e_to_ei_and_cache_log_nh(ixI^L,ixO^L,w,x)
1344 integer,
intent(in) :: ixi^
l, ixo^
l
1345 double precision,
intent(inout) :: w(ixi^s, nw)
1346 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1349 block%wextra(ixo^s, iw_log_nh) = dlog10(w(ixo^s,
rho_) / eos%nH2rhoFactor)
1350 end subroutine hd_e_to_ei_and_cache_log_nh
1353 function hd_get_ei(w, ixI^L, ixO^L)
result(ei)
1355 integer,
intent(in) :: ixi^
l, ixo^
l
1356 double precision,
intent(in) :: w(ixi^s, nw)
1357 double precision :: ei(ixo^s)
1360 ei(ixo^s) = w(ixo^s,
e_) - half*(^
c&w(ixo^s,
m^
c_)**2+)/w(ixo^s,
rho_)
1361 end function hd_get_ei
1364 subroutine hd_get_v_idim(w, x, ixI^L, ixO^L, idim, v)
1366 integer,
intent(in) :: ixi^
l, ixo^
l, idim
1367 double precision,
intent(in) :: w(ixi^s, nw), x(ixi^s, 1:
ndim)
1368 double precision,
intent(out) :: v(ixi^s)
1370 v(ixo^s) = w(ixo^s,
mom(idim)) / w(ixo^s,
rho_)
1371 end subroutine hd_get_v_idim
1374 subroutine hd_get_v(w,x,ixI^L,ixO^L,v)
1377 integer,
intent(in) :: ixi^
l, ixo^
l
1378 double precision,
intent(in) :: w(ixi^s,nw), x(ixi^s,1:^nd)
1379 double precision,
intent(out) :: v(ixi^s,1:
ndir)
1384 v(ixo^s,idir) = w(ixo^s,
mom(idir)) / w(ixo^s,
rho_)
1387 end subroutine hd_get_v
1390 subroutine hd_get_cmax(w, x, ixI^L, ixO^L, idim, cmax)
1395 integer,
intent(in) :: ixi^
l, ixo^
l, idim
1397 double precision,
intent(in) :: w(ixi^s, nw), x(ixi^s, 1:
ndim)
1398 double precision,
intent(inout) :: cmax(ixi^s)
1399 double precision :: csound2(ixi^s)
1402 call eos%get_csound2(w, x, ixi^
l, ixo^
l, csound2)
1403 cmax(ixo^s)=dabs(w(ixo^s,
mom(idim)))+dsqrt(csound2(ixo^s))
1410 cmax(ixo^s)=dabs(w(ixo^s,
mom(idim)))+dsqrt(eos%gamma*cmax(ixo^s)/w(ixo^s,
rho_))
1416 end subroutine hd_get_cmax
1419 subroutine hd_get_tcutoff(ixI^L,ixO^L,w,x,tco_local,Tmax_local)
1425 integer,
intent(in) :: ixi^
l,ixo^
l
1426 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1428 double precision,
intent(inout) :: w(ixi^s,1:nw)
1429 double precision,
intent(out) :: tco_local, tmax_local
1431 double precision,
parameter :: trac_delta=0.25d0
1432 double precision :: tmp1(ixi^s),te(ixi^s),lts(ixi^s), r(ixi^s)
1433 double precision :: ltrc,ltrp
1434 integer :: jxo^
l,hxo^
l
1435 integer :: jxp^
l,hxp^
l,ixp^
l
1436 logical :: lrlt(ixi^s)
1438 double precision :: dtdx, l_t, a_coeff, l1, cooling, net_cool
1439 double precision :: kappa_par, disc, kappa_trac, kappa_eff, tcoff_eff
1440 double precision :: dx_over_delta, v_abs, v_n, gnorm, dl_eff
1441 double precision :: q_heat(ixi^s), ne(ixi^s), nh_arr(ixi^s)
1442 double precision :: gradtd(ixi^s,1:
ndim), nhat(1:
ndim)
1443 integer :: ix^
d, idims
1445 call eos%get_Rfactor(w,x,ixi^
l,ixi^
l,r)
1446 te(ixi^s)=w(ixi^s,
p_)/(r(ixi^s)*w(ixi^s,
rho_))
1448 if (eos%eos_type ==
'LTE')
then
1449 te(ixi^s) = w(ixi^s,
te_)
1453 tmax_local=maxval(te(ixo^s))
1463 lts(ixo^s)=0.5d0*dabs(te(jxo^s)-te(hxo^s))/te(ixo^s)
1465 where(lts(ixo^s) > trac_delta)
1468 if(any(lrlt(ixo^s)))
then
1469 tco_local=maxval(te(ixo^s), mask=lrlt(ixo^s))
1480 lts(ixp^s)=0.5d0*abs(te(jxp^s)-te(hxp^s))/te(ixp^s)
1481 lts(ixp^s)=max(one, (exp(lts(ixp^s))/ltrc)**ltrp)
1483 lts(ixo^s)=0.25d0*(lts(jxo^s)+two*lts(ixo^s)+lts(hxo^s))
1484 block%wextra(ixo^s,
tcoff_)=te(ixo^s)*lts(ixo^s)**0.4d0
1489 block%wextra(ixomin1-1,
tcoff_)=te(ixomin1-1)*lts(ixomin1-1)**0.4d0
1490 block%wextra(ixomax1+1,
tcoff_)=te(ixomax1+1)*lts(ixomax1+1)**0.4d0
1505 call eos%get_ne_nH(ixi^
l, ixp^
l, w, x, ne, nh_arr)
1511 do ix1=ixpmin1,ixpmax1
1513 dtdx = abs(te(ix1+1) - te(ix1-1)) / (2.d0 *
dxlevel(1))
1515 if(dtdx < smalldouble .or. te(ix1) <
tc_fl%trac_T_floor)
then
1519 l_t = te(ix1) / dtdx
1523 v_abs = abs(w(ix1,m1_))
1524 a_coeff = 2.5d0 * w(ix1,
p_) * v_abs / te(ix1)
1528 if(te(ix1) >
rc_fl%tcoolmin .and. te(ix1) <
rc_fl%tcoolmax)
then
1529 call findl(te(ix1), l1,
rc_fl); cooling = ne(ix1) * nh_arr(ix1) * l1
1530 else if(te(ix1) >=
rc_fl%tcoolmax)
then
1537 net_cool = abs(cooling - q_heat(ix1))
1540 kappa_par =
tc_fl%tc_k_para * te(ix1)**2.5d0
1543 disc = a_coeff**2 + 4.d0 *
tc_fl%tc_k_para * te(ix1)**1.5d0 * net_cool
1545 if(l_t <= 2.d0 * dx_over_delta)
then
1547 kappa_trac = (a_coeff + dsqrt(disc)) / (2.d0 / dx_over_delta)
1550 kappa_trac = dsqrt(4.d0 *
tc_fl%tc_k_para * te(ix1)**1.5d0 * net_cool) &
1551 / (2.d0 / dx_over_delta)
1555 kappa_eff = max(kappa_trac, kappa_par)
1558 tcoff_eff = (kappa_eff /
tc_fl%tc_k_para)**0.4d0
1561 block%wextra(ix1,
tcoff_) = max(te(ix1), tcoff_eff)
1569 call eos%get_ne_nH(ixi^
l, ixo^
l, w, x, ne, nh_arr)
1573 call gradient(te,ixi^
l,ixo^
l,idims,gradtd(ixi^s,idims))
1575 {
do ix^db=ixomin^db,ixomax^db\}
1576 gnorm = dsqrt(^
d&gradtd({ix^
d},^
d)**2+ )
1577 if(gnorm < smalldouble .or. te(ix^
d) <
tc_fl%trac_T_floor)
then
1581 ^
d&nhat(^
d)=gradtd({ix^
d},^
d)/gnorm\
1583 dl_eff = 1.d0/dsqrt(^
d&(nhat(^
d)/
block%ds({ix^
d},^
d))**2+ )
1584 l_t = te(ix^
d)/gnorm
1586 v_n = ^
d&w({ix^
d},
mom(^
d))*nhat(^
d)+
1587 a_coeff = 2.5d0*w(ix^
d,
p_)*dabs(v_n)/te(ix^
d)
1591 if(te(ix^
d) >
rc_fl%tcoolmin .and. te(ix^
d) <
rc_fl%tcoolmax)
then
1592 call findl(te(ix^
d),l1,
rc_fl); cooling = l1*ne(ix^
d)*nh_arr(ix^
d)
1593 else if(te(ix^
d) >=
rc_fl%tcoolmax)
then
1598 net_cool = dabs(cooling-q_heat(ix^
d))
1599 kappa_par =
tc_fl%tc_k_para*te(ix^
d)**2.5d0
1600 disc = a_coeff**2 + 4.d0*
tc_fl%tc_k_para*te(ix^
d)**1.5d0*net_cool
1602 if(l_t <= 2.d0*dx_over_delta)
then
1603 kappa_trac = (a_coeff+dsqrt(disc))/(2.d0/dx_over_delta)
1605 kappa_trac = dsqrt(4.d0*
tc_fl%tc_k_para*te(ix^
d)**1.5d0*net_cool)/(2.d0/dx_over_delta)
1607 kappa_eff = max(kappa_trac,kappa_par)
1608 tcoff_eff = (kappa_eff/
tc_fl%tc_k_para)**0.4d0
1614 call mpistop(
"hd_trac_type not allowed")
1616 end subroutine hd_get_tcutoff
1619 subroutine hd_get_cbounds(wLC, wRC, wLp, wRp, x, ixI^L, ixO^L, idim,Hspeed,cmax, cmin)
1625 integer,
intent(in) :: ixi^
l, ixo^
l, idim
1627 double precision,
intent(in) :: wlc(ixi^s,
nw), wrc(ixi^s,
nw)
1629 double precision,
intent(in) :: wlp(ixi^s,
nw), wrp(ixi^s,
nw)
1630 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1632 double precision,
intent(inout),
optional :: cmin(ixi^s,1:
number_species)
1635 double precision :: wmean(ixi^s,
nw)
1636 double precision,
dimension(ixI^S) :: umean, dmean, csoundl, csoundr, tmp1,tmp2,tmp3
1644 tmp1(ixo^s)=dsqrt(wlp(ixo^s,
rho_))
1645 tmp2(ixo^s)=dsqrt(wrp(ixo^s,
rho_))
1646 tmp3(ixo^s)=1.d0/(tmp1(ixo^s)+tmp2(ixo^s))
1647 umean(ixo^s)=(wlp(ixo^s,
mom(idim))*tmp1(ixo^s)+wrp(ixo^s,
mom(idim))*tmp2(ixo^s))*tmp3(ixo^s)
1650 call eos%get_csound2(wlp, x, ixi^
l, ixo^
l, csoundl)
1651 call eos%get_csound2(wrp, x, ixi^
l, ixo^
l, csoundr)
1653 csoundl(ixo^s)=csoundl(ixo^s)+(4.0d0/9.0d0)*wlp(ixo^s,
r_e)/wlp(ixo^s,
rho_)
1654 csoundr(ixo^s)=csoundr(ixo^s)+(4.0d0/9.0d0)*wrp(ixo^s,
r_e)/wrp(ixo^s,
rho_)
1662 dmean(ixo^s) = (tmp1(ixo^s)*csoundl(ixo^s)+tmp2(ixo^s)*csoundr(ixo^s)) * &
1663 tmp3(ixo^s) + 0.5d0*tmp1(ixo^s)*tmp2(ixo^s)*tmp3(ixo^s)**2 * &
1664 (wrp(ixo^s,
mom(idim))-wlp(ixo^s,
mom(idim)))**2
1666 dmean(ixo^s)=dsqrt(dmean(ixo^s))
1667 if(
present(cmin))
then
1668 cmin(ixo^s,1)=umean(ixo^s)-dmean(ixo^s)
1669 cmax(ixo^s,1)=umean(ixo^s)+dmean(ixo^s)
1671 {
do ix^db=ixomin^db,ixomax^db\}
1672 cmin(ix^
d,1)=sign(one,cmin(ix^
d,1))*max(abs(cmin(ix^
d,1)),hspeed(ix^
d,1))
1673 cmax(ix^
d,1)=sign(one,cmax(ix^
d,1))*max(abs(cmax(ix^
d,1)),hspeed(ix^
d,1))
1677 cmax(ixo^s,1)=dabs(umean(ixo^s))+dmean(ixo^s)
1681 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
1682 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
1693 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
1694 tmp1(ixo^s)=wmean(ixo^s,
mom(idim))/wmean(ixo^s,
rho_)
1696 if(
hd_radiation_fld.and.fld_bound_diff)csoundr(ixo^s)=csoundr(ixo^s)+(4.0d0/9.0d0)*wmean(ixo^s,
r_e)/wmean(ixo^s,
rho_)
1698 csoundr(ixo^s) = dsqrt(csoundr(ixo^s))
1700 if(
present(cmin))
then
1701 cmax(ixo^s,1)=max(tmp1(ixo^s)+csoundr(ixo^s),zero)
1702 cmin(ixo^s,1)=min(tmp1(ixo^s)-csoundr(ixo^s),zero)
1703 if(h_correction)
then
1704 {
do ix^db=ixomin^db,ixomax^db\}
1705 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
1706 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
1710 cmax(ixo^s,1)=dabs(tmp1(ixo^s))+csoundr(ixo^s)
1714 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
1719 call eos%get_csound2(wlp, x, ixi^l, ixo^l, csoundl)
1720 call eos%get_csound2(wrp, x, ixi^l, ixo^l, csoundr)
1722 csoundl(ixo^s)=csoundl(ixo^s)+(4.0d0/9.0d0)*wlp(ixo^s,
r_e)/wlp(ixo^s,
rho_)
1723 csoundr(ixo^s)=csoundr(ixo^s)+(4.0d0/9.0d0)*wrp(ixo^s,
r_e)/wrp(ixo^s,
rho_)
1730 csoundl(ixo^s)=max(dsqrt(csoundl(ixo^s)),dsqrt(csoundr(ixo^s)))
1731 if(
present(cmin))
then
1732 cmin(ixo^s,1)=min(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))-csoundl(ixo^s)
1733 cmax(ixo^s,1)=max(wlp(ixo^s,
mom(idim)),wrp(ixo^s,
mom(idim)))+csoundl(ixo^s)
1734 if(h_correction)
then
1735 {
do ix^db=ixomin^db,ixomax^db\}
1736 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
1737 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
1741 cmax(ixo^s,1)=max(dabs(wlp(ixo^s,
mom(idim))),dabs(wrp(ixo^s,
mom(idim))))+csoundl(ixo^s)
1744 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
1745 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
1754 call eos%get_csound2(wlp, x, ixi^l, ixo^l, csoundl)
1755 call eos%get_csound2(wrp, x, ixi^l, ixo^l, csoundr)
1757 csoundl(ixo^s)=csoundl(ixo^s)+(4.0d0/9.0d0)*wlp(ixo^s,
r_e)/wlp(ixo^s,
rho_)
1758 csoundr(ixo^s)=csoundr(ixo^s)+(4.0d0/9.0d0)*wrp(ixo^s,
r_e)/wrp(ixo^s,
rho_)
1764 csoundl(ixo^s) = dsqrt(csoundl(ixo^s))
1765 csoundr(ixo^s) = dsqrt(csoundr(ixo^s))
1766 if(
present(cmin))
then
1767 {
do ix^db=ixomin^db,ixomax^db\}
1770 tmp1(ix^d) = 0.25d0*(wlp(ix^d,
rho_)+wrp(ix^d,
rho_)) &
1771 *(csoundl(ix^d)+csoundr(ix^d))
1773 tmp2(ix^d) = max(zero, 0.5d0*(wlp(ix^d,
e_)+wrp(ix^d,
e_)) &
1774 + 0.5d0*(wlp(ix^d,
mom(idim))-wrp(ix^d,
mom(idim))) &
1777 if(tmp2(ix^d) > wlp(ix^d,
e_) .and. wlp(ix^d,
e_) > zero)
then
1779 tmp3(ix^d) = csoundl(ix^d)**2*wlp(ix^d,
rho_)/wlp(ix^d,
e_)
1780 dmean(ix^d) = dsqrt(1.0d0 + (tmp3(ix^d)+1.0d0) &
1781 /(2.0d0*tmp3(ix^d)) &
1782 *(tmp2(ix^d)/wlp(ix^d,
e_) - 1.0d0))
1787 cmin(ix^d,1) = wlp(ix^d,
mom(idim)) - csoundl(ix^d)*dmean(ix^d)
1789 if(tmp2(ix^d) > wrp(ix^d,
e_) .and. wrp(ix^d,
e_) > zero)
then
1791 tmp3(ix^d) = csoundr(ix^d)**2*wrp(ix^d,
rho_)/wrp(ix^d,
e_)
1792 dmean(ix^d) = dsqrt(1.0d0 + (tmp3(ix^d)+1.0d0) &
1793 /(2.0d0*tmp3(ix^d)) &
1794 *(tmp2(ix^d)/wrp(ix^d,
e_) - 1.0d0))
1799 cmax(ix^d,1) = wrp(ix^d,
mom(idim)) + csoundr(ix^d)*dmean(ix^d)
1801 if(h_correction)
then
1802 {
do ix^db=ixomin^db,ixomax^db\}
1803 cmin(ix^d,1)=sign(one,cmin(ix^d,1))*max(abs(cmin(ix^d,1)),hspeed(ix^d,1))
1804 cmax(ix^d,1)=sign(one,cmax(ix^d,1))*max(abs(cmax(ix^d,1)),hspeed(ix^d,1))
1808 {
do ix^db=ixomin^db,ixomax^db\}
1809 tmp1(ix^d) = 0.25d0*(wlp(ix^d,
rho_)+wrp(ix^d,
rho_)) &
1810 *(csoundl(ix^d)+csoundr(ix^d))
1811 tmp2(ix^d) = max(zero, 0.5d0*(wlp(ix^d,
e_)+wrp(ix^d,
e_)) &
1812 + 0.5d0*(wlp(ix^d,
mom(idim))-wrp(ix^d,
mom(idim))) &
1814 if(tmp2(ix^d) > wlp(ix^d,
e_) .and. wlp(ix^d,
e_) > zero)
then
1815 tmp3(ix^d) = csoundl(ix^d)**2*wlp(ix^d,
rho_)/wlp(ix^d,
e_)
1816 dmean(ix^d) = dsqrt(1.0d0 + (tmp3(ix^d)+1.0d0) &
1817 /(2.0d0*tmp3(ix^d)) &
1818 *(tmp2(ix^d)/wlp(ix^d,
e_) - 1.0d0))
1822 umean(ix^d) = dabs(wlp(ix^d,
mom(idim)) &
1823 - csoundl(ix^d)*dmean(ix^d))
1824 if(tmp2(ix^d) > wrp(ix^d,
e_) .and. wrp(ix^d,
e_) > zero)
then
1825 tmp3(ix^d) = csoundr(ix^d)**2*wrp(ix^d,
rho_)/wrp(ix^d,
e_)
1826 dmean(ix^d) = dsqrt(1.0d0 + (tmp3(ix^d)+1.0d0) &
1827 /(2.0d0*tmp3(ix^d)) &
1828 *(tmp2(ix^d)/wrp(ix^d,
e_) - 1.0d0))
1832 cmax(ix^d,1) = max(umean(ix^d), &
1833 wrp(ix^d,
mom(idim))+csoundr(ix^d)*dmean(ix^d))
1837 wmean(ixo^s,1:nwflux)=0.5d0*(wlc(ixo^s,1:nwflux)+wrc(ixo^s,1:nwflux))
1838 call dust_get_cmax(wmean, x, ixi^l, ixo^l, idim, cmax, cmin)
1842 end subroutine hd_get_cbounds
1854 integer,
intent(in) :: ixi^
l, ixo^
l
1855 double precision,
intent(in) :: w(ixi^s,nw)
1856 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1857 double precision,
intent(out) :: csound2(ixi^s)
1858 double precision :: pthermal(ixi^s)
1859 double precision :: inv_rho, nh_val, pres, g1
1866 tab_g1 =
eos%ionE .and.
eos%gamma1_method /=
'constant'
1867 {
do ix^db=ixomin^db,ixomax^db\}
1868 inv_rho = 1.0d0/w(ix^
d,
rho_)
1869 nh_val = w(ix^
d,
rho_)/
eos%nH2rhoFactor
1871 nh_val, dlog10(nh_val), inv_rho)
1874 csound2(ix^
d) = g1*pres*inv_rho
1877 call eos%get_thermal_pressure(w, x, ixi^l, ixo^l, pthermal)
1878 csound2(ixo^s) = eos%gamma * pthermal(ixo^s) / w(ixo^s,
rho_)
1880 call eos_timer_stop(timeeos_csound)
1890 integer,
intent(in) :: ixi^
l, ixo^
l
1891 double precision,
intent(in) :: w(ixi^s, nw), x(ixi^s,1:
ndim)
1892 double precision,
intent(out):: csound(ixi^s)
1894 double precision :: wprim(ixi^s, nw)
1896 wprim(ixi^s,1:nw)=w(ixi^s,1:nw)
1897 call eos%to_primitive(ixi^
l,ixo^
l,wprim,x)
1908 integer,
intent(in) :: ixi^
l, ixo^
l
1909 double precision,
intent(in) :: w(ixi^s, nw), x(ixi^s,1:
ndim)
1910 double precision,
intent(out):: csound(ixi^s)
1913 double precision :: inv_rho
1914 double precision :: prad_tensor(ixi^s, 1:
ndim, 1:
ndim)
1915 double precision :: prad_max(ixi^s)
1923 prad_tensor(ixo^s,idim,idim)=w(ixo^s,
r_e)/3.0d0
1927 {
do ix^db=ixomin^db,ixomax^db \}
1928 inv_rho=1.d0/w(ix^
d,
rho_)
1929 prad_max(ix^
d) = (4.0d0/3.0d0)*maxval(prad_tensor(ix^
d,:,:))
1930 csound(ix^
d)=(eos%gamma*w(ix^
d,
p_)+prad_max(ix^
d))*inv_rho
1933 if(minval(csound(ixo^s))<smalldouble)
then
1934 print *,
'issue with squared speed and rad pressure'
1935 print *,minval(csound(ixo^s))
1936 print *,minval(prad_max(ixo^s))
1937 call mpistop(
"negative squared speed in get_csrad2 for dt")
1948 integer,
intent(in) :: ixi^
l, ixo^
l
1949 double precision,
intent(in) :: w(ixi^s, 1:nw)
1950 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1951 double precision,
intent(out):: prad(ixi^s, 1:
ndim, 1:
ndim)
1961 integer,
intent(in) :: ixi^
l, ixo^
l
1962 double precision,
intent(in) :: w(ixi^s, 1:nw)
1963 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1964 double precision,
intent(out):: pth_plus_prad(ixi^s)
1966 double precision :: wprim(ixi^s, 1:nw)
1967 double precision :: prad_tensor(ixi^s, 1:
ndim, 1:
ndim)
1968 double precision :: prad_max(ixi^s)
1971 wprim(ixi^s,1:nw)=w(ixi^s,1:nw)
1972 call eos%to_primitive(ixi^
l,ixo^
l,wprim,x)
1974 {
do ix^
d = ixomin^
d,ixomax^
d\}
1975 prad_max(ix^
d) = maxval(prad_tensor(ix^
d,:,:))
1977 pth_plus_prad(ixo^s) = wprim(ixo^s,
p_) + prad_max(ixo^s)
1985 integer,
intent(in) :: ixi^
l, ixo^
l
1986 double precision,
intent(in) :: w(ixi^s, 1:nw)
1987 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1988 double precision,
intent(out):: trad(ixi^s)
1997 integer,
intent(in) :: ixi^
l, ixo^
l
1998 double precision,
intent(in) :: w(ixi^s, 1:nw)
1999 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2000 double precision,
intent(out):: res(ixi^s)
2002 double precision :: r(ixi^s)
2004 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
2005 call eos%get_thermal_pressure(w, x, ixi^
l, ixo^
l, res)
2006 res(ixo^s)=res(ixo^s)/(r(ixo^s)*w(ixo^s,
rho_))
2010 subroutine hd_get_temperature_from_eint(w, x, ixI^L, ixO^L, res)
2012 integer,
intent(in) :: ixi^
l, ixo^
l
2013 double precision,
intent(in) :: w(ixi^s, 1:nw)
2014 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2015 double precision,
intent(out):: res(ixi^s)
2017 double precision :: r(ixi^s)
2019 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
2020 res(ixo^s) = (eos%gamma - 1.0d0) * w(ixo^s,
e_)/(w(ixo^s,
rho_)*r(ixo^s))
2021 end subroutine hd_get_temperature_from_eint
2024 subroutine hd_get_flux(wC, w, x, ixI^L, ixO^L, idim, f)
2028 integer,
intent(in) :: ixi^
l, ixo^
l, idim
2030 double precision,
intent(in) :: wc(ixi^s, 1:nw)
2032 double precision,
intent(in) :: w(ixi^s, 1:nw)
2033 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2034 double precision,
intent(out) :: f(ixi^s, nwflux)
2036 double precision :: pth(ixi^s)
2040 {
do ix^db=ixomin^db,ixomax^db\}
2056 {
do ix^db=ixomin^db,ixomax^db\}
2061 call eos%get_thermal_pressure(wc, x, ixi^l, ixo^l, pth)
2062 {
do ix^db=ixomin^db,ixomax^db\}
2065 ^
c&f(ix^d,
m^
c_)=w(ix^d,
mom(idim))*wc(ix^d,
m^
c_)\
2066 f(ix^d,
mom(idim))=f(ix^d,
mom(idim))+pth(ix^d)
2071 {
do ix^db=ixomin^db,ixomax^db\}
2073 f(ix^d,
r_e)=w(ix^d,
mom(idim))*wc(ix^d,
r_e)
2082 f(ixo^s,
fip_) = w(ixo^s,
mom(idim)) * wc(ixo^s,
fip_)
2087 call dust_get_flux_prim(w, x, ixi^l, ixo^l, idim, f)
2090 end subroutine hd_get_flux
2097 subroutine hd_add_source_geom(qdt, dtfactor, ixI^L, ixO^L, wCT, wprim, w, x)
2103 integer,
intent(in) :: ixi^
l, ixo^
l
2104 double precision,
intent(in) :: qdt, dtfactor, x(ixi^s, 1:
ndim)
2105 double precision,
intent(inout) :: wct(ixi^s, 1:nw), wprim(ixi^s,1:nw),w(ixi^s, 1:nw)
2106 double precision :: pth(ixi^s),
source(ixi^s), minrho
2107 integer :: iw,idir, h1x^
l{^nooned, h2x^
l}
2108 integer :: mr_,mphi_
2109 integer :: irho, ifluid, n_fluids
2110 double precision :: exp_factor(ixi^s), del_exp_factor(ixi^s), exp_factor_primitive(ixi^s)
2132 source(ixo^s) =
source(ixo^s)*del_exp_factor(ixo^s)/exp_factor(ixo^s)
2136 do ifluid = 0, n_fluids-1
2138 if (ifluid == 0)
then
2162 where (wct(ixo^s, irho) > minrho)
2163 source(ixo^s) =
source(ixo^s) + wct(ixo^s,mphi_)*wprim(ixo^s,mphi_)
2164 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt*
source(ixo^s)/x(ixo^s,
r_)
2167 where (wct(ixo^s, irho) > minrho)
2168 source(ixo^s) = -wct(ixo^s, mphi_) * wprim(ixo^s, mr_)
2169 w(ixo^s, mphi_) = w(ixo^s, mphi_) + qdt *
source(ixo^s) / x(ixo^s,
r_)
2173 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt *
source(ixo^s) / x(ixo^s,
r_)
2178 call mpistop(
"Dust geom source terms not implemented yet with spherical geometries")
2182 h1x^
l=ixo^
l-
kr(1,^
d); {^nooned h2x^
l=ixo^
l-
kr(2,^
d);}
2184 pth(ixo^s)=wprim(ixo^s,
p_)
2193 source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
2194 *(
block%surfaceC(ixo^s, 1) -
block%surfaceC(h1x^s, 1)) &
2195 /
block%dvolume(ixo^s)
2199 w(ixo^s, mr_) = w(ixo^s, mr_) + qdt *
source(ixo^s) / x(ixo^s, 1)
2203 source(ixo^s) = pth(ixo^s) * x(ixo^s, 1) &
2204 * (
block%surfaceC(ixo^s, 2) -
block%surfaceC(h2x^s, 2)) &
2205 /
block%dvolume(ixo^s)
2207 source(ixo^s) =
source(ixo^s) + (wprim(ixo^s,
mom(3))**2 * wprim(ixo^s,
rho_)) / tan(x(ixo^s, 2))
2209 source(ixo^s) =
source(ixo^s) - (wprim(ixo^s,
mom(2)) * wprim(ixo^s, mr_)) * wprim(ixo^s,
rho_)
2210 w(ixo^s,
mom(2)) = w(ixo^s,
mom(2)) + qdt *
source(ixo^s) / x(ixo^s, 1)
2214 source(ixo^s) = -(wprim(ixo^s,
mom(3)) * wprim(ixo^s, mr_)) * wprim(ixo^s,
rho_)&
2215 - (wprim(ixo^s,
mom(2)) * wprim(ixo^s,
mom(3))) * wprim(ixo^s,
rho_) / tan(x(ixo^s, 2))
2216 w(ixo^s,
mom(3)) = w(ixo^s,
mom(3)) + qdt *
source(ixo^s) / x(ixo^s, 1)
2223 call mpistop(
"Rotating frame not implemented yet with dust")
2229 end subroutine hd_add_source_geom
2232 subroutine hd_add_source(qdt,dtfactor, ixI^L,ixO^L,wCT,wCTprim,w,x,qsourcesplit,active)
2241 integer,
intent(in) :: ixi^
l, ixo^
l
2242 double precision,
intent(in) :: qdt, dtfactor
2243 double precision,
intent(in) :: wct(ixi^s, 1:nw),wctprim(ixi^s,1:nw), x(ixi^s, 1:
ndim)
2244 double precision,
intent(inout) :: w(ixi^s, 1:nw)
2245 logical,
intent(in) :: qsourcesplit
2246 logical,
intent(inout) :: active
2248 double precision :: gravity_field(ixi^s, 1:
ndim)
2249 integer :: idust, idim, ix^
d
2265 qsourcesplit,active,
rc_fl)
2290 + qdt * gravity_field(ixo^s, idim) * wct(ixo^s,
dust_rho(idust))
2302 call hd_add_radiation_source(qdt,ixi^
l,ixo^
l,wct,wctprim,w,x,qsourcesplit,active)
2305 if(eos%eos_type ==
'PI')
then
2306 if(.not.qsourcesplit)
then
2308 call eos%update_eos(ixi^
l,ixo^
l,w,x)
2315 call add_hypertc_source(qdt,ixi^
l,ixo^
l,wct,w,x,wctprim)
2318 end subroutine hd_add_source
2340 subroutine add_hypertc_source(qdt,ixI^L,ixO^L,wCT,w,x,wCTprim)
2343 integer,
intent(in) :: ixi^
l,ixo^
l
2344 double precision,
intent(in) :: qdt
2345 double precision,
dimension(ixI^S,1:ndim),
intent(in) :: x
2346 double precision,
dimension(ixI^S,1:nw),
intent(in) :: wct,wctprim
2347 double precision,
dimension(ixI^S,1:nw),
intent(inout) :: w
2349 double precision :: te(ixi^s), rfactor(ixi^s)
2350 double precision :: qf_half(ixglo1:ixghi1)
2351 double precision :: qf_full(ixglo1:ixghi1)
2352 double precision :: t_l, t_r, t_cool_l, t_cool_r, t_kap_l, t_kap_r
2353 double precision :: kappa_l, kappa_r, kappa_f
2354 double precision :: sigma_t7_f, dt_face, dx_f
2355 double precision :: rho_f, p_l, p_r, p_f, cs_f, q_sat, q_sp, q_sp_star
2356 double precision :: f_sat, eint_loc_l, eint_loc_r, eint_loc_f
2357 double precision :: qn_face, tau_f, ratio, decay, ave_factor
2358 double precision :: q_face_max
2359 double precision,
parameter :: ratio_cap = 50.0d0
2360 integer :: ix1, nface_lo, nface_hi
2364 te(ixi^s) = wct(ixi^s,
te_)
2366 call eos%get_Rfactor(wctprim, x, ixi^
l, ixi^
l, rfactor)
2367 te(ixi^s) = wctprim(ixi^s,
p_) / (rfactor(ixi^s) * wctprim(ixi^s,
rho_))
2371 nface_lo = ixomin1 - 1
2376 do ix1 = nface_lo, nface_hi
2387 t_kap_l = max(t_l, t_cool_l)
2388 t_kap_r = max(t_r, t_cool_r)
2394 if (kappa_l + kappa_r > smalldouble)
then
2395 kappa_f = 2.0d0 * kappa_l * kappa_r / (kappa_l + kappa_r)
2400 dx_f = 0.5d0 * (
block%ds(ix1, 1) +
block%ds(ix1 + 1, 1))
2402 q_sp = -kappa_f * dt_face / dx_f
2405 rho_f = 0.5d0 * (wctprim(ix1,
rho_) + wctprim(ix1 + 1,
rho_))
2406 p_l = wctprim(ix1,
p_)
2407 p_r = wctprim(ix1 + 1,
p_)
2408 p_f = 0.5d0 * (p_l + p_r)
2409 cs_f = dsqrt(max(smalldouble, eos%gamma * p_f / max(rho_f, smalldouble)))
2413 q_sat = 1.5d0 * rho_f * (p_f / max(rho_f, smalldouble))**1.5d0
2414 if (q_sat > smalldouble)
then
2415 f_sat = 1.0d0 / (1.0d0 + dabs(q_sp) / q_sat)
2419 q_sp_star = f_sat * q_sp
2425 eint_loc_l = wct(ix1,
e_) &
2426 - 0.5d0 * wct(ix1, m1_)**2 / max(wct(ix1,
rho_), smalldouble)
2427 eint_loc_r = wct(ix1 + 1,
e_) &
2428 - 0.5d0 * wct(ix1 + 1, m1_)**2 / max(wct(ix1 + 1,
rho_), smalldouble)
2429 eint_loc_l = max(eint_loc_l, smalldouble)
2430 eint_loc_r = max(eint_loc_r, smalldouble)
2431 eint_loc_f = 0.5d0 * (eint_loc_l + eint_loc_r)
2436 sigma_t7_f = kappa_f * 0.5d0 * (t_l + t_r)
2437 tau_f = max(4.0d0 *
dt, &
2441 ratio = min(qdt / tau_f, ratio_cap)
2442 decay = dexp(-ratio)
2443 if (ratio > 1.0
d-6)
then
2444 ave_factor = (1.0d0 - decay) / ratio
2446 ave_factor = 1.0d0 - 0.5d0 * ratio + ratio * ratio / 6.0d0
2449 qn_face = 0.5d0 * (wct(ix1,
q_) + wct(ix1 + 1,
q_))
2451 qf_full(ix1) = q_sp_star + (qn_face - q_sp_star) * decay
2452 qf_half(ix1) = q_sp_star + (qn_face - q_sp_star) * ave_factor
2456 block%ds(ix1, 1) / max(qdt, smalldouble)
2457 qf_half(ix1) = sign(min(dabs(qf_half(ix1)), q_face_max), qf_half(ix1))
2461 do ix1 = ixomin1, ixomax1
2462 w(ix1,
e_) = w(ix1,
e_) &
2463 - qdt * (qf_half(ix1) - qf_half(ix1 - 1)) /
block%ds(ix1, 1)
2464 w(ix1,
q_) = 0.5d0 * (qf_full(ix1 - 1) + qf_full(ix1))
2468 end subroutine add_hypertc_source
2470 subroutine hd_add_radiation_source(qdt,ixI^L,ixO^L,wCT,wCTprim,w,x,qsourcesplit,active)
2476 integer,
intent(in) :: ixi^
l, ixo^
l
2477 double precision,
intent(in) :: qdt, x(ixi^s,1:
ndim)
2478 double precision,
intent(in) :: wct(ixi^s,1:nw),wctprim(ixi^s,1:nw)
2479 double precision,
intent(inout) :: w(ixi^s,1:nw)
2480 logical,
intent(in) :: qsourcesplit
2481 logical,
intent(inout) :: active
2487 end subroutine hd_add_radiation_source
2489 subroutine hd_get_dt(wprim, ixI^L, ixO^L, dtnew, dx^D, x)
2497 integer,
intent(in) :: ixi^
l, ixo^
l
2498 double precision,
intent(in) ::
dx^
d, x(ixi^s, 1:^nd)
2499 double precision,
intent(in) :: wprim(ixi^s, 1:nw)
2500 double precision,
intent(inout) :: dtnew
2524 end subroutine hd_get_dt
2529 subroutine hd_fld_implicit_update(dtfactor,qdt,qtC,psa,psb)
2534 double precision,
intent(in) :: qdt
2535 double precision,
intent(in) :: qtc
2536 double precision,
intent(in) :: dtfactor
2539 end subroutine hd_fld_implicit_update
2541 subroutine hd_fld_evaluate_implicit(qtC,psa)
2545 double precision,
intent(in) :: qtc
2548 end subroutine hd_fld_evaluate_implicit
2552 integer,
intent(in) :: ixi^
l, ixo^
l
2553 double precision,
intent(in) :: w(ixi^s, nw)
2554 double precision :: ke(ixo^s)
2555 double precision,
intent(in),
optional :: inv_rho(ixo^s)
2557 if (
present(inv_rho))
then
2558 ke = 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) * inv_rho
2560 ke = 0.5d0 * sum(w(ixo^s,
mom(:))**2, dim=
ndim+1) / w(ixo^s,
rho_)
2564 function hd_inv_rho(w, ixI^L, ixO^L)
result(inv_rho)
2566 integer,
intent(in) :: ixi^
l, ixo^
l
2567 double precision,
intent(in) :: w(ixi^s, nw)
2568 double precision :: inv_rho(ixo^s)
2571 inv_rho = 1.0d0 / w(ixo^s,
rho_)
2572 end function hd_inv_rho
2581 logical,
intent(in) :: primitive
2582 integer,
intent(in) :: ixi^
l,ixo^
l
2583 double precision,
intent(inout) :: w(ixi^s,1:nw)
2584 double precision,
intent(in) :: x(ixi^s,1:
ndim)
2585 character(len=*),
intent(in) :: subname
2588 logical :: flag(ixi^s,1:nw)
2598 where(flag(ixo^s,
rho_)) w(ixo^s,
mom(idir)) = 0.0d0
2620 where(flag(ixo^s,
e_))
2646 call eos%get_thermal_pressure(w, x, ixi^
l, ixo^
l, w(ixo^s,
p_))
2649 w(ixo^s,
mom(idir)) = w(ixo^s,
mom(idir))/w(ixo^s,
rho_)
2651 call eos%p_to_e(ixi^
l, ixo^
l, w, x)
2653 w(ixo^s,
mom(idir)) = w(ixo^s,
mom(idir))*w(ixo^s,
rho_)
2672 if(.not.primitive)
then
2676 call eos%get_thermal_pressure(w, x, ixi^
l, ixo^
l, w(ixo^s,
p_))
2681 w(ixo^s,
mom(idir)) = w(ixo^s,
mom(idir))/w(ixo^s,
rho_)
2688 if (
hd_fip)
call hd_bound_fip(primitive, ixi^
l, ixo^
l, w)
2711 subroutine hd_wb_prolong(ixI^L, ixO^L, w, x)
2715 integer,
intent(in) :: ixi^
l, ixo^
l
2716 double precision,
intent(inout) :: w(ixi^s, 1:nw)
2717 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2719 double precision :: gravity_field(ixi^s, 1:
ndim)
2720 double precision :: wb_t(ixi^s), p_eq(ixi^s)
2721 double precision :: dx_idims
2722 double precision :: alpha(ixi^s), beta(ixi^s)
2724 integer :: ix1, ix_mid
2728 wb_t(ixo^s) = w(ixo^s,
p_) / w(ixo^s,
rho_)
2737 alpha(ixomin1:ixomax1) = 0.5d0 * dx_idims &
2738 * gravity_field(ixomin1:ixomax1, 1) / wb_t(ixomin1:ixomax1)
2741 ix_mid = (ixomin1 + ixomax1) / 2
2742 p_eq(ix_mid) = w(ix_mid,
p_)
2745 beta(ix_mid:ixomax1-1) = (1.0d0 + alpha(ix_mid:ixomax1-1)) &
2746 / (1.0d0 - alpha(ix_mid+1:ixomax1))
2747 do ix1 = ix_mid + 1, ixomax1
2748 p_eq(ix1) = p_eq(ix1 - 1) * beta(ix1 - 1)
2752 beta(ixomin1:ix_mid-1) = (1.0d0 - alpha(ixomin1+1:ix_mid)) &
2753 / (1.0d0 + alpha(ixomin1:ix_mid-1))
2754 do ix1 = ix_mid - 1, ixomin1, -1
2755 p_eq(ix1) = p_eq(ix1 + 1) * beta(ix1)
2759 w(ixomin1:ixomax1,
p_) = p_eq(ixomin1:ixomax1)
2760 w(ixomin1:ixomax1,
rho_) = p_eq(ixomin1:ixomax1) / wb_t(ixomin1:ixomax1)
2763 end subroutine hd_wb_prolong
2775 subroutine hd_wb_transform(ixI^L, ixO^L, idims, w, x, wb_phi, &
2780 integer,
intent(in) :: ixi^
l, ixo^
l, idims
2781 double precision,
intent(inout) :: w(ixi^s, 1:nw)
2782 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2783 double precision,
intent(out) :: wb_phi(ixi^s)
2784 double precision,
intent(out) :: wb_phi_face(ixi^s)
2785 double precision,
intent(out) :: wb_t(ixi^s)
2787 double precision :: gravity_field(ixi^s, 1:
ndim)
2788 double precision :: dx_idims
2789 double precision :: alpha(ixi^s), beta(ixi^s)
2795 wb_t(ixi^s) = w(ixi^s,
p_) / w(ixi^s,
rho_)
2809 alpha(iximin1:iximax1) = 0.5d0 * dx_idims &
2810 * gravity_field(iximin1:iximax1, idims) / wb_t(iximin1:iximax1)
2813 beta(iximin1:iximax1-1) = (1.0d0 + alpha(iximin1:iximax1-1)) &
2814 / (1.0d0 - alpha(iximin1+1:iximax1))
2817 wb_phi(iximin1) = w(iximin1,
p_)
2818 do ix1 = iximin1 + 1, iximax1
2819 wb_phi(ix1) = wb_phi(ix1 - 1) * beta(ix1 - 1)
2824 wb_phi_face(ixi^s) = wb_phi(ixi^s) * (1.0d0 + 0.5d0 * dx_idims * &
2825 gravity_field(ixi^s, idims) / wb_t(ixi^s))
2828 w(ixi^s,
rho_) = wb_t(ixi^s)
2829 w(ixi^s,
p_) = w(ixi^s,
p_) / wb_phi(ixi^s)
2831 end subroutine hd_wb_transform
2853 subroutine hd_wb_inverse(ixI^L, ixL^L, ixR^L, idims, wLp, wRp, w, &
2854 wb_phi, wb_phi_face, wb_T)
2857 integer,
intent(in) :: ixi^
l, ixl^
l, ixr^
l, idims
2858 double precision,
intent(inout) :: wlp(ixi^s, 1:nw), wrp(ixi^s, 1:nw)
2859 double precision,
intent(inout) :: w(ixi^s, 1:nw)
2860 double precision,
intent(in) :: wb_phi(ixi^s), wb_phi_face(ixi^s)
2861 double precision,
intent(in) :: wb_t(ixi^s)
2863 double precision :: t_shared(ixi^s)
2864 double precision :: t_face_l(ixi^s), t_face_r(ixi^s)
2865 double precision :: sigma(ixi^s), t_for_rhol(ixi^s), t_for_rhor(ixi^s)
2869 t_shared(iximin1:iximax1-1) = 0.5d0 * (wb_t(iximin1:iximax1-1) &
2870 + wb_t(iximin1+1:iximax1))
2871 t_shared(iximax1) = wb_t(iximax1)
2876 t_face_l(ixl^s) = wlp(ixl^s,
rho_)
2877 t_face_r(ixr^s) = wrp(ixr^s,
rho_)
2881 sigma(ixl^s) = dabs(t_face_l(ixl^s) - t_face_r(ixr^s)) &
2882 / (0.5d0 * (t_face_l(ixl^s) + t_face_r(ixr^s)) + smalldouble)
2883 sigma(ixl^s) = min(sigma(ixl^s), 1.0d0)
2886 t_for_rhol(ixl^s) = (1.d0 - sigma(ixl^s)) * t_shared(ixl^s) &
2887 + sigma(ixl^s) * t_face_l(ixl^s)
2888 t_for_rhor(ixr^s) = (1.d0 - sigma(ixl^s)) * t_shared(ixr^s) &
2889 + sigma(ixl^s) * t_face_r(ixr^s)
2892 wlp(ixl^s,
p_) = wlp(ixl^s,
p_) * wb_phi_face(ixl^s)
2893 wrp(ixr^s,
p_) = wrp(ixr^s,
p_) * wb_phi_face(ixr^s)
2896 wlp(ixl^s,
rho_) = wlp(ixl^s,
p_) / t_for_rhol(ixl^s)
2897 wrp(ixr^s,
rho_) = wrp(ixr^s,
p_) / t_for_rhor(ixr^s)
2900 w(ixi^s,
p_) = w(ixi^s,
p_) * wb_phi(ixi^s)
2901 w(ixi^s,
rho_) = w(ixi^s,
p_) / wb_t(ixi^s)
2903 end subroutine hd_wb_inverse
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, public 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 cak_get_dt(wprim, ixil, ixol, dtnew, dxd, x)
Check time step for total radiation contribution.
subroutine, public cak_init(phys_gamma)
Initialize the module.
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_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_evaluate_implicit(qtc, psa)
inplace update of psa==>F_im(psa)
integer, dimension(:, :), allocatable, public, protected dust_mom
Indices of the dust momentum densities.
integer, public, protected dust_n_species
The number of dust species.
subroutine, public dust_get_flux_prim(w, x, ixil, ixol, idim, f)
integer, dimension(:), allocatable, public, protected dust_rho
Indices of the dust densities.
subroutine, public dust_get_cmax(w, x, ixil, ixol, idim, cmax, cmin)
subroutine, public dust_check_w(ixil, ixol, w, x, flag)
subroutine, public dust_check_params()
subroutine, public dust_get_cmax_prim(w, x, ixil, ixol, idim, cmax, cmin)
subroutine, public dust_get_dt(wprim, ixil, ixol, dtnew, dxd, x)
Get dt related to dust and gas stopping time (Laibe 2011).
subroutine, public dust_init(g_rho, g_mom, g_energy)
subroutine, public dust_implicit_update(dtfactor, qdt, qtc, psb, psa)
Implicit solve of psb=psa+dtfactor*dt*F_im(psb).
EoS state container – the single thermodynamic authority for AMRVAC.
type(eos_container), allocatable, public eos
The single EoS state object, allocated in eos_init and shared (read-mostly) across all EoS sub-module...
integer, parameter, public eos_type_lte
LTE (Saha-table) EoS kernels and finalise for the eos% family.
double precision function, public lte_gamma1_from_p(pres, rho_val)
Gamma_1 of one cell from (p, rho): the ideal value where fully ionised, else the pressure- indexed ta...
double precision function, public lte_p_from_eint(eint_val, nh_val, log_nh_val, inv_rho)
LTE pressure from internal energy in one cell: ideal without ionE, else the table floor,...
PI (partial-ionisation) ionisation-degree backend for the eos% family.
Equation of state for AMRVAC, handled through a single eos_container object.
Module for escape probability radiative cooling modification.
subroutine, public escape_prob_init(iw_colmass, escape_sym, escape_height)
Register escape probability parameters. Called during hd_phys_init (before mesh parameters are availa...
Module for flux conservation near refinement boundaries.
Module for flux limited diffusion (FLD)-approximation in Radiation-(Magneto)hydrodynamics simulations...
double precision, public fld_bisect_tol
Tolerance for bisection method for Energy sourceterms This is a percentage of the minimum of gas- and...
subroutine, public fld_radforce_get_dt(w, ixil, ixol, dtnew, dxd, x, fl)
get dt limit for radiation force and FLD explicit source additions NOTE: w is primitive on entry
double precision, public fld_diff_tol
Tolerance for radiative Energy diffusion.
character(len=40) fld_fluxlimiter
flux limiter choice
character(len=40) fld_opal_table
double precision, public fld_cnorm
double precision, public fld_kappa0
Opacity value when using constant opacity.
subroutine, public add_fld_rad_force(qdt, ixil, ixol, wct, wctprim, w, x, qsourcesplit, active, fl)
w[iw]=w[iw]+qdt*S[wCT,qtC,x] where S is the source based on wCT within ixO This subroutine handles th...
character(len=40) fld_opacity_law
switches for opacity
character(len=40) fld_interaction_method
Which method to find the root for the energy interaction polynomial.
subroutine, public fld_get_radpress(w, x, ixil, ixol, rad_pressure, fl)
Returns Radiation Pressure as tensor NOTE: w is primitive on entry.
logical fld_radforce_split
source split for energy interact and radforce:
logical fld_bound_diff
switches for using changed cmax-cmin bounds
subroutine, public fld_implicit_update(dtfactor, qdt, qtc, psa, psb, fl)
Calling all subroutines to perform the multigrid method Communicates rad_e and diff_coeff to multigri...
subroutine, public fld_evaluate_implicit(qtc, psa, fl)
inplace update of psa==>F_im(psa)
subroutine, public fld_init(gas_eos_type, gas_ion_energy, gas_pi_table)
Initialising FLD-module Read opacities Initialise Multigrid and adimensionalise kappa.
integer nth_for_diff_mg
diffusion coefficient stencil control
Module with geometry-related routines (e.g., divergence, curl).
integer, parameter spherical
integer, parameter cylindrical
integer, parameter cartesian_expansion
subroutine gradient(q, ixil, ixol, idir, gradq, nth_in)
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 const_kappae
double precision arad_norm
Normalised radiation constant.
double precision small_pressure
double precision unit_time
Physical scaling factor for time.
double precision unit_density
Physical scaling factor for density.
double precision unit_opacity
Physical scaling factor for Opacity.
integer, parameter unitpar
file handle for IO
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.
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 phys_escape_prob
Use escape probability for radiative cooling modification.
double precision const_rad_a
Physical factors useful for radiation fld.
double precision cmax_global
global fastest wave speed needed in fd scheme and glm method
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 dt
global time step
integer ndir
Number of spatial dimensions (components) for vector variables.
double precision courantpar
The Courant (CFL) number used for the simulation.
double precision, dimension(:), allocatable, parameter d
logical slab
Cartesian geometry or not.
double precision const_sigmasb
integer nwauxio
Number of auxiliary variables that are only included in output.
double precision unit_velocity
Physical scaling factor for velocity.
double precision small_r_e
double precision c_norm
Normalised speed of light.
double precision unit_temperature
Physical scaling factor for temperature.
double precision unit_radflux
Physical scaling factor for radiation flux.
double precision, dimension(10) phys_trac_zone_splits
logical si_unit
Use SI units (.true.) or use cgs units (.false.).
double precision, dimension(:,:), allocatable dx
spatial steps for all dimensions at all levels
integer nghostcells
Number of ghost cells surrounding a grid.
double precision, dimension(:), allocatable w_refine_weight
Weights of variables used to calculate error for mesh refinement.
logical phys_trac
Use TRAC for MHD or 1D HD.
logical need_global_cmax
need global maximal wave speed
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
logical use_multigrid
Use multigrid (only available in 2D and 3D).
double precision small_density
integer max_blocks
The maximum number of grid blocks in a processor.
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 unit_erad
Physical scaling factor for radiation energy density.
Module for including gravity in (magneto)hydrodynamics simulations.
logical grav_split
source split or not
subroutine gravity_get_dt(wprim, ixil, ixol, dtnew, dxd, x)
subroutine gravity_init()
Initialize the module.
subroutine gravity_add_source(qdt, ixil, ixol, wct, wctprim, w, x, energy, qsourcesplit, active)
w[iw]=w[iw]+qdt*S[wCT,qtC,x] where S is the source based on wCT within ixO
Hydrodynamics physics module.
integer, public, protected m
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, public hd_get_pthermal_plus_pradiation(w, x, ixil, ixol, pth_plus_prad)
calculates the sum of the gas pressure and max Prad tensor element NOTE: only for diagnostic purposes...
subroutine, public hd_ei_to_e(ixil, ixol, w, x)
Transform internal energy to total energy.
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, public hd_get_temperature_from_etot(w, x, ixil, ixol, res)
Calculate temperature=p/rho when in e_ the total energy is stored.
logical, public, protected hd_fld_pradtensor
integer, public, protected hd_trac_type
logical, public, protected hd_particles
Whether particles module is added.
logical, public, protected hd_fip
Whether FIP passive scalar is enabled.
double precision, public hypertc_kappa
Thermal-conductivity prefactor in hyperbolic TC, set in hd_physical_units. Spitzer form: κ(T) = hyper...
logical, public, protected hd_radiation_fld
Whether radiation-gas interaction is handled using flux limited diffusion.
double precision, public, protected hd_htc_beta
Face-recipe heat-wave speed scaling: c_HTC,f = hd_htc_beta * c_max,f. Higher value -> closer to diffu...
double precision, public, protected hd_trac_delta
Johnston 2021 resolution parameter delta (default 0.5).
type(tc_fluid), allocatable, public tc_fl
subroutine, public hd_check_w(primitive, ixil, ixol, w, flag)
Returns logical argument flag where values are ok.
logical, public, protected hd_viscosity
Whether viscosity is added.
integer, public, protected r_e
Index of the radiation energy (when fld active).
integer, public, protected c
Indices of the momentum density for the form of better vectorization.
subroutine, public hd_get_csound2(w, x, ixil, ixol, csound2)
Calculate the square of the thermal sound speed csound2 within ixO^L. For conserved w: extracts pther...
integer, public, protected tcoff_
Index of the cutoff temperature for the TRAC method.
double precision, public, protected he_ion_fr2
Ratio of number He2+ / number He+ + He2+ He_ion_fr2 = He2+/(He2+ + He+).
double precision, public, protected hd_htc_gradt_floor
Gradient deadband: zero out the Spitzer face flux when abs(T_R - T_L) / max(T_L, T_R) < hd_htc_gradT_...
integer, public, protected te_
Indices of temperature.
integer, dimension(:), allocatable, public, protected mom
Indices of the momentum density.
subroutine, public hd_get_pradiation_from_prim(w, x, ixil, ixol, prad)
Calculate radiation pressure within ixO^L NOTE: w is primitive on entry here! NOTE: used in FLD modul...
double precision, public, protected hd_trac_tfix
fixed cutoff temperature in K for hd_trac_type=0 (Lionello et al. 2009, Mikic et al....
double precision, public, protected hd_htc_hyp_diff
Hyperdiffusion coefficient applied to the cell-refreshed q at the end of each face-recipe substep....
logical, public, protected hd_hyperbolic_thermal_conduction
Whether hyperbolic thermal conduction (Cattaneo relaxation) is used. 1D only : the q-variable is trea...
double precision, public, protected h_ion_fr
Helium abundance over Hydrogen He_abundance is set in &eos_list and accessed via eosHe_abundance Ioni...
double precision function, dimension(ixo^s), public hd_kin_en(w, ixil, ixol, inv_rho)
logical, public, protected hd_cak_force
Whether CAK radiation line force is activated.
subroutine, public hd_phys_init()
Initialize the module.
integer, dimension(:), allocatable, public, protected tracer
Indices of the tracers.
subroutine, public hd_get_csrad2(w, x, ixil, ixol, csound)
Calculate modified squared sound speed for FLD NOTE: only for diagnostic purposes,...
logical, public, protected hd_thermal_conduction
Whether thermal conduction is added.
integer, public, protected q_
Index of the hyperbolic-TC heat-flux variable (-1 if not present).
double precision, public hd_htc_validity_max_runtime
Running max of l_r,f / dx_f across all face-recipe calls since simulation start. Inspect post-hoc via...
double precision, public hd_adiab
gamma is set in &eos_list and accessed via eosgamma
subroutine, public hd_get_trad(w, x, ixil, ixol, trad)
Calculates radiation temperature.
subroutine, public hd_get_csrad2_prim(w, x, ixil, ixol, csound)
Calculate modified squared sound speed for FLD NOTE: w is primitive on entry here!...
integer, public, protected rho_
Whether plasma is partially ionized.
subroutine, public hd_handle_small_values(primitive, w, x, ixil, ixol, subname)
double precision, public, protected hd_htc_sat_alpha
Cowie-McKee saturation coefficient: q_sat = hd_htc_sat_alpha * rho * c_s^3. Standard convention is al...
double precision, public, protected hd_htc_pos_eta
Per-face energy-positivity safety fraction: |q_f^{n+1/2} dt A_f| <= hd_htc_pos_eta * min(e_int_L V_L,...
logical, public, protected hd_radiative_transfer
Whether the short-characteristics radiative transfer is used, with its settings in &rt_list.
double precision, public, protected he_ion_fr
Ionization fraction of He He_ion_fr = (He2+ + He+)/(He2+ + He+ + He).
logical, public, protected hd_gravity
Whether gravity is added.
type(fld_fluid), allocatable, public fld_fl
Radiation fluid object (gas-EoS callbacks for FLD), wired in hd_link_eos.
double precision, public, protected hd_htc_kappa_override
Optional parfile override for hypertc_kappa (e.g. to match a constant-κ parabolic TC run for benchmar...
integer, public, protected hd_trac_nzones
integer, public, protected c_
type(rc_fluid), allocatable, public rc_fl
logical, public, protected hd_dust_implicit
Whether dust is added using and implicit update in IMEX.
logical, public, protected hd_trac
Whether TRAC method is used.
integer, public, protected fip_
Index of the FIP passive scalar rho*fip in conserved form, fip in primitive form.
double precision, public, protected hd_htc_validity_warn
Validity-monitor threshold for l_r,f / Delta_x_f. Warn if any face exceeds this in a given block (pri...
integer, public, protected hd_n_tracer
Number of tracer species.
type(te_fluid), allocatable, public te_fl_hd
double precision, dimension(10), public, protected hd_trac_zone_splits
logical, public, protected hd_rotating_frame
Whether rotating frame is activated.
logical, public, protected hd_htc_sat
Whether saturation is considered for hyperbolic TC.
logical, public, protected hd_well_balanced
Whether well-balanced reconstruction is used (Kaeppeli & Mishra style).
integer, public, protected iw_colmass
Index into wextra for escape probability column mass.
integer, public, protected p_
Index of the gas pressure (-1 if not present) should equal e_.
integer, public, protected ne_
Index of the electron number density for LTE module.
subroutine, public hd_e_to_ei(ixil, ixol, w, x)
Transform total energy to internal energy.
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
subroutine radiative_cooling_init_params(phys_gamma, he_abund)
Radiative cooling initialization.
subroutine findl(tpoint, lpoint, fl)
subroutine radiative_cooling_init(fl, read_params)
subroutine radiative_cooling_add_source(qdt, ixil, ixol, wct, wctprim, w, x, qsourcesplit, active, fl)
subroutine calc_l_extended(tpoint, lpoint, fl)
Module to include Coriolis and centrifugal forces in (radiation-)(magneto) hydrodynamics simulations ...
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.
Public face of the short-characteristics (SC) radiative transfer and its coupling to the (M)HD.
subroutine, public rt_sc_add_source(qdt, ixil, ixol, wct, w, x, thin_share, e_internal)
Unsplit heating source of one block and stage, e += qdt Q, with Q read from i_qrad,...
subroutine, public rt_sc_activate()
Switch the RT on. The physics module calls this from its initialisation when hd_radiative_transfer or...
Module for handling problematic values in simulations, such as negative pressures.
subroutine, public small_values_average(ixil, ixol, w, x, w_flag, windex)
subroutine, public small_values_error(wprim, x, ixil, ixol, w_flag, subname)
logical, dimension(:), allocatable, public small_values_fix_iw
Whether to apply small value fixes to certain variables.
character(len=20), public small_values_method
How to handle small values.
Generic supertimestepping method which can be used for multiple source terms in the governing equatio...
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 tc_get_hd_params(fl, read_hd_params)
Init TC coefficients: HD case.
double precision function, public get_tc_dt_hd(w, ixil, ixol, dxd, x, fl)
Get the explicit timestep for the TC (hd implementation) Note: also used in 1D MHD (or for neutrals i...
subroutine tc_init_params(phys_gamma)
subroutine, public sts_set_source_tc_hd(ixil, ixol, w, x, wres, fix_conserve_at_step, my_dt, igrid, nflux, fl)
subroutine get_euv_image(qunit, fl)
subroutine get_sxr_image(qunit, fl)
subroutine get_euv_spectrum(qunit, fl)
subroutine get_whitelight_image(qunit, fl)
subroutine eos_timer_start()
Open an EoS timing window; inside an OpenMP parallel region the EoS is not timed.
subroutine eos_timer_stop(acc)
Close an EoS timing window, adding its time to acc when it is the outermost.
double precision timeeos_csound
Module with all the methods that users can customize in AMRVAC.
procedure(rfactor), pointer usr_rfactor
procedure(sub_get_heating), pointer usr_get_heating
procedure(set_surface), pointer usr_set_surface
procedure(phys_gravity), pointer usr_gravity
procedure(hd_pthermal), pointer usr_set_pthermal
procedure(set_wlr), pointer usr_set_wlr
integer nw
Total number of variables.
integer number_species
number of species: each species has different characterictic speeds and should be used accordingly in...
The module add viscous source terms and check time step.
subroutine, public viscosity_get_dt(wprim, ixil, ixol, dtnew, dxd, x)
procedure(sub_add_source), pointer, public viscosity_add_source
subroutine, public viscosity_init(phys_wider_stencil)
Initialize the module.
Radiation fluid object: gas-EoS callbacks the FLD module needs, wired by the physics module at link t...