diff --git a/src/physical_constants.c b/src/physical_constants.c index a582f1724041727d4c85ebf360bdc382fa9e962e..bbd8672d530e0ff672273b6c28de796bfa1baebe 100644 --- a/src/physical_constants.c +++ b/src/physical_constants.c @@ -125,6 +125,12 @@ void phys_const_init(const struct unit_system *us, struct swift_params *params, internal_const->const_light_year = const_light_year_cgs / units_general_cgs_conversion_factor(us, dimension_length); + internal_const->const_solar_radius = + const_solar_radius_cgs / + units_general_cgs_conversion_factor(us, dimension_length); + internal_const->const_earth_radius = + const_earth_radius_cgs / + units_general_cgs_conversion_factor(us, dimension_length); const float dimension_power[5] = {1, 2, -3, 0, 0}; /* [g cm^2 s^-3] */ internal_const->const_solar_luminosity = @@ -169,9 +175,10 @@ void phys_const_print(const struct phys_const *internal_const) { message("%25s = %e", "Electron-Volt", internal_const->const_electron_volt); message("%25s = %e", "Proton mass", internal_const->const_proton_mass); message("%25s = %e", "Year", internal_const->const_year); + message("%25s = %e", "Parsec", internal_const->const_parsec); message("%25s = %e", "Astronomical Unit", internal_const->const_astronomical_unit); - message("%25s = %e", "Parsec", internal_const->const_parsec); + message("%25s = %e", "Earth radius", internal_const->const_earth_radius); message("%25s = %e", "Solar mass", internal_const->const_solar_mass); message("%25s = %e", "Solar luminosity", internal_const->const_solar_luminosity); @@ -226,6 +233,8 @@ void phys_const_print_snapshot(hid_t h_file, const struct phys_const *p) { const_astronomical_unit_cgs); io_write_attribute_d(h_grp_cgs, "parsec", const_parsec_cgs); io_write_attribute_d(h_grp_cgs, "light_year", const_light_year_cgs); + io_write_attribute_d(h_grp_cgs, "solar_radius", const_solar_radius_cgs); + io_write_attribute_d(h_grp_cgs, "earth_radius", const_earth_radius_cgs); io_write_attribute_d(h_grp_cgs, "solar_mass", const_solar_mass_cgs); io_write_attribute_d(h_grp_cgs, "earth_mass", const_earth_mass_cgs); io_write_attribute_d(h_grp_cgs, "solar_luminosity", @@ -262,6 +271,8 @@ void phys_const_print_snapshot(hid_t h_file, const struct phys_const *p) { p->const_astronomical_unit); io_write_attribute_d(h_grp_int, "parsec", p->const_parsec); io_write_attribute_d(h_grp_int, "light_year", p->const_light_year); + io_write_attribute_d(h_grp_int, "solar_radius", p->const_solar_radius); + io_write_attribute_d(h_grp_int, "earth_radius", p->const_earth_radius); io_write_attribute_d(h_grp_int, "solar_mass", p->const_solar_mass); io_write_attribute_d(h_grp_int, "earth_mass", p->const_earth_mass); io_write_attribute_d(h_grp_cgs, "solar_luminosity", diff --git a/src/physical_constants.h b/src/physical_constants.h index 8469b22e9eb3fa5c632423aa308f1a122fd9d69d..db034875fcc11d999ad3a50003ff9f220133cec8 100644 --- a/src/physical_constants.h +++ b/src/physical_constants.h @@ -91,6 +91,12 @@ struct phys_const { /*! Mass of the Earth */ double const_earth_mass; + /*! Radius of the Sun */ + double const_solar_radius; + + /*! Radius of the Earth */ + double const_earth_radius; + /*! Luminosity of the Sun */ double const_solar_luminosity; diff --git a/src/physical_constants_cgs.h b/src/physical_constants_cgs.h index f72dc80d16653ff01816c922dbe98f4df41dbe90..0a12240165985bea2c69071746dda2ea212576ad 100644 --- a/src/physical_constants_cgs.h +++ b/src/physical_constants_cgs.h @@ -109,6 +109,12 @@ const double const_parsec_cgs = 3.08567758149e18; /*! Light-year [cm] */ const double const_light_year_cgs = 9.46063e17; +/*! Solar radius [cm] */ +const double const_solar_radius_cgs = 6.957e10; + +/*! Earth radius [cm] */ +const double const_earth_radius_cgs = 6.3781e8; + #ifdef SWIFT_USE_GADGET2_PHYSICAL_CONSTANTS /*! Mass of the Sun [g] */