Constants¶
Configuration is an important part of any modelling framework. In Sympl, component-specific configuration is given to components directly. However, configuration values that may be shared by more than one component are stored as constants. Good examples of these are physical constants, such as gravitational_acceleration, or constants specifying processor counts.
Getting and Setting Constants¶
You can retrieve and set constants using get_constant()
and
set_constant()
. set_constant()
will
allow you to set constants regardless of whether a value is already defined
for that constant, allowing you to add new constants we haven’t thought of.
The constant library can be reverted to its original state when Sympl is
imported by calling reset_constants()
.
-
sympl.
get_constant
(name, units)[source]¶ Retrieves the value of a constant.
Parameters: - name (str) – The name of the constant.
- units (str) – The units requested for the returned value.
Returns: value – The value of the constant in the requested units.
Return type: float
Debugging and Logging Constants¶
You can get a string describing current constants by calling get_constants_string()
:
import sympl
print(sympl.get_constants_string())
Condensible Quantities¶
For Earth system modeling, water is used as a condensible compound. By
default, condensible quantities such as ‘density_of_ice’ and
‘heat_capacity_of_liquid_phase’ are aliases for the corresponding value for
water. If you would like to use a different condensible compound, you can
use the set_condensible_name()
function. For example:
import sympl
sympl.set_condensible_name('carbon_dioxide')
sympl.get_constant('heat_capacity_of_solid_phase', 'J kg^-1 K^-1')
will set the condensible compound to carbon dioxide, and then get the heat capacity of solid carbon dioxide (if it has been set). For example, the constant name ‘heat_capacity_of_solid_phase’ would then be an alias for ‘heat_capacity_of_solid_carbon_dioxide’.
When setting the value of an alias, the value of the aliased quantity is the one which will be altered. For example, if you run
import sympl
sympl.set_constant('heat_capacity_of_liquid_phase', 1.0, 'J kg^-1 K^-1')
you would change the heat capacity of liquid water (since water is the default condensible compound).
Default Constants¶
The following constants are available in Sympl by default:
-
class
sympl._core.constants.
ConstantList
[source]¶ - Stellar
stellar_irradiance: 1367.0 W m^-2
solar_constant: 1367.0 W m^-2
- Physical
stefan_boltzmann_constant: 5.670367e-08 W m^-2 K^-4
avogadro_constant: 6.022140857e+23 mole^-1
speed_of_light: 299792458.0 m s^-1
boltzmann_constant: 1.38064852e-23 J K^-1
loschmidt_constant: 2.6516467e+25 m^-3
universal_gas_constant: 8.3144598 J mole^-1 K^-1
planck_constant: 6.62607004e-34 J s
- Atmospheric
heat_capacity_of_dry_air_at_constant_pressure: 1004.64 J kg^-1 K^-1
gas_constant_of_dry_air: 287.0 J kg^-1 K^-1
thermal_conductivity_of_dry_air: 0.026 W m^-1 K^-1
reference_air_pressure: 101320.0 Pa
reference_air_temperature: 300.0 degK
- Chemical
heat_capacity_of_water_vapor_at_constant_pressure: 1846.0 J kg^-1 K^-1
density_of_liquid_water: 1000.0 kg m^-3
gas_constant_of_water_vapor: 461.5 J kg^-1 K^-1
latent_heat_of_vaporization_of_water: 2500000.0 J kg^-1
heat_capacity_of_liquid_water: 4185.5 J kg^-1 K^-1
latent_heat_of_fusion_of_water: 333550.0 J kg^-1
heat_capacity_of_solid_water_as_ice: 2108.0 J kg^-1 K^-1
heat_capacity_of_solid_water_as_snow: 2108.0 J kg^-1 K^-1
thermal_conductivity_of_solid_water_as_ice: 2.22 W m^-1 K^-1
thermal_conductivity_of_solid_water_as_snow: 0.2 W m^-1 K^-1
thermal_conductivity_of_liquid_water: 0.57 W m^-1 K^-1
density_of_solid_water_as_ice: 916.7 kg m^-3
density_of_solid_water_as_snow: 100.0 kg m^-3
freezing_temperature_of_liquid_water: 273.0 K
specific_enthalpy_of_water_vapor: 2500.0 J kg^-1
density_of_snow: 100.0 kg m^-3
heat_capacity_of_snow: 2108.0 J kg^-1 K^-1
heat_capacity_of_ice: 2108.0 J kg^-1 K^-1
density_of_ice: 916.7 kg m^-3
thermal_conductivity_of_ice: 2.22 W m^-1 K^-1
thermal_conductivity_of_snow: 0.2 W m^-1 K^-1
- Condensible
density_of_liquid_phase: 1000.0 kg m^-3
heat_capacity_of_liquid_phase: 4185.5 J kg^-1 K^-1
heat_capacity_of_vapor_phase: 1846.0 J kg^-1 K^-1
specific_enthalpy_of_vapor_phase: 2500.0 J kg^-1
gas_constant_of_vapor_phase: 461.5 J kg^-1 K^-1
latent_heat_of_condensation: 2500000.0 J kg^-1
latent_heat_of_fusion: 333550.0 J kg^-1
density_of_solid_phase_as_ice: 916.7 kg m^-3
density_of_solid_phase_as_snow: 100.0 kg m^-3
heat_capacity_of_solid_phase_as_ice: 2108.0 J kg^-1 K^-1
heat_capacity_of_solid_phase_as_snow: 2108.0 J kg^-1 K^-1
thermal_conductivity_of_solid_phase_as_ice: 2.22 W m^-1 K^-1
thermal_conductivity_of_solid_phase_as_snow: 0.2 W m^-1 K^-1
thermal_conductivity_of_liquid_phase: 0.57 W m^-1 K^-1
freezing_temperature_of_liquid_phase: 273.0 K
enthalpy_of_fusion: 333550.0 J kg^-1
latent_heat_of_vaporization: 2500000.0 J kg^-1
- Planetary
gravitational_acceleration: 9.80665 m s^-2
planetary_radius: 6371000.0 m
planetary_rotation_rate: 7.292e-05 s^-1
seconds_per_day: 86400.0