Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions misc/convert_eagle.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
G = const_internal_header["newton_G"][0]
critical_density = 3 * (H**2) / (8 * np.pi * G)
cosmology_header = {
"Cosmological run": 1,
"Omega_b": header.attrs["OmegaBaryon"],
"Omega_m": header.attrs["Omega0"],
"Omega_k": 0,
Expand Down Expand Up @@ -322,6 +323,13 @@
"description": None,
"conversion_factor": None,
},
"SmoothingLength": {
"swift_name": "SmoothingLengths",
"exponents": {"L": 1, "M": 0, "T": 0, "t": 0},
"a_exponent": None,
"description": None,
"conversion_factor": None,
},
"StarFormationRate": {
"swift_name": "StarFormationRates",
"exponents": {"L": 0, "M": 1, "T": 0, "t": -1},
Expand Down Expand Up @@ -560,10 +568,15 @@
"conversion_factor"
] = conversion_factor

# Load DM mass from mass table
# DM mass can be a special case
if "Mass" in properties.get(f"PartType1", {}):
dm_mass = infile["Header"].attrs["MassTable"][1] / h
properties["PartType1"]["Mass"]["conversion_factor"] = dm_mass
if "Mass" not in infile["PartType1"]:
# Load DM mass from mass table
dm_mass = infile["Header"].attrs["MassTable"][1] / h
properties["PartType1"]["Mass"]["conversion_factor"] = dm_mass
else:
# Treat DM mass as any other property
dm_mass = 0

# Get list of elements for ElementMassFractions
if "ElementMassFractions" in properties.get(f"PartType0", {}):
Expand Down Expand Up @@ -661,8 +674,8 @@
if comm_rank == 0:
print(f"Converting PartType{ptype}/{prop}")

# DM particles all have the same mass, so are not saved in the snapshots
if (ptype == 1) and (prop == "Mass"):
if (ptype == 1) and (prop == "Mass") and (dm_mass == 0):
# DM particles all have the same mass, so are not saved in the snapshots
arr = np.ones(pos.shape[0])
else:
# Load data from file and sort according to cell structure
Expand Down
6 changes: 5 additions & 1 deletion scripts/EAGLE.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
# Install Hdecompose with:
# pip install git+ssh://git@github.com/kyleaoman/Hdecompose.git
#
# Download virtual snapshot script with:
# Download virtual snapshot script (to the main SOAP directory) with:
# wget https://gitlab.cosma.dur.ac.uk/swift/swiftsim/-/raw/master/tools/create_virtual_snapshot.py
#
# Submit this script from the main SOAP directory ($ sbatch scripts/EAGLE.sh)

sim_name='L0100N1504'
snap_nr="028"
Expand All @@ -29,6 +31,8 @@ source openmpi-5.0.3-hdf5-1.12.3-env/bin/activate
######## Link files to snap (to remove awful z suffix)

sim_dir="/cosma7/data/Eagle/ScienceRuns/Planck1/${sim_name}/PE/REFERENCE/data"
# Note that if you update the output directory, you will also need to
# update the SOAP parameter file
output_dir="/snap7/scratch/dp004/dc-mcgi1/SOAP_EAGLE/${sim_name}"

sim_snap_dir="${sim_dir}/particledata_${snap_nr}_${z_suffix}"
Expand Down
Loading