Commit 7bca4ea7 authored by lhausamm's avatar lhausamm
Browse files

Comments mode > 0, initialize a_value, removed grackle_data from printing...

Comments mode > 0, initialize a_value, removed grackle_data from printing function (use cooling->chemistry now)
parent 3a6ea61d
...@@ -75,10 +75,10 @@ __attribute__((always_inline))INLINE static void cooling_print_backend( ...@@ -75,10 +75,10 @@ __attribute__((always_inline))INLINE static void cooling_print_backend(
const struct cooling_function_data* cooling) { const struct cooling_function_data* cooling) {
message("Cooling function is 'Grackle'."); message("Cooling function is 'Grackle'.");
message("Using Grackle = %i", grackle_data->use_grackle); message("Using Grackle = %i", cooling->chemistry.use_grackle);
message("Chemical network = %i", grackle_data->primordial_chemistry); message("Chemical network = %i", cooling->chemistry.primordial_chemistry);
message("Radiative cooling = %i", grackle_data->with_radiative_cooling); message("Radiative cooling = %i", cooling->chemistry.with_radiative_cooling);
message("Metal cooling = %i", grackle_data->metal_cooling); message("Metal cooling = %i", cooling->chemistry.metal_cooling);
message("CloudyTable = %s", message("CloudyTable = %s",
cooling->cloudy_table); cooling->cloudy_table);
...@@ -113,7 +113,8 @@ __attribute__((always_inline)) INLINE static double cooling_rate( ...@@ -113,7 +113,8 @@ __attribute__((always_inline)) INLINE static double cooling_rate(
const struct cooling_function_data* restrict cooling, const struct cooling_function_data* restrict cooling,
struct part* restrict p, float dt) { struct part* restrict p, float dt) {
cooling_print_backend(cooling); if (cooling->chemistry.primordial_chemistry > 1)
error("Not implemented");
/* set current time */ /* set current time */
code_units units = cooling->units; code_units units = cooling->units;
...@@ -150,39 +151,59 @@ __attribute__((always_inline)) INLINE static double cooling_rate( ...@@ -150,39 +151,59 @@ __attribute__((always_inline)) INLINE static double cooling_rate(
data.y_velocity = &vy; data.y_velocity = &vy;
data.z_velocity = &vz; data.z_velocity = &vz;
/* primordial chemistry >= 1 */ /* /\* primordial chemistry >= 1 *\/ */
data.HI_density = NULL; /* gr_float HI_density = density; */
data.HII_density = NULL; /* gr_float HII_density = 0.; */
data.HeI_density = NULL; /* gr_float HeI_density = 0.; */
data.HeII_density = NULL; /* gr_float HeII_density = 0.; */
data.HeIII_density = NULL; /* gr_float HeIII_density = 0.; */
data.e_density = NULL; /* gr_float e_density = 0.; */
/* primordial chemistry >= 2 */
data.HM_density = NULL; /* data.HI_density = &HI_density; */
data.H2I_density = NULL; /* data.HII_density = &HII_density; */
data.H2II_density = NULL; /* data.HeI_density = &HeI_density; */
/* primordial chemistry >= 3 */ /* data.HeII_density = &HeII_density; */
data.DI_density = NULL; /* data.HeIII_density = &HeIII_density; */
data.DII_density = NULL; /* data.e_density = &e_density; */
data.HDI_density = NULL;
/* /\* primordial chemistry >= 2 *\/ */
/* gr_float HM_density = 0.; */
/* gr_float H2I_density = 0.; */
/* gr_float H2II_density = 0.; */
/* data.HM_density = &HM_density; */
/* data.H2I_density = &H2I_density; */
/* data.H2II_density = &H2II_density; */
/* /\* primordial chemistry >= 3 *\/ */
/* gr_float DI_density = 0.; */
/* gr_float DII_density = 0.; */
/* gr_float HDI_density = 0.; */
/* data.DI_density = &DI_density; */
/* data.DII_density = &DII_density; */
/* data.HDI_density = &HDI_density; */
/* metal cooling = 1 */ /* metal cooling = 1 */
const double Z = 0.02041; gr_float metal_density = density * grackle_data->SolarMetalFractionByMass;
gr_float metal_density = Z * density;
data.metal_density = &metal_density; data.metal_density = &metal_density;
/* volumetric heating rate */ /* /\* volumetric heating rate *\/ */
data.volumetric_heating_rate = NULL; /* gr_float volumetric_heating_rate = 0.; */
/* specific heating rate */
data.specific_heating_rate = NULL; /* data.volumetric_heating_rate = &volumetric_heating_rate; */
/* /\* specific heating rate *\/ */
/* gr_float specific_heating_rate = 0.; */
/* data.specific_heating_rate = &specific_heating_rate; */
/* solve chemistry with table */ /* solve chemistry with table */
if (solve_chemistry(&units, &data, dt) == 0) { if (solve_chemistry(&units, &data, dt) == 0) {
error("Error in solve_chemistry."); error("Error in solve_chemistry.");
} }
message("Energy: %g, %g, %g", energy, energy_before, dt);
exit(1);
return (energy - energy_before) / dt; return (energy - energy_before) / dt;
} }
...@@ -269,6 +290,7 @@ __attribute__((always_inline))INLINE static void cooling_init_backend( ...@@ -269,6 +290,7 @@ __attribute__((always_inline))INLINE static void cooling_init_backend(
/* first cosmo */ /* first cosmo */
cooling->units.a_units = 1.0; // units for the expansion factor (1/1+zi) cooling->units.a_units = 1.0; // units for the expansion factor (1/1+zi)
cooling->units.a_value = 1.0;
/* We assume here all physical quantities to /* We assume here all physical quantities to
be in proper coordinate (not comobile) */ be in proper coordinate (not comobile) */
...@@ -297,16 +319,20 @@ __attribute__((always_inline))INLINE static void cooling_init_backend( ...@@ -297,16 +319,20 @@ __attribute__((always_inline))INLINE static void cooling_init_backend(
chemistry->metal_cooling = 1; // metal cooling on chemistry->metal_cooling = 1; // metal cooling on
chemistry->UVbackground = cooling->uv_background; chemistry->UVbackground = cooling->uv_background;
chemistry->grackle_data_file = cooling->cloudy_table; chemistry->grackle_data_file = cooling->cloudy_table;
chemistry->use_radiative_transfer = 0;
chemistry->use_volumetric_heating_rate = 0;
chemistry->use_specific_heating_rate = 0;
/* Initialize the chemistry object. */ /* Initialize the chemistry object. */
if (initialize_chemistry_data(&cooling->units) == 0) { if (initialize_chemistry_data(&cooling->units) == 0) {
error("Error in initialize_chemistry_data."); error("Error in initialize_chemistry_data.");
} }
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (GRACKLE_NPART != 1) if (GRACKLE_NPART != 1)
error("Grackle with multiple particles not implemented"); error("Grackle with multiple particles not implemented");
float threshold = cooling->GrackleHSShieldingDensityThreshold; float threshold = cooling->density_self_shielding;
threshold /= phys_const->const_proton_mass; threshold /= phys_const->const_proton_mass;
threshold /= pow(us->UnitLength_in_cgs, 3); threshold /= pow(us->UnitLength_in_cgs, 3);
...@@ -318,10 +344,10 @@ __attribute__((always_inline))INLINE static void cooling_init_backend( ...@@ -318,10 +344,10 @@ __attribute__((always_inline))INLINE static void cooling_init_backend(
message("Density Self Shielding = %g atom/cm3", threshold); message("Density Self Shielding = %g atom/cm3", threshold);
//grackle_print_data();
message(""); message("");
message("***************************************"); message("***************************************");
#endif #endif
} }
#endif /* SWIFT_COOLING_GRACKLE_H */ #endif /* SWIFT_COOLING_GRACKLE_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