60 if (
eos%eos_type ==
'FI' .or.
eos%eos_type ==
'PI')
then
64 call mpistop(
'PI EoS not supported with equilibrium splitting')
66 if(
eos%ionE)
call mpistop(
'PI energy EoS not supported with mhd_hydrodynamic_e')
67 eos%to_primitive => mhd_to_primitive_hde
68 eos%to_conserved => mhd_to_conserved_hde
74 eos%to_primitive => mhd_to_primitive_semirelati
75 eos%to_conserved => mhd_to_conserved_semirelati
85 eos%to_primitive => mhd_to_primitive_semirelati_noe
86 eos%to_conserved => mhd_to_conserved_semirelati_noe
92 eos%to_primitive => mhd_to_primitive_split_rho
93 eos%to_conserved => mhd_to_conserved_split_rho
96 eos%to_conserved => mhd_to_conserved_inte_pi
97 eos%to_primitive => mhd_to_primitive_inte_pi
98 eos%p_to_e => mhd_p_to_eint_pi
102 eos%to_primitive => mhd_to_primitive_inte
103 eos%to_conserved => mhd_to_conserved_inte
109 eos%to_conserved => mhd_to_conserved_origin_pi
110 eos%to_primitive => mhd_to_primitive_origin_pi
111 eos%p_to_e => mhd_p_to_e_pi
115 eos%to_primitive => mhd_to_primitive_origin
116 eos%to_conserved => mhd_to_conserved_origin
121 eos%to_primitive => mhd_to_primitive_origin_noe
122 eos%to_conserved => mhd_to_conserved_origin_noe
127 else if (
eos%eos_type ==
'LTE')
then
130 call mpistop(
'LTE EoS not supported with mhd_hydrodynamic_e')
132 call mpistop(
'LTE EoS not supported with equilibrium splitting')
134 call mpistop(
'LTE EoS requires mhd_energy=.true.')
137 eos%to_primitive => mhd_to_primitive_semirelati
138 eos%to_conserved => mhd_to_conserved_semirelati
140 eos%to_primitive => mhd_to_primitive_inte_lte
141 eos%to_conserved => mhd_to_conserved_inte_lte
143 eos%to_primitive => mhd_to_primitive_origin_lte
144 eos%to_conserved => mhd_to_conserved_origin_lte
147 call mpistop(
'Error: Unknown MHD EOS type: ' // trim(
eos%eos_type))
156 eos%p_to_e => mhd_p_to_eint
158 eos%p_to_e => mhd_p_to_e
162 if (
eos%eos_type ==
'LTE' .and.
eos%ionE)
then
163 eos%get_csound2 => mhd_get_csound2_lte
165 else if (
eos%eos_type ==
'PI' .and.
eos%ionE)
then
166 eos%get_csound2 => mhd_get_csound2_fi
169 eos%get_csound2 => mhd_get_csound2_fi
174 if (
eos%eos_type ==
'LTE' .and.
eos%ionE)
then
186 eos%get_Rfactor => rfactor_from_constant_ionization
190 if (
eos%eos_type ==
'LTE')
then
198 if(
eos%eos_type ==
'PI' .or.
eos%eos_type ==
'LTE')
then
238 subroutine bind_eos_to_source()
247 if (
eos%eos_type ==
'LTE' .or. (
eos%eos_type ==
'PI' .and.
eos%ionE))
then
252 eos%get_temperature_from_etot =>
eos%get_temperature_from_eint
255 eos%get_temperature_from_etot => mhd_get_temperature_from_etot_lte
261 eos%get_temperature_from_etot => mhd_get_temperature_from_eint_with_equi
262 eos%get_temperature_from_eint => mhd_get_temperature_from_eint_with_equi
264 eos%get_temperature_from_etot => mhd_get_temperature_from_eint
265 eos%get_temperature_from_eint => mhd_get_temperature_from_eint
270 eos%get_temperature_from_etot => mhd_get_temperature_from_etot_with_equi
271 eos%get_temperature_from_eint => mhd_get_temperature_from_eint_with_equi
273 eos%get_temperature_from_etot => mhd_get_temperature_from_etot
274 eos%get_temperature_from_eint => mhd_get_temperature_from_eint
279 if (
allocated(
tc_fl))
then
280 call eos_bind_tc(
tc_fl, .not.
associated(
eos%get_Rfactor, rfactor_from_constant_ionization))
283 tc_fl%subtract_equi = .true.
284 tc_fl%get_temperature_equi => mhd_get_temperature_equi
285 tc_fl%get_rho_equi => mhd_get_rho_equi
287 tc_fl%subtract_equi = .false.
291 if (
allocated(
rc_fl))
then
293 rc_fl%get_pthermal =>
eos%get_thermal_pressure
294 rc_fl%get_var_Rfactor =>
eos%get_Rfactor
297 nullify(
rc_fl%get_rho2_factor)
301 rc_fl%inv_gamma_minus_1 =
eos%inv_gamma_minus_1
302 rc_fl%nH2rhoFactor =
eos%nH2rhoFactor
305 rc_fl%log_T_floor = eos_get_log_t_floor()
312 rc_fl%subtract_equi = .true.
313 rc_fl%get_rho_equi => mhd_get_rho_equi
314 rc_fl%get_pthermal_equi => mhd_get_pe_equi
315 rc_fl%get_ne_nH_equi => mhd_get_ne_nh_equi
316 rc_fl%get_temperature_equi => mhd_get_temperature_equi
318 rc_fl%subtract_equi = .false.
327 if (
eos%ionE .and.
eos%eos_type ==
'LTE')
then
338 if (
eos%eos_type ==
'PI' .and.
eos%ionE)
then
340 if (
allocated(
rc_fl))
then
355 if (
allocated(
fld_fl))
then
359 fld_fl%get_tgas =>
eos%get_temperature_from_pressure
363 end subroutine bind_eos_to_source
368 subroutine mhd_to_conserved_origin(ixI^L,ixO^L,w,x)
370 integer,
intent(in) :: ixi^
l, ixo^
l
371 double precision,
intent(inout) :: w(ixi^s, nw)
372 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
376 {
do ix^db=ixomin^db,ixomax^db\}
378 w(ix^
d,
e_)=w(ix^
d,
p_)*
eos%inv_gamma_minus_1&
380 +(^
c&w(ix^
d,
b^
c_)**2+))
387 end subroutine mhd_to_conserved_origin
390 subroutine mhd_to_conserved_origin_noe(ixI^L,ixO^L,w,x)
392 integer,
intent(in) :: ixi^
l, ixo^
l
393 double precision,
intent(inout) :: w(ixi^s, nw)
394 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
398 {
do ix^db=ixomin^db,ixomax^db\}
400 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)\
403 end subroutine mhd_to_conserved_origin_noe
406 subroutine mhd_to_conserved_hde(ixI^L,ixO^L,w,x)
408 integer,
intent(in) :: ixi^
l, ixo^
l
409 double precision,
intent(inout) :: w(ixi^s, nw)
410 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
414 {
do ix^db=ixomin^db,ixomax^db\}
416 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1&
417 +half*(^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)
419 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)\
422 end subroutine mhd_to_conserved_hde
425 subroutine mhd_to_conserved_inte(ixI^L,ixO^L,w,x)
427 integer,
intent(in) :: ixi^
l, ixo^
l
428 double precision,
intent(inout) :: w(ixi^s, nw)
429 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
433 {
do ix^db=ixomin^db,ixomax^db\}
435 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1
437 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)\
440 end subroutine mhd_to_conserved_inte
443 subroutine mhd_to_conserved_split_rho(ixI^L,ixO^L,w,x)
445 integer,
intent(in) :: ixi^
l, ixo^
l
446 double precision,
intent(inout) :: w(ixi^s, nw)
447 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
449 double precision :: rho
452 {
do ix^db=ixomin^db,ixomax^db\}
453 rho=w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,
b0i)
455 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1&
456 +half*((^c&w(ix^
d,m^c_)**2+)*rho&
457 +(^c&w(ix^
d,b^c_)**2+))
459 ^c&w(ix^
d,m^c_)=rho*w(ix^
d,m^c_)\
462 end subroutine mhd_to_conserved_split_rho
465 subroutine mhd_to_conserved_semirelati(ixI^L,ixO^L,w,x)
467 integer,
intent(in) :: ixi^
l, ixo^
l
468 double precision,
intent(inout) :: w(ixi^s, nw)
469 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
471 double precision :: efd(1:
ndir), s(1:
ndir), eint(ixo^s)
472 double precision :: btot(1:
ndir)
475 {
do ix^db=ixomin^db,ixomax^db\}
477 eint(ix^
d)=mhd_semirelati_eint(w(ix^
d,p_),w(ix^
d,rho_))
479 {
do ix^db=ixomin^db,ixomax^db\}
481 ^c&btot(^c)=w(ix^d,b^c_)\
483 ^c&btot(^c)=btot(^c)+block%B0(ix^d,^c,b0i)\
486 efd(1)=btot(2)*w(ix^d,m3_)-btot(3)*w(ix^d,m2_)
487 efd(2)=btot(3)*w(ix^d,m1_)-btot(1)*w(ix^d,m3_)
488 efd(3)=btot(1)*w(ix^d,m2_)-btot(2)*w(ix^d,m1_)
489 s(1)=efd(2)*btot(3)-efd(3)*btot(2)
490 s(2)=efd(3)*btot(1)-efd(1)*btot(3)
491 s(3)=efd(1)*btot(2)-efd(2)*btot(1)
496 efd(2)=btot(1)*w(ix^d,m2_)-btot(2)*w(ix^d,m1_)
504 if(mhd_internal_e)
then
505 w(ix^d,e_)=eint(ix^d)
508 w(ix^d,e_)=eint(ix^d)+half*((^c&w(ix^d,m^c_)**2+)*w(ix^d,rho_)&
509 +(^c&w(ix^d,b^c_)**2+)&
510 +(^c&efd(^c)**2+)*eos%inv_squared_c)
513 ^c&w(ix^d,m^c_)=w(ix^d,rho_)*w(ix^d,m^c_)+s(^c)*eos%inv_squared_c\
516 end subroutine mhd_to_conserved_semirelati
518 subroutine mhd_to_conserved_semirelati_noe(ixI^L,ixO^L,w,x)
520 integer,
intent(in) :: ixi^
l, ixo^
l
521 double precision,
intent(inout) :: w(ixi^s, nw)
522 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
524 double precision :: efd(1:
ndir), s(1:
ndir)
525 double precision :: btot(1:
ndir)
528 {
do ix^db=ixomin^db,ixomax^db\}
530 ^c&btot(^c)=w(ix^
d,b^c_)\
532 ^c&btot(^c)=btot(^c)+
block%B0(ix^
d,^c,
b0i)\
535 efd(1)=btot(2)*w(ix^
d,m3_)-btot(3)*w(ix^
d,m2_)
536 efd(2)=btot(3)*w(ix^
d,m1_)-btot(1)*w(ix^
d,m3_)
537 efd(3)=btot(1)*w(ix^
d,m2_)-btot(2)*w(ix^
d,m1_)
538 s(1)=efd(2)*btot(3)-efd(3)*btot(2)
539 s(2)=efd(3)*btot(1)-efd(1)*btot(3)
540 s(3)=efd(1)*btot(2)-efd(2)*btot(1)
545 efd(2)=btot(1)*w(ix^
d,m2_)-btot(2)*w(ix^
d,m1_)
554 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)+s(^c)*eos%inv_squared_c\
557 end subroutine mhd_to_conserved_semirelati_noe
560 subroutine mhd_to_primitive_origin(ixI^L,ixO^L,w,x)
562 integer,
intent(in) :: ixi^
l, ixo^
l
563 double precision,
intent(inout) :: w(ixi^s, nw)
564 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
566 double precision :: inv_rho
570 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_origin')
573 {
do ix^db=ixomin^db,ixomax^db\}
574 inv_rho = 1.d0/w(ix^
d,rho_)
576 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
578 w(ix^
d,p_)=eos%gamma_minus_1*(w(ix^
d,e_)&
579 -half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+)&
580 +(^c&w(ix^
d,b^c_)**2+))&
581 -mhd_uawsom_wave_energy_cell(w(ix^
d,:)))
584 end subroutine mhd_to_primitive_origin
587 subroutine mhd_to_primitive_origin_noe(ixI^L,ixO^L,w,x)
589 integer,
intent(in) :: ixi^
l, ixo^
l
590 double precision,
intent(inout) :: w(ixi^s, nw)
591 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
593 double precision :: inv_rho
597 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_origin_noe')
600 {
do ix^db=ixomin^db,ixomax^db\}
601 inv_rho = 1.d0/w(ix^
d,rho_)
603 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
606 end subroutine mhd_to_primitive_origin_noe
609 subroutine mhd_to_primitive_hde(ixI^L,ixO^L,w,x)
611 integer,
intent(in) :: ixi^
l, ixo^
l
612 double precision,
intent(inout) :: w(ixi^s, nw)
613 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
615 double precision :: inv_rho
619 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_hde')
622 {
do ix^db=ixomin^db,ixomax^db\}
623 inv_rho = 1.d0/w(ix^
d,rho_)
625 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
627 w(ix^
d,p_)=eos%gamma_minus_1*(w(ix^
d,e_)-half*w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+))
630 end subroutine mhd_to_primitive_hde
633 subroutine mhd_to_primitive_inte(ixI^L,ixO^L,w,x)
635 integer,
intent(in) :: ixi^
l, ixo^
l
636 double precision,
intent(inout) :: w(ixi^s, nw)
637 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
639 double precision :: inv_rho
643 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_inte')
646 {
do ix^db=ixomin^db,ixomax^db\}
648 w(ix^
d,p_)=w(ix^
d,e_)*eos%gamma_minus_1
650 inv_rho = 1.d0/w(ix^
d,rho_)
651 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
654 end subroutine mhd_to_primitive_inte
657 subroutine mhd_to_primitive_split_rho(ixI^L,ixO^L,w,x)
659 integer,
intent(in) :: ixi^
l, ixo^
l
660 double precision,
intent(inout) :: w(ixi^s, nw)
661 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
663 double precision :: inv_rho
667 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_split_rho')
670 {
do ix^db=ixomin^db,ixomax^db\}
671 inv_rho=1.d0/(w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,
b0i))
673 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
675 w(ix^
d,p_)=eos%gamma_minus_1*(w(ix^
d,e_)&
676 -half*((w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,
b0i))*&
677 (^c&w(ix^
d,m^c_)**2+)+(^c&w(ix^
d,b^c_)**2+)))
680 end subroutine mhd_to_primitive_split_rho
683 subroutine mhd_to_primitive_semirelati(ixI^L,ixO^L,w,x)
685 integer,
intent(in) :: ixi^
l, ixo^
l
686 double precision,
intent(inout) :: w(ixi^s, nw)
687 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
689 double precision :: btot(1:
ndir), efd(1:
ndir)
690 double precision :: b2, tmp, inv_rho, rhoc2
694 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_semirelati')
697 {
do ix^db=ixomin^db,ixomax^db\}
698 ^c&btot(^c)=w(ix^
d,b^c_)\
700 ^c&btot(^c)=btot(^c)+
block%B0(ix^
d,^c,
b0i)\
704 tmp=(^c&btot(^c)*w(ix^
d,m^c_)+)
705 rhoc2=w(ix^
d,rho_)*mhd_squared_c
706 inv_rho=1.d0/(w(ix^
d,rho_)*(rhoc2+b2))
707 ^c&w(ix^
d,m^c_)=(rhoc2*w(ix^
d,m^c_)+btot(^c)*tmp)*inv_rho\
708 if(.not.mhd_internal_e)
then
711 efd(1)=btot(2)*w(ix^
d,m3_)-btot(3)*w(ix^
d,m2_)
712 efd(2)=btot(3)*w(ix^
d,m1_)-btot(1)*w(ix^
d,m3_)
713 efd(3)=btot(1)*w(ix^
d,m2_)-btot(2)*w(ix^
d,m1_)
717 efd(2)=btot(1)*w(ix^
d,m2_)-btot(2)*w(ix^
d,m1_)
722 w(ix^
d,e_)=w(ix^
d,e_)-half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
723 +(^c&w(ix^
d,b^c_)**2+)&
724 +(^c&efd(^c)**2+)*eos%inv_squared_c)
727 {
do ix^db=ixomin^db,ixomax^db\}
729 w(ix^d,p_)=mhd_semirelati_p(w(ix^d,e_),w(ix^d,rho_))
732 end subroutine mhd_to_primitive_semirelati
735 subroutine mhd_to_primitive_semirelati_noe(ixI^L,ixO^L,w,x)
737 integer,
intent(in) :: ixi^
l, ixo^
l
738 double precision,
intent(inout) :: w(ixi^s, nw)
739 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
741 double precision :: btot(1:
ndir)
742 double precision :: b2, rhoc2, tmp, inv_rho
746 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_semirelati')
749 {
do ix^db=ixomin^db,ixomax^db\}
750 ^c&btot(^c)=w(ix^
d,b^c_)\
752 ^c&btot(^c)=btot(^c)+
block%B0(ix^
d,^c,
b0i)\
756 tmp=(^c&btot(^c)*w(ix^
d,m^c_)+)
757 rhoc2=w(ix^
d,rho_)*mhd_squared_c
758 inv_rho=1.d0/(w(ix^
d,rho_)*(rhoc2+b2))
759 ^c&w(ix^
d,m^c_)=(rhoc2*w(ix^
d,m^c_)+btot(^c)*tmp)*inv_rho\
762 end subroutine mhd_to_primitive_semirelati_noe
768 subroutine mhd_to_conserved_origin_lte(ixI^L,ixO^L,w,x)
770 integer,
intent(in) :: ixi^
l, ixo^
l
771 double precision,
intent(inout) :: w(ixi^s, nw)
772 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
775 call mhd_p_to_e(ixi^
l, ixo^
l, w, x)
777 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
779 end subroutine mhd_to_conserved_origin_lte
783 subroutine mhd_to_conserved_inte_lte(ixI^L,ixO^L,w,x)
785 integer,
intent(in) :: ixi^
l, ixo^
l
786 double precision,
intent(inout) :: w(ixi^s, nw)
787 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
790 call mhd_p_to_eint(ixi^
l, ixo^
l, w, x)
792 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
794 end subroutine mhd_to_conserved_inte_lte
797 subroutine mhd_p_to_e(ixI^L,ixO^L,w,x)
799 integer,
intent(in) :: ixi^
l, ixo^
l
800 double precision,
intent(inout) :: w(ixi^s, nw)
801 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
805 call mhd_p_to_eint(ixi^
l,ixo^
l,w,x)
806 {
do ix^db=ixomin^db,ixomax^db\}
807 w(ix^
d,e_) = w(ix^
d,e_) + half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_) + (^c&w(ix^
d,b^c_)**2+))
808 if(mhd_uawsom) w(ix^
d,e_)=w(ix^
d,e_)+&
809 w(ix^
d,waplus_)+w(ix^
d,waminus_)+w(ix^
d,wkplus_)+w(ix^
d,wkminus_)
812 end subroutine mhd_p_to_e
815 subroutine mhd_p_to_eint(ixI^L,ixO^L,w,x)
817 integer,
intent(in) :: ixi^
l, ixo^
l
818 double precision,
intent(inout) :: w(ixi^s, nw)
819 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
822 double precision :: nh(ixi^s), log_nh(ixi^s)
824 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
825 log_nh(ixo^s) = 0.0d0
826 if (eos%ionE) log_nh(ixo^s) = dlog10(nh(ixo^s))
828 {
do ix^db=ixomin^db,ixomax^db\}
829 w(ix^
d,e_) = lte_eint_from_p(w(ix^
d,p_), nh(ix^
d), log_nh(ix^
d), w(ix^
d,rho_))
832 end subroutine mhd_p_to_eint
835 subroutine mhd_to_primitive_origin_lte(ixI^L,ixO^L,w,x)
837 integer,
intent(in) :: ixi^
l, ixo^
l
838 double precision,
intent(inout) :: w(ixi^s, nw)
839 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
841 double precision :: inv_rho, eint_val
842 double precision :: nh(ixi^s), log_nh(ixi^s)
846 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
847 'mhd_to_primitive_origin_LTE')
850 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
851 log_nh(ixo^s) = 0.0d0
852 if (eos%ionE) log_nh(ixo^s) = dlog10(nh(ixo^s))
854 {
do ix^db=ixomin^db,ixomax^db\}
855 inv_rho = 1.d0/w(ix^
d,rho_)
856 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
857 eint_val = w(ix^
d,e_) &
858 - half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+) &
859 + (^c&w(ix^
d,b^c_)**2+))
860 w(ix^
d,p_) = lte_p_from_eint(eint_val, nh(ix^
d), log_nh(ix^
d), inv_rho)
863 end subroutine mhd_to_primitive_origin_lte
867 subroutine mhd_to_primitive_inte_lte(ixI^L,ixO^L,w,x)
869 integer,
intent(in) :: ixi^
l, ixo^
l
870 double precision,
intent(inout) :: w(ixi^s, nw)
871 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
873 double precision :: inv_rho
874 double precision :: nh(ixi^s), log_nh(ixi^s)
878 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
879 'mhd_to_primitive_inte_LTE')
882 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
883 log_nh(ixo^s) = 0.0d0
884 if (eos%ionE) log_nh(ixo^s) = dlog10(nh(ixo^s))
886 {
do ix^db=ixomin^db,ixomax^db\}
887 inv_rho = 1.d0/w(ix^
d,rho_)
888 w(ix^
d,p_) = lte_p_from_eint(w(ix^
d,e_), nh(ix^
d), log_nh(ix^
d), inv_rho)
889 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
892 end subroutine mhd_to_primitive_inte_lte
899 subroutine mhd_to_prolong_lte(ixI^L,ixO^L,w,x)
901 integer,
intent(in) :: ixi^
l, ixo^
l
902 double precision,
intent(inout) :: w(ixi^s, nw)
903 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
905 double precision :: inv_rho, eint_val, t_loc, y_loc
906 double precision :: nh(ixi^s), log_nh(ixi^s)
907 double precision :: vel(ixo^s,1:
ndir), emech(ixo^s)
910 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
911 log_nh(ixo^s) = dlog10(nh(ixo^s))
912 if (mhd_semirelativistic)
call mhd_semirelati_vel_emech(w,ixi^
l,ixo^
l,vel,emech)
914 {
do ix^db=ixomin^db,ixomax^db\}
915 inv_rho = 1.d0/w(ix^
d,rho_)
916 if (mhd_semirelativistic)
then
918 ^c&w(ix^
d,m^c_)=vel(ix^
d,^c)\
919 eint_val = w(ix^
d,e_) - emech(ix^
d)
922 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
923 if (mhd_internal_e)
then
924 eint_val = w(ix^
d,e_)
927 eint_val = w(ix^
d,e_) &
928 - half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+) &
929 + (^c&w(ix^
d,b^c_)**2+))
932 eint_val = max(eint_val, nh(ix^
d)*eos%eint_nH_min, smalldouble)
934 if (eint_val * inv_rho > eos%eint_rho_FI_threshold)
then
936 w(ix^
d,p_) = eos%gamma_minus_1 &
937 * (eint_val - eos%eion_per_nH * nh(ix^
d)) &
938 / (nh(ix^
d) * eos%n_per_nH_FI)
939 else if (eos%method_id == eos_analytic)
then
941 call saha_t_from_nh_eint(nh(ix^
d), &
942 eint_val / nh(ix^
d), t_loc, y_loc)
946 w(ix^
d,p_) = t_from_nh_eint( &
948 dlog10(eint_val) - log_nh(ix^
d))
952 end subroutine mhd_to_prolong_lte
956 subroutine mhd_from_prolong_lte(ixI^L,ixO^L,w,x)
958 integer,
intent(in) :: ixi^
l, ixo^
l
959 double precision,
intent(inout) :: w(ixi^s, nw)
960 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
962 double precision :: t_val, eint_val(ixo^s), t_fi, log_t_min
963 double precision :: nh(ixi^s), btot(1:
ndir)
964 double precision :: efd(1:
ndir), s(1:
ndir)
968 t_fi = (eos%eint_rho_FI_threshold &
969 * eos%nH2rhoFactor - eos%eion_per_nH) &
970 * eos%gamma_minus_1 / eos%n_per_nH_FI
975 if (eos%method_id == eos_entropy)
then
976 log_t_min = eos%eintT%var2_min
978 log_t_min = eos%eint_from_T%var2_min
981 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
983 {
do ix^db=ixomin^db,ixomax^db\}
986 if (t_val > t_fi)
then
988 eint_val(ix^
d) = nh(ix^
d) &
989 * (eos%n_per_nH_FI * t_val * eos%inv_gamma_minus_1 &
991 else if (eos%method_id == eos_analytic)
then
993 eint_val(ix^
d) = saha_eint_from_nh_t(nh(ix^
d), t_val) * nh(ix^
d)
996 eint_val(ix^
d) = eint_nh_from_t( &
998 dlog10(max(t_val, 10.0d0**log_t_min))) &
1003 if (mhd_semirelativistic)
then
1004 {
do ix^db=ixomin^db,ixomax^db\}
1006 ^c&btot(^c)=w(ix^d,b^c_)\
1008 ^c&btot(^c)=btot(^c)+block%B0(ix^d,^c,b0i)\
1011 efd(1)=btot(2)*w(ix^d,m3_)-btot(3)*w(ix^d,m2_)
1012 efd(2)=btot(3)*w(ix^d,m1_)-btot(1)*w(ix^d,m3_)
1013 efd(3)=btot(1)*w(ix^d,m2_)-btot(2)*w(ix^d,m1_)
1014 s(1)=efd(2)*btot(3)-efd(3)*btot(2)
1015 s(2)=efd(3)*btot(1)-efd(1)*btot(3)
1016 s(3)=efd(1)*btot(2)-efd(2)*btot(1)
1021 efd(2)=btot(1)*w(ix^d,m2_)-btot(2)*w(ix^d,m1_)
1022 s(1)=-efd(2)*btot(2)
1029 if (mhd_internal_e)
then
1030 w(ix^d,e_) = eint_val(ix^d)
1033 w(ix^d,e_) = eint_val(ix^d) &
1034 + half*(w(ix^d,rho_)*(^c&w(ix^d,m^c_)**2+) &
1035 + (^c&w(ix^d,b^c_)**2+) &
1036 + (^c&efd(^c)**2+)*eos%inv_squared_c)
1039 ^c&w(ix^d,m^c_)=w(ix^d,rho_)*w(ix^d,m^c_)+s(^c)*eos%inv_squared_c\
1042 {
do ix^db=ixomin^db,ixomax^db\}
1043 if (mhd_internal_e)
then
1044 w(ix^d,e_) = eint_val(ix^d)
1047 w(ix^d,e_) = eint_val(ix^d) &
1048 + half*(w(ix^d,rho_)*(^c&w(ix^d,m^c_)**2+) &
1049 + (^c&w(ix^d,b^c_)**2+))
1052 ^c&w(ix^d,m^c_)=w(ix^d,rho_)*w(ix^d,m^c_)\
1056 end subroutine mhd_from_prolong_lte
1062 subroutine mhd_get_csound2_fi(w, x, ixI^L, ixO^L, cs2)
1064 integer,
intent(in) :: ixi^
l, ixo^
l
1065 double precision,
intent(in) :: w(ixi^s, nw)
1066 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1067 double precision,
intent(out) :: cs2(ixi^s)
1069 double precision :: rho, ploc
1072 {
do ix^db=ixomin^db,ixomax^db \}
1073 if(has_equi_rho_and_p)
then
1074 rho=(w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,0))
1075 ploc=(w(ix^
d,p_)+
block%equi_vars(ix^
d,equi_pe0_,0))
1077 cs2(ix^
d)=eos%gamma*ploc/rho
1080 cs2(ix^
d)=eos%gamma*w(ix^
d,p_)/w(ix^
d,rho_)
1084 end subroutine mhd_get_csound2_fi
1088 subroutine mhd_get_csound2_lte(w, x, ixI^L, ixO^L, cs2)
1090 integer,
intent(in) :: ixi^
l, ixo^
l
1091 double precision,
intent(in) :: w(ixi^s, nw)
1092 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1093 double precision,
intent(out) :: cs2(ixi^s)
1097 if (eos%gamma1_method ==
'constant')
then
1098 cs2(ixo^s) = eos%gamma * w(ixo^s, p_) / w(ixo^s, rho_)
1100 {
do ix^db=ixomin^db,ixomax^db\}
1101 cs2(ix^
d) = lte_gamma1_from_p(w(ix^
d,p_), w(ix^
d,rho_)) * (w(ix^
d,p_) / w(ix^
d,rho_))
1105 end subroutine mhd_get_csound2_lte
1107 subroutine mhd_get_gamma1_lte(w, x, ixI^L, ixO^L, gamma1)
1109 integer,
intent(in) :: ixi^
l, ixo^
l
1110 double precision,
intent(in) :: w(ixi^s, nw)
1111 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1112 double precision,
intent(out) :: gamma1(ixi^s)
1116 if (eos%gamma1_method ==
'constant')
then
1117 gamma1(ixo^s) = eos%gamma
1121 {
do ix^db=ixomin^db,ixomax^db\}
1122 gamma1(ix^
d) = lte_gamma1_from_p(w(ix^
d,p_), w(ix^
d,rho_))
1125 end subroutine mhd_get_gamma1_lte
1132 subroutine rfactor_from_constant_ionization(w,x,ixI^L,ixO^L,Rfactor)
1134 integer,
intent(in) :: ixi^
l, ixo^
l
1135 double precision,
intent(in) :: w(ixi^s,1:nw)
1136 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1137 double precision,
intent(out):: rfactor(ixi^s)
1141 end subroutine rfactor_from_constant_ionization
1148 subroutine mhd_get_pthermal_noe(w,x,ixI^L,ixO^L,pth)
1152 integer,
intent(in) :: ixi^
l, ixo^
l
1153 double precision,
intent(in) :: w(ixi^s,nw)
1154 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1155 double precision,
intent(out):: pth(ixi^s)
1157 double precision :: adiabs(ixi^s), gammas(ixi^s)
1170 if(has_equi_rho_and_p)
then
1171 pth(ixo^s)=adiabs(ixo^s)*(w(ixo^s,rho_)+
block%equi_vars(ixo^s,equi_rho0_,0))**gammas(ixo^s)
1173 pth(ixo^s)=adiabs(ixo^s)*w(ixo^s,rho_)**gammas(ixo^s)
1176 end subroutine mhd_get_pthermal_noe
1179 subroutine mhd_get_pthermal_inte(w,x,ixI^L,ixO^L,pth)
1183 integer,
intent(in) :: ixi^
l, ixo^
l
1184 double precision,
intent(in) :: w(ixi^s,nw)
1185 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1186 double precision,
intent(out):: pth(ixi^s)
1190 {
do ix^db= ixomin^db,ixomax^db\}
1191 if(has_equi_rho_and_p)
then
1192 pth(ix^
d)=eos%gamma_minus_1*w(ix^
d,e_)+
block%equi_vars(ix^
d,equi_pe0_,0)
1194 pth(ix^
d)=eos%gamma_minus_1*w(ix^
d,e_)
1199 if(check_small_values.and..not.fix_small_values)
then
1200 {
do ix^db= ixomin^db,ixomax^db\}
1201 if(pth(ix^d)<small_pressure)
then
1202 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1203 " encountered when call mhd_get_pthermal_inte"
1204 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1205 write(*,*)
"Location: ", x(ix^d,:)
1206 write(*,*)
"Cell number: ", ix^d
1208 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1210 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1211 write(*,*)
"Saving status at the previous time step"
1217 end subroutine mhd_get_pthermal_inte
1220 subroutine mhd_get_pthermal_origin(w,x,ixI^L,ixO^L,pth)
1224 integer,
intent(in) :: ixi^
l, ixo^
l
1225 double precision,
intent(in) :: w(ixi^s,nw)
1226 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1227 double precision,
intent(out):: pth(ixi^s)
1231 {
do ix^db=ixomin^db,ixomax^db\}
1232 if(has_equi_rho_and_p)
then
1233 pth(ix^
d)=eos%gamma_minus_1*(w(ix^
d,e_)-half*((^c&w(ix^
d,m^c_)**2+)/(w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,0))&
1234 +(^c&w(ix^
d,b^c_)**2+)))+
block%equi_vars(ix^
d,equi_pe0_,0)
1236 pth(ix^
d)=eos%gamma_minus_1*(w(ix^
d,e_)-half*((^c&w(ix^
d,m^c_)**2+)/w(ix^
d,rho_)&
1237 +(^c&w(ix^
d,b^c_)**2+))-mhd_uawsom_wave_energy_cell(w(ix^
d,:)))
1242 if(check_small_values.and..not.fix_small_values)
then
1243 {
do ix^db=ixomin^db,ixomax^db\}
1244 if(pth(ix^d)<small_pressure)
then
1245 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1246 " encountered when call mhd_get_pthermal"
1247 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1248 write(*,*)
"Location: ", x(ix^d,:)
1249 write(*,*)
"Cell number: ", ix^d
1251 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1253 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1254 write(*,*)
"Saving status at the previous time step"
1260 end subroutine mhd_get_pthermal_origin
1263 subroutine mhd_get_pthermal_lte(w,x,ixI^L,ixO^L,pth)
1267 integer,
intent(in) :: ixi^
l, ixo^
l
1268 double precision,
intent(in) :: w(ixi^s,nw)
1269 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1270 double precision,
intent(out):: pth(ixi^s)
1271 double precision :: nh(ixi^s)
1276 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
1277 pth(ixo^s) = nh(ixo^s) * (1.0d0 + eos%He_abundance &
1278 + (w(ixo^s,ne_) / nh(ixo^s))) * w(ixo^s,te_)
1281 {
do ix^db=ixomin^db,ixomax^db\}
1284 else if(check_small_values)
then
1285 {
do ix^db=ixomin^db,ixomax^db\}
1286 if(pth(ix^d)<small_pressure)
then
1287 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1288 " encountered when call mhd_get_pthermal_LTE"
1289 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1290 write(*,*)
"Location: ", x(ix^d,:)
1291 write(*,*)
"Cell number: ", ix^d
1293 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1295 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1296 write(*,*)
"Saving status at the previous time step"
1302 end subroutine mhd_get_pthermal_lte
1305 subroutine mhd_get_pthermal_semirelati(w,x,ixI^L,ixO^L,pth)
1309 integer,
intent(in) :: ixi^
l, ixo^
l
1310 double precision,
intent(in) :: w(ixi^s,nw)
1311 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1312 double precision,
intent(out):: pth(ixi^s)
1314 double precision :: vel(ixo^s,1:
ndir), emech(ixo^s)
1317 if(mhd_internal_e)
then
1318 {
do ix^db=ixomin^db,ixomax^db\}
1319 pth(ix^
d)=mhd_semirelati_p(w(ix^
d,e_),w(ix^
d,rho_))
1323 call mhd_semirelati_vel_emech(w,ixi^l,ixo^l,vel,emech)
1324 {
do ix^db=ixomin^db,ixomax^db\}
1325 pth(ix^d)=mhd_semirelati_p(w(ix^d,e_)-emech(ix^d),w(ix^d,rho_))
1326 if(fix_small_values.and.pth(ix^d)<small_pressure) pth(ix^d)=small_pressure
1330 if(check_small_values.and..not.fix_small_values)
then
1331 {
do ix^db=ixomin^db,ixomax^db\}
1332 if(pth(ix^d)<small_pressure)
then
1333 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1334 " encountered when call mhd_get_pthermal_semirelati"
1335 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1336 write(*,*)
"Location: ", x(ix^d,:)
1337 write(*,*)
"Cell number: ", ix^d
1339 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1341 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1342 write(*,*)
"Saving status at the previous time step"
1348 end subroutine mhd_get_pthermal_semirelati
1351 subroutine mhd_get_pthermal_hde(w,x,ixI^L,ixO^L,pth)
1355 integer,
intent(in) :: ixi^
l, ixo^
l
1356 double precision,
intent(in) :: w(ixi^s,nw)
1357 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1358 double precision,
intent(out):: pth(ixi^s)
1362 {
do ix^db= ixomin^db,ixomax^db\}
1363 pth(ix^
d)=eos%gamma_minus_1*(w(ix^
d,e_)-half*((^c&w(ix^
d,m^c_)**2+)/w(ix^
d,rho_)))
1366 if(check_small_values.and..not.fix_small_values)
then
1367 {
do ix^db= ixomin^db,ixomax^db\}
1368 if(pth(ix^d)<small_pressure)
then
1369 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1370 " encountered when call mhd_get_pthermal_hde"
1371 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1372 write(*,*)
"Location: ", x(ix^d,:)
1373 write(*,*)
"Cell number: ", ix^d
1375 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1377 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1378 write(*,*)
"Saving status at the previous time step"
1384 end subroutine mhd_get_pthermal_hde
1389 subroutine mhd_get_temperature_from_te(w, x, ixI^L, ixO^L, res)
1391 integer,
intent(in) :: ixi^
l, ixo^
l
1392 double precision,
intent(in) :: w(ixi^s, 1:nw)
1393 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1394 double precision,
intent(out):: res(ixi^s)
1395 res(ixo^s) = w(ixo^s, te_)
1396 end subroutine mhd_get_temperature_from_te
1399 subroutine mhd_get_temperature_from_eint(w, x, ixI^L, ixO^L, res)
1401 integer,
intent(in) :: ixi^
l, ixo^
l
1402 double precision,
intent(in) :: w(ixi^s, 1:nw)
1403 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1404 double precision,
intent(out):: res(ixi^s)
1406 double precision :: r(ixi^s)
1408 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1409 res(ixo^s) = eos%gamma_minus_1 * w(ixo^s, e_)/(w(ixo^s,rho_)*r(ixo^s))
1410 end subroutine mhd_get_temperature_from_eint
1413 subroutine mhd_get_temperature_from_etot(w, x, ixI^L, ixO^L, res)
1415 integer,
intent(in) :: ixi^
l, ixo^
l
1416 double precision,
intent(in) :: w(ixi^s, 1:nw)
1417 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1418 double precision,
intent(out):: res(ixi^s)
1420 double precision :: r(ixi^s)
1422 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1424 res(ixo^s)=res(ixo^s)/(r(ixo^s)*w(ixo^s,rho_))
1426 end subroutine mhd_get_temperature_from_etot
1428 subroutine mhd_get_temperature_from_etot_with_equi(w, x, ixI^L, ixO^L, res)
1430 integer,
intent(in) :: ixi^
l, ixo^
l
1431 double precision,
intent(in) :: w(ixi^s, 1:nw)
1432 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1433 double precision,
intent(out):: res(ixi^s)
1435 double precision :: r(ixi^s)
1437 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1439 res(ixo^s)=res(ixo^s)/(r(ixo^s)*(w(ixo^s,rho_)+
block%equi_vars(ixo^s,equi_rho0_,
b0i)))
1441 end subroutine mhd_get_temperature_from_etot_with_equi
1443 subroutine mhd_get_temperature_from_eint_with_equi(w, x, ixI^L, ixO^L, res)
1445 integer,
intent(in) :: ixi^
l, ixo^
l
1446 double precision,
intent(in) :: w(ixi^s, 1:nw)
1447 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1448 double precision,
intent(out):: res(ixi^s)
1450 double precision :: r(ixi^s)
1452 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1453 res(ixo^s) = (eos%gamma_minus_1 * w(ixo^s, e_) +
block%equi_vars(ixo^s,equi_pe0_,
b0i)) /&
1454 ((w(ixo^s,rho_) +
block%equi_vars(ixo^s,equi_rho0_,
b0i))*r(ixo^s))
1456 end subroutine mhd_get_temperature_from_eint_with_equi
1462 subroutine mhd_get_temperature_from_etot_lte(w, x, ixI^L, ixO^L, res)
1464 integer,
intent(in) :: ixi^
l, ixo^
l
1465 double precision,
intent(in) :: w(ixi^s, 1:nw)
1466 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1467 double precision,
intent(out):: res(ixi^s)
1469 double precision :: wlocal(ixi^s, 1:nw)
1471 wlocal(ixi^s, 1:nw) = w(ixi^s, 1:nw)
1473 call phys_e_to_ei(ixi^
l, ixo^
l, wlocal, x)
1475 call eos%get_temperature_from_eint(wlocal, x, ixi^
l, ixo^
l, res)
1477 end subroutine mhd_get_temperature_from_etot_lte
1479 subroutine mhd_get_temperature_equi(w,x, ixI^L, ixO^L, res)
1481 integer,
intent(in) :: ixi^
l, ixo^
l
1482 double precision,
intent(in) :: w(ixi^s, 1:nw)
1483 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1484 double precision,
intent(out):: res(ixi^s)
1486 double precision :: r(ixi^s)
1488 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1489 res(ixo^s)=
block%equi_vars(ixo^s,equi_pe0_,
b0i)/(
block%equi_vars(ixo^s,equi_rho0_,
b0i)*r(ixo^s))
1491 end subroutine mhd_get_temperature_equi
1495 subroutine mhd_get_rho_equi(w, x, ixI^L, ixO^L, res)
1497 integer,
intent(in) :: ixi^
l, ixo^
l
1498 double precision,
intent(in) :: w(ixi^s, 1:nw)
1499 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1500 double precision,
intent(out):: res(ixi^s)
1501 res(ixo^s) =
block%equi_vars(ixo^s,equi_rho0_,
b0i)
1502 end subroutine mhd_get_rho_equi
1504 subroutine mhd_get_pe_equi(w,x, ixI^L, ixO^L, res)
1506 integer,
intent(in) :: ixi^
l, ixo^
l
1507 double precision,
intent(in) :: w(ixi^s, 1:nw)
1508 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1509 double precision,
intent(out):: res(ixi^s)
1510 res(ixo^s) =
block%equi_vars(ixo^s,equi_pe0_,
b0i)
1511 end subroutine mhd_get_pe_equi
1516 subroutine mhd_get_ne_nh_equi(ixI^L, ixO^L, w, x, ne, nH)
1518 integer,
intent(in) :: ixi^
l, ixo^
l
1519 double precision,
intent(in) :: w(ixi^s, nw)
1520 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1521 double precision,
intent(out):: ne(ixi^s), nh(ixi^s)
1522 nh(ixo^s) =
block%equi_vars(ixo^s,equi_rho0_,
b0i) / eos%nH2rhoFactor
1523 ne(ixo^s) = nh(ixo^s) * eos%neOnH_FI
1524 end subroutine mhd_get_ne_nh_equi
1529 function mhd_get_ei_origin(w, ixI^L, ixO^L)
result(ei)
1531 integer,
intent(in) :: ixi^
l, ixo^
l
1532 double precision,
intent(in) :: w(ixi^s, nw)
1533 double precision :: ei(ixo^s)
1536 ei(ixo^s) = w(ixo^s,e_) - half*((^c&w(ixo^s,m^c_)**2+)/w(ixo^s,rho_) &
1537 + (^c&w(ixo^s,b^c_)**2+))
1538 end function mhd_get_ei_origin
1541 function mhd_get_ei_semirelati(w, ixI^L, ixO^L)
result(ei)
1543 integer,
intent(in) :: ixi^
l, ixo^
l
1544 double precision,
intent(in) :: w(ixi^s, nw)
1545 double precision :: ei(ixo^s)
1547 double precision :: vel(ixo^s,1:
ndir), emech(ixo^s)
1549 call mhd_semirelati_vel_emech(w,ixi^
l,ixo^
l,vel,emech)
1550 ei(ixo^s)=w(ixo^s,e_)-emech(ixo^s)
1551 end function mhd_get_ei_semirelati
1554 function mhd_get_ei_inte(w, ixI^L, ixO^L)
result(ei)
1556 integer,
intent(in) :: ixi^
l, ixo^
l
1557 double precision,
intent(in) :: w(ixi^s, nw)
1558 double precision :: ei(ixo^s)
1561 ei(ixo^s) = w(ixo^s,e_)
1562 end function mhd_get_ei_inte
1577 subroutine mhd_p_to_e_pi(ixI^L,ixO^L,w,x)
1579 integer,
intent(in) :: ixi^
l, ixo^
l
1580 double precision,
intent(inout) :: w(ixi^s, nw)
1581 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1583 double precision :: eint
1586 {
do ix^db=ixomin^db,ixomax^db\}
1587 call eint_from_rho_p_pi(w(ix^
d,rho_), w(ix^
d,p_), eint)
1589 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
1590 +(^c&w(ix^
d,b^c_)**2+))
1593 end subroutine mhd_p_to_e_pi
1596 subroutine mhd_p_to_eint_pi(ixI^L,ixO^L,w,x)
1598 integer,
intent(in) :: ixi^
l, ixo^
l
1599 double precision,
intent(inout) :: w(ixi^s, nw)
1600 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1602 double precision :: eint
1605 {
do ix^db=ixomin^db,ixomax^db\}
1606 call eint_from_rho_p_pi(w(ix^
d,rho_), w(ix^
d,p_), eint)
1610 end subroutine mhd_p_to_eint_pi
1613 subroutine mhd_to_conserved_origin_pi(ixI^L,ixO^L,w,x)
1615 integer,
intent(in) :: ixi^
l, ixo^
l
1616 double precision,
intent(inout) :: w(ixi^s, nw)
1617 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1619 call mhd_p_to_e_pi(ixi^
l, ixo^
l, w, x)
1620 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
1622 end subroutine mhd_to_conserved_origin_pi
1625 subroutine mhd_to_conserved_inte_pi(ixI^L,ixO^L,w,x)
1627 integer,
intent(in) :: ixi^
l, ixo^
l
1628 double precision,
intent(inout) :: w(ixi^s, nw)
1629 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1631 call mhd_p_to_eint_pi(ixi^
l, ixo^
l, w, x)
1632 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
1634 end subroutine mhd_to_conserved_inte_pi
1637 subroutine mhd_to_primitive_origin_pi(ixI^L,ixO^L,w,x)
1639 integer,
intent(in) :: ixi^
l, ixo^
l
1640 double precision,
intent(inout) :: w(ixi^s, nw)
1641 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1643 double precision :: inv_rho, eint_val, t, rfac
1647 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
1648 'mhd_to_primitive_origin_PI')
1651 {
do ix^db=ixomin^db,ixomax^db\}
1652 inv_rho = 1.d0/w(ix^
d,rho_)
1654 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
1656 eint_val = w(ix^
d,e_) &
1657 - half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+) &
1658 + (^c&w(ix^
d,b^c_)**2+))
1659 eint_val = max(eint_val, smalldouble)
1660 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, w(ix^
d,p_), rfac)
1663 end subroutine mhd_to_primitive_origin_pi
1666 subroutine mhd_to_primitive_inte_pi(ixI^L,ixO^L,w,x)
1668 integer,
intent(in) :: ixi^
l, ixo^
l
1669 double precision,
intent(inout) :: w(ixi^s, nw)
1670 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1672 double precision :: inv_rho, eint_val, t, rfac
1676 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
1677 'mhd_to_primitive_inte_PI')
1680 {
do ix^db=ixomin^db,ixomax^db\}
1681 eint_val = max(w(ix^
d,e_), smalldouble)
1682 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, w(ix^
d,p_), rfac)
1684 inv_rho = 1.d0/w(ix^
d,rho_)
1685 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
1688 end subroutine mhd_to_primitive_inte_pi
1691 subroutine mhd_get_pthermal_origin_pi(w,x,ixI^L,ixO^L,pth)
1693 integer,
intent(in) :: ixi^
l, ixo^
l
1694 double precision,
intent(in) :: w(ixi^s,nw)
1695 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1696 double precision,
intent(out):: pth(ixi^s)
1698 double precision :: eint_val, t, rfac
1701 {
do ix^db=ixomin^db,ixomax^db\}
1702 eint_val = w(ix^
d,e_) &
1703 - half*((^c&w(ix^
d,m^c_)**2+)/w(ix^
d,rho_) &
1704 + (^c&w(ix^
d,b^c_)**2+))
1705 eint_val = max(eint_val, smalldouble)
1706 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, pth(ix^
d), rfac)
1710 end subroutine mhd_get_pthermal_origin_pi
1713 subroutine mhd_get_pthermal_inte_pi(w,x,ixI^L,ixO^L,pth)
1715 integer,
intent(in) :: ixi^
l, ixo^
l
1716 double precision,
intent(in) :: w(ixi^s,nw)
1717 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1718 double precision,
intent(out):: pth(ixi^s)
1720 double precision :: eint_val, t, rfac
1723 {
do ix^db=ixomin^db,ixomax^db\}
1724 eint_val = max(w(ix^
d,e_), smalldouble)
1725 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, pth(ix^
d), rfac)
1729 end subroutine mhd_get_pthermal_inte_pi
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
EoS state container – the single thermodynamic authority for AMRVAC.
integer, parameter, public eos_analytic
type(eos_container), allocatable, public eos
The single EoS state object, allocated in eos_init and shared (read-mostly) across all EoS sub-module...
Analytic hydrogen Saha EoS with neutral helium (eos_method == 'analytic').
LTE (Saha-table) EoS kernels and finalise for the eos% family.
double precision function, public p2eint_from_nh_p(nh, ponh)
Ratio eint/p from (log10 nH, log10 p/nH).
double precision function, public eint_nh_from_t(log_nh, log_t)
eint/nH from (log10 nH, log10 T), from the inverse table when one is built and the Saha solve otherwi...
double precision function, public y_from_nh_eint(nh, eint_nh)
Scalar EoS kernels: one cell on (log10 nH, log10 eint/nH) or (log10 nH, log10 p/nH),...
subroutine, public eos_get_eintt_grid(n_nh, lg_nh_min, lg_nh_max)
####################################################################### Table-metadata helpers: expos...
double precision function, public t_from_nh_eint(nh, eint_nh)
Temperature from (log10 nH, log10 eint/nH).
PI (partial-ionisation, eos_type='PI') arm of the eos% family.
double precision function, dimension(log_nh, log_p_nh), public p2eint_pi(log_nh, log_p_nh)
eint/p factor from pressure per H: maps p -> eint = p * (this).
double precision function, dimension(log_nh, log_t), public eint_from_t_pi(log_nh, log_t)
Internal energy per H from temperature: eint/nH(T).
double precision function, dimension(log_nh, log_eint_nh), public y_from_eint_pi(log_nh, log_eint_nh)
Electron-to-hydrogen ratio ne/nH from internal energy per H. ne/nH = iz_H + A_He*iz_He*(1+iz_He) (mat...
subroutine, public get_gamma1_pi(w, x, ixil, ixol, gamma1)
Effective Gamma1 = cs2 * rho / p for the same primitive state.
double precision function, dimension(log_nh, log_eint_nh), public t_from_eint_pi(log_nh, log_eint_nh)
Temperature from internal energy per H.
Equation of state for AMRVAC, handled through a single eos_container object.
subroutine, public eos_bind_tc(fl, sat_r_variable)
The EoS hooks of the conduction fluid fl. sat_R_variable is false when R is the constant 1,...
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
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer b0i
background magnetic field location indicator
integer ndir
Number of spatial dimensions (components) for vector variables.
double precision, dimension(:), allocatable, parameter d
logical b0field
split magnetic field as background B0 field
double precision unit_temperature
Physical scaling factor for temperature.
logical fix_small_values
fix small values with average or replace methods
MHD <-> EoS seam: binds the eos% authority into magnetohydrodynamics.
subroutine, public mhd_link_eos()
Link the appropriate EOS conversion routines based on the selected EoS type.
procedure(sub_get_pthermal), pointer, public mhd_get_temperature
Temperature pointer: set by mhd_link_eos based on EoS type and energy formulation.
procedure(sub_get_pthermal), pointer, public mhd_get_pthermal
Thermal pressure pointer: set by mhd_link_eos based on energy formulation. Internal to mod_mhd_eos — ...
procedure(sub_convert), pointer, public mhd_to_conserved
use habitual name of converting to conserved
procedure(sub_convert), pointer, public mhd_to_primitive
use habitual name of converting to primitive
Magneto-hydrodynamics module.
integer, public, protected c_
logical, public, protected mhd_internal_e
Whether internal energy is solved instead of total energy.
integer, public, protected wkminus_
type(tc_fluid), allocatable, public tc_fl
type of fluid for thermal conduction
logical, public, protected mhd_semirelativistic
Whether semirelativistic MHD equations (Gombosi 2002 JCP) are solved.
integer, public, protected m
type(te_fluid), allocatable, public te_fl_mhd
type of fluid for thermal emission synthesis
logical, public has_equi_rho_and_p
whether split off equilibrium density and pressure
integer, public, protected waminus_
logical, public, protected mhd_energy
Whether an energy equation is used.
type(fld_fluid), allocatable, public fld_fl
Radiation fluid object (gas-EoS callbacks for FLD), wired in mhd_link_eos.
integer, public, protected waplus_
Conserved wave-energy indices. The plus variables propagate against B.
subroutine, public mhd_uawsom_rho2_factor(ixil, ixol, w, x, factor)
integer, public, protected p_
Index of the gas pressure (-1 if not present) should equal e_.
integer, public, protected c
Indices of the momentum density for the form of better vectorization.
integer, public, protected b
logical, public, protected mhd_hydrodynamic_e
Whether hydrodynamic energy is solved instead of total energy.
type(rc_fluid), allocatable, public rc_fl
type of fluid for radiative cooling
integer, public, protected wkplus_
integer, public, protected rho_
Index of the density (in the w array).
integer, public, protected e_
Index of the energy density (-1 if not present).
logical, public, protected mhd_uawsom
Enable the Uniturbulence and Alfven Wave Solar Model extension.
logical, public mhd_equi_thermal
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_check_params), pointer phys_bind_eos_to_source
procedure(sub_convert), pointer phys_to_primitive
procedure(sub_get_pthermal), pointer phys_get_gamma1
procedure(sub_get_pthermal), pointer phys_get_pthermal
procedure(sub_get_ei), pointer phys_get_ei
procedure(sub_convert), pointer phys_to_prolong
procedure(sub_convert), pointer phys_to_conserved
procedure(sub_convert), pointer phys_from_prolong
module radiative cooling – add optically thin radiative cooling
double precision, parameter rc_t_ymod_max_k
Temperature in K above which c_V is constant, the upper end of the Y_mod path.
subroutine build_y_mod_table(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
Module with all the methods that users can customize in AMRVAC.
procedure(rfactor), pointer usr_rfactor
procedure(set_adiab), pointer usr_set_adiab
procedure(set_adiab), pointer usr_set_gamma