Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
e47db28b
Commit
e47db28b
authored
Oct 08, 2018
by
Matthieu Schaller
Browse files
Updated the definition of Lambda in the const-lambda cooling model to have the right units.
parent
a868520d
Changes
10
Hide whitespace changes
Inline
Side-by-side
examples/AgoraDisk/agora_disk.yml
View file @
e47db28b
...
...
@@ -49,7 +49,7 @@ InitialConditions:
# Dimensionless pre-factor for the time-step condition
LambdaCooling
:
lambda_cgs
:
1.0
e-22
# Cooling rate
(in cgs units
)
lambda_
nH2_
cgs
:
1
e-22
# Cooling rate
divided by square Hydrogen number density (in cgs units [erg * s^-1 * cm^3]
)
cooling_tstep_mult
:
1.0
# Dimensionless pre-factor for the time-step condition
# Cooling with Grackle 2.0
...
...
examples/CoolingBox/coolingBox.yml
View file @
e47db28b
...
...
@@ -35,7 +35,7 @@ InitialConditions:
# Dimensionless pre-factor for the time-step condition
LambdaCooling
:
lambda_cgs
:
1.0
e-22
# Cooling rate
(in cgs units
)
lambda_
nH2_
cgs
:
1
e-22
# Cooling rate
divided by square Hydrogen number density (in cgs units [erg * s^-1 * cm^3]
)
cooling_tstep_mult
:
1.0
# Dimensionless pre-factor for the time-step condition
# Cooling with Grackle 2.0
...
...
examples/CoolingHalo/cooling_halo.yml
View file @
e47db28b
...
...
@@ -41,5 +41,5 @@ IsothermalPotential:
# Cooling parameters
LambdaCooling
:
lambda_cgs
:
1.0
e-22
# Cooling rate
(in cgs units
)
lambda_
nH2_
cgs
:
1
e-22
# Cooling rate
divided by square Hydrogen number density (in cgs units [erg * s^-1 * cm^3]
)
cooling_tstep_mult
:
1.0
# Dimensionless pre-factor for the time-step condition
examples/CoolingHaloWithSpin/cooling_halo.yml
View file @
e47db28b
...
...
@@ -41,5 +41,5 @@ IsothermalPotential:
# Cooling parameters
LambdaCooling
:
lambda_cgs
:
1.0
e-22
# Cooling rate
(in cgs units
)
lambda_
nH2_
cgs
:
1
e-22
# Cooling rate
divided by square Hydrogen number density (in cgs units [erg * s^-1 * cm^3]
)
cooling_tstep_mult
:
0.1
# Dimensionless pre-factor for the time-step condition
examples/SmallCosmoVolume_cooling/plotTempEvolution.py
View file @
e47db28b
...
...
@@ -71,7 +71,7 @@ git = sim["Code"].attrs["Git Revision"]
cooling_model
=
sim
[
"/SubgridScheme"
].
attrs
[
"Cooling Model"
]
if
cooling_model
==
"Constant Lambda"
:
Lambda
=
sim
[
"/SubgridScheme"
].
attrs
[
"Lambda [cgs]"
][
0
]
Lambda
=
sim
[
"/SubgridScheme"
].
attrs
[
"Lambda
/n_H^2
[cgs]"
][
0
]
# Cosmological parameters
H_0
=
sim
[
"/Cosmology"
].
attrs
[
"H0 [internal units]"
][
0
]
...
...
examples/SmallCosmoVolume_cooling/small_cosmo_volume.yml
View file @
e47db28b
...
...
@@ -59,4 +59,4 @@ InitialConditions:
# Constant lambda cooling function
LambdaCooling
:
lambda_cgs
:
1e-26
# Cooling rate (in cgs units [erg * s^-1 * cm^
-
3])
lambda_
nH2_
cgs
:
1e-26
# Cooling rate
divided by square Hydrogen number density
(in cgs units [erg * s^-1 * cm^3])
examples/parameter_example.yml
View file @
e47db28b
...
...
@@ -198,7 +198,7 @@ ConstCooling:
# Constant lambda cooling function
LambdaCooling
:
lambda_cgs
:
1e-22
# Cooling rate (in cgs units [erg * s^-1 * cm^
-
3])
lambda_
nH2_
cgs
:
1e-22
# Cooling rate
divided by square Hydrogen number density
(in cgs units [erg * s^-1 * cm^3])
cooling_tstep_mult
:
1.0
# (Optional) Dimensionless pre-factor for the time-step condition.
# Cooling with Grackle 3.0
...
...
src/cooling/const_lambda/cooling.h
View file @
e47db28b
...
...
@@ -47,8 +47,10 @@
/**
* @brief Calculates du/dt in CGS units for a particle.
*
* The cooling rate is \f$\frac{du}{dt} = -\Lambda \frac{n_H^2}{\rho} \f$ and
* the returned value is in physical [erg * g^-1 * s^-1].
* The cooling rate is \f$\frac{du}{dt} = -\frac{\Lambda}{n_H^2}
* \frac{n_H^2}{\rho} \f$, where \f$ \frac{\Lambda}{n_H^2} \f$ is a constant in
* this model (lambda_nH2_cgs in #cooling_function_data).
* The returned value is in physical [erg * g^-1 * s^-1].
*
* @param cosmo The current cosmological model.
* @param hydro_props The properties of the hydro scheme.
...
...
@@ -61,18 +63,19 @@ __attribute__((always_inline)) INLINE static double cooling_rate_cgs(
const
struct
cosmology
*
cosmo
,
const
struct
hydro_props
*
hydro_props
,
const
struct
cooling_function_data
*
cooling
,
const
struct
part
*
p
)
{
/* Get particle density */
/* Get particle density
[g * cm^-3]
*/
const
double
rho
=
hydro_get_physical_density
(
p
,
cosmo
);
const
double
rho_cgs
=
rho
*
cooling
->
conv_factor_density_to_cgs
;
/* Get Hydrogen mass fraction */
const
double
X_H
=
hydro_props
->
hydrogen_mass_fraction
;
/* Hydrogen number density (X_H * rho / m_p) */
/* Hydrogen number density (X_H * rho / m_p)
[cm^-3]
*/
const
double
n_H_cgs
=
X_H
*
rho_cgs
*
cooling
->
proton_mass_cgs_inv
;
/* Calculate du_dt (Lambda * n_H^2 / rho) */
const
double
du_dt_cgs
=
-
cooling
->
lambda_cgs
*
n_H_cgs
*
n_H_cgs
/
rho_cgs
;
/* Calculate du_dt ((Lambda / n_H^2) * n_H^2 / rho) */
const
double
du_dt_cgs
=
-
cooling
->
lambda_nH2_cgs
*
n_H_cgs
*
n_H_cgs
/
rho_cgs
;
return
du_dt_cgs
;
}
...
...
@@ -238,8 +241,8 @@ static INLINE void cooling_init_backend(struct swift_params* parameter_file,
struct
cooling_function_data
*
cooling
)
{
/* Read in the cooling parameters */
cooling
->
lambda_cgs
=
parser_get_param_double
(
parameter_file
,
"LambdaCooling:lambda_cgs"
);
cooling
->
lambda_
nH2_
cgs
=
parser_get_param_double
(
parameter_file
,
"LambdaCooling:lambda_
nH2_
cgs"
);
cooling
->
cooling_tstep_mult
=
parser_get_opt_param_float
(
parameter_file
,
"LambdaCooling:cooling_tstep_mult"
,
FLT_MAX
);
...
...
@@ -265,9 +268,10 @@ static INLINE void cooling_print_backend(
const
struct
cooling_function_data
*
cooling
)
{
message
(
"Cooling function is 'Constant lambda' with Lambda=%g [erg * s^-1 * "
"cm^-3]"
,
cooling
->
lambda_cgs
);
"Cooling function is 'Constant lambda' with Lambda/n_H^2=%g [erg * s^-1 "
"* "
"cm^3]"
,
cooling
->
lambda_nH2_cgs
);
if
(
cooling
->
cooling_tstep_mult
==
FLT_MAX
)
message
(
"Cooling function time-step size is unlimited"
);
...
...
src/cooling/const_lambda/cooling_io.h
View file @
e47db28b
...
...
@@ -45,7 +45,7 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
hid_t
h_grp
,
const
struct
cooling_function_data
*
cooling
)
{
io_write_attribute_s
(
h_grp
,
"Cooling Model"
,
"Constant Lambda"
);
io_write_attribute_d
(
h_grp
,
"Lambda [cgs]"
,
cooling
->
lambda_cgs
);
io_write_attribute_d
(
h_grp
,
"Lambda
/n_H^2
[cgs]"
,
cooling
->
lambda_
nH2_
cgs
);
}
#endif
...
...
src/cooling/const_lambda/cooling_struct.h
View file @
e47db28b
...
...
@@ -33,8 +33,8 @@
*/
struct
cooling_function_data
{
/*! Cooling rate in physical cgs units [erg * s^-1 * cm^
-
3] */
double
lambda_cgs
;
/*! Cooling rate
/ nH^2
in physical cgs units [erg * s^-1 * cm^3] */
double
lambda_
nH2_
cgs
;
/*! Conversion factor from internal units to cgs for density */
double
conv_factor_density_to_cgs
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment