Skip to content

Commit

Permalink
Fix problems with EOS detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jzuhone committed Nov 15, 2023
1 parent 788241b commit 3f96629
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 8 additions & 8 deletions yt/frontends/gamer/cfields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand All @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions yt/frontends/gamer/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3f96629

Please sign in to comment.