Skip to content

Commit

Permalink
ENH: [ARMVAC] implement variable He abundance (#4937)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordidj authored Jul 3, 2024
1 parent f373558 commit 7ea1dd1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
32 changes: 18 additions & 14 deletions yt/frontends/amrvac/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,8 @@ def __init__(
# note: geometry_override and parfiles are specific to this frontend

self._geometry_override = geometry_override
super().__init__(
filename,
dataset_type,
units_override=units_override,
unit_system=unit_system,
default_species_fields=default_species_fields,
)
self._parfiles = []

self._parfiles = parfiles

namelist = None
namelist_gamma = None
c_adiab = None
e_is_internal = None
if parfiles is not None:
parfiles = list(always_iterable(parfiles))
ppf = Path(parfiles[0])
Expand All @@ -228,7 +216,22 @@ def __init__(
filename,
)
parfiles = [Path(ytcfg["yt", "test_data_dir"]) / pf for pf in parfiles]
self._parfiles = parfiles

super().__init__(
filename,
dataset_type,
units_override=units_override,
unit_system=unit_system,
default_species_fields=default_species_fields,
)

namelist = None
namelist_gamma = None
c_adiab = None
e_is_internal = None

if parfiles is not None:
namelist = read_amrvac_namelist(parfiles)
if "hd_list" in namelist:
c_adiab = namelist["hd_list"].get("hd_adiab", 1.0)
Expand Down Expand Up @@ -373,10 +376,11 @@ def _set_code_unit_attributes(self):

# note: yt sets hydrogen mass equal to proton mass, amrvac doesn't.
mp_cgs = self.quan(1.672621898e-24, "g") # This value is taken from AstroPy
He_abundance = 0.1 # hardcoded parameter in AMRVAC

# get self.length_unit if overrides are supplied, otherwise use default
length_unit = getattr(self, "length_unit", self.quan(1, "cm"))
namelist = read_amrvac_namelist(self._parfiles)
He_abundance = namelist.get("mhd_list", {}).get("he_abundance", 0.1)

# 1. calculations for mass, density, numberdensity
if "mass_unit" in self.units_override:
Expand Down
3 changes: 3 additions & 0 deletions yt/frontends/amrvac/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def read_amrvac_namelist(parfiles):
for nml in namelists:
unified_namelist.patch(nml)

if "filelist" not in unified_namelist:
return unified_namelist

# accumulate `&filelist:base_filename`
base_filename = "".join(
nml.get("filelist", {}).get("base_filename", "") for nml in namelists
Expand Down

0 comments on commit 7ea1dd1

Please sign in to comment.