Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
5502ab44
Commit
5502ab44
authored
7 years ago
by
lhausamm
Browse files
Options
Downloads
Patches
Plain Diff
Update grackle parameters and clean code
parent
e541a136
No related branches found
No related tags found
1 merge request
!499
Improved grackle
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/parameter_example.yml
+8
-5
8 additions, 5 deletions
examples/parameter_example.yml
src/cooling/grackle/cooling.h
+104
-106
104 additions, 106 deletions
src/cooling/grackle/cooling.h
src/cooling/grackle/cooling_struct.h
+13
-1
13 additions, 1 deletion
src/cooling/grackle/cooling_struct.h
with
125 additions
and
112 deletions
examples/parameter_example.yml
+
8
−
5
View file @
5502ab44
...
@@ -179,12 +179,15 @@ LambdaCooling:
...
@@ -179,12 +179,15 @@ LambdaCooling:
hydrogen_mass_abundance
:
0.75
# Hydrogen mass abundance (dimensionless)
hydrogen_mass_abundance
:
0.75
# Hydrogen mass abundance (dimensionless)
cooling_tstep_mult
:
1.0
# Dimensionless pre-factor for the time-step condition
cooling_tstep_mult
:
1.0
# Dimensionless pre-factor for the time-step condition
# Cooling with Grackle
2
.0
# Cooling with Grackle
3
.0
GrackleCooling
:
GrackleCooling
:
GrackleCloudyTable
:
CloudyData_UVB=HM2012.h5
# Name of the Cloudy Table (available on the grackle bitbucket repository)
CloudyTable
:
CloudyData_UVB=HM2012.h5
# Name of the Cloudy Table (available on the grackle bitbucket repository)
UVbackground
:
1
# Enable or not the UV background
WithUVbackground
:
1
# Enable or not the UV background
GrackleRedshift
:
0
# Redshift to use (-1 means time based redshift)
Redshift
:
0
# Redshift to use (-1 means time based redshift)
GrackleHSShieldingDensityThreshold
:
1.1708e-26
# self shielding threshold in atom/cm3
WithMetalCooling
:
1
# Enable or not the metal cooling
ProvideVolumetricHeatingRates
:
0
# User provide volumetric heating rates
ProvideSpecificHeatingRates
:
0
# User provide specific heating rates
SelfShieldingMethod
:
0
# Grackle (<= 3) or Gear self shielding method
# Parameters related to chemistry models -----------------------------------------------
# Parameters related to chemistry models -----------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
src/cooling/grackle/cooling.h
+
104
−
106
View file @
5502ab44
...
@@ -123,92 +123,24 @@ __attribute__((always_inline)) INLINE static void cooling_print_backend(
...
@@ -123,92 +123,24 @@ __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"
,
cooling
->
chemistry
.
use_grackle
);
message
(
"Using Grackle = %i"
,
cooling
->
chemistry
.
use_grackle
);
message
(
"Chemical network
= %i"
,
message
(
"Chemical network = %i"
,
cooling
->
chemistry
.
primordial_chemistry
);
cooling
->
chemistry
.
primordial_chemistry
);
message
(
"
Radiative cooling
= %
i
"
,
message
(
"
CloudyTable
= %
s
"
,
cooling
->
cloudy_table
);
cooling
->
chemistry
.
with_radiative_cooling
);
message
(
"Redshift = %g"
,
cooling
->
redshift
);
message
(
"
Metal cooling
= %
i
"
,
cooling
->
chemistry
.
metal_cooling
);
message
(
"
UV background
= %
d
"
,
cooling
->
with_uv_background
);
message
(
"Metal cooling = %i"
,
cooling
->
chemistry
.
metal_cooling
);
message
(
"
CloudyTable
= %
s
"
,
cooling
->
cloudy_table
);
message
(
"
Self Shielding
= %
i
"
,
cooling
->
self_shielding_method
);
message
(
"
UVbackground
= %
d
"
,
cooling
->
uv_background
);
message
(
"
Specific Heating Rates
= %
i
"
,
message
(
"Redshift = %g"
,
cooling
->
redshift
);
cooling
->
provide_specific_heating_rates
);
message
(
"
S
ol
ar Metal Fraction
= %
g
"
,
message
(
"
V
ol
umetric Heating Rates
= %
i
"
,
cooling
->
chemistry
.
SolarMetalFractionByMas
s
);
cooling
->
provide_volumetric_heating_rate
s
);
message
(
"Units:"
);
message
(
"Units:"
);
message
(
"
\t
Comoving = %i"
,
cooling
->
units
.
comoving_coordinates
);
message
(
"
\t
Comoving = %i"
,
cooling
->
units
.
comoving_coordinates
);
message
(
"
\t
Length = %g"
,
cooling
->
units
.
length_units
);
message
(
"
\t
Length = %g"
,
cooling
->
units
.
length_units
);
message
(
"
\t
Density = %g"
,
cooling
->
units
.
density_units
);
message
(
"
\t
Density = %g"
,
cooling
->
units
.
density_units
);
message
(
"
\t
Time = %g"
,
cooling
->
units
.
time_units
);
message
(
"
\t
Time = %g"
,
cooling
->
units
.
time_units
);
message
(
"
\t
Scale Factor = %g"
,
cooling
->
units
.
a_units
);
message
(
"
\t
Scale Factor = %g"
,
cooling
->
units
.
a_units
);
#ifdef SWIFT_DEBUG_CHECKS
/*
const chemistry_data *tmp = &cooling->chemistry;
message("Debug:");
message("UVBackground = %i", tmp->UVbackground);
message("Grackle data file = %s", tmp->grackle_data_file);
message("CMB temperature floor = %i", tmp->cmb_temperature_floor);
message("Gamma = %g", tmp->Gamma);
message("H2 on dust = %i", tmp->h2_on_dust);
message("Photoelectric heating = %i", tmp->photoelectric_heating);
message("Photoelectric heating rate = %g",
tmp->photoelectric_heating_rate);
message("Use volumetric heating rate = %i",
tmp->use_volumetric_heating_rate);
message("Use specific heating rate = %i",
tmp->use_specific_heating_rate);
message("Three body = %i", tmp->three_body_rate);
message("Cie cooling = %i", tmp->cie_cooling);
message("h2 optical depth approx = %i",
tmp->h2_optical_depth_approximation);
message("ih2co = %i", tmp->ih2co);
message("ipiht = %i", tmp->ipiht);
message("Hydrogen Fraction = %g", tmp->HydrogenFractionByMass);
message("Deuterium/Hydrogen ratio = %g",
tmp->DeuteriumToHydrogenRatio);
message("Solar metal fraction = %g",
tmp->SolarMetalFractionByMass);
message("Number T bins = %i",
tmp->NumberOfTemperatureBins);
message("Case B recombination = %i", tmp->CaseBRecombination);
message("T start = %g", tmp->TemperatureStart);
message("T end = %g", tmp->TemperatureEnd);
message("Number dust T bins = %i",
tmp->NumberOfDustTemperatureBins);
message("Dust T start = %g", tmp->DustTemperatureStart);
message("Dust T end = %g", tmp->DustTemperatureEnd);
message("Compton xray heating = %i", tmp->Compton_xray_heating);
message("LW background sawtooth suppression = %i",
tmp->LWbackground_sawtooth_suppression);
message("LW background intensity = %g", tmp->LWbackground_intensity);
message("UV redshift on = %g",
tmp->UVbackground_redshift_on);
message("UV redshift off = %g",
tmp->UVbackground_redshift_off);
message("UV redshift fullon = %g",
tmp->UVbackground_redshift_fullon);
message("UV redshift drop = %g",
tmp->UVbackground_redshift_drop);
message("Cloudy electron fraction = %g",
tmp->cloudy_electron_fraction_factor);
message("Use radiative transfer = %i", tmp->use_radiative_transfer);
message("RT coupled rate solver = %i",
tmp->radiative_transfer_coupled_rate_solver);
message("RT intermediate step = %i",
tmp->radiative_transfer_intermediate_step);
message("RT H only = %i",
tmp->radiative_transfer_hydrogen_only);
message("Self shielding method = %i", tmp->self_shielding_method);
*/
#endif
}
}
/**
/**
...
@@ -513,37 +445,49 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
...
@@ -513,37 +445,49 @@ __attribute__((always_inline)) INLINE static float cooling_timestep(
return
FLT_MAX
;
return
FLT_MAX
;
}
}
/**
/**
* @brief Initialises the cooling properties.
* @brief Parser the parameter file and initialize the #cooling_function_data
*
* @param parameter_file The parser parameter file
* @param parameter_file The parsed parameter file.
* @param us The current internal system of units.
* @param phys_const The physical constants in internal units.
* @param cooling The cooling properties to initialize
* @param cooling The cooling properties to initialize
*/
*/
__attribute__
((
always_inline
))
INLINE
static
void
cooling_init_backend
(
__attribute__
((
always_inline
))
INLINE
static
void
cooling_parse_arguments
(
const
struct
swift_params
*
parameter_file
,
const
struct
unit_system
*
us
,
const
struct
swift_params
*
parameter_file
,
const
struct
phys_const
*
phys_const
,
struct
cooling_function_data
*
cooling
)
{
struct
cooling_function_data
*
cooling
)
{
if
(
GRACKLE_NPART
!=
1
)
parser_get_param_string
(
parameter_file
,
"GrackleCooling:CloudyTable"
,
error
(
"Grackle with multiple particles not implemented"
);
/* read parameters */
parser_get_param_string
(
parameter_file
,
"GrackleCooling:GrackleCloudyTable"
,
cooling
->
cloudy_table
);
cooling
->
cloudy_table
);
cooling
->
uv_background
=
cooling
->
with_
uv_background
=
parser_get_param_int
(
parameter_file
,
"GrackleCooling:UVbackground"
);
parser_get_param_int
(
parameter_file
,
"GrackleCooling:
With
UVbackground"
);
cooling
->
redshift
=
cooling
->
redshift
=
parser_get_param_double
(
parameter_file
,
"GrackleCooling:
Grackle
Redshift"
);
parser_get_param_double
(
parameter_file
,
"GrackleCooling:Redshift"
);
#ifdef SWIFT_DEBUG_CHECKS
cooling
->
with_metal_cooling
=
/* enable verbose for grackle */
parser_get_param_int
(
parameter_file
,
"GrackleCooling:WithMetalCooling"
);
grackle_verbose
=
1
;
#endif
cooling
->
provide_volumetric_heating_rates
=
/* Set up the units system.
parser_get_param_int
(
parameter_file
,
"GrackleCooling:ProvideVolumetricHeatingRates"
);
These are conversions from code units to cgs. */
cooling
->
provide_specific_heating_rates
=
parser_get_param_int
(
parameter_file
,
"GrackleCooling:ProvideSpecificHeatingRates"
);
cooling
->
self_shielding_method
=
parser_get_param_int
(
parameter_file
,
"GrackleCooling:SelfShieldingMethod"
);
}
/**
* @brief Initialises the cooling unit system.
*
* @param us The current internal system of units.
* @param cooling The cooling properties to initialize
*/
__attribute__
((
always_inline
))
INLINE
static
void
cooling_init_units
(
const
struct
unit_system
*
us
,
struct
cooling_function_data
*
cooling
)
{
/* These are conversions from code units to cgs. */
/* 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)
...
@@ -561,6 +505,20 @@ __attribute__((always_inline)) INLINE static void cooling_init_backend(
...
@@ -561,6 +505,20 @@ __attribute__((always_inline)) INLINE static void cooling_init_backend(
cooling
->
units
.
velocity_units
=
cooling
->
units
.
a_units
*
cooling
->
units
.
velocity_units
=
cooling
->
units
.
a_units
*
cooling
->
units
.
length_units
/
cooling
->
units
.
length_units
/
cooling
->
units
.
time_units
;
cooling
->
units
.
time_units
;
}
/**
* @brief Initialises Grackle.
*
* @param cooling The cooling properties to initialize
*/
__attribute__
((
always_inline
))
INLINE
static
void
cooling_init_grackle
(
struct
cooling_function_data
*
cooling
)
{
#ifdef SWIFT_DEBUG_CHECKS
/* enable verbose for grackle */
grackle_verbose
=
1
;
#endif
chemistry_data
*
chemistry
=
&
cooling
->
chemistry
;
chemistry_data
*
chemistry
=
&
cooling
->
chemistry
;
...
@@ -576,13 +534,26 @@ __attribute__((always_inline)) INLINE static void cooling_init_backend(
...
@@ -576,13 +534,26 @@ __attribute__((always_inline)) INLINE static void cooling_init_backend(
/* molecular network with H, He, D
/* molecular network with H, He, D
From Cloudy table */
From Cloudy table */
chemistry
->
primordial_chemistry
=
COOLING_GRACKLE_MODE
;
chemistry
->
primordial_chemistry
=
COOLING_GRACKLE_MODE
;
chemistry
->
metal_cooling
=
1
;
chemistry
->
metal_cooling
=
cooling
->
with_metal_cooling
;
chemistry
->
UVbackground
=
cooling
->
uv_background
;
chemistry
->
UVbackground
=
cooling
->
with_
uv_background
;
chemistry
->
grackle_data_file
=
cooling
->
cloudy_table
;
chemistry
->
grackle_data_file
=
cooling
->
cloudy_table
;
chemistry
->
use_radiative_transfer
=
0
;
/* radiative transfer */
chemistry
->
use_volumetric_heating_rate
=
0
;
chemistry
->
use_radiative_transfer
=
chemistry
->
use_specific_heating_rate
=
0
;
cooling
->
provide_specific_heating_rates
||
cooling
->
provide_volumetric_heating_rates
;
chemistry
->
use_volumetric_heating_rate
=
cooling
->
provide_volumetric_heating_rates
;
chemistry
->
use_specific_heating_rate
=
cooling
->
provide_specific_heating_rates
;
if
(
cooling
->
provide_specific_heating_rates
&&
cooling
->
provide_volumetric_heating_rates
)
message
(
"WARNING: You should specified either the specific or the volumetric heating rates, not both"
);
/* self shielding */
chemistry
->
self_shielding_method
=
cooling
->
self_shielding_method
;
/* Initialize the chemistry object. */
/* Initialize the chemistry object. */
if
(
initialize_chemistry_data
(
&
cooling
->
units
)
==
0
)
{
if
(
initialize_chemistry_data
(
&
cooling
->
units
)
==
0
)
{
...
@@ -597,6 +568,33 @@ __attribute__((always_inline)) INLINE static void cooling_init_backend(
...
@@ -597,6 +568,33 @@ __attribute__((always_inline)) INLINE static void cooling_init_backend(
message
(
""
);
message
(
""
);
message
(
"***************************************"
);
message
(
"***************************************"
);
#endif
#endif
}
/**
* @brief Initialises the cooling properties.
*
* @param parameter_file The parsed parameter file.
* @param us The current internal system of units.
* @param phys_const The physical constants in internal units.
* @param cooling The cooling properties to initialize
*/
__attribute__
((
always_inline
))
INLINE
static
void
cooling_init_backend
(
const
struct
swift_params
*
parameter_file
,
const
struct
unit_system
*
us
,
const
struct
phys_const
*
phys_const
,
struct
cooling_function_data
*
cooling
)
{
if
(
GRACKLE_NPART
!=
1
)
error
(
"Grackle with multiple particles not implemented"
);
/* read parameters */
cooling_parse_arguments
(
parameter_file
,
cooling
);
/* Set up the units system. */
cooling_init_units
(
us
,
cooling
);
cooling_init_grackle
(
cooling
);
}
}
#endif
/* SWIFT_COOLING_GRACKLE_H */
#endif
/* SWIFT_COOLING_GRACKLE_H */
This diff is collapsed.
Click to expand it.
src/cooling/grackle/cooling_struct.h
+
13
−
1
View file @
5502ab44
...
@@ -38,7 +38,7 @@ struct cooling_function_data {
...
@@ -38,7 +38,7 @@ struct cooling_function_data {
char
cloudy_table
[
200
];
char
cloudy_table
[
200
];
/* Enable/Disable UV backgroud */
/* Enable/Disable UV backgroud */
int
uv_background
;
int
with_
uv_background
;
/* Redshift to use for the UV backgroud (-1 to use cosmological one) */
/* Redshift to use for the UV backgroud (-1 to use cosmological one) */
double
redshift
;
double
redshift
;
...
@@ -48,6 +48,18 @@ struct cooling_function_data {
...
@@ -48,6 +48,18 @@ struct cooling_function_data {
/* grackle chemistry data */
/* grackle chemistry data */
chemistry_data
chemistry
;
chemistry_data
chemistry
;
/* Enable/Disable metal cooling */
int
with_metal_cooling
;
/* User provide volumetric heating rates */
int
provide_volumetric_heating_rates
;
/* User provide specific heating rates */
int
provide_specific_heating_rates
;
/* Self shielding method (<= 3) means grackle modes */
int
self_shielding_method
;
};
};
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment