83 double precision :: rfactor_norm
85 eos%update_eos => update_eos_pi
87 eos%get_Te => get_te_pi
91 if (
eos%pi_table ==
'prominence')
then
92 eos%get_Rfactor => get_rfactor_prominence_pi
94 eos%get_Rfactor => get_rfactor_tonly_pi
97 eos%n_per_nH_FI = 2.0d0 + 3.0d0 *
eos%He_abundance
98 eos%neOnH_FI = 1.0d0 + 2.0d0 *
eos%He_abundance
105 rfactor_norm = 2.0d0 + 3.0d0 *
eos%He_abundance
107 trim(
eos%pi_table), include_energy=
eos%ionE)
108 if (
mype == 0)
write(*,*)
"[eos PI] ionisation backend initialised: table=", &
109 trim(
eos%pi_table),
" ionE=",
eos%ionE,
" Rfactor_norm=", rfactor_norm
115 eos%get_temperature_from_eint => get_temperature_from_eint_pi
116 eos%get_csound2 => get_csound2_pi
128 subroutine get_csound2_pi(w, x, ixI^L, ixO^L, cs2)
129 integer,
intent(in) :: ixi^l, ixo^l
130 double precision,
intent(in) :: w(ixi^s, nw)
131 double precision,
intent(in) :: x(ixi^s, 1:ndim)
132 double precision,
intent(out):: cs2(ixi^s)
136 {
do ix^db=ixomin^db,ixomax^db\}
139 end subroutine get_csound2_pi
143 integer,
intent(in) :: ixi^l, ixo^l
144 double precision,
intent(in) :: w(ixi^s, nw)
145 double precision,
intent(in) :: x(ixi^s, 1:ndim)
146 double precision,
intent(out):: gamma1(ixi^s)
148 double precision :: cs2
151 {
do ix^db=ixomin^db,ixomax^db\}
153 gamma1(ix^d) = cs2 * w(ix^d,iw_rho) / w(ix^d,iw_e)
160 subroutine get_rfactor_tonly_pi(w, x, ixI^L, ixO^L, Rfactor)
161 integer,
intent(in) :: ixi^l, ixo^l
162 double precision,
intent(in) :: w(ixi^s,1:nw)
163 double precision,
intent(in) :: x(ixi^s,1:ndim)
164 double precision,
intent(out):: rfactor(ixi^s)
165 double precision :: iz_h(ixo^s), iz_he(ixo^s)
167 call ionization_degree_from_temperature(ixi^l,ixo^l,w(ixi^s,iw_te),iz_h,iz_he)
168 rfactor(ixo^s) = (1.d0 + iz_h(ixo^s) + eos%He_abundance &
169 * (1.d0 + iz_he(ixo^s)*(1.d0+iz_he(ixo^s)))) / (2.d0 + 3.d0*eos%He_abundance)
170 end subroutine get_rfactor_tonly_pi
174 subroutine get_rfactor_prominence_pi(w, x, ixI^L, ixO^L, Rfactor)
176 integer,
intent(in) :: ixi^l, ixo^l
177 double precision,
intent(in) :: w(ixi^s,1:nw)
178 double precision,
intent(in) :: x(ixi^s,1:ndim)
179 double precision,
intent(out):: rfactor(ixi^s)
180 double precision :: ei(ixi^s), pth(ixi^s), rho(ixi^s), t(ixi^s)
183 pth(ixo^s) = eos%gamma_minus_1 * ei(ixo^s)
184 rho(ixo^s) = w(ixo^s,iw_rho)
185 call ionization_get_state(ixi^l, ixo^l, rho, pth, t, rfactor)
186 end subroutine get_rfactor_prominence_pi
194 subroutine update_eos_pi(ixI^L, ixO^L, w, x)
196 integer,
intent(in) :: ixi^l, ixo^l
197 double precision,
intent(in) :: x(ixi^s,1:ndim)
198 double precision,
intent(inout) :: w(ixi^s,1:nw)
199 double precision :: ei(ixi^s), pth(ixi^s), rho(ixi^s), t(ixi^s), rf(ixi^s)
200 double precision :: tsc, psc, rsc
207 {
do ix^db=ixomin^db,ixomax^db\}
214 pth(ixo^s) = eos%gamma_minus_1 * ei(ixo^s)
215 rho(ixo^s) = w(ixo^s,iw_rho)
216 call ionization_get_state(ixi^l, ixo^l, rho, pth, t, rf)
217 w(ixo^s,iw_te) = t(ixo^s)
219 end subroutine update_eos_pi
223 subroutine get_te_pi(w, x, ixI^L, ixO^L, T)
224 integer,
intent(in) :: ixi^l, ixo^l
225 double precision,
intent(in) :: w(ixi^s,1:nw)
226 double precision,
intent(in) :: x(ixi^s,1:ndim)
227 double precision,
intent(out) :: t(ixi^s)
228 t(ixo^s) = w(ixo^s,iw_te)
229 end subroutine get_te_pi
235 subroutine get_temperature_from_eint_pi(w, x, ixI^L, ixO^L, res)
236 integer,
intent(in) :: ixi^l, ixo^l
237 double precision,
intent(in) :: x(ixi^s,1:ndim)
238 double precision,
intent(in) :: w(ixi^s,1:nw)
239 double precision,
intent(out):: res(ixi^s)
241 double precision :: pth, rfac
244 {
do ix^db=ixomin^db,ixomax^db\}
246 res(ix^d), pth, rfac)
248 end subroutine get_temperature_from_eint_pi
260 double precision,
intent(in) :: rho, eint
261 double precision,
intent(out) :: t, p, rfactor
262 double precision,
intent(out),
optional :: iz_h, iz_he
264 if (eos%type_id /= eos_type_pi)
call mpistop( &
265 "state_from_eint_PI called outside eos_type='PI'")
266 call ionization_get_state_from_eint(rho, eint, eos%inv_gamma_minus_1, &
267 t, p, rfactor, iz_h, iz_he)
272 double precision,
intent(in) :: rho, t
273 double precision,
intent(out) :: p, eint, rfactor
274 double precision,
intent(out),
optional :: iz_h, iz_he
276 if (eos%type_id /= eos_type_pi)
call mpistop( &
277 "p_eint_from_rho_T_PI called outside eos_type='PI'")
278 call ionization_get_p_eint_from_rho_t(rho, t, eos%inv_gamma_minus_1, &
279 p, eint, rfactor, iz_h, iz_he)
285 double precision,
intent(in) :: rho, p
286 double precision,
intent(out) :: eint
287 double precision :: t, pcheck, rfactor
289 if (eos%type_id /= eos_type_pi)
call mpistop( &
290 "eint_from_rho_p_PI called outside eos_type='PI'")
291 call ionization_get_state_scalar(rho, p, t, rfactor)
292 call ionization_get_p_eint_from_rho_t(rho, t, eos%inv_gamma_minus_1, &
293 pcheck, eint, rfactor)
298 double precision,
intent(in) :: rho, p
299 double precision,
intent(out) :: csound2
300 double precision :: t, rfactor
302 if (eos%type_id /= eos_type_pi)
call mpistop( &
303 "csound2_prim_PI called outside eos_type='PI'")
304 call ionization_get_state_scalar(rho, p, t, rfactor)
305 call ionization_get_csound2_t(t, eos%inv_gamma_minus_1, csound2)
315 double precision,
intent(in) :: log_nh, log_t
316 double precision :: p, rfactor
321 double precision function p2eint_pi(log_nH, log_p_nH)
result(factor)
322 double precision,
intent(in) :: log_nh, log_p_nh
323 double precision :: p, eint
331 double precision,
intent(in) :: log_nh, log_eint_nh
332 double precision :: p, rfactor
340 double precision,
intent(in) :: log_nh, log_eint_nh
341 double precision :: t, p, rfactor, iz_h, iz_he
343 y = iz_h + eos%He_abundance*iz_he*(1.d0+iz_he)
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
EoS state container – the single thermodynamic authority for AMRVAC.
integer, parameter, public eos_type_pi
type(eos_container), allocatable, public eos
The single EoS state object, allocated in eos_init and shared (read-mostly) across all EoS sub-module...
FI (fully-ionised, constant-gamma) EoS kernels for the eos% family.
subroutine, public get_temperature_from_pressure_fi(w, x, ixil, ixol, res)
FI temperature from primitive pressure: T = p / (R * rho). w is PRIMITIVE here, so iw_e holds the the...
subroutine, public get_temperature_from_eint_fi(w, x, ixil, ixol, res)
Temperature from internal energy, fully-ionised ideal gas: T = pth/(rho*R).
PI (partial-ionisation) ionisation-degree backend for the eos% family.
subroutine, public ionization_degree_init(he_abundance, rfactor_norm, table_name, include_energy)
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).
subroutine, public eos_finalise_pi()
PI arm of eos_finalise (after unit_* are set): ride FI's ideal-gas getter set and RR=1 normalisation ...
subroutine, public csound2_prim_pi(rho, p, csound2)
Adiabatic sound speed squared from primitive (rho, p).
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 eos_init_pi()
Lifecycle (PI arms of the eos_init / eos_finalise dispatchers). The eos% block getters (update_eos_PI...
subroutine, public p_eint_from_rho_t_pi(rho, t, p, eint, rfactor, iz_h, iz_he)
Temperature -> thermal pressure and GAS internal energy (incl. ion energy).
subroutine, public get_gamma1_pi(w, x, ixil, ixol, gamma1)
Effective Gamma1 = cs2 * rho / p for the same primitive state.
subroutine, public eint_from_rho_p_pi(rho, p, eint)
Primitive pressure -> GAS internal energy (prim -> conserved direction): invert (rho,...
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.
subroutine, public state_from_eint_pi(rho, eint, t, p, rfactor, iz_h, iz_he)
Conserved gas internal energy -> temperature, thermal pressure, R. Inverse of p_eint_from_rho_T_PI....
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer mype
The rank of the current MPI task.
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_get_ei), pointer phys_get_ei