From 903f845a7fc0a8735e35c45c6a8d28b70a48a484 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Thu, 3 Jan 2019 15:10:06 +0100 Subject: [PATCH] Naming convention improvements in the EAGLE cooling section of the YAML file. Code formatting. --- doc/RTD/source/SubgridModels/EAGLE/index.rst | 62 +++++++++---------- examples/CoolingBox/coolingBox.yml | 22 +++---- examples/CoolingRates/cooling_rates.yml | 20 +++--- examples/EAGLE_12/eagle_12.yml | 22 +++---- examples/EAGLE_25/eagle_25.yml | 24 +++---- examples/EAGLE_50/eagle_50.yml | 24 +++---- examples/EAGLE_6/eagle_6.yml | 22 +++---- examples/SantaBarbara/santa_barbara.yml | 21 ++++--- .../small_cosmo_volume.yml | 20 +++--- examples/parameter_example.yml | 20 +++--- src/chemistry/EAGLE/chemistry.h | 5 +- src/cooling/EAGLE/cooling.c | 6 +- 12 files changed, 134 insertions(+), 134 deletions(-) diff --git a/doc/RTD/source/SubgridModels/EAGLE/index.rst b/doc/RTD/source/SubgridModels/EAGLE/index.rst index a5687efb8a..6388f7d3d4 100644 --- a/doc/RTD/source/SubgridModels/EAGLE/index.rst +++ b/doc/RTD/source/SubgridModels/EAGLE/index.rst @@ -98,32 +98,30 @@ In the snapshots, we output for each gas and star particle: | | | smoothed over SPH neighbours | | | +----------------------------------+-------------------------------------+-----------+-----------------------------+ -The stars will lose mass over their lifetime (up to ~45%). The -fractions will remain unchanged but if one is interested in computing -an absolute metal mass (say) for a star, the ``InitialMass`` (see -below) of the star must be used. - -The chemistry model only requires a small number of parameters to be -specified in the `EAGLEChemistry` section of the YAML file. These are -the initial values of the metallicity and element mass -fractions. These are then applied at the start of a simulation to -*all* the *gas* particles. All 9 elements have to be specified An -example section, for primordial abundances (typical for a cosmological -run), is: +The stars will lose mass over their lifetime (up to ~45%). The fractions will +remain unchanged but if one is interested in computing an absolute metal mass +(say) for a star, the ``InitialMass`` (see below) of the star must be used. + +The chemistry model only requires a small number of parameters to be specified +in the `EAGLEChemistry` section of the YAML file. These are the initial values +of the metallicity and element mass fractions. These are then applied at the +start of a simulation to *all* the *gas* particles. All 9 traced elements have +to be specified An example section, for primordial abundances (typical for a +cosmological run), is: .. code:: YAML EAGLEChemistry: - Metallicity: 0. # Mass fraction in all metals - InitAbundance_Hydrogen: 0.755 # Mass fraction in Hydrogen - InitAbundance_Helium: 0.245 # Mass fraction in Helium - InitAbundance_Carbon: 0. # Mass fraction in Carbon - InitAbundance_Nitrogen: 0. # Mass fraction in Nitrogen - InitAbundance_Oxygen: 0. # Mass fraction in Oxygen - InitAbundance_Neon: 0. # Mass fraction in Neon - InitAbundance_Magnesium: 0. # Mass fraction in Magnesium - InitAbundance_Silicon: 0. # Mass fraction in Silicon - InitAbundance_Iron: 0. # Mass fraction in Iron + init_abundance_metal: 0. # Mass fraction in *all* metals + init_abundance_Hydrogen: 0.755 # Mass fraction in Hydrogen + init_abundance_Helium: 0.245 # Mass fraction in Helium + init_abundance_Carbon: 0. # Mass fraction in Carbon + init_abundance_Nitrogen: 0. # Mass fraction in Nitrogen + init_abundance_Oxygen: 0. # Mass fraction in Oxygen + init_abundance_Neon: 0. # Mass fraction in Neon + init_abundance_Magnesium: 0. # Mass fraction in Magnesium + init_abundance_Silicon: 0. # Mass fraction in Silicon + init_abundance_Iron: 0. # Mass fraction in Iron Whilst one would use the following values for solar abundances (typical for an idealised low-redshift run): @@ -131,16 +129,16 @@ Whilst one would use the following values for solar abundances .. code:: YAML EAGLEChemistry: - Metallicity: 0.014 # Mass fraction in all metals - InitAbundance_Hydrogen: 0.70649785 # Mass fraction in Hydrogen - InitAbundance_Helium: 0.28055534 # Mass fraction in Helium - InitAbundance_Carbon: 2.0665436e-3 # Mass fraction in Carbon - InitAbundance_Nitrogen: 8.3562563e-4 # Mass fraction in Nitrogen - InitAbundance_Oxygen: 5.4926244e-3 # Mass fraction in Oxygen - InitAbundance_Neon: 1.4144605e-3 # Mass fraction in Neon - InitAbundance_Magnesium: 5.907064e-4 # Mass fraction in Magnesium - InitAbundance_Silicon: 6.825874e-4 # Mass fraction in Silicon - InitAbundance_Iron: 1.1032152e-3 # Mass fraction in Iron + init_abundance_metal: 0.014 # Mass fraction in *all* metals + init_abundance_Hydrogen: 0.70649785 # Mass fraction in Hydrogen + init_abundance_Helium: 0.28055534 # Mass fraction in Helium + init_abundance_Carbon: 2.0665436e-3 # Mass fraction in Carbon + init_abundance_Nitrogen: 8.3562563e-4 # Mass fraction in Nitrogen + init_abundance_Oxygen: 5.4926244e-3 # Mass fraction in Oxygen + init_abundance_Neon: 1.4144605e-3 # Mass fraction in Neon + init_abundance_Magnesium: 5.907064e-4 # Mass fraction in Magnesium + init_abundance_Silicon: 6.825874e-4 # Mass fraction in Silicon + init_abundance_Iron: 1.1032152e-3 # Mass fraction in Iron diff --git a/examples/CoolingBox/coolingBox.yml b/examples/CoolingBox/coolingBox.yml index 785f699bf0..97b452e5ea 100644 --- a/examples/CoolingBox/coolingBox.yml +++ b/examples/CoolingBox/coolingBox.yml @@ -59,17 +59,17 @@ EAGLECooling: He_reion_z_sigma: 0.5 He_reion_eV_p_H: 2.0 -EAGLEChemistry: - InitMetallicity: 0.014 - InitAbundance_Hydrogen: 0.70649785 - InitAbundance_Helium: 0.28055534 - InitAbundance_Carbon: 2.0665436e-3 - InitAbundance_Nitrogen: 8.3562563e-4 - InitAbundance_Oxygen: 5.4926244e-3 - InitAbundance_Neon: 1.4144605e-3 - InitAbundance_Magnesium: 5.907064e-4 - InitAbundance_Silicon: 6.825874e-4 - InitAbundance_Iron: 1.1032152e-3 +EAGLEChemistry: # Solar abundances + init_abundance_metal: 0.014 + init_abundance_Hydrogen: 0.70649785 + init_abundance_Helium: 0.28055534 + init_abundance_Carbon: 2.0665436e-3 + init_abundance_Nitrogen: 8.3562563e-4 + init_abundance_Oxygen: 5.4926244e-3 + init_abundance_Neon: 1.4144605e-3 + init_abundance_Magnesium: 5.907064e-4 + init_abundance_Silicon: 6.825874e-4 + init_abundance_Iron: 1.1032152e-3 GearChemistry: InitialMetallicity: 0.01295 diff --git a/examples/CoolingRates/cooling_rates.yml b/examples/CoolingRates/cooling_rates.yml index 343c24d320..1d67ad0af7 100644 --- a/examples/CoolingRates/cooling_rates.yml +++ b/examples/CoolingRates/cooling_rates.yml @@ -16,16 +16,16 @@ Cosmology: Omega_b: 0.0455 # Baryon density parameter EAGLEChemistry: - InitMetallicity: 0.014 - InitAbundance_Hydrogen: 0.70649785 - InitAbundance_Helium: 0.28055534 - InitAbundance_Carbon: 2.0665436e-3 - InitAbundance_Nitrogen: 8.3562563e-4 - InitAbundance_Oxygen: 5.4926244e-3 - InitAbundance_Neon: 1.4144605e-3 - InitAbundance_Magnesium: 5.907064e-4 - InitAbundance_Silicon: 6.825874e-4 - InitAbundance_Iron: 1.1032152e-3 + init_abundance_metal: 0.014 + init_abundance_Hydrogen: 0.70649785 + init_abundance_Helium: 0.28055534 + init_abundance_Carbon: 2.0665436e-3 + init_abundance_Nitrogen: 8.3562563e-4 + init_abundance_Oxygen: 5.4926244e-3 + init_abundance_Neon: 1.4144605e-3 + init_abundance_Magnesium: 5.907064e-4 + init_abundance_Silicon: 6.825874e-4 + init_abundance_Iron: 1.1032152e-3 EAGLECooling: dir_name: ./coolingtables/ diff --git a/examples/EAGLE_12/eagle_12.yml b/examples/EAGLE_12/eagle_12.yml index 062870a23b..367c5f7697 100644 --- a/examples/EAGLE_12/eagle_12.yml +++ b/examples/EAGLE_12/eagle_12.yml @@ -57,17 +57,17 @@ InitialConditions: cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget -EAGLEChemistry: # Solar abundances - InitMetallicity: 0.014 - InitAbundance_Hydrogen: 0.70649785 - InitAbundance_Helium: 0.28055534 - InitAbundance_Carbon: 2.0665436e-3 - InitAbundance_Nitrogen: 8.3562563e-4 - InitAbundance_Oxygen: 5.4926244e-3 - InitAbundance_Neon: 1.4144605e-3 - InitAbundance_Magnesium: 5.907064e-4 - InitAbundance_Silicon: 6.825874e-4 - InitAbundance_Iron: 1.1032152e-3 +EAGLEChemistry: # Solar abundances + init_abundance_metal: 0.014 + init_abundance_Hydrogen: 0.70649785 + init_abundance_Helium: 0.28055534 + init_abundance_Carbon: 2.0665436e-3 + init_abundance_Nitrogen: 8.3562563e-4 + init_abundance_Oxygen: 5.4926244e-3 + init_abundance_Neon: 1.4144605e-3 + init_abundance_Magnesium: 5.907064e-4 + init_abundance_Silicon: 6.825874e-4 + init_abundance_Iron: 1.1032152e-3 EAGLECooling: dir_name: ./coolingtables/ diff --git a/examples/EAGLE_25/eagle_25.yml b/examples/EAGLE_25/eagle_25.yml index 0edc8bfa1d..0aec970db4 100644 --- a/examples/EAGLE_25/eagle_25.yml +++ b/examples/EAGLE_25/eagle_25.yml @@ -66,18 +66,18 @@ InitialConditions: cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget -EAGLEChemistry: # Solar abundances - InitMetallicity: 0.014 - InitAbundance_Hydrogen: 0.70649785 - InitAbundance_Helium: 0.28055534 - InitAbundance_Carbon: 2.0665436e-3 - InitAbundance_Nitrogen: 8.3562563e-4 - InitAbundance_Oxygen: 5.4926244e-3 - InitAbundance_Neon: 1.4144605e-3 - InitAbundance_Magnesium: 5.907064e-4 - InitAbundance_Silicon: 6.825874e-4 - InitAbundance_Iron: 1.1032152e-3 - +EAGLEChemistry: # Solar abundances + init_abundance_metal: 0.014 + init_abundance_Hydrogen: 0.70649785 + init_abundance_Helium: 0.28055534 + init_abundance_Carbon: 2.0665436e-3 + init_abundance_Nitrogen: 8.3562563e-4 + init_abundance_Oxygen: 5.4926244e-3 + init_abundance_Neon: 1.4144605e-3 + init_abundance_Magnesium: 5.907064e-4 + init_abundance_Silicon: 6.825874e-4 + init_abundance_Iron: 1.1032152e-3 + EAGLECooling: dir_name: ./coolingtables/ H_reion_z: 11.5 diff --git a/examples/EAGLE_50/eagle_50.yml b/examples/EAGLE_50/eagle_50.yml index 56b945a06a..35f7c85993 100644 --- a/examples/EAGLE_50/eagle_50.yml +++ b/examples/EAGLE_50/eagle_50.yml @@ -59,18 +59,18 @@ InitialConditions: cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget -EAGLEChemistry: # Solar abundances - InitMetallicity: 0.014 - InitAbundance_Hydrogen: 0.70649785 - InitAbundance_Helium: 0.28055534 - InitAbundance_Carbon: 2.0665436e-3 - InitAbundance_Nitrogen: 8.3562563e-4 - InitAbundance_Oxygen: 5.4926244e-3 - InitAbundance_Neon: 1.4144605e-3 - InitAbundance_Magnesium: 5.907064e-4 - InitAbundance_Silicon: 6.825874e-4 - InitAbundance_Iron: 1.1032152e-3 - +EAGLEChemistry: # Solar abundances + init_abundance_metal: 0.014 + init_abundance_Hydrogen: 0.70649785 + init_abundance_Helium: 0.28055534 + init_abundance_Carbon: 2.0665436e-3 + init_abundance_Nitrogen: 8.3562563e-4 + init_abundance_Oxygen: 5.4926244e-3 + init_abundance_Neon: 1.4144605e-3 + init_abundance_Magnesium: 5.907064e-4 + init_abundance_Silicon: 6.825874e-4 + init_abundance_Iron: 1.1032152e-3 + EAGLECooling: dir_name: ./coolingtables/ H_reion_z: 11.5 diff --git a/examples/EAGLE_6/eagle_6.yml b/examples/EAGLE_6/eagle_6.yml index af533f5d84..7c64c1cded 100644 --- a/examples/EAGLE_6/eagle_6.yml +++ b/examples/EAGLE_6/eagle_6.yml @@ -70,17 +70,17 @@ InitialConditions: cleanup_h_factors: 1 # Remove the h-factors inherited from Gadget cleanup_velocity_factors: 1 # Remove the sqrt(a) factor in the velocities inherited from Gadget -EAGLEChemistry: # Solar abundances - InitMetallicity: 0.014 - InitAbundance_Hydrogen: 0.70649785 - InitAbundance_Helium: 0.28055534 - InitAbundance_Carbon: 2.0665436e-3 - InitAbundance_Nitrogen: 8.3562563e-4 - InitAbundance_Oxygen: 5.4926244e-3 - InitAbundance_Neon: 1.4144605e-3 - InitAbundance_Magnesium: 5.907064e-4 - InitAbundance_Silicon: 6.825874e-4 - InitAbundance_Iron: 1.1032152e-3 +EAGLEChemistry: # Solar abundances + init_abundance_metal: 0.014 + init_abundance_Hydrogen: 0.70649785 + init_abundance_Helium: 0.28055534 + init_abundance_Carbon: 2.0665436e-3 + init_abundance_Nitrogen: 8.3562563e-4 + init_abundance_Oxygen: 5.4926244e-3 + init_abundance_Neon: 1.4144605e-3 + init_abundance_Magnesium: 5.907064e-4 + init_abundance_Silicon: 6.825874e-4 + init_abundance_Iron: 1.1032152e-3 EAGLECooling: dir_name: ./coolingtables/ diff --git a/examples/SantaBarbara/santa_barbara.yml b/examples/SantaBarbara/santa_barbara.yml index 08cb71d0ce..eb20030e00 100644 --- a/examples/SantaBarbara/santa_barbara.yml +++ b/examples/SantaBarbara/santa_barbara.yml @@ -59,17 +59,18 @@ InitialConditions: generate_gas_in_ics: 1 # Generate gas particles from the DM-only ICs cleanup_smoothing_lengths: 1 # Since we generate gas, make use of the (expensive) cleaning-up procedure. +# Impose primoridal metallicity EAGLEChemistry: - InitMetallicity: 0.0 - InitAbundance_Hydrogen: 0.752 - InitAbundance_Helium: 0.248 - InitAbundance_Carbon: 0.0 - InitAbundance_Nitrogen: 0.0 - InitAbundance_Oxygen: 0.0 - InitAbundance_Neon: 0.0 - InitAbundance_Magnesium: 0.0 - InitAbundance_Silicon: 0.0 - InitAbundance_Iron: 0.0 + init_abundance_metal: 0.0 + init_abundance_Hydrogen: 0.752 + init_abundance_Helium: 0.248 + init_abundance_Carbon: 0.0 + init_abundance_Nitrogen: 0.0 + init_abundance_Oxygen: 0.0 + init_abundance_Neon: 0.0 + init_abundance_Magnesium: 0.0 + init_abundance_Silicon: 0.0 + init_abundance_Iron: 0.0 EAGLECooling: dir_name: ./coolingtables/ diff --git a/examples/SmallCosmoVolume_cooling/small_cosmo_volume.yml b/examples/SmallCosmoVolume_cooling/small_cosmo_volume.yml index 47511f6b40..2d2dec8408 100644 --- a/examples/SmallCosmoVolume_cooling/small_cosmo_volume.yml +++ b/examples/SmallCosmoVolume_cooling/small_cosmo_volume.yml @@ -72,13 +72,13 @@ EAGLECooling: # Impose primoridal metallicity EAGLEChemistry: - InitMetallicity: 0.0 - InitAbundance_Hydrogen: 0.755 - InitAbundance_Helium: 0.245 - InitAbundance_Carbon: 0. - InitAbundance_Nitrogen: 0. - InitAbundance_Oxygen: 0. - InitAbundance_Neon: 0. - InitAbundance_Magnesium: 0. - InitAbundance_Silicon: 0. - InitAbundance_Iron: 0. + init_abundance_metal: 0.0 + init_abundance_Hydrogen: 0.752 + init_abundance_Helium: 0.248 + init_abundance_Carbon: 0.0 + init_abundance_Nitrogen: 0.0 + init_abundance_Oxygen: 0.0 + init_abundance_Neon: 0.0 + init_abundance_Magnesium: 0.0 + init_abundance_Silicon: 0.0 + init_abundance_Iron: 0.0 diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 2b20909b9d..9fdfc993c3 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -276,16 +276,16 @@ GrackleCooling: # EAGLE model EAGLEChemistry: - InitMetallicity: 0. # Inital fraction of particle mass in *all* metals - InitAbundance_Hydrogen: 0.752 # Inital fraction of particle mass in Hydrogen - InitAbundance_Helium: 0.248 # Inital fraction of particle mass in Helium - InitAbundance_Carbon: 0.000 # Inital fraction of particle mass in Carbon - InitAbundance_Nitrogen: 0.000 # Inital fraction of particle mass in Nitrogen - InitAbundance_Oxygen: 0.000 # Inital fraction of particle mass in Oxygen - InitAbundance_Neon: 0.000 # Inital fraction of particle mass in Neon - InitAbundance_Magnesium: 0.000 # Inital fraction of particle mass in Magnesium - InitAbundance_Silicon: 0.000 # Inital fraction of particle mass in Silicon - InitAbundance_Iron: 0.000 # Inital fraction of particle mass in Iron + init_abundance_metal: 0. # Inital fraction of particle mass in *all* metals + init_abundance_Hydrogen: 0.752 # Inital fraction of particle mass in Hydrogen + init_abundance_Helium: 0.248 # Inital fraction of particle mass in Helium + init_abundance_Carbon: 0.000 # Inital fraction of particle mass in Carbon + init_abundance_Nitrogen: 0.000 # Inital fraction of particle mass in Nitrogen + init_abundance_Oxygen: 0.000 # Inital fraction of particle mass in Oxygen + init_abundance_Neon: 0.000 # Inital fraction of particle mass in Neon + init_abundance_Magnesium: 0.000 # Inital fraction of particle mass in Magnesium + init_abundance_Silicon: 0.000 # Inital fraction of particle mass in Silicon + init_abundance_Iron: 0.000 # Inital fraction of particle mass in Iron # Structure finding options (requires velociraptor) StructureFinding: diff --git a/src/chemistry/EAGLE/chemistry.h b/src/chemistry/EAGLE/chemistry.h index 9e9dc3b323..b8a50f237a 100644 --- a/src/chemistry/EAGLE/chemistry.h +++ b/src/chemistry/EAGLE/chemistry.h @@ -154,6 +154,7 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part( if (data->initial_metal_mass_fraction_total != -1) { p->chemistry_data.metal_mass_fraction_total = data->initial_metal_mass_fraction_total; + for (int elem = 0; elem < chemistry_element_count; ++elem) p->chemistry_data.metal_mass_fraction[elem] = data->initial_metal_mass_fraction[elem]; @@ -176,13 +177,13 @@ static INLINE void chemistry_init_backend(struct swift_params* parameter_file, /* Read the total metallicity */ data->initial_metal_mass_fraction_total = parser_get_opt_param_float( - parameter_file, "EAGLEChemistry:InitMetallicity", -1); + parameter_file, "EAGLEChemistry:init_abundance_metal", -1); if (data->initial_metal_mass_fraction_total != -1) { /* Read the individual mass fractions */ for (int elem = 0; elem < chemistry_element_count; ++elem) { char buffer[50]; - sprintf(buffer, "EAGLEChemistry:InitAbundance_%s", + sprintf(buffer, "EAGLEChemistry:init_abundance_%s", chemistry_get_element_name((enum chemistry_element)elem)); data->initial_metal_mass_fraction[elem] = diff --git a/src/cooling/EAGLE/cooling.c b/src/cooling/EAGLE/cooling.c index bf3d2ace16..8345109a4e 100644 --- a/src/cooling/EAGLE/cooling.c +++ b/src/cooling/EAGLE/cooling.c @@ -740,8 +740,8 @@ void cooling_init_backend(struct swift_params *parameter_file, /* read some parameters */ parser_get_param_string(parameter_file, "EAGLECooling:dir_name", cooling->cooling_table_path); - cooling->H_reion_z = parser_get_param_float( - parameter_file, "EAGLECooling:H_reion_z"); + cooling->H_reion_z = + parser_get_param_float(parameter_file, "EAGLECooling:H_reion_z"); cooling->He_reion_z_centre = parser_get_param_float(parameter_file, "EAGLECooling:He_reion_z_centre"); cooling->He_reion_z_sigma = @@ -754,7 +754,7 @@ void cooling_init_backend(struct swift_params *parameter_file, parameter_file, "EAGLECooling:Ca_over_Si_in_solar", 1.f); cooling->S_over_Si_ratio_in_solar = parser_get_opt_param_float( parameter_file, "EAGLECooling:S_over_Si_in_solar", 1.f); - + /* convert to cgs */ cooling->He_reion_heat_cgs *= phys_const->const_electron_volt * -- GitLab