diff --git a/examples/EAGLE_ICs/EAGLE_100/vrconfig_3dfof_subhalos_SO_hydro.cfg b/examples/EAGLE_ICs/EAGLE_100/vrconfig_3dfof_subhalos_SO_hydro.cfg index 2c190e870ab5e2c1af92efe7c13ec2df891aa65b..2903ddd7268aaaae5a290cbf33bd0395f9a629b2 100644 --- a/examples/EAGLE_ICs/EAGLE_100/vrconfig_3dfof_subhalos_SO_hydro.cfg +++ b/examples/EAGLE_ICs/EAGLE_100/vrconfig_3dfof_subhalos_SO_hydro.cfg @@ -177,12 +177,11 @@ Reference_frame_for_properties=2 #use the minimum potential as reference frame a #Extra fields ################################ -# Also compute the H abundance as well as the HI, HII and H_2 fractions -Gas_internal_property_names=ElementMassFractions,SpeciesFractions,SpeciesFractions,SpeciesFractions, -Gas_internal_property_index_in_file=0,0,1,2, -Gas_internal_property_input_output_unit_conversion_factors=1.0,1.0,1.0,1.0 -Gas_internal_property_calculation_type =averagemassweighted,averagemassweighted,averagemassweighted,averagemassweighted, -Gas_internal_property_output_units=unitless,unitless,unitless,unitless, +# Also compute the HI and H_2 masses in apertures +Gas_internal_property_names=AtomicHydrogenMasses,MolecularHydrogenMasses, +Gas_internal_property_input_output_unit_conversion_factors=1.0e10,1.0e10, +Gas_internal_property_calculation_type=aperture_total,aperture_total, +Gas_internal_property_output_units=solar_mass,solar_mass, # Collect the BH subgrid masses and compute the max, min, average and total mass in apertures BH_internal_property_names=SubgridMasses,SubgridMasses,SubgridMasses,SubgridMasses, diff --git a/examples/EAGLE_ICs/EAGLE_12/vrconfig_3dfof_subhalos_SO_hydro.cfg b/examples/EAGLE_ICs/EAGLE_12/vrconfig_3dfof_subhalos_SO_hydro.cfg index 2c190e870ab5e2c1af92efe7c13ec2df891aa65b..2903ddd7268aaaae5a290cbf33bd0395f9a629b2 100644 --- a/examples/EAGLE_ICs/EAGLE_12/vrconfig_3dfof_subhalos_SO_hydro.cfg +++ b/examples/EAGLE_ICs/EAGLE_12/vrconfig_3dfof_subhalos_SO_hydro.cfg @@ -177,12 +177,11 @@ Reference_frame_for_properties=2 #use the minimum potential as reference frame a #Extra fields ################################ -# Also compute the H abundance as well as the HI, HII and H_2 fractions -Gas_internal_property_names=ElementMassFractions,SpeciesFractions,SpeciesFractions,SpeciesFractions, -Gas_internal_property_index_in_file=0,0,1,2, -Gas_internal_property_input_output_unit_conversion_factors=1.0,1.0,1.0,1.0 -Gas_internal_property_calculation_type =averagemassweighted,averagemassweighted,averagemassweighted,averagemassweighted, -Gas_internal_property_output_units=unitless,unitless,unitless,unitless, +# Also compute the HI and H_2 masses in apertures +Gas_internal_property_names=AtomicHydrogenMasses,MolecularHydrogenMasses, +Gas_internal_property_input_output_unit_conversion_factors=1.0e10,1.0e10, +Gas_internal_property_calculation_type=aperture_total,aperture_total, +Gas_internal_property_output_units=solar_mass,solar_mass, # Collect the BH subgrid masses and compute the max, min, average and total mass in apertures BH_internal_property_names=SubgridMasses,SubgridMasses,SubgridMasses,SubgridMasses, diff --git a/examples/EAGLE_ICs/EAGLE_25/vrconfig_3dfof_subhalos_SO_hydro.cfg b/examples/EAGLE_ICs/EAGLE_25/vrconfig_3dfof_subhalos_SO_hydro.cfg index 2c190e870ab5e2c1af92efe7c13ec2df891aa65b..2903ddd7268aaaae5a290cbf33bd0395f9a629b2 100644 --- a/examples/EAGLE_ICs/EAGLE_25/vrconfig_3dfof_subhalos_SO_hydro.cfg +++ b/examples/EAGLE_ICs/EAGLE_25/vrconfig_3dfof_subhalos_SO_hydro.cfg @@ -177,12 +177,11 @@ Reference_frame_for_properties=2 #use the minimum potential as reference frame a #Extra fields ################################ -# Also compute the H abundance as well as the HI, HII and H_2 fractions -Gas_internal_property_names=ElementMassFractions,SpeciesFractions,SpeciesFractions,SpeciesFractions, -Gas_internal_property_index_in_file=0,0,1,2, -Gas_internal_property_input_output_unit_conversion_factors=1.0,1.0,1.0,1.0 -Gas_internal_property_calculation_type =averagemassweighted,averagemassweighted,averagemassweighted,averagemassweighted, -Gas_internal_property_output_units=unitless,unitless,unitless,unitless, +# Also compute the HI and H_2 masses in apertures +Gas_internal_property_names=AtomicHydrogenMasses,MolecularHydrogenMasses, +Gas_internal_property_input_output_unit_conversion_factors=1.0e10,1.0e10, +Gas_internal_property_calculation_type=aperture_total,aperture_total, +Gas_internal_property_output_units=solar_mass,solar_mass, # Collect the BH subgrid masses and compute the max, min, average and total mass in apertures BH_internal_property_names=SubgridMasses,SubgridMasses,SubgridMasses,SubgridMasses, diff --git a/examples/EAGLE_ICs/EAGLE_25_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg b/examples/EAGLE_ICs/EAGLE_25_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg index 2c190e870ab5e2c1af92efe7c13ec2df891aa65b..2903ddd7268aaaae5a290cbf33bd0395f9a629b2 100644 --- a/examples/EAGLE_ICs/EAGLE_25_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg +++ b/examples/EAGLE_ICs/EAGLE_25_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg @@ -177,12 +177,11 @@ Reference_frame_for_properties=2 #use the minimum potential as reference frame a #Extra fields ################################ -# Also compute the H abundance as well as the HI, HII and H_2 fractions -Gas_internal_property_names=ElementMassFractions,SpeciesFractions,SpeciesFractions,SpeciesFractions, -Gas_internal_property_index_in_file=0,0,1,2, -Gas_internal_property_input_output_unit_conversion_factors=1.0,1.0,1.0,1.0 -Gas_internal_property_calculation_type =averagemassweighted,averagemassweighted,averagemassweighted,averagemassweighted, -Gas_internal_property_output_units=unitless,unitless,unitless,unitless, +# Also compute the HI and H_2 masses in apertures +Gas_internal_property_names=AtomicHydrogenMasses,MolecularHydrogenMasses, +Gas_internal_property_input_output_unit_conversion_factors=1.0e10,1.0e10, +Gas_internal_property_calculation_type=aperture_total,aperture_total, +Gas_internal_property_output_units=solar_mass,solar_mass, # Collect the BH subgrid masses and compute the max, min, average and total mass in apertures BH_internal_property_names=SubgridMasses,SubgridMasses,SubgridMasses,SubgridMasses, diff --git a/examples/EAGLE_ICs/EAGLE_50/vrconfig_3dfof_subhalos_SO_hydro.cfg b/examples/EAGLE_ICs/EAGLE_50/vrconfig_3dfof_subhalos_SO_hydro.cfg index 2c190e870ab5e2c1af92efe7c13ec2df891aa65b..2903ddd7268aaaae5a290cbf33bd0395f9a629b2 100644 --- a/examples/EAGLE_ICs/EAGLE_50/vrconfig_3dfof_subhalos_SO_hydro.cfg +++ b/examples/EAGLE_ICs/EAGLE_50/vrconfig_3dfof_subhalos_SO_hydro.cfg @@ -177,12 +177,11 @@ Reference_frame_for_properties=2 #use the minimum potential as reference frame a #Extra fields ################################ -# Also compute the H abundance as well as the HI, HII and H_2 fractions -Gas_internal_property_names=ElementMassFractions,SpeciesFractions,SpeciesFractions,SpeciesFractions, -Gas_internal_property_index_in_file=0,0,1,2, -Gas_internal_property_input_output_unit_conversion_factors=1.0,1.0,1.0,1.0 -Gas_internal_property_calculation_type =averagemassweighted,averagemassweighted,averagemassweighted,averagemassweighted, -Gas_internal_property_output_units=unitless,unitless,unitless,unitless, +# Also compute the HI and H_2 masses in apertures +Gas_internal_property_names=AtomicHydrogenMasses,MolecularHydrogenMasses, +Gas_internal_property_input_output_unit_conversion_factors=1.0e10,1.0e10, +Gas_internal_property_calculation_type=aperture_total,aperture_total, +Gas_internal_property_output_units=solar_mass,solar_mass, # Collect the BH subgrid masses and compute the max, min, average and total mass in apertures BH_internal_property_names=SubgridMasses,SubgridMasses,SubgridMasses,SubgridMasses, diff --git a/examples/EAGLE_ICs/EAGLE_50_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg b/examples/EAGLE_ICs/EAGLE_50_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg index 2c190e870ab5e2c1af92efe7c13ec2df891aa65b..2903ddd7268aaaae5a290cbf33bd0395f9a629b2 100644 --- a/examples/EAGLE_ICs/EAGLE_50_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg +++ b/examples/EAGLE_ICs/EAGLE_50_low_res/vrconfig_3dfof_subhalos_SO_hydro.cfg @@ -177,12 +177,11 @@ Reference_frame_for_properties=2 #use the minimum potential as reference frame a #Extra fields ################################ -# Also compute the H abundance as well as the HI, HII and H_2 fractions -Gas_internal_property_names=ElementMassFractions,SpeciesFractions,SpeciesFractions,SpeciesFractions, -Gas_internal_property_index_in_file=0,0,1,2, -Gas_internal_property_input_output_unit_conversion_factors=1.0,1.0,1.0,1.0 -Gas_internal_property_calculation_type =averagemassweighted,averagemassweighted,averagemassweighted,averagemassweighted, -Gas_internal_property_output_units=unitless,unitless,unitless,unitless, +# Also compute the HI and H_2 masses in apertures +Gas_internal_property_names=AtomicHydrogenMasses,MolecularHydrogenMasses, +Gas_internal_property_input_output_unit_conversion_factors=1.0e10,1.0e10, +Gas_internal_property_calculation_type=aperture_total,aperture_total, +Gas_internal_property_output_units=solar_mass,solar_mass, # Collect the BH subgrid masses and compute the max, min, average and total mass in apertures BH_internal_property_names=SubgridMasses,SubgridMasses,SubgridMasses,SubgridMasses, diff --git a/examples/EAGLE_ICs/EAGLE_6/vrconfig_3dfof_subhalos_SO_hydro.cfg b/examples/EAGLE_ICs/EAGLE_6/vrconfig_3dfof_subhalos_SO_hydro.cfg index 2c190e870ab5e2c1af92efe7c13ec2df891aa65b..2903ddd7268aaaae5a290cbf33bd0395f9a629b2 100644 --- a/examples/EAGLE_ICs/EAGLE_6/vrconfig_3dfof_subhalos_SO_hydro.cfg +++ b/examples/EAGLE_ICs/EAGLE_6/vrconfig_3dfof_subhalos_SO_hydro.cfg @@ -177,12 +177,11 @@ Reference_frame_for_properties=2 #use the minimum potential as reference frame a #Extra fields ################################ -# Also compute the H abundance as well as the HI, HII and H_2 fractions -Gas_internal_property_names=ElementMassFractions,SpeciesFractions,SpeciesFractions,SpeciesFractions, -Gas_internal_property_index_in_file=0,0,1,2, -Gas_internal_property_input_output_unit_conversion_factors=1.0,1.0,1.0,1.0 -Gas_internal_property_calculation_type =averagemassweighted,averagemassweighted,averagemassweighted,averagemassweighted, -Gas_internal_property_output_units=unitless,unitless,unitless,unitless, +# Also compute the HI and H_2 masses in apertures +Gas_internal_property_names=AtomicHydrogenMasses,MolecularHydrogenMasses, +Gas_internal_property_input_output_unit_conversion_factors=1.0e10,1.0e10, +Gas_internal_property_calculation_type=aperture_total,aperture_total, +Gas_internal_property_output_units=solar_mass,solar_mass, # Collect the BH subgrid masses and compute the max, min, average and total mass in apertures BH_internal_property_names=SubgridMasses,SubgridMasses,SubgridMasses,SubgridMasses, diff --git a/src/cooling/COLIBRE/cooling_io.h b/src/cooling/COLIBRE/cooling_io.h index 1bbc9a16db7156253b2a8f998f675c0d767ba96b..13f4dcda93bddbb7fce9d98b2ca3ec9ec95d3304 100644 --- a/src/cooling/COLIBRE/cooling_io.h +++ b/src/cooling/COLIBRE/cooling_io.h @@ -114,6 +114,34 @@ INLINE static void convert_part_sub_species_frac(const struct engine* e, ret[2] /= sum; } +INLINE static void convert_part_HI_mass(const struct engine* e, + const struct part* p, + const struct xpart* xp, float* ret) { + + const float X_H = + chemistry_get_metal_mass_fraction_for_cooling(p)[chemistry_element_H]; + + const float HI_frac = cooling_get_particle_subgrid_HI_fraction( + e->internal_units, e->physical_constants, e->cosmology, + e->hydro_properties, e->entropy_floor, e->cooling_func, p, xp); + + *ret = hydro_get_mass(p) * X_H * HI_frac; +} + +INLINE static void convert_part_H2_mass(const struct engine* e, + const struct part* p, + const struct xpart* xp, float* ret) { + + const float X_H = + chemistry_get_metal_mass_fraction_for_cooling(p)[chemistry_element_H]; + + const float H2_frac = cooling_get_particle_subgrid_H2_fraction( + e->internal_units, e->physical_constants, e->cosmology, + e->hydro_properties, e->entropy_floor, e->cooling_func, p, xp); + + *ret = hydro_get_mass(p) * X_H * H2_frac * 2.f; +} + /** * @brief Specifies which particle fields to write to a dataset * @@ -160,7 +188,23 @@ __attribute__((always_inline)) INLINE static int cooling_write_particles( "above deltaT of the entropy floor, the normal hydro quantities are " "used."); - return 4; + list[4] = io_make_output_field_convert_part( + "AtomicHydrogenMasses", FLOAT, 1, UNIT_CONV_MASS, 0.f, parts, xparts, + convert_part_HI_mass, + "Atomic hydrogen masses containted in the particles. This quantity is " + "obtained from the cooling tables and, if the particle is on the entropy " + "floor, by extrapolating to the equilibrium curve assuming constant " + "pressure."); + + list[5] = io_make_output_field_convert_part( + "MolecularHydrogenMasses", FLOAT, 1, UNIT_CONV_MASS, 0.f, parts, xparts, + convert_part_H2_mass, + "Molecular hydrogen masses containted in the particles. This quantity is " + "obtained from the cooling tables and, if the particle is on the entropy " + "floor, by extrapolating to the equilibrium curve assuming constant " + "pressure."); + + return 6; } #endif /* SWIFT_COOLING_COLIBRE_IO_H */