From 47ff6c06f8b0b515b85497f4b76dec6466a73f27 Mon Sep 17 00:00:00 2001 From: Jacob Kegerreis <jacob.kegerreis@durham.ac.uk> Date: Wed, 16 May 2018 11:27:33 +0100 Subject: [PATCH] Add parameter file options to select which EOS are being used and for table file names --- .../MoonFormingImpact/moon_forming_impact.yml | 4 + examples/UranusImpact/uranus_impact.yml | 8 ++ examples/parameter_example.yml | 11 ++- .../planetary/equation_of_state.h | 78 +++++++++++-------- src/equation_of_state/planetary/hm80.h | 6 -- 5 files changed, 69 insertions(+), 38 deletions(-) diff --git a/examples/MoonFormingImpact/moon_forming_impact.yml b/examples/MoonFormingImpact/moon_forming_impact.yml index 7d726bc02b..331f7a2504 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 aae9f66847..7216e4cd7c 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 c9bc981180..ac4f7f1e15 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 7ab52a8337..2bfc115b23 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 8e9032f3b0..69f213f381 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) { -- GitLab