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) {
struct part p;
struct xpart xp;
struct phys_const internal_const;
struct hydro_props hydro_properties;
struct cooling_function_data cooling;
struct cosmology cosmo;
struct space s;
......@@ -210,8 +211,13 @@ int main(int argc, char **argv) {
// Init units
units_init_from_params(&us, params, "InternalUnitSystem");
// Init physical constants
phys_const_init(&us, params, &internal_const);
// Init porperties of hydro
hydro_props_init(&hydro_properties, &internal_const, &us, params);
// Init chemistry
chemistry_init(params, &us, &internal_const, &chem_data);
chemistry_first_init_part(&internal_const, &us, &cosmo, &chem_data, &p, &xp);
......@@ -228,7 +234,7 @@ int main(int argc, char **argv) {
message("Redshift is %f", cosmo.z);
// Init cooling
cooling_init(params, &us, &internal_const, &cooling);
cooling_init(params, &us, &internal_const, &hydro_properties, &cooling);
cooling_print(&cooling);
cooling_update(&cosmo, &cooling, &s);
......
......@@ -15,6 +15,11 @@ Cosmology:
Omega_lambda: 0.693 # Dark-energy density parameter
Omega_b: 0.0455 # Baryon density parameter
SPH:
resolution_eta: 1.234
CFL_condition: 0.1
minimal_temperature: 100.
EAGLEChemistry:
init_abundance_metal: 0.014
init_abundance_Hydrogen: 0.70649785
......
......@@ -27,7 +27,6 @@ Snapshots:
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)
# Parameters governing the conserved quantities statistics
Statistics:
delta_time: 1e-2 # Time between statistics output
......@@ -45,6 +44,7 @@ SPH:
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
h_min_ratio: 0.1 # Minimal smoothing in units of softening.
h_max: 10.
minimal_temperature: 10. # Kelvin
# Standard EAGLE cooling options
EAGLECooling:
......@@ -55,7 +55,7 @@ EAGLECooling:
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
# Primordial abundances
# Solar abundances
EAGLEChemistry:
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
......
......@@ -766,7 +766,7 @@ int main(int argc, char *argv[]) {
#endif
bzero(&cooling_func, sizeof(struct cooling_function_data));
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);
......
......@@ -22,6 +22,10 @@
/* This object's header. */
#include "cooling.h"
/* Local includes */
#include "error.h"
#include "hydro_properties.h"
#include "restart.h"
/**
......@@ -37,8 +41,15 @@
void cooling_init(struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
const struct hydro_props* hydro_props,
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);
}
......
......@@ -55,6 +55,7 @@
void cooling_init(struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
const struct hydro_props* hydro_props,
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,
const struct phys_const *phys_const,
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
* that are read in are actually in units of electron volts per proton mass.
* 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_z =
parser_get_param_float(parameter_file, "EAGLECooling:H_reion_z");
......
......@@ -135,10 +135,16 @@ void hydro_props_init(struct hydro_props *p,
p->initial_temperature = parser_get_opt_param_float(
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 */
p->minimal_temperature = parser_get_opt_param_float(
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.) &&
(p->initial_temperature < p->minimal_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