API Reference

The Grackle has a few different versions of the various functions for solving the chemistry and cooling and calculating related fields. One set of functions requires the user to work with C structs, while the other does not. The set that does not use structs is simpler to implement in Fortran codes. Both of these rely internally on a chemistry_data type struct called grackle_data, which exists in the grackle namespace. A third set of functions also exists that requires the user to hold and pass their own chemistry_data struct.

Functions using structs (best for C and C++)

These functions require the user to directly access the grackle_data data structure to set parameters and to creata a code_units struct to control the unit system. These functions are used in the examples, c_example.c, c_table_example.c, cxx_example.C, and cxx_table_example.C.

int set_default_chemistry_parameters();

Initializes the grackle_data data structure. This must be called before run time parameters can be set.

Return type:int
Returns:1 (success) or 0 (failure)
int initialize_chemistry_data(code_units *my_units, double a_value);

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
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
Return type:

int

Returns:

1 (success) or 0 (failure)

int solve_chemistry(code_units *my_units, double a_value, double dt_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density);

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
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • dt_value (double) – the integration timestep in code units
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • x_velocity (gr_float*) – array containing the x velocity values in code units
  • y_velocity (gr_float*) – array containing the y velocity values in code units
  • z_velocity (gr_float*) – array containing the z velocity values in code units
  • HI_density (gr_float*) – array containing the HI densities in code units equivalent those of the density array. Used with primordial_chemistry >= 1.
  • HII_density (gr_float*) – array containing the HII densities in code units equivalent those of the density array. Used with primordial_chemistry >= 1.
  • HM_density (gr_float*) – array containing the H- densities in code units equivalent those of the density array. Used with primordial_chemistry >= 2.
  • HeI_density (gr_float*) – array containing the HeI densities in code units equivalent those of the density array. Used with primordial_chemistry >= 1.
  • HeII_density (gr_float*) – array containing the HeII densities in code units equivalent those of the density array. Used with primordial_chemistry >= 1.
  • HeIII_density (gr_float*) – array containing the HeIII densities in code units equivalent those of the density array. Used with primordial_chemistry >= 1.
  • H2I_density (gr_float*) – array containing the H2: densities in code units equivalent those of the density array. Used with primordial_chemistry >= 2.
  • H2II_density (gr_float*) – array containing the H2+densities in code units equivalent those of the density array. Used with primordial_chemistry >= 2.
  • DI_density (gr_float*) – array containing the DI (deuterium) densities in code units equivalent those of the density array. Used with primordial_chemistry = 3.
  • DII_density (gr_float*) – array containing the DII densities in code units equivalent those of the density array. Used with primordial_chemistry = 3.
  • HDI_density (gr_float*) – array containing the HD densities in code units equivalent those of the density array. Used with primordial_chemistry = 3.
  • e_density (gr_float*) – array containing the e- densities in code units equivalent those of the density array but normalized to the ratio of the proton to electron mass. Used with primordial_chemistry >= 1.
  • metal_density (gr_float*) – array containing the metal densities in code units equivalent those of the density array. Used with metal_cooling = 1.
Return type:

int

Returns:

1 (success) or 0 (failure)

int calculate_cooling_time(code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *cooling_time);

Calculates the instantaneous cooling time.

Parameters:
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • x_velocity, y_velocity, z_velocity (gr_float*) – arrays containing the x, y, and z velocity values in code units
  • HI_density, HII_density, HM_density, HeI_density, HeII_density, HeIII_density, H2I_density, H2II_density, DI_density, DII_density, HDI_density, e_density, metal_density (gr_float*) – arrays containing the species densities in code units equivalent those of the density array
  • 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, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, 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
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • HI_density, HII_density, HM_density, HeI_density, HeII_density, HeIII_density, H2I_density, H2II_density, DI_density, DII_density, HDI_density, e_density, metal_density (gr_float*) – arrays containing the species densities in code units equivalent those of the density array
  • 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, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *pressure);

Calculates the gas pressure.

Parameters:
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • HI_density, HII_density, HM_density, HeI_density, HeII_density, HeIII_density, H2I_density, H2II_density, DI_density, DII_density, HDI_density, e_density, metal_density (gr_float*) – arrays containing the species densities in code units equivalent those of the density array
  • 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, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *temperature);

Calculates the gas temperature.

Parameters:
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • HI_density, HII_density, HM_density, HeI_density, HeII_density, HeIII_density, H2I_density, H2II_density, DI_density, DII_density, HDI_density, e_density, metal_density (gr_float*) – arrays containing the species densities in code units equivalent those of the density array
  • temperature (gr_float*) – array which will be filled with the calculated temperature values
Return type:

int

Returns:

1 (success) or 0 (failure)

Tabular-Only Functions

These are slimmed down functions that require primordial_chemistry = 0 and use only the tabulated cooling rates (no chemistry).

int solve_chemistry_table(code_units *my_units, double a_value, double dt_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *metal_density);

Evolves the internal energies over a given timestep by solving the cooling rate equations. This version allows only for the use of the tabulated cooling functions.

Parameters:
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • dt_value (double) – the integration timestep in code units
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • x_velocity (gr_float*) – array containing the x velocity values in code units
  • y_velocity (gr_float*) – array containing the y velocity values in code units
  • z_velocity (gr_float*) – array containing the z velocity values in code units
  • metal_density (gr_float*) – array containing the metal densities in code units equivalent those of the density array. Used with metal_cooling = 1.
Return type:

int

Returns:

1 (success) or 0 (failure)

int calculate_cooling_time_table(code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *metal_density, gr_float *cooling_time);

Calculates the instantaneous cooling time. This version allows only for the use of the tabulated cooling functions.

Parameters:
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • x_velocity, y_velocity, z_velocity (gr_float*) – arrays containing the x, y, and z velocity values in code units
  • metal_density (gr_float*) – array containing the metal densities in code units equivalent those of the density array. Used with metal_cooling = 1.
  • 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_pressure_table(code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *pressure);

Calculates the gas pressure. This version allows only for the use of the tabulated cooling functions.

Parameters:
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • 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_table(code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *metal_density, gr_float *temperature);

Calculates the gas temperature. This version allows only for the use of the tabulated cooling functions.

Parameters:
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
  • grid_rank (int) – the dimensionality of the grid
  • grid_dimension (int*) – array holding the size of the baryon field in each dimension
  • grid_start (int*) – array holding the starting indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones
  • grid_end (int*) – array holding the ending indices in each dimension of the active portion of the baryon fields. This is used to ignore ghost zones.
  • density (gr_float*) – array containing the density values in code units
  • internal_energy (gr_float*) – array containing the specific internal energy values in code units corresponding to erg/g
  • pressure (gr_float*) – array which will be filled with the calculated pressure values
Return type:

int

Returns:

1 (success) or 0 (failure)

Functions without structs (best for Fortran)

These functions do not use any structs and are therefore much simpler to implement in Fortran codes. These are used in the example files, c_example_nostruct.c, c_table_example_nostruct.c, fortran_example.F, and fortran_table_example.F.

Note

In Fortran codes, these should be called without the trailing underscore. The variable types can be mapped to Fortran as: int* becomes integer, double* becomes real*8, and gr_float* becomes R_PREC.

int initialize_grackle_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *use_grackle, int *with_radiative_cooling, char *grackle_file, int *primordial_chemistry, int *metal_cooling, int *UVbackground, int *h2_on_dust, int *cmb_temperature_floor, double *gamma, int n1);

Initializes the grackle data structures and associated chemistry and cooling data. This performs the operations of both set_default_chemistry_parameters() and initialize_chemistry_data().

Parameters:

Note

The last argument should omitted.

int solve_chemistry_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, double *dt_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density);

Evolves the species densities and internal energies over a given timestep by solving the chemistry and cooling rate equations.

int calculate_cooling_time_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *cooling_time);

Calculates the instantaneous cooling time.

int calculate_gamma_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, 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.

int calculate_pressure_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *pressure);

Calculates the gas pressure.

int calculate_temperature_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *temperature);

Calculates the gas temperature.

Tabular-Only Functions

These are slimmed down functions that require primordial_chemistry = 0 and use only the tabulated cooling rates (no chemistry).

int solve_chemistry_table_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, double *dt_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *metal_density);

Evolves the internal energies over a given timestep by solving the cooling rate equations. This version allows only for the use of the tabulated cooling functions.

int calculate_cooling_time_table_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *metal_density, gr_float *cooling_time);

Calculates the instantaneous cooling time. This version allows only for the use of the tabulated cooling functions.

int calculate_pressure_table_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *pressure);

Calculates the gas pressure. This version allows only for the use of the tabulated cooling functions.

int calculate_temperature_table_(int *comoving_coordinates, double *density_units, double *length_units, double *time_units, double *velocity_units, double *a_units, double *a_value, int *grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *metal_density, gr_float *temperature);

Calculates the gas temperature. This version allows only for the use of the tabulated cooling functions.

Internal Functions

These functions are mostly for internal use, but can also be used to call the various functions with different parameter values within a single code.

chemistry_data _set_default_chemistry_parameters();

Initializes and returns chemistry_data data structure. This must be called before run time parameters can be set.

Returns:data structure containing all run time parameters and all chemistry and cooling data arrays
Return type:chemistry_data
int _initialize_chemistry_data(chemistry_data *my_chemistry, code_units *my_units, double a_value);

Loads all chemistry and cooling data, given the set run time parameters. This can only be called after _set_default_chemistry_parameters().

Parameters:
  • my_chemistry (chemistry_data*) – the structure returned by _set_default_chemistry_parameters()
  • my_units (code_units*) – code units conversions
  • a_value (double) – the expansion factor in code units (a_code = a / a_units)
Return type:

int

Returns:

1 (success) or 0 (failure)

int _solve_chemistry(chemistry_data *my_chemistry, code_units *my_units, double a_value, double dt_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density);

Evolves the species densities and internal energies over a given timestep by solving the chemistry and cooling rate equations.

int _calculate_cooling_time(chemistry_data *my_chemistry, code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *cooling_time);

Calculates the instantaneous cooling time.

int _calculate_gamma(chemistry_data *my_chemistry, code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, 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.

int _calculate_pressure(chemistry_data *my_chemistry, code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *pressure);

Calculates the gas pressure.

int _calculate_temperature(chemistry_data *my_chemistry, code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *HI_density, gr_float *HII_density, gr_float *HM_density, gr_float *HeI_density, gr_float *HeII_density, gr_float *HeIII_density, gr_float *H2I_density, gr_float *H2II_density, gr_float *DI_density, gr_float *DII_density, gr_float *HDI_density, gr_float *e_density, gr_float *metal_density, gr_float *temperature);

Calculates the gas temperature.

Tabular-Only Functions

These are slimmed down functions that require primordial_chemistry = 0 and use only the tabulated cooling rates (no chemistry).

int _solve_chemistry_table(chemistry_data *my_chemistry, code_units *my_units, double a_value, double dt_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *metal_density);

Evolves the internal energies over a given timestep by solving the cooling rate equations. This version allows only for the use of the tabulated cooling functions.

int _calculate_cooling_time_table(chemistry_data *my_chemistry, code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *x_velocity, gr_float *y_velocity, gr_float *z_velocity, gr_float *metal_density, gr_float *cooling_time);

Calculates the instantaneous cooling time. This version allows only for the use of the tabulated cooling functions.

int _calculate_pressure_table(chemistry_data *my_chemistry, code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *pressure);

Calculates the gas pressure. This version allows only for the use of the tabulated cooling functions.

int _calculate_temperature_table(chemistry_data *my_chemistry, code_units *my_units, double a_value, int grid_rank, int *grid_dimension, int *grid_start, int *grid_end, gr_float *density, gr_float *internal_energy, gr_float *metal_density, gr_float *temperature);

Calculates the gas temperature. This version allows only for the use of the tabulated cooling functions.