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!=============================================================================
13 use mod_timing
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)
73
74 !> No timing here: get_thermal_pressure is already timed.
75 !> The division and Rfactor call are trivial.
76 call eos%get_thermal_pressure(w, x, ixi^l, ixo^l, pth)
77 call eos%get_Rfactor(w,x,ixi^l,ixo^l,rfactor)
78 t(ixo^s) = pth(ixo^s) / (w(ixo^s,iw_rho) * rfactor(ixo^s))
79
80 end subroutine get_te_fi
81
82 !> Temperature from internal energy, fully-ionised ideal gas: T = pth/(rho*R).
83 subroutine get_temperature_from_eint_fi(w, x, ixI^L, ixO^L, res)
84 !> Assumes input energy is internal energy
85 use mod_physics
86 integer, intent(in) :: ixi^l,ixo^l
87 double precision, intent(in) :: x(ixi^s,1:ndim)
88 double precision, intent(in) :: w(ixi^s,1:nw)
89 double precision, intent(out) :: res(ixi^s)
90
91 double precision :: rfactor(ixi^s)
92
93 timeeos0 = mpi_wtime()
94
95 call eos%get_Rfactor(w,x,ixi^l,ixo^l,rfactor)
96 res(ixo^s) = (eos%gamma_minus_1 * w(ixo^s,iw_e) / (rfactor(ixo^s) * w(ixo^s,iw_rho))) !> pth/rho
97
99 end subroutine get_temperature_from_eint_fi
100
101 !> FI temperature from primitive pressure: T = p / (R * rho).
102 !> w is PRIMITIVE here, so iw_e holds the thermal pressure. Lives in the EoS
103 !> so hd and mhd share one routine (replaces the orphaned, never-called
104 !> hd_get_temperature_from_prim that used to sit in mod_hd_phys).
105 subroutine get_temperature_from_pressure_fi(w, x, ixI^L, ixO^L, res)
106 integer, intent(in) :: ixi^l, ixo^l
107 double precision, intent(in) :: x(ixi^s,1:ndim)
108 double precision, intent(in) :: w(ixi^s,1:nw)
109 double precision, intent(out) :: res(ixi^s)
110
111 double precision :: rfactor(ixi^s)
112
113 call eos%get_Rfactor(w, x, ixi^l, ixo^l, rfactor)
114 res(ixo^s) = w(ixo^s,iw_e) / (rfactor(ixo^s) * w(ixo^s,iw_rho))
116
117end 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:106
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:84
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer, parameter ndim
Number of spatial dimensions for grid variables.
This module defines the procedures of a physics module. It contains function pointers for the various...
Definition mod_physics.t:4
double precision timeeos0
Definition mod_timing.t:10
double precision timeeos_tfromei
Definition mod_timing.t:15