Commit deb10021 authored by Loic Hausammann's avatar Loic Hausammann

GEAR: do not dump the feedback arrays

parent f6fb95a8
......@@ -99,18 +99,19 @@ EAGLEEntropyFloor:
# Cooling with Grackle 3.0
GrackleCooling:
CloudyTable: CloudyData_UVB=HM2012.h5 # Name of the Cloudy Table (available on the grackle bitbucket repository)
WithUVbackground: 1 # Enable or not the UV background
Redshift: -1 # Redshift to use (-1 means time based redshift)
WithMetalCooling: 1 # Enable or not the metal cooling
ProvideVolumetricHeatingRates: 0 # (optional) User provide volumetric heating rates
ProvideSpecificHeatingRates: 0 # (optional) User provide specific heating rates
SelfShieldingMethod: 0 # (optional) Grackle (<= 3) or Gear self shielding method
MaxSteps: 10000 # (optional) Max number of step when computing the initial composition
ConvergenceLimit: 1e-2 # (optional) Convergence threshold (relative) for initial composition
cloudy_table: CloudyData_UVB=HM2012.h5 # Name of the Cloudy Table (available on the grackle bitbucket repository)
with_UV_background: 1 # Enable or not the UV background
redshift: -1 # Redshift to use (-1 means time based redshift)
with_metal_cooling: 1 # Enable or not the metal cooling
provide_volumetric_heating_rates: 0 # (optional) User provide volumetric heating rates
provide_specific_heating_rates: 0 # (optional) User provide specific heating rates
self_shielding_method: 0 # (optional) Grackle (<= 3) or Gear self shielding method
max_steps: 10000 # (optional) Max number of step when computing the initial composition
convergence_limit: 1e-2 # (optional) Convergence threshold (relative) for initial composition
thermal_time_myr: 5
GearChemistry:
InitialMetallicity: 0.01295
GEARChemistry:
initial_metallicity: 0.01295
GEARPressureFloor:
Jeans_factor: 10. # Number of particles required to suppose a resolved clump and avoid the pressure floor.
jeans_factor: 10. # Number of particles required to suppose a resolved clump and avoid the pressure floor.
......@@ -5278,13 +5278,13 @@ void engine_struct_dump(struct engine *e, FILE *stream) {
potential_struct_dump(e->external_potential, stream);
cooling_struct_dump(e->cooling_func, stream);
starformation_struct_dump(e->star_formation, stream);
feedback_struct_dump(e->feedback_props, stream);
black_holes_struct_dump(e->black_holes_properties, stream);
chemistry_struct_dump(e->chemistry, stream);
#ifdef WITH_FOF
fof_struct_dump(e->fof_properties, stream);
#endif
parser_struct_dump(e->parameter_file, stream);
feedback_struct_dump(e->feedback_props, stream);
if (e->output_list_snapshots)
output_list_struct_dump(e->output_list_snapshots, stream);
if (e->output_list_stats)
......@@ -5391,11 +5391,6 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
starformation_struct_restore(star_formation, stream);
e->star_formation = star_formation;
struct feedback_props *feedback_properties =
(struct feedback_props *)malloc(sizeof(struct feedback_props));
feedback_struct_restore(feedback_properties, stream);
e->feedback_props = feedback_properties;
struct black_holes_props *black_holes_properties =
(struct black_holes_props *)malloc(sizeof(struct black_holes_props));
black_holes_struct_restore(black_holes_properties, stream);
......@@ -5419,6 +5414,11 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
parser_struct_restore(parameter_file, stream);
e->parameter_file = parameter_file;
struct feedback_props *feedback_properties =
(struct feedback_props *)malloc(sizeof(struct feedback_props));
feedback_struct_restore(feedback_properties, stream, e);
e->feedback_props = feedback_properties;
if (e->output_list_snapshots) {
struct output_list *output_list_snapshots =
(struct output_list *)malloc(sizeof(struct output_list));
......
......@@ -265,12 +265,13 @@ void feedback_struct_dump(const struct feedback_props* feedback, FILE* stream) {
* @param feedback the struct
* @param stream the file stream
*/
void feedback_struct_restore(struct feedback_props* feedback, FILE* stream) {
void feedback_struct_restore(struct feedback_props* feedback, FILE* stream,
struct engine *e) {
restart_read_blocks((void*)feedback, sizeof(struct feedback_props), 1, stream,
NULL, "feedback function");
stellar_evolution_restore(&feedback->stellar_model, stream);
stellar_evolution_restore(&feedback->stellar_model, stream, e);
}
/**
......
......@@ -61,7 +61,8 @@ void feedback_evolve_spart(struct spart* restrict sp,
const double time, const integertime_t ti_begin,
const int with_cosmology);
void feedback_struct_dump(const struct feedback_props* feedback, FILE* stream);
void feedback_struct_restore(struct feedback_props* feedback, FILE* stream);
void feedback_struct_restore(struct feedback_props* feedback, FILE* stream,
struct engine *e);
void feedback_clean(struct feedback_props* feedback);
/**
......
......@@ -488,7 +488,8 @@ void stellar_evolution_dump(const struct stellar_model* sm, FILE* stream) {
* @param sm the struct
* @param stream the file stream
*/
void stellar_evolution_restore(struct stellar_model* sm, FILE* stream) {
void stellar_evolution_restore(struct stellar_model* sm, FILE* stream,
struct engine *e) {
/* Restore the initial mass function */
initial_mass_function_restore(&sm->imf, stream, sm);
......@@ -500,7 +501,7 @@ void stellar_evolution_restore(struct stellar_model* sm, FILE* stream) {
supernovae_ia_restore(&sm->snia, stream, sm);
/* Restore the supernovae II model */
supernovae_ii_restore(&sm->snii, stream, sm);
supernovae_ii_restore(&sm->snii, stream, sm, e);
}
/**
......
......@@ -63,7 +63,8 @@ void stellar_evolution_props_init(struct stellar_model* sm,
const struct cosmology* cosmo);
void stellar_evolution_dump(const struct stellar_model* sm, FILE* stream);
void stellar_evolution_restore(struct stellar_model* sm, FILE* stream);
void stellar_evolution_restore(struct stellar_model* sm, FILE* stream,
struct engine *e);
void stellar_evolution_clean(struct stellar_model* sm);
......
......@@ -21,6 +21,7 @@
#include "supernovae_ii.h"
/* Local headers */
#include "engine.h"
#include "hdf5_functions.h"
#include "interpolation.h"
#include "stellar_evolution.h"
......@@ -403,65 +404,6 @@ void supernovae_ii_init(struct supernovae_ii *snii,
*/
void supernovae_ii_dump(const struct supernovae_ii *snii, FILE *stream,
const struct stellar_model *sm) {
/* Dump the yields. */
for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) {
const char *element_name = stellar_evolution_get_element_name(sm, i);
/* Integrated yields */
if (snii->integrated.yields[i].data != NULL) {
/* Generate name */
char name[200];
sprintf(name, "%s_int", element_name);
/* Write the array */
restart_write_blocks((void *)snii->integrated.yields[i].data,
sizeof(float), snii->integrated.yields[i].N, stream,
name, name);
}
/* Raw yields */
if (snii->raw.yields[i].data != NULL) {
/* Generate name */
char name[200];
sprintf(name, "%s_raw", element_name);
/* Write the array */
restart_write_blocks((void *)snii->raw.yields[i].data, sizeof(float),
snii->raw.yields[i].N, stream, name, name);
}
}
/*! Dump the processed mass (integrated). */
if (snii->integrated.ejected_mass_processed.data != NULL) {
restart_write_blocks((void *)snii->integrated.ejected_mass_processed.data,
sizeof(float),
snii->integrated.ejected_mass_processed.N, stream,
"processed_mass_int", "processed_mass_int");
}
/*! Dump the processed mass (raw). */
if (snii->raw.ejected_mass_processed.data != NULL) {
restart_write_blocks((void *)snii->raw.ejected_mass_processed.data,
sizeof(float), snii->raw.ejected_mass_processed.N,
stream, "processed_mass_raw", "processed_mass_raw");
}
/*! Dump the non processed mass (integrated). */
if (snii->integrated.ejected_mass_non_processed.data != NULL) {
restart_write_blocks(
(void *)snii->integrated.ejected_mass_non_processed.data, sizeof(float),
snii->integrated.ejected_mass_non_processed.N, stream,
"non_processed_mass_int", "non_processed_mass_int");
}
/*! Dump the non processed mass (raw). */
if (snii->raw.ejected_mass_non_processed.data != NULL) {
restart_write_blocks((void *)snii->raw.ejected_mass_non_processed.data,
sizeof(float), snii->raw.ejected_mass_non_processed.N,
stream, "non_processed_mass_raw",
"non_processed_mass_raw");
}
}
/**
......@@ -476,103 +418,18 @@ void supernovae_ii_dump(const struct supernovae_ii *snii, FILE *stream,
* @param sm The #stellar_model.
*/
void supernovae_ii_restore(struct supernovae_ii *snii, FILE *stream,
const struct stellar_model *sm) {
/* Restore the yields */
for (int i = 0; i < GEAR_CHEMISTRY_ELEMENT_COUNT; i++) {
const char *element_name = stellar_evolution_get_element_name(sm, i);
/* Integrated yields */
if (snii->integrated.yields[i].data != NULL) {
/* Generate name */
char name[200];
sprintf(name, "%s_int", element_name);
/* Allocate the memory */
snii->integrated.yields[i].data =
(float *)malloc(sizeof(float) * snii->integrated.yields[i].N);
if (snii->integrated.yields[i].data == NULL) {
error("Failed to allocate memory for the yields");
}
/* Read the data */
restart_read_blocks((void *)snii->integrated.yields[i].data,
sizeof(float), snii->integrated.yields[i].N, stream,
NULL, name);
}
/* Raw yields */
if (snii->raw.yields[i].data != NULL) {
/* Generate name */
char name[200];
sprintf(name, "%s_raw", element_name);
/* Allocate the memory */
snii->raw.yields[i].data =
(float *)malloc(sizeof(float) * snii->raw.yields[i].N);
if (snii->raw.yields[i].data == NULL) {
error("Failed to allocate memory for the yields");
}
/* Read the data */
restart_read_blocks((void *)snii->raw.yields[i].data, sizeof(float),
snii->raw.yields[i].N, stream, NULL, name);
}
}
/* Restore the processed mass (integrated) */
if (snii->integrated.ejected_mass_processed.data != NULL) {
snii->integrated.ejected_mass_processed.data = (float *)malloc(
sizeof(float) * snii->integrated.ejected_mass_processed.N);
if (snii->integrated.ejected_mass_processed.data == NULL) {
error("Failed to allocate memory for the yields");
}
restart_read_blocks((void *)snii->integrated.ejected_mass_processed.data,
sizeof(float),
snii->integrated.ejected_mass_processed.N, stream, NULL,
"processed_mass_int");
}
const struct stellar_model *sm,
struct engine *e) {
/* Restore the processed mass (raw) */
if (snii->raw.ejected_mass_processed.data != NULL) {
snii->raw.ejected_mass_processed.data =
(float *)malloc(sizeof(float) * snii->raw.ejected_mass_processed.N);
if (snii->raw.ejected_mass_processed.data == NULL) {
error("Failed to allocate memory for the yields");
}
restart_read_blocks((void *)snii->raw.ejected_mass_processed.data,
sizeof(float), snii->raw.ejected_mass_processed.N,
stream, NULL, "processed_mass_raw");
}
/* Restore the non processed mass (integrated) */
if (snii->integrated.ejected_mass_non_processed.data != NULL) {
snii->integrated.ejected_mass_non_processed.data = (float *)malloc(
sizeof(float) * snii->integrated.ejected_mass_non_processed.N);
if (snii->integrated.ejected_mass_non_processed.data == NULL) {
error("Failed to allocate memory for the yields");
}
restart_read_blocks(
(void *)snii->integrated.ejected_mass_non_processed.data, sizeof(float),
snii->integrated.ejected_mass_non_processed.N, stream, NULL,
"non_processed_mass_int");
}
/* Read the supernovae yields (and apply the units) */
supernovae_ii_read_yields(snii, e->parameter_file, e->physical_constants, sm);
/* Restore the non processed mass (raw) */
if (snii->raw.ejected_mass_non_processed.data != NULL) {
snii->raw.ejected_mass_non_processed.data =
(float *)malloc(sizeof(float) * snii->raw.ejected_mass_non_processed.N);
if (snii->raw.ejected_mass_non_processed.data == NULL) {
error("Failed to allocate memory for the yields");
}
restart_read_blocks((void *)snii->raw.ejected_mass_non_processed.data,
sizeof(float), snii->raw.ejected_mass_non_processed.N,
stream, NULL, "non_processed_mass_raw");
}
/* Get the IMF parameters */
snii->exponent = initial_mass_function_get_exponent(&sm->imf, snii->mass_min,
snii->mass_max);
snii->coef_exp = initial_mass_function_get_coefficient(
&sm->imf, snii->mass_min, snii->mass_max);
snii->coef_exp /= snii->exponent;
}
/**
......
......@@ -70,6 +70,7 @@ void supernovae_ii_init(struct supernovae_ii *snii,
void supernovae_ii_dump(const struct supernovae_ii *snii, FILE *stream,
const struct stellar_model *sm);
void supernovae_ii_restore(struct supernovae_ii *snii, FILE *stream,
const struct stellar_model *sm);
const struct stellar_model *sm,
struct engine *e);
void supernovae_ii_clean(struct supernovae_ii *snii);
#endif // SWIFT_SUPERNOVAE_II_GEAR_H
Markdown is supported
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