MPI-AMRVAC 3.2
The MPI - Adaptive Mesh Refinement - Versatile Advection Code (development version)
Loading...
Searching...
No Matches
mod_eos_fi.t
Go to the documentation of this file.
1!=============================================================================
2!> FI (fully-ionised, constant-gamma) EoS kernels for the eos% family.
3!>
4!> Carved out of mod_eos.t (the per-type split). The fully-ionised ideal gas:
5!> p = (gamma-1) eint, constant Gamma_1 = gamma, temperature T = p/(R rho) with
6!> R the constant ionisation R-factor. update_eos is a no-op (nothing cached).
7!> mod_eos re-exports the public names so existing `use mod_eos` callers are
8!> unaffected; eos_finalise wires these as the FI pointer targets.
9!=============================================================================
14
15 implicit none
16 private
17
18 !> get_Te_FI is PRIVATE: bound to eos%get_Te inside eos_finalise_FI only.
19 !> The rest stay public: update_eos_FI (ffhd_phys), get_gamma1_FI (the seam
20 !> phys_get_gamma1), get_temperature_from_{eint,pressure}_FI (reused by
21 !> mod_eos_pi), and the init/finalise dispatcher arms.
22 public :: update_eos_fi
23 public :: get_gamma1_fi
26 public :: eos_init_fi
27 public :: eos_finalise_fi
28
29contains
30
31 !> FI arm of eos_init (before units are known): wire the FI
32 !> temperature-from-pressure getter, which must be live before
33 !> (m)hd_link_eos captures it into the radiation fluid object.
34 subroutine eos_init_fi()
35 eos%get_temperature_from_pressure => get_temperature_from_pressure_fi
36 end subroutine eos_init_fi
37
38 !> FI arm of eos_finalise: wire the ideal-gas getter set and the fully-ionised
39 !> particle counts (2 + 3*A_He per H; ne/nH = 1 + 2*A_He). No tables to load.
40 subroutine eos_finalise_fi()
41 eos%update_eos => update_eos_fi !> nothing cached for ideal gas
42 eos%get_temperature_from_eint => get_temperature_from_eint_fi
43 eos%get_Te => get_te_fi
44 eos%n_per_nH_FI = 2.0d0 + 3.0d0 * eos%He_abundance
45 eos%neOnH_FI = 1.0d0 + 2.0d0 * eos%He_abundance
46 end subroutine eos_finalise_fi
47
48 !> FI update_eos: nothing to cache for an ideal gas. Called each RK substep.
49 subroutine update_eos_fi(ixI^L, ixO^L, w, x)
50 integer, intent(in) :: ixi^l,ixo^l
51 double precision, intent(in) :: x(ixi^s,1:ndim)
52 double precision, intent(inout) :: w(ixi^s,1:nw)
53 end subroutine update_eos_fi
54
55 !> Gamma_1 for the fully-ionised ideal gas: constant eos%gamma.
56 subroutine get_gamma1_fi(w, x, ixI^L, ixO^L, gamma1)
57 integer, intent(in) :: ixi^l, ixo^l
58 double precision, intent(in) :: w(ixi^s, nw)
59 double precision, intent(in) :: x(ixi^s, 1:ndim)
60 double precision, intent(out) :: gamma1(ixi^s)
61
62 gamma1(ixo^s) = eos%gamma
63
64 end subroutine get_gamma1_fi
65
66 !> Cached-Te accessor for FI: T = pth/(rho*R) (no stored Te_; recompute).
67 subroutine get_te_fi(w,x,ixI^L,ixO^L,T)
68 integer, intent(in) :: ixi^l, ixo^l
69 double precision, intent(in) :: w(ixi^s,1:nw)
70 double precision, intent(in) :: x(ixi^s,1:ndim)
71 double precision, intent(out) :: t(ixi^s)
72 double precision :: rfactor(ixi^s), pth(ixi^s), rho(ixi^s)
73
74 !> No timing here: get_thermal_pressure is already timed.
75 !> The division and Rfactor call are trivial.
76 !> get_thermal_pressure already returns the total pressure under
77 !> equilibrium splitting, so only the density needs the background.
78 call eos%get_thermal_pressure(w, x, ixi^l, ixo^l, pth)
79 call eos%get_Rfactor(w,x,ixi^l,ixo^l,rfactor)
80 call get_rho(w,x,ixi^l,ixo^l,rho)
81 t(ixo^s) = pth(ixo^s) / (rho(ixo^s) * rfactor(ixo^s))
82
83 end subroutine get_te_fi
84
85 !> Temperature from internal energy, fully-ionised ideal gas: T = pth/(rho*R).
86 subroutine get_temperature_from_eint_fi(w, x, ixI^L, ixO^L, res)
87 !> Assumes input energy is internal energy
88 use mod_physics
89 integer, intent(in) :: ixi^l,ixo^l
90 double precision, intent(in) :: x(ixi^s,1:ndim)
91 double precision, intent(in) :: w(ixi^s,1:nw)
92 double precision, intent(out) :: res(ixi^s)
93
94 double precision :: rfactor(ixi^s), rho(ixi^s), pth(ixi^s)
95
96 call eos%get_Rfactor(w,x,ixi^l,ixo^l,rfactor)
97 call get_rho(w,x,ixi^l,ixo^l,rho)
98 !> Under equilibrium splitting the e slot holds the perturbation internal
99 !> energy, so the background pressure is added back to recover the total.
100 pth(ixo^s) = eos%gamma_minus_1 * w(ixo^s,iw_e)
101 if (iw_equi_p > 0) pth(ixo^s) = pth(ixo^s) &
102 + block%equi_vars(ixo^s,iw_equi_p,b0i)
103 res(ixo^s) = pth(ixo^s) / (rfactor(ixo^s) * rho(ixo^s))
104
105 end subroutine get_temperature_from_eint_fi
106
107 !> FI temperature from primitive pressure: T = p / (R * rho).
108 !> w is PRIMITIVE here, so iw_e holds the thermal pressure. Lives in the EoS
109 !> so hd and mhd share one routine (replaces the orphaned, never-called
110 !> hd_get_temperature_from_prim that used to sit in mod_hd_phys).
111 subroutine get_temperature_from_pressure_fi(w, x, ixI^L, ixO^L, res)
112 integer, intent(in) :: ixi^l, ixo^l
113 double precision, intent(in) :: x(ixi^s,1:ndim)
114 double precision, intent(in) :: w(ixi^s,1:nw)
115 double precision, intent(out) :: res(ixi^s)
116
117 double precision :: rfactor(ixi^s)
118
119 call eos%get_Rfactor(w, x, ixi^l, ixo^l, rfactor)
120 res(ixo^s) = w(ixo^s,iw_e) / (rfactor(ixo^s) * w(ixo^s,iw_rho))
122
123end module mod_eos_fi
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...
FI (fully-ionised, constant-gamma) EoS kernels for the eos% family.
Definition mod_eos_fi.t:10
subroutine, public update_eos_fi(ixil, ixol, w, x)
FI update_eos: nothing to cache for an ideal gas. Called each RK substep.
Definition mod_eos_fi.t:50
subroutine, public get_gamma1_fi(w, x, ixil, ixol, gamma1)
Gamma_1 for the fully-ionised ideal gas: constant eosgamma.
Definition mod_eos_fi.t:57
subroutine, public eos_init_fi()
get_Te_FI is PRIVATE: bound to eosget_Te inside eos_finalise_FI only. The rest stay public: update_eo...
Definition mod_eos_fi.t:35
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...
Definition mod_eos_fi.t:112
subroutine, public eos_finalise_fi()
FI arm of eos_finalise: wire the ideal-gas getter set and the fully-ionised particle counts (2 + 3*A_...
Definition mod_eos_fi.t:41
subroutine, public get_temperature_from_eint_fi(w, x, ixil, ixol, res)
Temperature from internal energy, fully-ionised ideal gas: T = pth/(rho*R).
Definition mod_eos_fi.t:87
Shared EoS accessors (EoS-type-agnostic) for the eos% family.
subroutine, public get_rho(w, x, ixil, ixol, rho)
Mass density (code units).
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.
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer b0i
background magnetic field location indicator
This module defines the procedures of a physics module. It contains function pointers for the various...
Definition mod_physics.t:4