61 if (
eos%eos_type ==
'FI' .or.
eos%eos_type ==
'PI')
then
65 call mpistop(
'PI EoS not supported with equilibrium splitting')
67 if(
eos%ionE)
call mpistop(
'PI energy EoS not supported with mhd_hydrodynamic_e')
68 eos%to_primitive => mhd_to_primitive_hde
69 eos%to_conserved => mhd_to_conserved_hde
75 eos%to_primitive => mhd_to_primitive_semirelati_pi
76 eos%to_conserved => mhd_to_conserved_semirelati_pi
78 eos%p_to_e => mhd_p_to_eint_pi
82 eos%p_to_e => mhd_p_to_e_pi
87 eos%to_primitive => mhd_to_primitive_semirelati
88 eos%to_conserved => mhd_to_conserved_semirelati
98 eos%to_primitive => mhd_to_primitive_semirelati_noe
99 eos%to_conserved => mhd_to_conserved_semirelati_noe
105 eos%to_primitive => mhd_to_primitive_split_rho
106 eos%to_conserved => mhd_to_conserved_split_rho
109 eos%to_conserved => mhd_to_conserved_inte_pi
110 eos%to_primitive => mhd_to_primitive_inte_pi
111 eos%p_to_e => mhd_p_to_eint_pi
115 eos%to_primitive => mhd_to_primitive_inte
116 eos%to_conserved => mhd_to_conserved_inte
122 eos%to_conserved => mhd_to_conserved_origin_pi
123 eos%to_primitive => mhd_to_primitive_origin_pi
124 eos%p_to_e => mhd_p_to_e_pi
128 eos%to_primitive => mhd_to_primitive_origin
129 eos%to_conserved => mhd_to_conserved_origin
134 eos%to_primitive => mhd_to_primitive_origin_noe
135 eos%to_conserved => mhd_to_conserved_origin_noe
140 else if (
eos%eos_type ==
'LTE')
then
143 call mpistop(
'LTE EoS not supported with mhd_hydrodynamic_e')
145 call mpistop(
'LTE EoS not supported with mhd_semirelativistic')
147 call mpistop(
'LTE EoS not supported with equilibrium splitting')
149 call mpistop(
'LTE EoS requires mhd_energy=.true.')
152 eos%to_primitive => mhd_to_primitive_inte_lte
153 eos%to_conserved => mhd_to_conserved_inte_lte
155 eos%to_primitive => mhd_to_primitive_origin_lte
156 eos%to_conserved => mhd_to_conserved_origin_lte
159 call mpistop(
'Error: Unknown MHD EOS type: ' // trim(
eos%eos_type))
168 eos%p_to_e => mhd_p_to_eint
170 eos%p_to_e => mhd_p_to_e
174 if (
eos%eos_type ==
'LTE' .and.
eos%ionE)
then
175 eos%get_csound2 => mhd_get_csound2_lte
177 else if (
eos%eos_type ==
'PI' .and.
eos%ionE)
then
178 eos%get_csound2 => mhd_get_csound2_fi
181 eos%get_csound2 => mhd_get_csound2_fi
186 if (
eos%eos_type ==
'LTE' .and.
eos%ionE)
then
198 eos%get_Rfactor => rfactor_from_constant_ionization
202 if (
eos%eos_type ==
'LTE')
then
210 if(
eos%eos_type ==
'PI' .or.
eos%eos_type ==
'LTE')
then
250 subroutine bind_eos_to_source()
261 if (
eos%eos_type ==
'LTE')
then
264 eos%get_temperature_from_etot =>
eos%get_temperature_from_eint
267 eos%get_temperature_from_etot => mhd_get_temperature_from_etot_lte
273 eos%get_temperature_from_etot => mhd_get_temperature_from_eint_with_equi
274 eos%get_temperature_from_eint => mhd_get_temperature_from_eint_with_equi
276 eos%get_temperature_from_etot => mhd_get_temperature_from_eint
277 eos%get_temperature_from_eint => mhd_get_temperature_from_eint
282 eos%get_temperature_from_etot => mhd_get_temperature_from_etot_with_equi
283 eos%get_temperature_from_eint => mhd_get_temperature_from_eint_with_equi
285 eos%get_temperature_from_etot => mhd_get_temperature_from_etot
286 eos%get_temperature_from_eint => mhd_get_temperature_from_eint
291 if (
allocated(
tc_fl))
then
292 tc_fl%get_temperature_from_conserved =>
eos%get_temperature_from_etot
293 if (
eos%eos_type ==
'LTE' .and.
eos%ionE)
then
296 tc_fl%get_temperature_from_eint =>
eos%get_temperature_from_eint
300 tc_fl%get_var_Rfactor =>
eos%get_Rfactor
301 tc_fl%inv_gamma_minus_1 =
eos%inv_gamma_minus_1
302 tc_fl%nH2rhoFactor =
eos%nH2rhoFactor
303 tc_fl%log_T_floor = eos_get_log_t_floor()
307 tc_fl%subtract_equi = .true.
308 tc_fl%get_temperature_equi => mhd_get_temperature_equi
309 tc_fl%get_rho_equi => mhd_get_rho_equi
311 tc_fl%subtract_equi = .false.
315 if (
allocated(
rc_fl))
then
317 rc_fl%get_pthermal =>
eos%get_thermal_pressure
318 rc_fl%get_var_Rfactor =>
eos%get_Rfactor
321 nullify(
rc_fl%get_rho2_factor)
325 rc_fl%inv_gamma_minus_1 =
eos%inv_gamma_minus_1
326 rc_fl%nH2rhoFactor =
eos%nH2rhoFactor
334 rc_fl%subtract_equi = .true.
335 rc_fl%get_rho_equi => mhd_get_rho_equi
336 rc_fl%get_pthermal_equi => mhd_get_pe_equi
337 rc_fl%get_ne_nH_equi => mhd_get_ne_nh_equi
338 rc_fl%get_temperature_equi => mhd_get_temperature_equi
340 rc_fl%subtract_equi = .false.
349 if (
eos%ionE .and.
eos%eos_type ==
'LTE')
then
360 if (
eos%eos_type ==
'PI' .and.
eos%ionE)
then
362 if (
allocated(
rc_fl))
then
377 if (
allocated(
fld_fl))
then
381 fld_fl%get_tgas =>
eos%get_temperature_from_pressure
385 end subroutine bind_eos_to_source
390 subroutine mhd_to_conserved_origin(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 w(ix^
d,
e_)=w(ix^
d,
p_)*
eos%inv_gamma_minus_1&
402 +(^
c&w(ix^
d,
b^
c_)**2+))
409 end subroutine mhd_to_conserved_origin
412 subroutine mhd_to_conserved_origin_noe(ixI^L,ixO^L,w,x)
414 integer,
intent(in) :: ixi^
l, ixo^
l
415 double precision,
intent(inout) :: w(ixi^s, nw)
416 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
420 {
do ix^db=ixomin^db,ixomax^db\}
422 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)\
425 end subroutine mhd_to_conserved_origin_noe
428 subroutine mhd_to_conserved_hde(ixI^L,ixO^L,w,x)
430 integer,
intent(in) :: ixi^
l, ixo^
l
431 double precision,
intent(inout) :: w(ixi^s, nw)
432 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
436 {
do ix^db=ixomin^db,ixomax^db\}
438 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1&
439 +half*(^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)
441 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)\
444 end subroutine mhd_to_conserved_hde
447 subroutine mhd_to_conserved_inte(ixI^L,ixO^L,w,x)
449 integer,
intent(in) :: ixi^
l, ixo^
l
450 double precision,
intent(inout) :: w(ixi^s, nw)
451 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
455 {
do ix^db=ixomin^db,ixomax^db\}
457 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1
459 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)\
462 end subroutine mhd_to_conserved_inte
465 subroutine mhd_to_conserved_split_rho(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 :: rho
474 {
do ix^db=ixomin^db,ixomax^db\}
475 rho=w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,
b0i)
477 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1&
478 +half*((^c&w(ix^
d,m^c_)**2+)*rho&
479 +(^c&w(ix^
d,b^c_)**2+))
481 ^c&w(ix^
d,m^c_)=rho*w(ix^
d,m^c_)\
484 end subroutine mhd_to_conserved_split_rho
487 subroutine mhd_to_conserved_semirelati(ixI^L,ixO^L,w,x)
489 integer,
intent(in) :: ixi^
l, ixo^
l
490 double precision,
intent(inout) :: w(ixi^s, nw)
491 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
493 double precision :: e(ixo^s,1:
ndir), s(ixo^s,1:
ndir)
496 {
do ix^db=ixomin^db,ixomax^db\}
498 e(ix^
d,1)=w(ix^
d,b2_)*w(ix^
d,m3_)-w(ix^
d,b3_)*w(ix^
d,m2_)
499 e(ix^
d,2)=w(ix^
d,b3_)*w(ix^
d,m1_)-w(ix^
d,b1_)*w(ix^
d,m3_)
500 e(ix^
d,3)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
501 s(ix^
d,1)=e(ix^
d,2)*w(ix^
d,b3_)-e(ix^
d,3)*w(ix^
d,b2_)
502 s(ix^
d,2)=e(ix^
d,3)*w(ix^
d,b1_)-e(ix^
d,1)*w(ix^
d,b3_)
503 s(ix^
d,3)=e(ix^
d,1)*w(ix^
d,b2_)-e(ix^
d,2)*w(ix^
d,b1_)
508 e(ix^
d,2)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
509 s(ix^
d,1)=-e(ix^
d,2)*w(ix^
d,b2_)
510 s(ix^
d,2)=e(ix^
d,2)*w(ix^
d,b1_)
516 if(mhd_internal_e)
then
518 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1
522 w(ix^
d,e_)=w(ix^
d,p_)*eos%inv_gamma_minus_1&
523 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
524 +(^c&w(ix^
d,b^c_)**2+)&
525 +(^c&e(ix^
d,^c)**2+)*eos%inv_squared_c)
529 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)+s(ix^
d,^c)*eos%inv_squared_c\
533 end subroutine mhd_to_conserved_semirelati
536 subroutine mhd_to_conserved_semirelati_pi(ixI^L,ixO^L,w,x)
538 integer,
intent(in) :: ixi^
l, ixo^
l
539 double precision,
intent(inout) :: w(ixi^s, nw)
540 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
542 double precision :: e(ixo^s,1:
ndir), s(ixo^s,1:
ndir), eint
545 {
do ix^db=ixomin^db,ixomax^db\}
547 e(ix^
d,1)=w(ix^
d,b2_)*w(ix^
d,m3_)-w(ix^
d,b3_)*w(ix^
d,m2_)
548 e(ix^
d,2)=w(ix^
d,b3_)*w(ix^
d,m1_)-w(ix^
d,b1_)*w(ix^
d,m3_)
549 e(ix^
d,3)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
550 s(ix^
d,1)=e(ix^
d,2)*w(ix^
d,b3_)-e(ix^
d,3)*w(ix^
d,b2_)
551 s(ix^
d,2)=e(ix^
d,3)*w(ix^
d,b1_)-e(ix^
d,1)*w(ix^
d,b3_)
552 s(ix^
d,3)=e(ix^
d,1)*w(ix^
d,b2_)-e(ix^
d,2)*w(ix^
d,b1_)
557 e(ix^
d,2)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
558 s(ix^
d,1)=-e(ix^
d,2)*w(ix^
d,b2_)
559 s(ix^
d,2)=e(ix^
d,2)*w(ix^
d,b1_)
565 if(mhd_internal_e)
then
567 call eint_from_rho_p_pi(w(ix^
d,rho_), w(ix^
d,p_), w(ix^
d,e_))
571 call eint_from_rho_p_pi(w(ix^
d,rho_), w(ix^
d,p_), eint)
573 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
574 +(^c&w(ix^
d,b^c_)**2+)&
575 +(^c&e(ix^
d,^c)**2+)*eos%inv_squared_c)
579 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)+s(ix^
d,^c)*eos%inv_squared_c\
583 end subroutine mhd_to_conserved_semirelati_pi
585 subroutine mhd_to_conserved_semirelati_noe(ixI^L,ixO^L,w,x)
587 integer,
intent(in) :: ixi^
l, ixo^
l
588 double precision,
intent(inout) :: w(ixi^s, nw)
589 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
591 double precision :: e(ixo^s,1:
ndir), s(ixo^s,1:
ndir)
594 {
do ix^db=ixomin^db,ixomax^db\}
596 e(ix^
d,1)=w(ix^
d,b2_)*w(ix^
d,m3_)-w(ix^
d,b3_)*w(ix^
d,m2_)
597 e(ix^
d,2)=w(ix^
d,b3_)*w(ix^
d,m1_)-w(ix^
d,b1_)*w(ix^
d,m3_)
598 e(ix^
d,3)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
599 s(ix^
d,1)=e(ix^
d,2)*w(ix^
d,b3_)-e(ix^
d,3)*w(ix^
d,b2_)
600 s(ix^
d,2)=e(ix^
d,3)*w(ix^
d,b1_)-e(ix^
d,1)*w(ix^
d,b3_)
601 s(ix^
d,3)=e(ix^
d,1)*w(ix^
d,b2_)-e(ix^
d,2)*w(ix^
d,b1_)
606 e(ix^
d,2)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
607 s(ix^
d,1)=-e(ix^
d,2)*w(ix^
d,b2_)
608 s(ix^
d,2)=e(ix^
d,2)*w(ix^
d,b1_)
614 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)+s(ix^
d,^c)*eos%inv_squared_c\
618 end subroutine mhd_to_conserved_semirelati_noe
621 subroutine mhd_to_primitive_origin(ixI^L,ixO^L,w,x)
623 integer,
intent(in) :: ixi^
l, ixo^
l
624 double precision,
intent(inout) :: w(ixi^s, nw)
625 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
627 double precision :: inv_rho
631 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_origin')
634 {
do ix^db=ixomin^db,ixomax^db\}
635 inv_rho = 1.d0/w(ix^
d,rho_)
637 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
639 w(ix^
d,p_)=eos%gamma_minus_1*(w(ix^
d,e_)&
640 -half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+)&
641 +(^c&w(ix^
d,b^c_)**2+))&
642 -mhd_uawsom_wave_energy_cell(w(ix^
d,:)))
645 end subroutine mhd_to_primitive_origin
648 subroutine mhd_to_primitive_origin_noe(ixI^L,ixO^L,w,x)
650 integer,
intent(in) :: ixi^
l, ixo^
l
651 double precision,
intent(inout) :: w(ixi^s, nw)
652 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
654 double precision :: inv_rho
658 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_origin_noe')
661 {
do ix^db=ixomin^db,ixomax^db\}
662 inv_rho = 1.d0/w(ix^
d,rho_)
664 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
667 end subroutine mhd_to_primitive_origin_noe
670 subroutine mhd_to_primitive_hde(ixI^L,ixO^L,w,x)
672 integer,
intent(in) :: ixi^
l, ixo^
l
673 double precision,
intent(inout) :: w(ixi^s, nw)
674 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
676 double precision :: inv_rho
680 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_hde')
683 {
do ix^db=ixomin^db,ixomax^db\}
684 inv_rho = 1.d0/w(ix^
d,rho_)
686 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
688 w(ix^
d,p_)=eos%gamma_minus_1*(w(ix^
d,e_)-half*w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+))
691 end subroutine mhd_to_primitive_hde
694 subroutine mhd_to_primitive_inte(ixI^L,ixO^L,w,x)
696 integer,
intent(in) :: ixi^
l, ixo^
l
697 double precision,
intent(inout) :: w(ixi^s, nw)
698 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
700 double precision :: inv_rho
704 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_inte')
707 {
do ix^db=ixomin^db,ixomax^db\}
709 w(ix^
d,p_)=w(ix^
d,e_)*eos%gamma_minus_1
711 inv_rho = 1.d0/w(ix^
d,rho_)
712 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
715 end subroutine mhd_to_primitive_inte
718 subroutine mhd_to_primitive_split_rho(ixI^L,ixO^L,w,x)
720 integer,
intent(in) :: ixi^
l, ixo^
l
721 double precision,
intent(inout) :: w(ixi^s, nw)
722 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
724 double precision :: inv_rho
728 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_split_rho')
731 {
do ix^db=ixomin^db,ixomax^db\}
732 inv_rho=1.d0/(w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,
b0i))
734 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
736 w(ix^
d,p_)=eos%gamma_minus_1*(w(ix^
d,e_)&
737 -half*((w(ix^
d,rho_)+
block%equi_vars(ix^
d,equi_rho0_,
b0i))*&
738 (^c&w(ix^
d,m^c_)**2+)+(^c&w(ix^
d,b^c_)**2+)))
741 end subroutine mhd_to_primitive_split_rho
744 subroutine mhd_to_primitive_semirelati(ixI^L,ixO^L,w,x)
746 integer,
intent(in) :: ixi^
l, ixo^
l
747 double precision,
intent(inout) :: w(ixi^s, nw)
748 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
750 double precision :: b(ixo^s,1:
ndir), tmp, b2, gamma2, inv_rho
754 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_semirelati')
757 {
do ix^db=ixomin^db,ixomax^db\}
758 b2=(^c&w(ix^
d,b^c_)**2+)
759 if(b2>smalldouble)
then
764 ^c&b(ix^
d,^c)=w(ix^
d,b^c_)*tmp\
765 tmp=(^c&b(ix^
d,^c)*w(ix^
d,m^c_)+)
767 inv_rho=1.d0/w(ix^
d,rho_)
769 b2=b2*inv_rho*eos%inv_squared_c
771 gamma2=1.d0/(1.d0+b2)
773 ^c&w(ix^
d,m^c_)=gamma2*(w(ix^
d,m^c_)+b2*b(ix^
d,^c)*tmp)*inv_rho\
775 if(mhd_internal_e)
then
777 w(ix^
d,p_)=eos%gamma_minus_1*w(ix^
d,e_)
781 b(ix^
d,1)=w(ix^
d,b2_)*w(ix^
d,m3_)-w(ix^
d,b3_)*w(ix^
d,m2_)
782 b(ix^
d,2)=w(ix^
d,b3_)*w(ix^
d,m1_)-w(ix^
d,b1_)*w(ix^
d,m3_)
783 b(ix^
d,3)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
787 b(ix^
d,2)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
793 w(ix^
d,p_)=eos%gamma_minus_1*(w(ix^
d,e_)&
794 -half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
795 +(^c&w(ix^
d,b^c_)**2+)&
796 +(^c&b(ix^
d,^c)**2+)*eos%inv_squared_c))
800 end subroutine mhd_to_primitive_semirelati
803 subroutine mhd_to_primitive_semirelati_pi(ixI^L,ixO^L,w,x)
805 integer,
intent(in) :: ixi^
l, ixo^
l
806 double precision,
intent(inout) :: w(ixi^s, nw)
807 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
809 double precision :: b(ixo^s,1:
ndir), tmp, b2, gamma2, inv_rho, eint, t, rfac
813 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_semirelati')
816 {
do ix^db=ixomin^db,ixomax^db\}
817 b2=(^c&w(ix^
d,b^c_)**2+)
818 if(b2>smalldouble)
then
823 ^c&b(ix^
d,^c)=w(ix^
d,b^c_)*tmp\
824 tmp=(^c&b(ix^
d,^c)*w(ix^
d,m^c_)+)
826 inv_rho=1.d0/w(ix^
d,rho_)
828 b2=b2*inv_rho*eos%inv_squared_c
830 gamma2=1.d0/(1.d0+b2)
832 ^c&w(ix^
d,m^c_)=gamma2*(w(ix^
d,m^c_)+b2*b(ix^
d,^c)*tmp)*inv_rho\
834 if(mhd_internal_e)
then
836 call state_from_eint_pi(w(ix^
d,rho_), w(ix^
d,e_), t, w(ix^
d,p_), rfac)
840 b(ix^
d,1)=w(ix^
d,b2_)*w(ix^
d,m3_)-w(ix^
d,b3_)*w(ix^
d,m2_)
841 b(ix^
d,2)=w(ix^
d,b3_)*w(ix^
d,m1_)-w(ix^
d,b1_)*w(ix^
d,m3_)
842 b(ix^
d,3)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
846 b(ix^
d,2)=w(ix^
d,b1_)*w(ix^
d,m2_)-w(ix^
d,b2_)*w(ix^
d,m1_)
853 -half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
854 +(^c&w(ix^
d,b^c_)**2+)&
855 +(^c&b(ix^
d,^c)**2+)*eos%inv_squared_c)
856 call state_from_eint_pi(w(ix^
d,rho_), eint, t, w(ix^
d,p_), rfac)
860 end subroutine mhd_to_primitive_semirelati_pi
863 subroutine mhd_to_primitive_semirelati_noe(ixI^L,ixO^L,w,x)
865 integer,
intent(in) :: ixi^
l, ixo^
l
866 double precision,
intent(inout) :: w(ixi^s, nw)
867 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
869 double precision :: b(ixo^s,1:
ndir),tmp,b2,gamma2,inv_rho
870 integer :: ix^
d, idir
873 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l,
'mhd_to_primitive_semirelati_noe')
876 {
do ix^db=ixomin^db,ixomax^db\}
877 b2=(^c&w(ix^
d,b^c_)**2+)
878 if(b2>smalldouble)
then
883 ^c&b(ix^
d,^c)=w(ix^
d,b^c_)*tmp\
884 tmp=(^c&b(ix^
d,^c)*w(ix^
d,m^c_)+)
886 inv_rho=1.d0/w(ix^
d,rho_)
888 b2=b2*inv_rho*eos%inv_squared_c
890 gamma2=1.d0/(1.d0+b2)
892 ^c&w(ix^
d,m^c_)=gamma2*(w(ix^
d,m^c_)+b2*b(ix^
d,^c)*tmp)*inv_rho\
895 end subroutine mhd_to_primitive_semirelati_noe
901 subroutine mhd_to_conserved_origin_lte(ixI^L,ixO^L,w,x)
903 integer,
intent(in) :: ixi^
l, ixo^
l
904 double precision,
intent(inout) :: w(ixi^s, nw)
905 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
907 timeeos0 = mpi_wtime()
910 call mhd_p_to_e(ixi^
l, ixo^
l, w, x)
912 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
914 timeeos_conv=timeeos_conv+(mpi_wtime()-timeeos0)
916 end subroutine mhd_to_conserved_origin_lte
920 subroutine mhd_to_conserved_inte_lte(ixI^L,ixO^L,w,x)
922 integer,
intent(in) :: ixi^
l, ixo^
l
923 double precision,
intent(inout) :: w(ixi^s, nw)
924 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
926 timeeos0 = mpi_wtime()
929 call mhd_p_to_eint(ixi^
l, ixo^
l, w, x)
931 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
933 timeeos_conv=timeeos_conv+(mpi_wtime()-timeeos0)
935 end subroutine mhd_to_conserved_inte_lte
939 subroutine mhd_p_to_e(ixI^L,ixO^L,w,x)
941 integer,
intent(in) :: ixi^
l, ixo^
l
942 double precision,
intent(inout) :: w(ixi^s, nw)
943 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
946 double precision :: p_to_eint, p_over_rho
947 double precision :: nh(ixi^s), nh_in(ixi^s), p_in(ixi^s)
948 double precision :: t_solve, y_solve, eint_nh_solve
949 double precision :: log_eint_mid, eint_total
952 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
953 nh_in(ixo^s) = dlog10(nh(ixo^s))
954 if (eos%p2eint_method /=
'bisect')
then
955 p_in(ixo^s) = dlog10(w(ixo^s,p_)) - nh_in(ixo^s)
959 p_to_eint = eos%inv_gamma_minus_1
960 {
do ix^db=ixomin^db,ixomax^db\}
962 p_over_rho = w(ix^
d,p_) / w(ix^
d,rho_)
963 if (p_over_rho > eos%p_rho_FI_threshold)
then
964 p_to_eint = eos%inv_gamma_minus_1 &
965 + eos%eion_per_nH * nh(ix^
d) / w(ix^
d,p_)
966 w(ix^
d,e_)=w(ix^
d,p_)*p_to_eint&
967 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
968 +(^c&w(ix^
d,b^c_)**2+))
969 else if (eos%method ==
'analytic')
then
970 call saha_state_from_nh_p(nh(ix^
d), w(ix^
d,p_), &
971 t_solve, y_solve, eint_nh_solve)
972 w(ix^
d,e_) = eint_nh_solve * nh(ix^
d) &
973 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
974 +(^c&w(ix^
d,b^c_)**2+))
975 else if (eos%p2eint_method ==
'bisect')
then
976 call eint_from_p_bisect(nh_in(ix^
d), &
977 dlog10(w(ix^
d,p_)), log_eint_mid)
978 eint_total = nh(ix^
d) * 10.0d0**log_eint_mid
979 eint_total = max(eint_total, &
980 nh(ix^
d) * 10.0d0**eos%T%var2_min)
981 w(ix^
d,e_) = eint_total + &
982 half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
983 +(^c&w(ix^
d,b^c_)**2+))
985 p_to_eint = p2eint_from_nh_p(nh_in(ix^
d), p_in(ix^
d))
986 w(ix^
d,e_)=w(ix^
d,p_)*p_to_eint&
987 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
988 +(^c&w(ix^
d,b^c_)**2+))
991 w(ix^
d,e_)=w(ix^
d,p_)*p_to_eint&
992 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
993 +(^c&w(ix^
d,b^c_)**2+))
995 if(mhd_uawsom) w(ix^
d,e_)=w(ix^
d,e_)+&
996 w(ix^
d,waplus_)+w(ix^
d,waminus_)+w(ix^
d,wkplus_)+w(ix^
d,wkminus_)
999 end subroutine mhd_p_to_e
1003 subroutine mhd_p_to_eint(ixI^L,ixO^L,w,x)
1005 integer,
intent(in) :: ixi^
l, ixo^
l
1006 double precision,
intent(inout) :: w(ixi^s, nw)
1007 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1010 double precision :: p_to_eint, p_over_rho
1011 double precision :: nh(ixi^s), nh_in(ixi^s), p_in(ixi^s)
1012 double precision :: t_solve, y_solve, eint_nh_solve
1013 double precision :: log_eint_mid, eint_total
1016 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
1017 nh_in(ixo^s) = dlog10(nh(ixo^s))
1018 if (eos%p2eint_method /=
'bisect')
then
1019 p_in(ixo^s) = dlog10(w(ixo^s,p_)) - nh_in(ixo^s)
1023 p_to_eint = eos%inv_gamma_minus_1
1024 {
do ix^db=ixomin^db,ixomax^db\}
1026 p_over_rho = w(ix^
d,p_) / w(ix^
d,rho_)
1027 if (p_over_rho > eos%p_rho_FI_threshold)
then
1028 p_to_eint = eos%inv_gamma_minus_1 &
1029 + eos%eion_per_nH * nh(ix^
d) / w(ix^
d,p_)
1030 w(ix^
d,e_) = w(ix^
d,p_) * p_to_eint
1031 else if (eos%method ==
'analytic')
then
1032 call saha_state_from_nh_p(nh(ix^
d), w(ix^
d,p_), &
1033 t_solve, y_solve, eint_nh_solve)
1034 w(ix^
d,e_) = eint_nh_solve * nh(ix^
d)
1035 else if (eos%p2eint_method ==
'bisect')
then
1036 call eint_from_p_bisect(nh_in(ix^
d), &
1037 dlog10(w(ix^
d,p_)), log_eint_mid)
1038 eint_total = nh(ix^
d) * 10.0d0**log_eint_mid
1039 eint_total = max(eint_total, &
1040 nh(ix^
d) * 10.0d0**eos%T%var2_min)
1041 w(ix^
d,e_) = eint_total
1043 p_to_eint = p2eint_from_nh_p(nh_in(ix^
d), p_in(ix^
d))
1044 w(ix^
d,e_) = w(ix^
d,p_) * p_to_eint
1047 w(ix^
d,e_) = w(ix^
d,p_) * p_to_eint
1051 end subroutine mhd_p_to_eint
1055 subroutine mhd_to_primitive_origin_lte(ixI^L,ixO^L,w,x)
1057 integer,
intent(in) :: ixi^
l, ixo^
l
1058 double precision,
intent(inout) :: w(ixi^s, nw)
1059 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1061 double precision :: inv_rho, eint_val, eint_in
1062 double precision :: nh(ixi^s), log_nh(ixi^s)
1065 timeeos0 = mpi_wtime()
1068 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
1069 'mhd_to_primitive_origin_LTE')
1072 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
1074 log_nh(ixo^s) = dlog10(nh(ixo^s))
1077 {
do ix^db=ixomin^db,ixomax^db\}
1078 inv_rho = 1.d0/w(ix^
d,rho_)
1080 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
1082 eint_val = w(ix^
d,e_) &
1083 - half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+) &
1084 + (^c&w(ix^
d,b^c_)**2+))
1086 if (eos%method /=
'analytic')
then
1087 eint_val = max(eint_val, nh(ix^
d) * 10.0d0**eos%T%var2_min)
1089 eint_val = max(eint_val, smalldouble)
1092 if (eint_val * inv_rho > eos%eint_rho_FI_threshold)
then
1094 w(ix^
d,p_) = eos%gamma_minus_1 &
1095 * (eint_val - eos%eion_per_nH * nh(ix^
d))
1098 eint_in = dlog10(eint_val) - log_nh(ix^
d)
1099 w(ix^
d,p_) = nh(ix^
d) * p_nh_from_eint(log_nh(ix^
d), eint_in)
1103 w(ix^
d,p_) = eos%gamma_minus_1 * eint_val
1107 timeeos_conv=timeeos_conv+(mpi_wtime()-timeeos0)
1109 end subroutine mhd_to_primitive_origin_lte
1113 subroutine mhd_to_primitive_inte_lte(ixI^L,ixO^L,w,x)
1115 integer,
intent(in) :: ixi^
l, ixo^
l
1116 double precision,
intent(inout) :: w(ixi^s, nw)
1117 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1119 double precision :: inv_rho, eint_val, eint_in, t_loc, y_loc
1120 double precision :: nh(ixi^s), log_nh(ixi^s)
1123 timeeos0 = mpi_wtime()
1126 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
1127 'mhd_to_primitive_inte_LTE')
1130 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
1132 log_nh(ixo^s) = dlog10(nh(ixo^s))
1135 {
do ix^db=ixomin^db,ixomax^db\}
1137 eint_val = w(ix^
d,e_)
1138 eint_val = max(eint_val, nh(ix^
d) * 10.0d0**eos%T%var2_min)
1141 if (eint_val / w(ix^
d,rho_) > eos%eint_rho_FI_threshold)
then
1142 w(ix^
d,p_) = eos%gamma_minus_1 &
1143 * (eint_val - eos%eion_per_nH * nh(ix^
d))
1145 eint_in = dlog10(eint_val) - log_nh(ix^
d)
1146 w(ix^
d,p_) = nh(ix^
d) * p_nh_from_eint(log_nh(ix^
d), eint_in)
1149 w(ix^
d,p_) = eos%gamma_minus_1 * eint_val
1153 inv_rho = 1.d0/w(ix^
d,rho_)
1154 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
1157 timeeos_conv=timeeos_conv+(mpi_wtime()-timeeos0)
1159 end subroutine mhd_to_primitive_inte_lte
1166 subroutine mhd_to_prolong_lte(ixI^L,ixO^L,w,x)
1168 integer,
intent(in) :: ixi^
l, ixo^
l
1169 double precision,
intent(inout) :: w(ixi^s, nw)
1170 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1172 double precision :: inv_rho, eint_val, t_loc, y_loc
1173 double precision :: nh(ixi^s), log_nh(ixi^s)
1176 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
1177 log_nh(ixo^s) = dlog10(nh(ixo^s))
1179 {
do ix^db=ixomin^db,ixomax^db\}
1180 inv_rho = 1.d0/w(ix^
d,rho_)
1182 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
1183 if (mhd_internal_e)
then
1184 eint_val = w(ix^
d,e_)
1187 eint_val = w(ix^
d,e_) &
1188 - half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+) &
1189 + (^c&w(ix^
d,b^c_)**2+))
1192 if (eos%method /=
'analytic')
then
1193 eint_val = max(eint_val, nh(ix^
d) * 10.0d0**eos%T%var2_min)
1195 eint_val = max(eint_val, smalldouble)
1197 if (eint_val * inv_rho > eos%eint_rho_FI_threshold)
then
1199 w(ix^
d,p_) = eos%gamma_minus_1 &
1200 * (eint_val - eos%eion_per_nH * nh(ix^
d)) &
1201 / (nh(ix^
d) * eos%n_per_nH_FI)
1202 else if (eos%method ==
'analytic')
then
1204 call saha_t_from_nh_eint(nh(ix^
d), &
1205 eint_val / nh(ix^
d), t_loc, y_loc)
1209 w(ix^
d,p_) = t_from_nh_eint( &
1211 dlog10(eint_val) - log_nh(ix^
d))
1215 end subroutine mhd_to_prolong_lte
1219 subroutine mhd_from_prolong_lte(ixI^L,ixO^L,w,x)
1221 integer,
intent(in) :: ixi^
l, ixo^
l
1222 double precision,
intent(inout) :: w(ixi^s, nw)
1223 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1225 double precision :: t_val, eint_val, t_fi, log_t_min
1226 double precision :: nh(ixi^s), log_nh(ixi^s)
1230 t_fi = (eos%eint_rho_FI_threshold &
1231 * eos%nH2rhoFactor - eos%eion_per_nH) &
1232 * eos%gamma_minus_1 / eos%n_per_nH_FI
1237 if (eos%method ==
'entropy')
then
1238 log_t_min = eos%eintT%var2_min
1240 log_t_min = eos%eint_from_T%var2_min
1243 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
1244 log_nh(ixo^s) = dlog10(nh(ixo^s))
1246 {
do ix^db=ixomin^db,ixomax^db\}
1248 if (t_val > t_fi)
then
1250 eint_val = nh(ix^
d) &
1251 * (eos%n_per_nH_FI * t_val * eos%inv_gamma_minus_1 &
1253 else if (eos%method ==
'analytic')
then
1255 eint_val = saha_eint_from_nh_t(nh(ix^
d), t_val) * nh(ix^
d)
1258 eint_val = eint_nh_from_t( &
1260 dlog10(max(t_val, 10.0d0**log_t_min))) &
1263 if (mhd_internal_e)
then
1264 w(ix^
d,e_) = eint_val
1267 w(ix^
d,e_) = eint_val &
1268 + half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+) &
1269 + (^c&w(ix^
d,b^c_)**2+))
1272 ^c&w(ix^
d,m^c_)=w(ix^
d,rho_)*w(ix^
d,m^c_)\
1275 end subroutine mhd_from_prolong_lte
1281 subroutine mhd_get_csound2_fi(w, x, ixI^L, ixO^L, cs2)
1283 integer,
intent(in) :: ixi^
l, ixo^
l
1284 double precision,
intent(in) :: w(ixi^s, nw)
1285 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1286 double precision,
intent(out) :: cs2(ixi^s)
1288 double precision :: rho(ixi^s), pth(ixi^s)
1290 timeeos0 = mpi_wtime()
1294 call eos%get_rho(w, x, ixi^
l, ixo^
l, rho)
1295 pth(ixo^s) = w(ixo^s, p_)
1296 if (iw_equi_p > 0) pth(ixo^s) = pth(ixo^s) &
1297 +
block%equi_vars(ixo^s, iw_equi_p,
b0i)
1298 cs2(ixo^s) = eos%gamma * pth(ixo^s) / rho(ixo^s)
1300 timeeos_csound = timeeos_csound + (mpi_wtime()-timeeos0)
1302 end subroutine mhd_get_csound2_fi
1306 subroutine mhd_get_csound2_lte(w, x, ixI^L, ixO^L, cs2)
1308 integer,
intent(in) :: ixi^
l, ixo^
l
1309 double precision,
intent(in) :: w(ixi^s, nw)
1310 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1311 double precision,
intent(out) :: cs2(ixi^s)
1313 double precision :: nh_val, log_nh, log_p_nh, g1, p_over_rho
1316 timeeos0 = mpi_wtime()
1318 if (eos%gamma1_method ==
'constant')
then
1319 cs2(ixo^s) = eos%gamma * w(ixo^s, p_) / w(ixo^s, rho_)
1321 {
do ix^db=ixomin^db,ixomax^db\}
1322 p_over_rho = w(ix^
d, p_) / w(ix^
d, rho_)
1323 if (p_over_rho > eos%p_rho_FI_threshold)
then
1324 cs2(ix^
d) = eos%gamma * p_over_rho
1326 nh_val = w(ix^
d, rho_) / eos%nH2rhoFactor
1327 if (eos%method ==
'analytic')
then
1328 if (iw_te > 0 .and. w(ix^
d,iw_te) > 0.0d0)
then
1329 g1 = saha_gamma1_from_nh_t(nh_val, w(ix^
d,iw_te))
1334 log_nh = dlog10(nh_val)
1335 log_p_nh = dlog10(w(ix^
d, p_) / nh_val)
1336 g1 = gamma1_from_nh_p(log_nh, log_p_nh)
1338 cs2(ix^
d) = g1 * p_over_rho
1343 timeeos_csound = timeeos_csound + (mpi_wtime()-timeeos0)
1345 end subroutine mhd_get_csound2_lte
1347 subroutine mhd_get_gamma1_lte(w, x, ixI^L, ixO^L, gamma1)
1349 integer,
intent(in) :: ixi^
l, ixo^
l
1350 double precision,
intent(in) :: w(ixi^s, nw)
1351 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1352 double precision,
intent(out) :: gamma1(ixi^s)
1354 double precision :: nh_val, p_over_rho
1357 if (eos%gamma1_method ==
'constant')
then
1358 gamma1(ixo^s) = eos%gamma
1362 {
do ix^db=ixomin^db,ixomax^db\}
1363 p_over_rho = w(ix^
d, p_) / w(ix^
d, rho_)
1364 if (p_over_rho > eos%p_rho_FI_threshold)
then
1365 gamma1(ix^
d) = eos%gamma
1367 nh_val = w(ix^
d, rho_) / eos%nH2rhoFactor
1368 if (eos%method ==
'analytic')
then
1369 if (iw_te > 0 .and. w(ix^
d,iw_te) > 0.0d0)
then
1370 gamma1(ix^
d) = saha_gamma1_from_nh_t(nh_val, w(ix^
d,iw_te))
1372 gamma1(ix^
d) = eos%gamma
1375 gamma1(ix^
d) = gamma1_from_nh_p(dlog10(nh_val), &
1376 dlog10(w(ix^
d, p_) / nh_val))
1381 end subroutine mhd_get_gamma1_lte
1388 subroutine rfactor_from_constant_ionization(w,x,ixI^L,ixO^L,Rfactor)
1390 integer,
intent(in) :: ixi^
l, ixo^
l
1391 double precision,
intent(in) :: w(ixi^s,1:nw)
1392 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1393 double precision,
intent(out):: rfactor(ixi^s)
1397 end subroutine rfactor_from_constant_ionization
1404 subroutine mhd_get_pthermal_noe(w,x,ixI^L,ixO^L,pth)
1408 integer,
intent(in) :: ixi^
l, ixo^
l
1409 double precision,
intent(in) :: w(ixi^s,nw)
1410 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1411 double precision,
intent(out):: pth(ixi^s)
1413 double precision :: adiabs(ixi^s), gammas(ixi^s)
1426 if(has_equi_rho_and_p)
then
1427 pth(ixo^s)=adiabs(ixo^s)*(w(ixo^s,rho_)+
block%equi_vars(ixo^s,equi_rho0_,0))**gammas(ixo^s)
1429 pth(ixo^s)=adiabs(ixo^s)*w(ixo^s,rho_)**gammas(ixo^s)
1432 end subroutine mhd_get_pthermal_noe
1435 subroutine mhd_get_pthermal_inte(w,x,ixI^L,ixO^L,pth)
1439 integer,
intent(in) :: ixi^
l, ixo^
l
1440 double precision,
intent(in) :: w(ixi^s,nw)
1441 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1442 double precision,
intent(out):: pth(ixi^s)
1446 {
do ix^db= ixomin^db,ixomax^db\}
1447 if(has_equi_rho_and_p)
then
1448 pth(ix^
d)=eos%gamma_minus_1*w(ix^
d,e_)+
block%equi_vars(ix^
d,equi_pe0_,0)
1450 pth(ix^
d)=eos%gamma_minus_1*w(ix^
d,e_)
1455 if(check_small_values.and..not.fix_small_values)
then
1456 {
do ix^db= ixomin^db,ixomax^db\}
1457 if(pth(ix^d)<small_pressure)
then
1458 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1459 " encountered when call mhd_get_pthermal_inte"
1460 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1461 write(*,*)
"Location: ", x(ix^d,:)
1462 write(*,*)
"Cell number: ", ix^d
1464 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1466 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1467 write(*,*)
"Saving status at the previous time step"
1473 end subroutine mhd_get_pthermal_inte
1476 subroutine mhd_get_pthermal_origin(w,x,ixI^L,ixO^L,pth)
1480 integer,
intent(in) :: ixi^
l, ixo^
l
1481 double precision,
intent(in) :: w(ixi^s,nw)
1482 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1483 double precision,
intent(out):: pth(ixi^s)
1487 {
do ix^db=ixomin^db,ixomax^db\}
1488 if(has_equi_rho_and_p)
then
1489 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))&
1490 +(^c&w(ix^
d,b^c_)**2+)))+
block%equi_vars(ix^
d,equi_pe0_,0)
1492 pth(ix^
d)=eos%gamma_minus_1*(w(ix^
d,e_)-half*((^c&w(ix^
d,m^c_)**2+)/w(ix^
d,rho_)&
1493 +(^c&w(ix^
d,b^c_)**2+))-mhd_uawsom_wave_energy_cell(w(ix^
d,:)))
1498 if(check_small_values.and..not.fix_small_values)
then
1499 {
do ix^db=ixomin^db,ixomax^db\}
1500 if(pth(ix^d)<small_pressure)
then
1501 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1502 " encountered when call mhd_get_pthermal"
1503 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1504 write(*,*)
"Location: ", x(ix^d,:)
1505 write(*,*)
"Cell number: ", ix^d
1507 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1509 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1510 write(*,*)
"Saving status at the previous time step"
1516 end subroutine mhd_get_pthermal_origin
1519 subroutine mhd_get_pthermal_lte(w,x,ixI^L,ixO^L,pth)
1523 integer,
intent(in) :: ixi^
l, ixo^
l
1524 double precision,
intent(in) :: w(ixi^s,nw)
1525 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1526 double precision,
intent(out):: pth(ixi^s)
1527 double precision :: nh(ixi^s)
1532 call eos%get_nH(w, x, ixi^
l, ixo^
l, nh)
1533 pth(ixo^s) = nh(ixo^s) * (1.0d0 + eos%He_abundance &
1534 + (w(ixo^s,ne_) / nh(ixo^s))) * w(ixo^s,te_)
1537 {
do ix^db=ixomin^db,ixomax^db\}
1540 else if(check_small_values)
then
1541 {
do ix^db=ixomin^db,ixomax^db\}
1542 if(pth(ix^d)<small_pressure)
then
1543 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1544 " encountered when call mhd_get_pthermal_LTE"
1545 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1546 write(*,*)
"Location: ", x(ix^d,:)
1547 write(*,*)
"Cell number: ", ix^d
1549 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1551 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1552 write(*,*)
"Saving status at the previous time step"
1558 end subroutine mhd_get_pthermal_lte
1561 subroutine mhd_get_pthermal_semirelati(w,x,ixI^L,ixO^L,pth)
1565 integer,
intent(in) :: ixi^
l, ixo^
l
1566 double precision,
intent(in) :: w(ixi^s,nw)
1567 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1568 double precision,
intent(out):: pth(ixi^s)
1570 double precision :: b(ixo^s,1:
ndir), v(
ndir), tmp, b2, gamma2, inv_rho
1573 {
do ix^db=ixomin^db,ixomax^db\}
1574 b2=(^c&w(ix^
d,b^c_)**2+)
1575 if(b2>smalldouble)
then
1580 ^c&b(ix^
d,^c)=w(ix^
d,b^c_)*tmp\
1581 tmp=(^c&b(ix^
d,^c)*w(ix^
d,m^c_)+)
1583 inv_rho=1.d0/w(ix^
d,rho_)
1585 b2=b2*inv_rho*eos%inv_squared_c
1587 gamma2=1.d0/(1.d0+b2)
1589 ^c&v(^c)=gamma2*(w(ix^
d,m^c_)+b2*b(ix^
d,^c)*tmp)*inv_rho\
1593 b(ix^
d,1)=w(ix^
d,b2_)*v(3)-w(ix^
d,b3_)*v(2)
1594 b(ix^
d,2)=w(ix^
d,b3_)*v(1)-w(ix^
d,b1_)*v(3)
1595 b(ix^
d,3)=w(ix^
d,b1_)*v(2)-w(ix^
d,b2_)*v(1)
1599 b(ix^
d,2)=w(ix^
d,b1_)*v(2)-w(ix^
d,b2_)*v(1)
1605 pth(ix^
d)=eos%gamma_minus_1*(w(ix^
d,e_)&
1606 -half*((^c&v(^c)**2+)*w(ix^
d,rho_)&
1607 +(^c&w(ix^
d,b^c_)**2+)&
1608 +(^c&b(ix^
d,^c)**2+)*eos%inv_squared_c))
1612 if(check_small_values.and..not.fix_small_values)
then
1613 {
do ix^db=ixomin^db,ixomax^db\}
1614 if(pth(ix^d)<small_pressure)
then
1615 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1616 " encountered when call mhd_get_pthermal_semirelati"
1617 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1618 write(*,*)
"Location: ", x(ix^d,:)
1619 write(*,*)
"Cell number: ", ix^d
1621 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1623 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1624 write(*,*)
"Saving status at the previous time step"
1630 end subroutine mhd_get_pthermal_semirelati
1633 subroutine mhd_get_pthermal_semirelati_pi(w,x,ixI^L,ixO^L,pth)
1637 integer,
intent(in) :: ixi^
l, ixo^
l
1638 double precision,
intent(in) :: w(ixi^s,nw)
1639 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1640 double precision,
intent(out):: pth(ixi^s)
1642 double precision :: b(ixo^s,1:
ndir), v(
ndir), tmp, b2, gamma2, inv_rho, eint, t, rfac
1645 {
do ix^db=ixomin^db,ixomax^db\}
1646 b2=(^c&w(ix^
d,b^c_)**2+)
1647 if(b2>smalldouble)
then
1652 ^c&b(ix^
d,^c)=w(ix^
d,b^c_)*tmp\
1653 tmp=(^c&b(ix^
d,^c)*w(ix^
d,m^c_)+)
1655 inv_rho=1.d0/w(ix^
d,rho_)
1657 b2=b2*inv_rho*eos%inv_squared_c
1659 gamma2=1.d0/(1.d0+b2)
1661 ^c&v(^c)=gamma2*(w(ix^
d,m^c_)+b2*b(ix^
d,^c)*tmp)*inv_rho\
1665 b(ix^
d,1)=w(ix^
d,b2_)*v(3)-w(ix^
d,b3_)*v(2)
1666 b(ix^
d,2)=w(ix^
d,b3_)*v(1)-w(ix^
d,b1_)*v(3)
1667 b(ix^
d,3)=w(ix^
d,b1_)*v(2)-w(ix^
d,b2_)*v(1)
1671 b(ix^
d,2)=w(ix^
d,b1_)*v(2)-w(ix^
d,b2_)*v(1)
1678 -half*((^c&v(^c)**2+)*w(ix^
d,rho_)&
1679 +(^c&w(ix^
d,b^c_)**2+)&
1680 +(^c&b(ix^
d,^c)**2+)*eos%inv_squared_c)
1681 call state_from_eint_pi(w(ix^
d,rho_), eint, t, pth(ix^
d), rfac)
1685 if(check_small_values.and..not.fix_small_values)
then
1686 {
do ix^db=ixomin^db,ixomax^db\}
1687 if(pth(ix^d)<small_pressure)
then
1688 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1689 " encountered when call mhd_get_pthermal_semirelati"
1690 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1691 write(*,*)
"Location: ", x(ix^d,:)
1692 write(*,*)
"Cell number: ", ix^d
1694 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1696 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1697 write(*,*)
"Saving status at the previous time step"
1703 end subroutine mhd_get_pthermal_semirelati_pi
1706 subroutine mhd_get_pthermal_hde(w,x,ixI^L,ixO^L,pth)
1710 integer,
intent(in) :: ixi^
l, ixo^
l
1711 double precision,
intent(in) :: w(ixi^s,nw)
1712 double precision,
intent(in) :: x(ixi^s,1:
ndim)
1713 double precision,
intent(out):: pth(ixi^s)
1717 {
do ix^db= ixomin^db,ixomax^db\}
1718 pth(ix^
d)=eos%gamma_minus_1*(w(ix^
d,e_)-half*((^c&w(ix^
d,m^c_)**2+)/w(ix^
d,rho_)))
1721 if(check_small_values.and..not.fix_small_values)
then
1722 {
do ix^db= ixomin^db,ixomax^db\}
1723 if(pth(ix^d)<small_pressure)
then
1724 write(*,*)
"Error: small value of gas pressure",pth(ix^d),&
1725 " encountered when call mhd_get_pthermal_hde"
1726 write(*,*)
"Iteration: ", it,
" Time: ", global_time
1727 write(*,*)
"Location: ", x(ix^d,:)
1728 write(*,*)
"Cell number: ", ix^d
1730 write(*,*) trim(cons_wnames(iw)),
": ",w(ix^d,iw)
1732 if(trace_small_values)
write(*,*) sqrt(pth(ix^d)-bigdouble)
1733 write(*,*)
"Saving status at the previous time step"
1739 end subroutine mhd_get_pthermal_hde
1744 subroutine mhd_get_temperature_from_te(w, x, ixI^L, ixO^L, res)
1746 integer,
intent(in) :: ixi^
l, ixo^
l
1747 double precision,
intent(in) :: w(ixi^s, 1:nw)
1748 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1749 double precision,
intent(out):: res(ixi^s)
1750 res(ixo^s) = w(ixo^s, te_)
1751 end subroutine mhd_get_temperature_from_te
1754 subroutine mhd_get_temperature_from_eint(w, x, ixI^L, ixO^L, res)
1756 integer,
intent(in) :: ixi^
l, ixo^
l
1757 double precision,
intent(in) :: w(ixi^s, 1:nw)
1758 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1759 double precision,
intent(out):: res(ixi^s)
1761 double precision :: r(ixi^s)
1763 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1764 res(ixo^s) = eos%gamma_minus_1 * w(ixo^s, e_)/(w(ixo^s,rho_)*r(ixo^s))
1765 end subroutine mhd_get_temperature_from_eint
1768 subroutine mhd_get_temperature_from_etot(w, x, ixI^L, ixO^L, res)
1770 integer,
intent(in) :: ixi^
l, ixo^
l
1771 double precision,
intent(in) :: w(ixi^s, 1:nw)
1772 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1773 double precision,
intent(out):: res(ixi^s)
1775 double precision :: r(ixi^s)
1777 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1779 res(ixo^s)=res(ixo^s)/(r(ixo^s)*w(ixo^s,rho_))
1781 end subroutine mhd_get_temperature_from_etot
1783 subroutine mhd_get_temperature_from_etot_with_equi(w, x, ixI^L, ixO^L, res)
1785 integer,
intent(in) :: ixi^
l, ixo^
l
1786 double precision,
intent(in) :: w(ixi^s, 1:nw)
1787 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1788 double precision,
intent(out):: res(ixi^s)
1790 double precision :: r(ixi^s)
1792 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1794 res(ixo^s)=res(ixo^s)/(r(ixo^s)*(w(ixo^s,rho_)+
block%equi_vars(ixo^s,equi_rho0_,
b0i)))
1796 end subroutine mhd_get_temperature_from_etot_with_equi
1798 subroutine mhd_get_temperature_from_eint_with_equi(w, x, ixI^L, ixO^L, res)
1800 integer,
intent(in) :: ixi^
l, ixo^
l
1801 double precision,
intent(in) :: w(ixi^s, 1:nw)
1802 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1803 double precision,
intent(out):: res(ixi^s)
1805 double precision :: r(ixi^s)
1807 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1808 res(ixo^s) = (eos%gamma_minus_1 * w(ixo^s, e_) +
block%equi_vars(ixo^s,equi_pe0_,
b0i)) /&
1809 ((w(ixo^s,rho_) +
block%equi_vars(ixo^s,equi_rho0_,
b0i))*r(ixo^s))
1811 end subroutine mhd_get_temperature_from_eint_with_equi
1819 subroutine mhd_get_temperature_from_etot_lte(w, x, ixI^L, ixO^L, res)
1821 integer,
intent(in) :: ixi^
l, ixo^
l
1822 double precision,
intent(in) :: w(ixi^s, 1:nw)
1823 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1824 double precision,
intent(out):: res(ixi^s)
1826 double precision :: wlocal(ixi^s, 1:nw)
1828 wlocal(ixi^s, 1:nw) = w(ixi^s, 1:nw)
1830 call phys_e_to_ei(ixi^
l, ixo^
l, wlocal, x)
1832 call eos%get_temperature_from_eint(wlocal, x, ixi^
l, ixo^
l, res)
1834 end subroutine mhd_get_temperature_from_etot_lte
1836 subroutine mhd_get_temperature_equi(w,x, ixI^L, ixO^L, res)
1838 integer,
intent(in) :: ixi^
l, ixo^
l
1839 double precision,
intent(in) :: w(ixi^s, 1:nw)
1840 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1841 double precision,
intent(out):: res(ixi^s)
1843 double precision :: r(ixi^s)
1845 call eos%get_Rfactor(w,x,ixi^
l,ixo^
l,r)
1846 res(ixo^s)=
block%equi_vars(ixo^s,equi_pe0_,
b0i)/(
block%equi_vars(ixo^s,equi_rho0_,
b0i)*r(ixo^s))
1848 end subroutine mhd_get_temperature_equi
1852 subroutine mhd_get_rho_equi(w, x, ixI^L, ixO^L, res)
1854 integer,
intent(in) :: ixi^
l, ixo^
l
1855 double precision,
intent(in) :: w(ixi^s, 1:nw)
1856 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1857 double precision,
intent(out):: res(ixi^s)
1858 res(ixo^s) =
block%equi_vars(ixo^s,equi_rho0_,
b0i)
1859 end subroutine mhd_get_rho_equi
1861 subroutine mhd_get_pe_equi(w,x, ixI^L, ixO^L, res)
1863 integer,
intent(in) :: ixi^
l, ixo^
l
1864 double precision,
intent(in) :: w(ixi^s, 1:nw)
1865 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1866 double precision,
intent(out):: res(ixi^s)
1867 res(ixo^s) =
block%equi_vars(ixo^s,equi_pe0_,
b0i)
1868 end subroutine mhd_get_pe_equi
1873 subroutine mhd_get_ne_nh_equi(ixI^L, ixO^L, w, x, ne, nH)
1875 integer,
intent(in) :: ixi^
l, ixo^
l
1876 double precision,
intent(in) :: w(ixi^s, nw)
1877 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1878 double precision,
intent(out):: ne(ixi^s), nh(ixi^s)
1879 nh(ixo^s) =
block%equi_vars(ixo^s,equi_rho0_,
b0i) / eos%nH2rhoFactor
1880 ne(ixo^s) = nh(ixo^s) * eos%neOnH_FI
1881 end subroutine mhd_get_ne_nh_equi
1886 function mhd_get_ei_origin(w, ixI^L, ixO^L)
result(ei)
1888 integer,
intent(in) :: ixi^
l, ixo^
l
1889 double precision,
intent(in) :: w(ixi^s, nw)
1890 double precision :: ei(ixo^s)
1893 ei(ixo^s) = w(ixo^s,e_) - half*((^c&w(ixo^s,m^c_)**2+)/w(ixo^s,rho_) &
1894 + (^c&w(ixo^s,b^c_)**2+))
1895 end function mhd_get_ei_origin
1898 function mhd_get_ei_semirelati(w, ixI^L, ixO^L)
result(ei)
1900 integer,
intent(in) :: ixi^
l, ixo^
l
1901 double precision,
intent(in) :: w(ixi^s, nw)
1902 double precision :: ei(ixo^s)
1904 double precision :: b(ixo^s,1:
ndir), v(
ndir), tmp, b2, gamma2, inv_rho
1907 {
do ix^db=ixomin^db,ixomax^db\}
1908 b2=(^c&w(ix^
d,b^c_)**2+)
1909 if(b2>smalldouble)
then
1914 ^c&b(ix^
d,^c)=w(ix^
d,b^c_)*tmp\
1915 tmp=(^c&b(ix^
d,^c)*w(ix^
d,m^c_)+)
1917 inv_rho=1.d0/w(ix^
d,rho_)
1919 b2=b2*inv_rho*eos%inv_squared_c
1921 gamma2=1.d0/(1.d0+b2)
1923 ^c&v(^c)=gamma2*(w(ix^
d,m^c_)+b2*b(ix^
d,^c)*tmp)*inv_rho\
1927 b(ix^
d,1)=w(ix^
d,b2_)*v(3)-w(ix^
d,b3_)*v(2)
1928 b(ix^
d,2)=w(ix^
d,b3_)*v(1)-w(ix^
d,b1_)*v(3)
1929 b(ix^
d,3)=w(ix^
d,b1_)*v(2)-w(ix^
d,b2_)*v(1)
1933 b(ix^
d,2)=w(ix^
d,b1_)*v(2)-w(ix^
d,b2_)*v(1)
1939 ei(ix^
d)=w(ix^
d,e_)&
1940 -half*((^c&v(^c)**2+)*w(ix^
d,rho_)&
1941 +(^c&w(ix^
d,b^c_)**2+)&
1942 +(^c&b(ix^
d,^c)**2+)*eos%inv_squared_c)
1944 end function mhd_get_ei_semirelati
1947 function mhd_get_ei_inte(w, ixI^L, ixO^L)
result(ei)
1949 integer,
intent(in) :: ixi^
l, ixo^
l
1950 double precision,
intent(in) :: w(ixi^s, nw)
1951 double precision :: ei(ixo^s)
1954 ei(ixo^s) = w(ixo^s,e_)
1955 end function mhd_get_ei_inte
1970 subroutine mhd_p_to_e_pi(ixI^L,ixO^L,w,x)
1972 integer,
intent(in) :: ixi^
l, ixo^
l
1973 double precision,
intent(inout) :: w(ixi^s, nw)
1974 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1976 double precision :: eint
1979 {
do ix^db=ixomin^db,ixomax^db\}
1980 call eint_from_rho_p_pi(w(ix^
d,rho_), w(ix^
d,p_), eint)
1982 +half*((^c&w(ix^
d,m^c_)**2+)*w(ix^
d,rho_)&
1983 +(^c&w(ix^
d,b^c_)**2+))
1986 end subroutine mhd_p_to_e_pi
1989 subroutine mhd_p_to_eint_pi(ixI^L,ixO^L,w,x)
1991 integer,
intent(in) :: ixi^
l, ixo^
l
1992 double precision,
intent(inout) :: w(ixi^s, nw)
1993 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
1995 double precision :: eint
1998 {
do ix^db=ixomin^db,ixomax^db\}
1999 call eint_from_rho_p_pi(w(ix^
d,rho_), w(ix^
d,p_), eint)
2003 end subroutine mhd_p_to_eint_pi
2006 subroutine mhd_to_conserved_origin_pi(ixI^L,ixO^L,w,x)
2008 integer,
intent(in) :: ixi^
l, ixo^
l
2009 double precision,
intent(inout) :: w(ixi^s, nw)
2010 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2012 call mhd_p_to_e_pi(ixi^
l, ixo^
l, w, x)
2013 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
2015 end subroutine mhd_to_conserved_origin_pi
2018 subroutine mhd_to_conserved_inte_pi(ixI^L,ixO^L,w,x)
2020 integer,
intent(in) :: ixi^
l, ixo^
l
2021 double precision,
intent(inout) :: w(ixi^s, nw)
2022 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2024 call mhd_p_to_eint_pi(ixi^
l, ixo^
l, w, x)
2025 ^c&w(ixo^s,m^c_)=w(ixo^s,rho_)*w(ixo^s,m^c_)\
2027 end subroutine mhd_to_conserved_inte_pi
2030 subroutine mhd_to_primitive_origin_pi(ixI^L,ixO^L,w,x)
2032 integer,
intent(in) :: ixi^
l, ixo^
l
2033 double precision,
intent(inout) :: w(ixi^s, nw)
2034 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2036 double precision :: inv_rho, eint_val, t, rfac
2040 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
2041 'mhd_to_primitive_origin_PI')
2044 {
do ix^db=ixomin^db,ixomax^db\}
2045 inv_rho = 1.d0/w(ix^
d,rho_)
2047 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
2049 eint_val = w(ix^
d,e_) &
2050 - half*(w(ix^
d,rho_)*(^c&w(ix^
d,m^c_)**2+) &
2051 + (^c&w(ix^
d,b^c_)**2+))
2052 eint_val = max(eint_val, smalldouble)
2053 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, w(ix^
d,p_), rfac)
2056 end subroutine mhd_to_primitive_origin_pi
2059 subroutine mhd_to_primitive_inte_pi(ixI^L,ixO^L,w,x)
2061 integer,
intent(in) :: ixi^
l, ixo^
l
2062 double precision,
intent(inout) :: w(ixi^s, nw)
2063 double precision,
intent(in) :: x(ixi^s, 1:
ndim)
2065 double precision :: inv_rho, eint_val, t, rfac
2069 call phys_handle_small_values(.false., w, x, ixi^
l, ixo^
l, &
2070 'mhd_to_primitive_inte_PI')
2073 {
do ix^db=ixomin^db,ixomax^db\}
2074 eint_val = max(w(ix^
d,e_), smalldouble)
2075 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, w(ix^
d,p_), rfac)
2077 inv_rho = 1.d0/w(ix^
d,rho_)
2078 ^c&w(ix^
d,m^c_)=w(ix^
d,m^c_)*inv_rho\
2081 end subroutine mhd_to_primitive_inte_pi
2084 subroutine mhd_get_pthermal_origin_pi(w,x,ixI^L,ixO^L,pth)
2086 integer,
intent(in) :: ixi^
l, ixo^
l
2087 double precision,
intent(in) :: w(ixi^s,nw)
2088 double precision,
intent(in) :: x(ixi^s,1:
ndim)
2089 double precision,
intent(out):: pth(ixi^s)
2091 double precision :: eint_val, t, rfac
2094 {
do ix^db=ixomin^db,ixomax^db\}
2095 eint_val = w(ix^
d,e_) &
2096 - half*((^c&w(ix^
d,m^c_)**2+)/w(ix^
d,rho_) &
2097 + (^c&w(ix^
d,b^c_)**2+))
2098 eint_val = max(eint_val, smalldouble)
2099 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, pth(ix^
d), rfac)
2103 end subroutine mhd_get_pthermal_origin_pi
2106 subroutine mhd_get_pthermal_inte_pi(w,x,ixI^L,ixO^L,pth)
2108 integer,
intent(in) :: ixi^
l, ixo^
l
2109 double precision,
intent(in) :: w(ixi^s,nw)
2110 double precision,
intent(in) :: x(ixi^s,1:
ndim)
2111 double precision,
intent(out):: pth(ixi^s)
2113 double precision :: eint_val, t, rfac
2116 {
do ix^db=ixomin^db,ixomax^db\}
2117 eint_val = max(w(ix^
d,e_), smalldouble)
2118 call state_from_eint_pi(w(ix^
d,rho_), eint_val, t, pth(ix^
d), rfac)
2122 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.
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 H-only Saha EoS (eos_method == 'analytic').
LTE (Saha-table) EoS kernels and finalise for the eos% family.
double precision function, public p2eint_from_nh_p(nh, ponh)
Pressure-to-eint ratio from (log10 nH, log10 p/nH) in code units. Dispatches: analytic -> Saha solve ...
double precision function, public eint_nh_from_t(log_nh, log_t)
Internal energy per nH from (log10 nH, log10 T) in code units. Uses the bisection-built inverse table...
double precision function, public y_from_nh_eint(nh, eint_nh)
Ionization fraction from (log10 nH, log10 eint/nH) in code units. Dispatches: analytic -> Saha quadra...
subroutine, public get_temperature_from_eint_fast_lte(w, x, ixil, ixol, res)
subroutine, public eos_get_eintt_grid(n_nh, lg_nh_min, lg_nh_max)
log_nH grid metadata of the (log_nH, log_T) inverse table (eint from T), choosing the container by me...
double precision function, public t_from_nh_eint(nh, eint_nh)
Temperature from (log10 nH, log10 eint/nH) in code units. Dispatches: analytic -> Saha bisection/Newt...
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.
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 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
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