Primary Functions¶
-
int set_default_chemistry_parameters(chemistry_data *my_grackle_data);
Initializes the
grackle_data
data structure. This must be called before run-time parameters can be set.Parameters: - my_grackle_data (chemistry_data*) – run-time parameters
Return type: int
Returns: 1 (success) or 0 (failure)
-
int initialize_chemistry_data(code_units *my_units);
Loads all chemistry and cooling data, given the set run-time parameters. This can only be called after
set_default_chemistry_parameters()
.Parameters: - my_units (code_units*) – code units conversions
Return type: int
Returns: 1 (success) or 0 (failure)
-
int free_chemistry_data ();
Deallocates all data allocations made during the call to
initialize_chemistry_data()
. Issues may arise if the globalgrackle_data
data structure was mutated between the call toinitialize_chemistry_data()
and the call to this function.Return type: int Returns: 1 (success) or 0 (failure)
-
void set_velocity_units(code_units *my_units);
Sets the
velocity_units
value of the inputmy_units
code_units
struct. For proper coordinates, velocity units are equal tolength_units
/time_units
. For comoving coordinates, velocity units are equal to (length_units
/a_value
) /time_units
.Parameters: - my_units (code_units*) – code units conversions
-
double get_velocity_units(code_units *my_units);
Returns the appropriate value for velocity units given the values of
length_units
,a_value
, andtime_units
in the inputmy_units
code_units
struct. For proper coordinates, velocity units are equal tolength_units
/time_units
. For comoving coordinates, velocity units are equal to (length_units
/a_value
) /time_units
. Note, this function only returns a value, but does not set it in the struct. To set the value in the struct, useset_velocity_units
.Parameters: - my_units (code_units*) – code units conversions
Return type: double
Returns: velocity_units
-
double get_temperature_units(code_units *my_units);
Returns the conversion factor between specific internal energy and temperature assuming gamma (the adiabatic index) = 1, such that temperature in K is equal to
internal_energy
*temperature_units
. This unit conversion is defined as mH *velocity_units
2 / kb, where mH is the Hydrogen mass and kb is the Boltzmann constant.Parameters: - my_units (code_units*) – code units conversions
Return type: double
Returns: temperature_units
-
int solve_chemistry(code_units *my_units, grackle_field_data *my_fields, double dt_value);
Evolves the species densities and internal energies over a given timestep by solving the chemistry and cooling rate equations.
Parameters: - my_units (code_units*) – code units conversions
- my_fields (grackle_field_data*) – field data storage
- dt_value (double) – the integration timestep in code units
Return type: int
Returns: 1 (success) or 0 (failure)
-
int calculate_cooling_time(code_units *my_units, grackle_field_data *my_fields, gr_float *cooling_time);
Calculates the instantaneous cooling time.
Parameters: - my_units (code_units*) – code units conversions
- my_fields (grackle_field_data*) – field data storage
- cooling_time (gr_float*) – array which will be filled with the calculated cooling time values
Return type: int
Returns: 1 (success) or 0 (failure)
-
int calculate_gamma(code_units *my_units, grackle_field_data *my_fields, gr_float *my_gamma);
Calculates the effective adiabatic index. This is only useful with
primordial_chemistry
>= 2 as the only thing that alters gamma from the single value is H2.Parameters: - my_units (code_units*) – code units conversions
- my_fields (grackle_field_data*) – field data storage
- my_gamma (gr_float*) – array which will be filled with the calculated gamma values
Return type: int
Returns: 1 (success) or 0 (failure)
-
int calculate_pressure(code_units *my_units, grackle_field_data *my_fields, gr_float *pressure);
Calculates the gas pressure.
Parameters: - my_units (code_units*) – code units conversions
- my_fields (grackle_field_data*) – field data storage
- pressure (gr_float*) – array which will be filled with the calculated pressure values
Return type: int
Returns: 1 (success) or 0 (failure)
-
int calculate_temperature(code_units *my_units, grackle_field_data *my_fields, gr_float *temperature);
Calculates the gas temperature.
Parameters: - my_units (code_units*) – code units conversions
- my_fields (grackle_field_data*) – field data storage
- temperature (gr_float*) – array which will be filled with the calculated temperature values
Return type: int
Returns: 1 (success) or 0 (failure)
-
int calculate_dust_temperature(code_units *my_units, grackle_field_data *my_fields, gr_float *dust_temperature);
Calculates the dust temperature. The dust temperature calculation is modified from its original version (Section 4.3 of Smith et al. 2017) to also include the heating of dust grains by the interstellar radiation field following equation B15 of Krumholz (2014).
Using this function requires
dust_chemistry
> 0 orh2_on_dust
> 0.Parameters: - my_units (code_units*) – code units conversions
- my_fields (grackle_field_data*) – field data storage
- dust_temperature (gr_float*) – array which will be filled with the calculated dust temperature values
Return type: int
Returns: 1 (success) or 0 (failure)
-
grackle_version get_grackle_version();
Constructs and returns a
grackle_version
struct that encodes the version information for the library.Return type: grackle_version