84 double precision :: rfactor_norm
86 eos%update_eos => update_eos_pi
88 eos%get_Te => get_te_pi
92 if (
eos%pi_table ==
'prominence')
then
93 eos%get_Rfactor => get_rfactor_prominence_pi
95 eos%get_Rfactor => get_rfactor_tonly_pi
98 eos%n_per_nH_FI = 2.0d0 + 3.0d0 *
eos%He_abundance
99 eos%neOnH_FI = 1.0d0 + 2.0d0 *
eos%He_abundance
106 rfactor_norm = 2.0d0 + 3.0d0 *
eos%He_abundance
108 trim(
eos%pi_table), include_energy=
eos%ionE)
109 if (
mype == 0)
write(*,*)
"[eos PI] ionisation backend initialised: table=", &
110 trim(
eos%pi_table),
" ionE=",
eos%ionE,
" Rfactor_norm=", rfactor_norm
116 eos%get_temperature_from_eint => get_temperature_from_eint_pi
117 eos%get_csound2 => get_csound2_pi
129 subroutine get_csound2_pi(w, x, ixI^L, ixO^L, cs2)
130 integer,
intent(in) :: ixi^l, ixo^l
131 double precision,
intent(in) :: w(ixi^s, nw)
132 double precision,
intent(in) :: x(ixi^s, 1:ndim)
133 double precision,
intent(out):: cs2(ixi^s)
138 {
do ix^db=ixomin^db,ixomax^db\}
142 end subroutine get_csound2_pi
146 integer,
intent(in) :: ixi^l, ixo^l
147 double precision,
intent(in) :: w(ixi^s, nw)
148 double precision,
intent(in) :: x(ixi^s, 1:ndim)
149 double precision,
intent(out):: gamma1(ixi^s)
151 double precision :: cs2
154 {
do ix^db=ixomin^db,ixomax^db\}
156 gamma1(ix^d) = cs2 * w(ix^d,iw_rho) / w(ix^d,iw_e)
163 subroutine get_rfactor_tonly_pi(w, x, ixI^L, ixO^L, Rfactor)
164 integer,
intent(in) :: ixi^l, ixo^l
165 double precision,
intent(in) :: w(ixi^s,1:nw)
166 double precision,
intent(in) :: x(ixi^s,1:ndim)
167 double precision,
intent(out):: rfactor(ixi^s)
168 double precision :: iz_h(ixo^s), iz_he(ixo^s)
170 call ionization_degree_from_temperature(ixi^l,ixo^l,w(ixi^s,iw_te),iz_h,iz_he)
171 rfactor(ixo^s) = (1.d0 + iz_h(ixo^s) + eos%He_abundance &
172 * (1.d0 + iz_he(ixo^s)*(1.d0+iz_he(ixo^s)))) / (2.d0 + 3.d0*eos%He_abundance)
173 end subroutine get_rfactor_tonly_pi
177 subroutine get_rfactor_prominence_pi(w, x, ixI^L, ixO^L, Rfactor)
179 integer,
intent(in) :: ixi^l, ixo^l
180 double precision,
intent(in) :: w(ixi^s,1:nw)
181 double precision,
intent(in) :: x(ixi^s,1:ndim)
182 double precision,
intent(out):: rfactor(ixi^s)
183 double precision :: ei(ixi^s), pth(ixi^s), rho(ixi^s), t(ixi^s)
186 pth(ixo^s) = eos%gamma_minus_1 * ei(ixo^s)
187 rho(ixo^s) = w(ixo^s,iw_rho)
188 call ionization_get_state(ixi^l, ixo^l, rho, pth, t, rfactor)
189 end subroutine get_rfactor_prominence_pi
197 subroutine refresh_te_pi(ixI^L, ixO^L, w, x)
199 integer,
intent(in) :: ixi^l, ixo^l
200 double precision,
intent(in) :: x(ixi^s,1:ndim)
201 double precision,
intent(inout) :: w(ixi^s,1:nw)
202 double precision :: ei(ixi^s), pth(ixi^s), rho(ixi^s), t(ixi^s), rf(ixi^s)
203 double precision :: tsc, psc, rsc
210 {
do ix^db=ixomin^db,ixomax^db\}
217 pth(ixo^s) = eos%gamma_minus_1 * ei(ixo^s)
218 rho(ixo^s) = w(ixo^s,iw_rho)
219 call ionization_get_state(ixi^l, ixo^l, rho, pth, t, rf)
220 w(ixo^s,iw_te) = t(ixo^s)
222 end subroutine refresh_te_pi
226 subroutine update_eos_pi(ixI^L, ixO^L, w, x)
227 integer,
intent(in) :: ixi^l, ixo^l
228 double precision,
intent(in) :: x(ixi^s,1:ndim)
229 double precision,
intent(inout) :: w(ixi^s,1:nw)
230 call refresh_te_pi(ixi^l, ixo^l, w, x)
231 end subroutine update_eos_pi
235 subroutine get_te_pi(w, x, ixI^L, ixO^L, T)
236 integer,
intent(in) :: ixi^l, ixo^l
237 double precision,
intent(in) :: w(ixi^s,1:nw)
238 double precision,
intent(in) :: x(ixi^s,1:ndim)
239 double precision,
intent(out) :: t(ixi^s)
240 t(ixo^s) = w(ixo^s,iw_te)
241 end subroutine get_te_pi
247 subroutine get_temperature_from_eint_pi(w, x, ixI^L, ixO^L, res)
248 integer,
intent(in) :: ixi^l, ixo^l
249 double precision,
intent(in) :: x(ixi^s,1:ndim)
250 double precision,
intent(in) :: w(ixi^s,1:nw)
251 double precision,
intent(out):: res(ixi^s)
253 double precision :: pth, rfac
256 timeeos0 = mpi_wtime()
257 {
do ix^db=ixomin^db,ixomax^db\}
259 res(ix^d), pth, rfac)
261 timeeos_tfromei=timeeos_tfromei+(mpi_wtime()-timeeos0)
262 end subroutine get_temperature_from_eint_pi
274 double precision,
intent(in) :: rho, eint
275 double precision,
intent(out) :: t, p, rfactor
276 double precision,
intent(out),
optional :: iz_h, iz_he
278 if (eos%type_id /= eos_type_pi)
call mpistop( &
279 "state_from_eint_PI called outside eos_type='PI'")
280 call ionization_get_state_from_eint(rho, eint, eos%inv_gamma_minus_1, &
281 t, p, rfactor, iz_h, iz_he)
286 double precision,
intent(in) :: rho, t
287 double precision,
intent(out) :: p, eint, rfactor
288 double precision,
intent(out),
optional :: iz_h, iz_he
290 if (eos%type_id /= eos_type_pi)
call mpistop( &
291 "p_eint_from_rho_T_PI called outside eos_type='PI'")
292 call ionization_get_p_eint_from_rho_t(rho, t, eos%inv_gamma_minus_1, &
293 p, eint, rfactor, iz_h, iz_he)
299 double precision,
intent(in) :: rho, p
300 double precision,
intent(out) :: eint
301 double precision :: t, pcheck, rfactor
303 if (eos%type_id /= eos_type_pi)
call mpistop( &
304 "eint_from_rho_p_PI called outside eos_type='PI'")
305 call ionization_get_state_scalar(rho, p, t, rfactor)
306 call ionization_get_p_eint_from_rho_t(rho, t, eos%inv_gamma_minus_1, &
307 pcheck, eint, rfactor)
312 double precision,
intent(in) :: rho, p
313 double precision,
intent(out) :: csound2
314 double precision :: t, rfactor
316 if (eos%type_id /= eos_type_pi)
call mpistop( &
317 "csound2_prim_PI called outside eos_type='PI'")
318 call ionization_get_state_scalar(rho, p, t, rfactor)
319 call ionization_get_csound2_t(t, eos%inv_gamma_minus_1, csound2)
329 double precision,
intent(in) :: log_nh, log_t
330 double precision :: p, rfactor
335 double precision function p2eint_pi(log_nH, log_p_nH)
result(factor)
336 double precision,
intent(in) :: log_nh, log_p_nh
337 double precision :: p, eint
345 double precision,
intent(in) :: log_nh, log_eint_nh
346 double precision :: p, rfactor
354 double precision,
intent(in) :: log_nh, log_eint_nh
355 double precision :: t, p, rfactor, iz_h, iz_he
357 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
double precision timeeos0
double precision timeeos_csound