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 use mod_timing
15
16 implicit none
17 private
18
19 !> get_Te_FI is PRIVATE: bound to eos%get_Te inside eos_finalise_FI only.
20 !> The rest stay public: update_eos_FI (ffhd_phys), get_gamma1_FI (the seam
21 !> phys_get_gamma1), get_temperature_from_{eint,pressure}_FI (reused by
22 !> mod_eos_PI), and the init/finalise dispatcher arms.
23 public :: update_eos_fi
24 public :: get_gamma1_fi
27 public :: eos_init_fi
28 public :: eos_finalise_fi
29
30contains
31
32 !> FI arm of eos_init (before units are known): wire the FI
33 !> temperature-from-pressure getter, which must be live before
34 !> (m)hd_link_eos captures it into the radiation fluid object.
35 subroutine eos_init_fi()
36 eos%get_temperature_from_pressure => get_temperature_from_pressure_fi
37 end subroutine eos_init_fi
38
39 !> FI arm of eos_finalise: wire the ideal-gas getter set and the fully-ionised
40 !> particle counts (2 + 3*A_He per H; ne/nH = 1 + 2*A_He). No tables to load.
41 subroutine eos_finalise_fi()
42 eos%update_eos => update_eos_fi !> nothing cached for ideal gas
43 eos%get_temperature_from_eint => get_temperature_from_eint_fi
44 eos%get_Te => get_te_fi
45 eos%n_per_nH_FI = 2.0d0 + 3.0d0 * eos%He_abundance
46 eos%neOnH_FI = 1.0d0 + 2.0d0 * eos%He_abundance
47 end subroutine eos_finalise_fi
48
49 !> FI update_eos: nothing to cache for an ideal gas. Called each RK substep.
50 subroutine update_eos_fi(ixI^L, ixO^L, w, x)
51 integer, intent(in) :: ixi^l,ixo^l
52 double precision, intent(in) :: x(ixi^s,1:ndim)
53 double precision, intent(inout) :: w(ixi^s,1:nw)
54 end subroutine update_eos_fi
55
56 !> Gamma_1 for the fully-ionised ideal gas: constant eos%gamma.
57 subroutine get_gamma1_fi(w, x, ixI^L, ixO^L, gamma1)
58 integer, intent(in) :: ixi^l, ixo^l
59 double precision, intent(in) :: w(ixi^s, nw)
60 double precision, intent(in) :: x(ixi^s, 1:ndim)
61 double precision, intent(out) :: gamma1(ixi^s)
62
63 gamma1(ixo^s) = eos%gamma
64
65 end subroutine get_gamma1_fi
66
67 !> Cached-Te accessor for FI: T = pth/(rho*R) (no stored Te_; recompute).
68 subroutine get_te_fi(w,x,ixI^L,ixO^L,T)
69 integer, intent(in) :: ixi^l, ixo^l
70 double precision, intent(in) :: w(ixi^s,1:nw)
71 double precision, intent(in) :: x(ixi^s,1:ndim)
72 double precision, intent(out) :: t(ixi^s)
73 double precision :: rfactor(ixi^s), pth(ixi^s), rho(ixi^s)
74
75 !> No timing here: get_thermal_pressure is already timed.
76 !> The division and Rfactor call are trivial.
77 !> get_thermal_pressure already returns the total pressure under
78 !> equilibrium splitting, so only the density needs the background.
79 call eos%get_thermal_pressure(w, x, ixi^l, ixo^l, pth)
80 call eos%get_Rfactor(w,x,ixi^l,ixo^l,rfactor)
81 call get_rho(w,x,ixi^l,ixo^l,rho)
82 t(ixo^s) = pth(ixo^s) / (rho(ixo^s) * rfactor(ixo^s))
83
84 end subroutine get_te_fi
85
86 !> Temperature from internal energy, fully-ionised ideal gas: T = pth/(rho*R).
87 subroutine get_temperature_from_eint_fi(w, x, ixI^L, ixO^L, res)
88 !> Assumes input energy is internal energy
89 use mod_physics
90 integer, intent(in) :: ixi^l,ixo^l
91 double precision, intent(in) :: x(ixi^s,1:ndim)
92 double precision, intent(in) :: w(ixi^s,1:nw)
93 double precision, intent(out) :: res(ixi^s)
94
95 double precision :: rfactor(ixi^s), rho(ixi^s), pth(ixi^s)
96
97 timeeos0 = mpi_wtime()
98
99 call eos%get_Rfactor(w,x,ixi^l,ixo^l,rfactor)
100 call get_rho(w,x,ixi^l,ixo^l,rho)
101 !> Under equilibrium splitting the e slot holds the perturbation internal
102 !> energy, so the background pressure is added back to recover the total.
103 pth(ixo^s) = eos%gamma_minus_1 * w(ixo^s,iw_e)
104 if (iw_equi_p > 0) pth(ixo^s) = pth(ixo^s) &
105 + block%equi_vars(ixo^s,iw_equi_p,b0i)
106 res(ixo^s) = pth(ixo^s) / (rfactor(ixo^s) * rho(ixo^s))
107
109 end subroutine get_temperature_from_eint_fi
110
111 !> FI temperature from primitive pressure: T = p / (R * rho).
112 !> w is PRIMITIVE here, so iw_e holds the thermal pressure. Lives in the EoS
113 !> so hd and mhd share one routine (replaces the orphaned, never-called
114 !> hd_get_temperature_from_prim that used to sit in mod_hd_phys).
115 subroutine get_temperature_from_pressure_fi(w, x, ixI^L, ixO^L, res)
116 integer, intent(in) :: ixi^l, ixo^l
117 double precision, intent(in) :: x(ixi^s,1:ndim)
118 double precision, intent(in) :: w(ixi^s,1:nw)
119 double precision, intent(out) :: res(ixi^s)
120
121 double precision :: rfactor(ixi^s)
122
123 call eos%get_Rfactor(w, x, ixi^l, ixo^l, rfactor)
124 res(ixo^s) = w(ixo^s,iw_e) / (rfactor(ixo^s) * w(ixo^s,iw_rho))
126
127end 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:51
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:58
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:36
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:116
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:42
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:88
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
double precision timeeos0
Definition mod_timing.t:10
double precision timeeos_tfromei
Definition mod_timing.t:15