diff --git a/examples/MoonFormingImpact/moon_forming_impact.yml b/examples/MoonFormingImpact/moon_forming_impact.yml index 7d726bc02ba4fb6c8dd02f74907ffc48c3ed9431..331f7a250498d8119ebee99d8e6e63b322625408 100644 --- a/examples/MoonFormingImpact/moon_forming_impact.yml +++ b/examples/MoonFormingImpact/moon_forming_impact.yml @@ -42,3 +42,7 @@ Gravity: InitialConditions: # The initial conditions file to read file_name: moon_forming_impact.hdf5 + +# Parameters related to the equation of state +EoS: + use_Til: 1 # Whether to prepare the Tillotson EOS diff --git a/examples/UranusImpact/uranus_impact.yml b/examples/UranusImpact/uranus_impact.yml index aae9f66847a9f9b55984ea5d2ea1c79099c01e95..7216e4cd7c1f3dbfa0d1143003207ec5120a27a4 100644 --- a/examples/UranusImpact/uranus_impact.yml +++ b/examples/UranusImpact/uranus_impact.yml @@ -41,3 +41,11 @@ Gravity: # Parameters related to the initial conditions InitialConditions: file_name: uranus_impact.hdf5 # The initial conditions file to read + +# Parameters related to the equation of state +EoS: + use_HM80: 1 # Whether to prepare the Hubbard & MacFarlane (1980) EOS + # Table file paths + HM80_HHe_table_file: /gpfs/data/dc-kege1/gihr_data/P_rho_u_HHe.txt + HM80_ice_table_file: /gpfs/data/dc-kege1/gihr_data/P_rho_u_ice.txt + HM80_rock_table_file: /gpfs/data/dc-kege1/gihr_data/P_rho_u_roc.txt diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index c9bc9811803051b274cd09cdcf6b58d1a65a0d7d..ac4f7f1e158e3a1ebb9d727060623c6dee2e4bcc 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -131,7 +131,16 @@ DomainDecomposition: # Parameters related to the equation of state ------------------------------------------ EoS: - isothermal_internal_energy: 20.26784 # Thermal energy per unit mass for the case of isothermal equation of state (in internal units). + isothermal_internal_energy: 20.26784 # Thermal energy per unit mass for the case of isothermal equation of state (in internal units). + + use_Til: 1 # (Optional) Whether to prepare the Tillotson EOS + use_HM80: 0 # (Optional) Whether to prepare the Hubbard & MacFarlane (1980) EOS + use_ANEOS: 0 # (Optional) Whether to prepare the ANEOS EOS + use_SESAME: 0 # (Optional) Whether to prepare the SESAME EOS + # (Optional) Table file paths + HM80_HHe_table_file: HM80_HHe.txt + HM80_ice_table_file: HM80_ice.txt + HM80_rock_table_file: HM80_rock.txt # Parameters related to external potentials -------------------------------------------- diff --git a/src/equation_of_state/planetary/equation_of_state.h b/src/equation_of_state/planetary/equation_of_state.h index 7ab52a83378303d4b30c9bb01d0f3d53d5f43eab..2bfc115b23d9be511321c347a1bee707f376f1c0 100644 --- a/src/equation_of_state/planetary/equation_of_state.h +++ b/src/equation_of_state/planetary/equation_of_state.h @@ -1077,46 +1077,62 @@ __attribute__((always_inline)) INLINE static void eos_init( struct eos_parameters *e, const struct phys_const *phys_const, const struct unit_system *us, const struct swift_params *params) { + // Table file names + char HM80_HHe_table_file[PARSER_MAX_LINE_SIZE]; + char HM80_ice_table_file[PARSER_MAX_LINE_SIZE]; + char HM80_rock_table_file[PARSER_MAX_LINE_SIZE]; + // Set the parameters and material IDs, load tables, etc. for each material + // and convert to internal units // Tillotson - set_Til_iron(&e->Til_iron, eos_planetary_id_Til_iron); - set_Til_granite(&e->Til_granite, eos_planetary_id_Til_granite); - set_Til_water(&e->Til_water, eos_planetary_id_Til_water); + if (parser_get_opt_param_int(params, "EoS:use_Til", 0)) { + set_Til_iron(&e->Til_iron, eos_planetary_id_Til_iron); + set_Til_granite(&e->Til_granite, eos_planetary_id_Til_granite); + set_Til_water(&e->Til_water, eos_planetary_id_Til_water); + + convert_units_Til(&e->Til_iron, us); + convert_units_Til(&e->Til_granite, us); + convert_units_Til(&e->Til_water, us); + } // Hubbard & MacFarlane (1980) - set_HM80_HHe(&e->HM80_HHe, eos_planetary_id_HM80_HHe); - set_HM80_ice(&e->HM80_ice, eos_planetary_id_HM80_ice); - set_HM80_rock(&e->HM80_rock, eos_planetary_id_HM80_rock); - - load_HM80_table(&e->HM80_HHe, HM80_HHe_table_file); - load_HM80_table(&e->HM80_ice, HM80_ice_table_file); - load_HM80_table(&e->HM80_rock, HM80_rock_table_file); + if (parser_get_opt_param_int(params, "EoS:use_HM80", 0)) { + set_HM80_HHe(&e->HM80_HHe, eos_planetary_id_HM80_HHe); + set_HM80_ice(&e->HM80_ice, eos_planetary_id_HM80_ice); + set_HM80_rock(&e->HM80_rock, eos_planetary_id_HM80_rock); + + parser_get_param_string(params, "EoS:HM80_HHe_table_file", + HM80_HHe_table_file); + parser_get_param_string(params, "EoS:HM80_ice_table_file", + HM80_ice_table_file); + parser_get_param_string(params, "EoS:HM80_rock_table_file", + HM80_rock_table_file); + + load_HM80_table(&e->HM80_HHe, HM80_HHe_table_file); + load_HM80_table(&e->HM80_ice, HM80_ice_table_file); + load_HM80_table(&e->HM80_rock, HM80_rock_table_file); + + convert_units_HM80(&e->HM80_HHe, us); + convert_units_HM80(&e->HM80_ice, us); + convert_units_HM80(&e->HM80_rock, us); + } // ANEOS - set_ANEOS_iron(&e->ANEOS_iron, eos_planetary_id_ANEOS_iron); - set_MANEOS_forsterite(&e->MANEOS_forsterite, - eos_planetary_id_MANEOS_forsterite); - - // SESAME - set_SESAME_iron(&e->SESAME_iron, eos_planetary_id_SESAME_iron); - - // Convert to internal units - // Tillotson - convert_units_Til(&e->Til_iron, us); - convert_units_Til(&e->Til_granite, us); - convert_units_Til(&e->Til_water, us); - - // Hubbard & MacFarlane (1980) - convert_units_HM80(&e->HM80_HHe, us); - convert_units_HM80(&e->HM80_ice, us); - convert_units_HM80(&e->HM80_rock, us); + if (parser_get_opt_param_int(params, "EoS:use_ANEOS", 0)) { + set_ANEOS_iron(&e->ANEOS_iron, eos_planetary_id_ANEOS_iron); + set_MANEOS_forsterite(&e->MANEOS_forsterite, + eos_planetary_id_MANEOS_forsterite); - // ANEOS - convert_units_ANEOS(&e->ANEOS_iron, us); - convert_units_ANEOS(&e->MANEOS_forsterite, us); + convert_units_ANEOS(&e->ANEOS_iron, us); + convert_units_ANEOS(&e->MANEOS_forsterite, us); + } // SESAME - convert_units_SESAME(&e->SESAME_iron, us); + if (parser_get_opt_param_int(params, "EoS:use_SESAME", 0)) { + set_SESAME_iron(&e->SESAME_iron, eos_planetary_id_SESAME_iron); + + convert_units_SESAME(&e->SESAME_iron, us); + } } /** diff --git a/src/equation_of_state/planetary/hm80.h b/src/equation_of_state/planetary/hm80.h index 8e9032f3b0657e9b26b62505a2264249bd6e9161..69f213f38184bcc15ec3ad82a66b7f197a7bb502 100644 --- a/src/equation_of_state/planetary/hm80.h +++ b/src/equation_of_state/planetary/hm80.h @@ -48,12 +48,6 @@ struct HM80_params { enum eos_planetary_material_id mat_id; }; -// Table file names -/// to be read in from the parameter file instead once finished testing... -#define HM80_HHe_table_file "/gpfs/data/dc-kege1/gihr_data/P_rho_u_HHe.txt" -#define HM80_ice_table_file "/gpfs/data/dc-kege1/gihr_data/P_rho_u_ice.txt" -#define HM80_rock_table_file "/gpfs/data/dc-kege1/gihr_data/P_rho_u_roc.txt" - // Parameter values for each material (cgs units) INLINE static void set_HM80_HHe(struct HM80_params *mat, enum eos_planetary_material_id mat_id) {