From 3f96629c4925cbcf446bfbff3e160ac9e1eab992 Mon Sep 17 00:00:00 2001 From: John ZuHone Date: Wed, 15 Nov 2023 11:24:17 -0500 Subject: [PATCH] Fix problems with EOS detection --- yt/frontends/gamer/cfields.pyx | 16 ++++++++-------- yt/frontends/gamer/fields.py | 8 +++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/yt/frontends/gamer/cfields.pyx b/yt/frontends/gamer/cfields.pyx index 76eb5c75d4a..dcdab90c0fd 100644 --- a/yt/frontends/gamer/cfields.pyx +++ b/yt/frontends/gamer/cfields.pyx @@ -7,7 +7,7 @@ cimport numpy as np import numpy as np -cdef np.float64_t h_eos4(np.float64_t kT, np.float64_t g) noexcept nogil: +cdef np.float64_t h_eos_tb(np.float64_t kT, np.float64_t g) noexcept nogil: cdef np.float64_t x x = 2.25 * kT * kT return 2.5 * kT + x / (1.0 + math.sqrt(x + 1.0)) @@ -18,14 +18,14 @@ cdef np.float64_t h_eos(np.float64_t kT, np.float64_t g) noexcept nogil: cdef np.float64_t gamma_eos(np.float64_t kT, np.float64_t g) noexcept nogil: return g -cdef np.float64_t gamma_eos4(np.float64_t kT, np.float64_t g) noexcept nogil: +cdef np.float64_t gamma_eos_tb(np.float64_t kT, np.float64_t g) noexcept nogil: cdef np.float64_t x, c_p, c_v x = 2.25 * kT / math.sqrt(2.25 * kT * kT + 1.0) c_p = 2.5 + x c_v = 1.5 + x return c_p / c_v -cdef np.float64_t cs_eos4(np.float64_t kT, np.float64_t c, np.float64_t g) noexcept nogil: +cdef np.float64_t cs_eos_tb(np.float64_t kT, np.float64_t c, np.float64_t g) noexcept nogil: cdef np.float64_t hp, cs2 hp = h_eos4(kT, 0.0) + 1.0 cs2 = kT / (3.0 * hp) @@ -52,14 +52,14 @@ cdef class SRHDFields: self._c = clight self._c2 = clight * clight # Select aux functions based on eos no. - if (eos == 4): - self.h = h_eos4 - self.gamma = gamma_eos4 - self.cs = cs_eos4 - else: + if eos == 1: self.h = h_eos self.gamma = gamma_eos self.cs = cs_eos + else: + self.h = h_eos_tb + self.gamma = gamma_eos_tb + self.cs = cs_eos_tb cdef np.float64_t _lorentz_factor( self, diff --git a/yt/frontends/gamer/fields.py b/yt/frontends/gamer/fields.py index fe182886ceb..b5e4ac4a06b 100644 --- a/yt/frontends/gamer/fields.py +++ b/yt/frontends/gamer/fields.py @@ -62,10 +62,12 @@ def setup_fluid_fields(self): if self.ds.srhd: c2 = pc.clight * pc.clight c = pc.clight.in_units("code_length / code_time") - if self.ds.eos == 4: - fgen = SRHDFields(self.ds.eos, 0.0, c.d) - else: + if self.ds.eos == 1: + # gamma-law EOS fgen = SRHDFields(self.ds.eos, self.ds.gamma, c.d) + else: + # Taub-Mathews EOS + fgen = SRHDFields(self.ds.eos, 0.0, c.d) def _sound_speed(field, data): out = fgen.sound_speed(data["gamer", "Temp"].d)