Make derived fields in yt for simulations run with the RAMSES-RTZ code. Specifically, the MEGATRON Simulation.
The functionality is ever-expanding, here are a few examples of what is currently available:
- Electron number density
- Mean molecular weight
- Metallicity
- H2 cooling (two different models)
- Full metal cooling
- Correct star particle ages
- Filters for Pop. II and Pop. III stars
- Boolean field that calculates whether a Pop. III star is still alive
- Energy density of the radiation field for each frequency bin
- Emission line module for collisional and recombination lines in the optical and UV (requires atomic data generated by the chianti package, see below)
- Nebular and stellar continuum spectra (requires data on glamdring, see below)
- INCOMING: Corrections for unresolved stromgren spheres.
- INCOMING: Ability to generate IFU spectra using bins of cells.
-
Install yt: Since the changes to YT can be very specific to the MEGATRON simulation, it is recommended to use a branch of yt that has been modified for this purpose. The branch
yt_megatronon Anatole Storck's yt fork in GitHub contains the necessary changes.git clone https://github.com/AnatoleStorck/yt.git cd yt git switch yt_megatron pip install -e .
-
Clone and install this repository and copy TOML specific to MEGATRON for global yt configuration. If you don't want to make the configuration global, you can also copy the
yt.tomlfile to the current working directory.git clone https://github.com/AnatoleStorck/yt_derived_fields.git cd yt_derived_fields pip install -e .
cp yt_derived_fields/megatron_derived_fields/yt.toml ~/.config/yt/. -
Use the derived field functions: Generate new fields to be used with various yt functions. Chemistry fields include the electron number density, mean molecular weight, molecular hydrogen number density, and others. Cooling includes two H2 cooling fields, full metal cooling, and others. Star derived fields include a proper way to derive the star particle ages.
import yt import pandas as pd import yt_derived_fields.megatron_derived_fields.chemistry_derived_fields as chem_fields import yt_derived_fields.megatron_derived_fields.cooling_derived_fields as cool_fields import yt_derived_fields.megatron_derived_fields.stars_derived_fields as star_fields ds = yt.load(<path_to_your_favorite_megatron_output>) hc = pd.read_csv(<path_to_your_halo_catalog_in_pandas_format>) chem_fields.create_chemistry_derived_fields(ds, molecules=True, electron_number_density=True, mean_molecular_weight=False) cool_fields.create_cooling_derived_fields(ds, H2_cooling="moseley") star_fields.create_stars_derived_fields(ds) some_halo = hc[hc["id"] == 42] halo_sphere = ds.sphere(([some_halo.x, some_halo.y, some_halo.z], "Mpccm/h"), (some_halo.r200b, "kpccm/h")) # An example field from each module halo_sphere["gas", "electron_number_density"] halo_sphere["gas", "cooling_H2"] halo_sphere["pop3", "isAlive"]
-
Generate atomic data for observational derived fields (On glamdring, this is currently found in
/mnt/glacier/chianti/, so no need to create a new database): The emission line module requires atomic data generated by the chianti package. Once a chianti database is generated (https://www.chiantidatabase.org/chianti_download.html), you can use thespectral_utils/generate_atomic_data.pyscript to generate the atomic data for the emission line module (make sure to replace the path at the top of the file to the database). Then you can use the emission line module as follows.import yt import pandas as pd import yt_derived_fields.megatron_derived_fields.emission_derived_fields as emiss_fields ds = yt.load(<path_to_your_favorite_megatron_output>) hc = pd.read_csv(<path_to_your_halo_catalog_in_pandas_format>) coll_lines = ["O3-5007", "S2-6731"] rec_lines = ["Lya", "Hb", "He-1640"] emiss_fields.get_emission_lines(ds, coll_lines=coll_lines, rec_lines=rec_lines) some_halo = hc[hc["id"] == 42] halo_sphere = ds.sphere(([some_halo.x, some_halo.y, some_halo.z], "Mpccm/h"), (some_halo.r200b, "kpccm/h")) # The O3-5007 luminosity in every cell of the sphere halo_sphere["gas", "O3-5007_luminosity"]
-
More observational derived fields for continuum spectra (nebular and stellar): The nebular and stellar continuum modules require data to compute the spectra. On glamdring, these can be found in
/mnt/glacier/DATA/.import yt import pandas as pd import yt_derived_fields.megatron_derived_fields.nebular_continuum_fields as neb_fields import yt_derived_fields.megatron_derived_fields.stellar_continuum_fields as stellar_spec_fields ds = yt.load(<path_to_your_favorite_megatron_output>) hc = pd.read_csv(<path_to_your_halo_catalog_in_pandas_format>) neb_fields.get_nebular_continuum(ds) stellar_spec_fields.get_stellar_continuum(ds) some_halo = hc[hc["id"] == 42] halo_sphere = ds.sphere(([some_halo.x, some_halo.y, some_halo.z], "Mpccm/h"), (some_halo.r200b, "kpccm/h")) # The two continuum processes as spectra in every cell of the sphere halo_sphere["gas", "nebc_resolved_recomb"] halo_sphere["gas", "nebc_resolved_two_photon"] # The pop2 stellar continuum (not per cell [YET], summed across the sphere) halo_sphere["gas", "pop2_spectra"] # One can then generate a full single spectra of the halo by summing the spectra in every cell for the nebular continuum and all emission lines, along with the stellar continuum.