Commit 881ad540 authored by lhausamm's avatar lhausamm
Browse files

Add printing functions for grackle

parent fffcb442
......@@ -59,7 +59,8 @@ __attribute__((always_inline)) INLINE static double cooling_rate(
const struct cooling_function_data* restrict cooling,
struct part* restrict p, float dt) {
if (cooling->GrackleRedshift == -1) error("TODO time dependant redshift");
if (cooling->GrackleRedshift == -1)
error("TODO time dependant redshift");
/* Get current internal energy (dt=0) */
double u_old = hydro_get_internal_energy(p);
......@@ -73,7 +74,6 @@ __attribute__((always_inline)) INLINE static double cooling_rate(
Grackle v2.1) */
double Z = 0.02041;
if (wrap_do_cooling(rho, &u_new, dt, Z, a_now) == 0) {
error("Error in do_cooling.\n");
return 0;
......@@ -217,6 +217,7 @@ static INLINE void cooling_init_backend(
}
#ifdef SWIFT_DEBUG_CHECKS
grackle_print_data();
message("");
message("***************************************");
#endif
......@@ -231,6 +232,12 @@ static INLINE void cooling_print_backend(
const struct cooling_function_data* cooling) {
message("Cooling function is 'Grackle'.");
message("CloudyTable = %s",
cooling->GrackleCloudyTable);
message("UVbackground = %d", cooling->UVbackground);
message("GrackleRedshift = %g", cooling->GrackleRedshift);
message("GrackleHSShieldingDensityThreshold = %g atom/cm3",
cooling->GrackleHSShieldingDensityThreshold);
}
#endif /* SWIFT_COOLING_GRACKLE_H */
......@@ -164,3 +164,67 @@ int wrap_do_cooling(double rho, double *u, double dt, double Z, double a_now) {
return 1;
}
void grackle_print_data() {
message("Grackle Data:");
message("\t Data file: %s", grackle_data.grackle_data_file);
message("\t With grackle: %i", grackle_data.use_grackle);
message("\t With radiative cooling: %i", grackle_data.with_radiative_cooling);
message("\t With UV background: %i", grackle_data.UVbackground);
message("\t With primordial chemistry: %i", grackle_data.primordial_chemistry);
message("\t Number temperature bins: %i", grackle_data.NumberOfTemperatureBins);
message("\t T = (%g, ..., %g)",
grackle_data.TemperatureStart,
grackle_data.TemperatureEnd);
message("Primordial Cloudy");
cloudy_print_data(grackle_data.cloudy_primordial, 1);
if (grackle_data.metal_cooling)
{
message("Metal Cooling");
cloudy_print_data(grackle_data.cloudy_metal, 0);
}
message("\t Gamma: %g", grackle_data.Gamma);
/* UVB */
if (grackle_data.UVbackground &&
grackle_data.primordial_chemistry != 0)
{
struct UVBtable uvb = grackle_data.UVbackground_table;
long long N = uvb.Nz;
message("\t UV Background");
message("\t\t Redshift from %g to %g with %lli steps", uvb.zmin, uvb.zmax, N);
message("\t\t z = (%g, ..., %g)", uvb.z[0], uvb.z[N-1]);
}
}
void cloudy_print_data(const cloudy_data c, const int print_mmw)
{
long long N = c.data_size;
message("\t Data size: %lli", N);
message("\t Grid rank: %lli", c.grid_rank);
char msg[200] = "\t Dimension: (";
for (long long i = 0; i < c.grid_rank; i++)
{
char tmp[200] = "%lli%s";
if (i == c.grid_rank - 1)
sprintf(tmp, tmp, c.grid_dimension[i], ")");
else
sprintf(tmp, tmp, c.grid_dimension[i], ", ");
strcat(msg, tmp);
}
message("%s", msg);
if (c.heating_data)
message("\t Heating: (%g, ..., %g)", c.heating_data[0], c.heating_data[N-1]);
if (c.cooling_data)
message("\t Cooling: (%g, ..., %g)", c.cooling_data[0], c.cooling_data[N-1]);
if (c.mmw_data && print_mmw)
message("\t Mean molecular weigth: (%g, ..., %g)", c.mmw_data[0], c.mmw_data[N-1]);
}
......@@ -17,6 +17,7 @@
#include "error.h"
#include <grackle.h>
#include <chemistry_data.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -40,4 +41,8 @@ int wrap_get_cooling_time(double rho, double u, double Z, double a_now,
int wrap_do_cooling(double density, double *energy, double dtime, double Z,
double a_now);
void grackle_print_data();
void cloudy_print_data(const cloudy_data c, const int print_mmw);
#endif /* SWIFT_COOLING_GRACKLE_WRAPPER_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