Commit f24917a1 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Prevent users from running with cooling switched on and no minimal temperature...

Prevent users from running with cooling switched on and no minimal temperature in the parameter file.
parent a1bbabbe
...@@ -164,6 +164,7 @@ int main(int argc, char **argv) { ...@@ -164,6 +164,7 @@ int main(int argc, char **argv) {
struct part p; struct part p;
struct xpart xp; struct xpart xp;
struct phys_const internal_const; struct phys_const internal_const;
struct hydro_props hydro_properties;
struct cooling_function_data cooling; struct cooling_function_data cooling;
struct cosmology cosmo; struct cosmology cosmo;
struct space s; struct space s;
...@@ -210,8 +211,13 @@ int main(int argc, char **argv) { ...@@ -210,8 +211,13 @@ int main(int argc, char **argv) {
// Init units // Init units
units_init_from_params(&us, params, "InternalUnitSystem"); units_init_from_params(&us, params, "InternalUnitSystem");
// Init physical constants
phys_const_init(&us, params, &internal_const); phys_const_init(&us, params, &internal_const);
// Init porperties of hydro
hydro_props_init(&hydro_properties, &internal_const, &us, params);
// Init chemistry // Init chemistry
chemistry_init(params, &us, &internal_const, &chem_data); chemistry_init(params, &us, &internal_const, &chem_data);
chemistry_first_init_part(&internal_const, &us, &cosmo, &chem_data, &p, &xp); chemistry_first_init_part(&internal_const, &us, &cosmo, &chem_data, &p, &xp);
...@@ -228,7 +234,7 @@ int main(int argc, char **argv) { ...@@ -228,7 +234,7 @@ int main(int argc, char **argv) {
message("Redshift is %f", cosmo.z); message("Redshift is %f", cosmo.z);
// Init cooling // Init cooling
cooling_init(params, &us, &internal_const, &cooling); cooling_init(params, &us, &internal_const, &hydro_properties, &cooling);
cooling_print(&cooling); cooling_print(&cooling);
cooling_update(&cosmo, &cooling, &s); cooling_update(&cosmo, &cooling, &s);
......
...@@ -15,6 +15,11 @@ Cosmology: ...@@ -15,6 +15,11 @@ Cosmology:
Omega_lambda: 0.693 # Dark-energy density parameter Omega_lambda: 0.693 # Dark-energy density parameter
Omega_b: 0.0455 # Baryon density parameter Omega_b: 0.0455 # Baryon density parameter
SPH:
resolution_eta: 1.234
CFL_condition: 0.1
minimal_temperature: 100.
EAGLEChemistry: EAGLEChemistry:
init_abundance_metal: 0.014 init_abundance_metal: 0.014
init_abundance_Hydrogen: 0.70649785 init_abundance_Hydrogen: 0.70649785
......
...@@ -25,9 +25,8 @@ TimeIntegration: ...@@ -25,9 +25,8 @@ TimeIntegration:
Snapshots: Snapshots:
basename: output # Common part of the name of output files basename: output # Common part of the name of output files
time_first: 0. # (Optional) Time of the first output if non-cosmological time-integration (in internal units) time_first: 0. # (Optional) Time of the first output if non-cosmological time-integration (in internal units)
delta_time: 0.001 # Time difference between consecutive outputs (in internal units) delta_time: 0.001 # Time difference between consecutive outputs (in internal units)
# Parameters governing the conserved quantities statistics # Parameters governing the conserved quantities statistics
Statistics: Statistics:
delta_time: 1e-2 # Time between statistics output delta_time: 1e-2 # Time between statistics output
...@@ -45,6 +44,7 @@ SPH: ...@@ -45,6 +44,7 @@ SPH:
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
h_min_ratio: 0.1 # Minimal smoothing in units of softening. h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 10. h_max: 10.
minimal_temperature: 10. # Kelvin
# Standard EAGLE cooling options # Standard EAGLE cooling options
EAGLECooling: EAGLECooling:
...@@ -55,18 +55,18 @@ EAGLECooling: ...@@ -55,18 +55,18 @@ EAGLECooling:
He_reion_z_sigma: 0.5 # Spread in redshift of the Helium re-ionization Gaussian He_reion_z_sigma: 0.5 # Spread in redshift of the Helium re-ionization Gaussian
He_reion_eV_p_H: 2.0 # Energy inject by Helium re-ionization in electron-volt per Hydrogen atom He_reion_eV_p_H: 2.0 # Energy inject by Helium re-ionization in electron-volt per Hydrogen atom
# Primordial abundances # Solar abundances
EAGLEChemistry: EAGLEChemistry:
init_abundance_metal: 0.0129 # Inital fraction of particle mass in *all* metals init_abundance_metal: 0.0129 # Inital fraction of particle mass in *all* metals
init_abundance_Hydrogen: 0.7065 # Inital fraction of particle mass in Hydrogen init_abundance_Hydrogen: 0.7065 # Inital fraction of particle mass in Hydrogen
init_abundance_Helium: 0.2806 # Inital fraction of particle mass in Helium init_abundance_Helium: 0.2806 # Inital fraction of particle mass in Helium
init_abundance_Carbon: 0.00207 # Inital fraction of particle mass in Carbon init_abundance_Carbon: 0.00207 # Inital fraction of particle mass in Carbon
init_abundance_Nitrogen: 0.000836 # Inital fraction of particle mass in Nitrogen init_abundance_Nitrogen: 0.000836 # Inital fraction of particle mass in Nitrogen
init_abundance_Oxygen: 0.00549 # Inital fraction of particle mass in Oxygen init_abundance_Oxygen: 0.00549 # Inital fraction of particle mass in Oxygen
init_abundance_Neon: 0.00141 # Inital fraction of particle mass in Neon init_abundance_Neon: 0.00141 # Inital fraction of particle mass in Neon
init_abundance_Magnesium: 0.000591 # Inital fraction of particle mass in Magnesium init_abundance_Magnesium: 0.000591 # Inital fraction of particle mass in Magnesium
init_abundance_Silicon: 0.000683 # Inital fraction of particle mass in Silicon init_abundance_Silicon: 0.000683 # Inital fraction of particle mass in Silicon
init_abundance_Iron: 0.0011 # Inital fraction of particle mass in Iron init_abundance_Iron: 0.0011 # Inital fraction of particle mass in Iron
# Hernquist potential parameters # Hernquist potential parameters
HernquistPotential: HernquistPotential:
......
...@@ -766,7 +766,7 @@ int main(int argc, char *argv[]) { ...@@ -766,7 +766,7 @@ int main(int argc, char *argv[]) {
#endif #endif
bzero(&cooling_func, sizeof(struct cooling_function_data)); bzero(&cooling_func, sizeof(struct cooling_function_data));
if (with_cooling || with_temperature) { if (with_cooling || with_temperature) {
cooling_init(params, &us, &prog_const, &cooling_func); cooling_init(params, &us, &prog_const, &hydro_properties, &cooling_func);
} }
if (myrank == 0) cooling_print(&cooling_func); if (myrank == 0) cooling_print(&cooling_func);
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
/* This object's header. */ /* This object's header. */
#include "cooling.h" #include "cooling.h"
/* Local includes */
#include "error.h"
#include "hydro_properties.h"
#include "restart.h" #include "restart.h"
/** /**
...@@ -37,8 +41,15 @@ ...@@ -37,8 +41,15 @@
void cooling_init(struct swift_params* parameter_file, void cooling_init(struct swift_params* parameter_file,
const struct unit_system* us, const struct unit_system* us,
const struct phys_const* phys_const, const struct phys_const* phys_const,
const struct hydro_props* hydro_props,
struct cooling_function_data* cooling) { struct cooling_function_data* cooling) {
/* Verify that we are not doing something stupid here */
if (hydro_props->minimal_temperature <= 0.)
error(
"ERROR: Cannot run with cooling switched on and no minimal "
"temperature.");
cooling_init_backend(parameter_file, us, phys_const, cooling); cooling_init_backend(parameter_file, us, phys_const, cooling);
} }
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
void cooling_init(struct swift_params* parameter_file, void cooling_init(struct swift_params* parameter_file,
const struct unit_system* us, const struct unit_system* us,
const struct phys_const* phys_const, const struct phys_const* phys_const,
const struct hydro_props* hydro_props,
struct cooling_function_data* cooling); struct cooling_function_data* cooling);
void cooling_print(const struct cooling_function_data* cooling); void cooling_print(const struct cooling_function_data* cooling);
......
...@@ -836,15 +836,16 @@ void cooling_init_backend(struct swift_params *parameter_file, ...@@ -836,15 +836,16 @@ void cooling_init_backend(struct swift_params *parameter_file,
const struct phys_const *phys_const, const struct phys_const *phys_const,
struct cooling_function_data *cooling) { struct cooling_function_data *cooling) {
/* read some parameters */ /* Read model parameters */
/* Directory for cooling tables */
parser_get_param_string(parameter_file, "EAGLECooling:dir_name",
cooling->cooling_table_path);
/* Despite the names, the values of H_reion_heat_cgs and He_reion_heat_cgs /* Despite the names, the values of H_reion_heat_cgs and He_reion_heat_cgs
* that are read in are actually in units of electron volts per proton mass. * that are read in are actually in units of electron volts per proton mass.
* We later convert to units just below */ * We later convert to units just below */
parser_get_param_string(parameter_file, "EAGLECooling:dir_name",
cooling->cooling_table_path);
cooling->H_reion_done = 0; cooling->H_reion_done = 0;
cooling->H_reion_z = cooling->H_reion_z =
parser_get_param_float(parameter_file, "EAGLECooling:H_reion_z"); parser_get_param_float(parameter_file, "EAGLECooling:H_reion_z");
......
...@@ -135,10 +135,16 @@ void hydro_props_init(struct hydro_props *p, ...@@ -135,10 +135,16 @@ void hydro_props_init(struct hydro_props *p,
p->initial_temperature = parser_get_opt_param_float( p->initial_temperature = parser_get_opt_param_float(
params, "SPH:initial_temperature", hydro_props_default_init_temp); params, "SPH:initial_temperature", hydro_props_default_init_temp);
if (p->initial_temperature < 0.f)
error("ERROR: Minimal temperature set to a negative value!!!");
/* Minimal temperature */ /* Minimal temperature */
p->minimal_temperature = parser_get_opt_param_float( p->minimal_temperature = parser_get_opt_param_float(
params, "SPH:minimal_temperature", hydro_props_default_min_temp); params, "SPH:minimal_temperature", hydro_props_default_min_temp);
if (p->minimal_temperature < 0.f)
error("ERROR: Minimal temperature set to a negative value!!!");
if ((p->initial_temperature != 0.) && if ((p->initial_temperature != 0.) &&
(p->initial_temperature < p->minimal_temperature)) (p->initial_temperature < p->minimal_temperature))
error("Initial temperature lower than minimal allowed temperature!"); error("Initial temperature lower than minimal allowed temperature!");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment