Skip to content

Commit

Permalink
Introduced the unit_handling chemistry parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
mabruzzo committed Aug 13, 2024
1 parent d9113f2 commit 2beb258
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/clib/grackle_chemistry_data_fields.def
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ ENTRY(collisional_ionisation_rates, INT, 1) //Collisional ionisation
ENTRY(recombination_cooling_rates, INT, 1) //Recombination cooling
ENTRY(bremsstrahlung_cooling_rates, INT, 1) //Bremsstrahlung cooling

/* Flag to specify unit-handling. Use the GR_UNIT_HANDLING_LEGACY and
GR_UNIT_HANDLING_AUTOMATIC to set the flag values */
ENTRY(unit_handling, INT, -3)

/* maximum number of subcycle iterations for solve_chemistry */
ENTRY(max_iterations, INT, 10000)

Expand Down
17 changes: 15 additions & 2 deletions src/clib/initialize_chemistry_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,21 @@ int local_initialize_chemistry_data(chemistry_data *my_chemistry,
//omp_set_schedule( omp_sched_auto, chunk_size );
# endif

if (my_chemistry->unit_handling == -3) {
if (grackle_verbose) {
fprintf(stderr, ("WARNING: unit_handling is unset. Defaulting to legacy "
"handling.\n"));
}
my_chemistry->unit_handling = GR_UNIT_HANDLING_LEGACY;
} else if ((my_chemistry->unit_handling != GR_UNIT_HANDLING_LEGACY) &&
(my_chemistry->unit_handling != GR_UNIT_HANDLING_AUTOMATIC)) {
fprintf(stderr, "unit_handling has an invalid value\n");
return GR_FAIL;
}

/* store a copy of the initial units */
my_rates->initial_units = *my_units;

/* Only allow a units to be one with proper coordinates. */
if (my_units->comoving_coordinates == FALSE &&
my_units->a_units != 1.0) {
Expand Down Expand Up @@ -342,8 +357,6 @@ int local_initialize_chemistry_data(chemistry_data *my_chemistry,
return GR_FAIL;
}

/* store a copy of the initial units */
my_rates->initial_units = *my_units;

if (grackle_verbose) {
time_t timer;
Expand Down
3 changes: 3 additions & 0 deletions src/include/grackle.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ extern "C" {
#define GR_FAIL 0

#define GR_SPECIFY_INITIAL_A_VALUE -1
#define GR_UNIT_HANDLING_LEGACY -2
#define GR_UNIT_HANDLING_AUTOMATIC -1


extern int grackle_verbose;

Expand Down
3 changes: 3 additions & 0 deletions src/include/grackle_chemistry_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ typedef struct
int recombination_cooling_rates; //Recombination cooling
int bremsstrahlung_cooling_rates; //Bremsstrahlung cooling

/* Flag to specify unit-handling */
int unit_handling;

/* maximum number of subcycle iterations for solve_chemistry */
int max_iterations;

Expand Down

0 comments on commit 2beb258

Please sign in to comment.