OCDocker.Toolbox.Constants module¶
Physical constants and unit-conversion helpers.
Usage:
import OCDocker.Toolbox.Constants as occ
- OCDocker.Toolbox.Constants.STANDARD_TEMPERATURE_K: float = 298.15¶
Standard temperature in Kelvin (298.15 K = 25°C).
This is the standard temperature used in thermodynamic calculations. Commonly used as a default value for temperature-dependent functions.
- Type:
float
- OCDocker.Toolbox.Constants.ZERO_C_IN_K: float = 273.15¶
Absolute zero in Celsius expressed in Kelvin (273.15 K = 0°C).
Used for converting between Celsius and Kelvin temperature scales.
- Type:
float
- OCDocker.Toolbox.Constants.CAL_TO_J: float = 4.184¶
Calories to Joules conversion factor.
This constant is used to convert energy values from calories to Joules. The conversion factor is 4.184 J/cal.
- Type:
float
- OCDocker.Toolbox.Constants.R: float = 1.9872036¶
Ideal gas constant in cal/(mol·K).
Gas constant used for thermodynamic calculations in calories per mole per Kelvin. Value: 1.9872036 cal/(mol·K)
- Type:
float
- OCDocker.Toolbox.Constants.Rk: float = 0.0019872036¶
Ideal gas constant in kcal/(mol·K).
Gas constant used for thermodynamic calculations in kilocalories per mole per Kelvin. Value: 0.0019872036 kcal/(mol·K)
- Type:
float
- OCDocker.Toolbox.Constants.RJ: float = 8.314462618¶
Ideal gas constant in J/(mol·K).
Gas constant used for thermodynamic calculations in Joules per mole per Kelvin. This is the SI unit value: 8.314462618 J/(mol·K)
- Type:
float
- OCDocker.Toolbox.Constants.RJK: float = 0.008314462618¶
Ideal gas constant in kJ/(mol·K).
Gas constant used for thermodynamic calculations in kilojoules per mole per Kelvin. Value: 0.008314462618 kJ/(mol·K)
- Type:
float
- OCDocker.Toolbox.Constants.order: dict[str, dict[str, float]] = {'E': {'E': 1.0, 'G': 1e-09, 'M': 1e-12, 'P': 0.001, 'T': 1e-06, 'Y': 1000000.0, 'Z': 1000.0, 'a': 1e-36, 'c': 1e-20, 'f': 1e-33, 'k': 1e-15, 'm': 1e-21, 'n': 1e-27, 'p': 1e-30, 'u': 1e-24, 'un': 1e-18, 'y': 1e-42, 'z': 1e-39}, 'G': {'E': 1000000000.0, 'G': 1.0, 'M': 0.001, 'P': 1000000.0, 'T': 1000.0, 'Y': 1000000000000000.0, 'Z': 1000000000000.0, 'a': 1e-27, 'c': 1e-11, 'f': 1e-24, 'k': 1e-06, 'm': 1e-12, 'n': 1e-18, 'p': 1e-21, 'u': 1e-15, 'un': 1e-09, 'y': 1e-33, 'z': 1e-30}, 'M': {'E': 1000000000000.0, 'G': 1000.0, 'M': 1.0, 'P': 1000000000.0, 'T': 1000000.0, 'Y': 1e+18, 'Z': 1e+18, 'a': 1e-24, 'c': 1e-08, 'f': 1e-21, 'k': 0.001, 'm': 1e-09, 'n': 1e-15, 'p': 1e-18, 'u': 1e-12, 'un': 1e-06, 'y': 1e-30, 'z': 1e-27}, 'P': {'E': 1000.0, 'G': 1e-06, 'M': 1e-09, 'P': 1.0, 'T': 0.001, 'Y': 1000000000.0, 'Z': 1000000.0, 'a': 1e-33, 'c': 1e-17, 'f': 1e-30, 'k': 1e-12, 'm': 1e-18, 'n': 1e-24, 'p': 1e-27, 'u': 1e-21, 'un': 1e-15, 'y': 1e-39, 'z': 1e-36}, 'T': {'E': 1000000.0, 'G': 0.001, 'M': 1e-06, 'P': 1000.0, 'T': 1.0, 'Y': 1000000000000.0, 'Z': 1000000000.0, 'a': 1e-30, 'c': 1e-14, 'f': 1e-27, 'k': 1e-09, 'm': 1e-15, 'n': 1e-21, 'p': 1e-24, 'u': 1e-18, 'un': 1e-12, 'y': 1e-34, 'z': 1e-33}, 'Y': {'E': 1e-06, 'G': 1e-15, 'M': 1e-18, 'P': 1e-09, 'T': 1e-12, 'Y': 1.0, 'Z': 0.001, 'a': 1e-42, 'c': 1e-26, 'f': 1e-39, 'k': 1e-21, 'm': 1e-27, 'n': 1e-33, 'p': 1e-36, 'u': 1e-30, 'un': 1e-24, 'y': 1e-48, 'z': 1e-45}, 'Z': {'E': 0.001, 'G': 1e-12, 'M': 1e-15, 'P': 1e-06, 'T': 1e-09, 'Y': 1000.0, 'Z': 1.0, 'a': 1e-39, 'c': 1e-23, 'f': 1e-36, 'k': 1e-18, 'm': 1e-24, 'n': 1e-30, 'p': 1e-33, 'u': 1e-27, 'un': 1e-21, 'y': 1e-45, 'z': 1e-42}, 'a': {'E': 1e+36, 'G': 1e+27, 'M': 1e+24, 'P': 1e+33, 'T': 1e+30, 'Y': 1e+42, 'Z': 1e+39, 'a': 1.0, 'c': 1e+16, 'f': 1000.0, 'k': 1e+21, 'm': 1000000000000000.0, 'n': 1000000000.0, 'p': 1000000.0, 'u': 1000000000000.0, 'un': 1e+18, 'y': 1e-06, 'z': 0.001}, 'c': {'E': 1e+20, 'G': 100000000000.0, 'M': 100000000.0, 'P': 1e+17, 'T': 100000000000000.0, 'Y': 1e+26, 'Z': 1e+23, 'a': 1e-16, 'c': 1.0, 'f': 1e-13, 'k': 100000.0, 'm': 0.1, 'n': 1e-07, 'p': 1e-10, 'u': 0.0001, 'un': 100.0, 'y': 1e-22, 'z': 1e-19}, 'f': {'E': 1e+33, 'G': 1e+24, 'M': 1e+21, 'P': 1e+30, 'T': 1e+27, 'Y': 1e+39, 'Z': 1e+36, 'a': 0.001, 'c': 10000000000000.0, 'f': 1.0, 'k': 1e+18, 'm': 1000000000000.0, 'n': 1000000.0, 'p': 1000.0, 'u': 1000000000.0, 'un': 1000000000000000.0, 'y': 1e-09, 'z': 1e-06}, 'k': {'E': 1000000000000000.0, 'G': 1000000.0, 'M': 1000.0, 'P': 1000000000000.0, 'T': 1000000000.0, 'Y': 1e+21, 'Z': 1e+18, 'a': 1e-21, 'c': 1e-05, 'f': 1e-18, 'k': 1.0, 'm': 1e-06, 'n': 1e-12, 'p': 1e-15, 'u': 1e-09, 'un': 0.001, 'y': 1e-27, 'z': 1e-24}, 'm': {'E': 1e+21, 'G': 1000000000000.0, 'M': 1000000000.0, 'P': 1e+18, 'T': 1000000000000000.0, 'Y': 1e+27, 'Z': 1e+24, 'a': 1e-15, 'c': 10.0, 'f': 1e-12, 'k': 1000000.0, 'm': 1.0, 'n': 1e-06, 'p': 1e-09, 'u': 0.001, 'un': 1000.0, 'y': 1e-21, 'z': 1e-18}, 'n': {'E': 1e+27, 'G': 1e+18, 'M': 1000000000000000.0, 'P': 1e+24, 'T': 1e+21, 'Y': 1e+33, 'Z': 1e+30, 'a': 1e-09, 'c': 10000000.0, 'f': 1e-06, 'k': 1000000000000.0, 'm': 1000000.0, 'n': 1.0, 'p': 0.001, 'u': 1000.0, 'un': 1000000000.0, 'y': 1e-15, 'z': 1e-12}, 'p': {'E': 1e+30, 'G': 1e+21, 'M': 1e+18, 'P': 1e+27, 'T': 1e+24, 'Y': 1e+36, 'Z': 1e+33, 'a': 1e-06, 'c': 10000000000.0, 'f': 0.001, 'k': 1000000000000000.0, 'm': 1000000000.0, 'n': 1000.0, 'p': 1.0, 'u': 1000000.0, 'un': 1000000000000.0, 'y': 1e-12, 'z': 1e-09}, 'u': {'E': 1e+24, 'G': 1000000000000000.0, 'M': 1000000000000.0, 'P': 1e+21, 'T': 1e+18, 'Y': 1e+30, 'Z': 1e+27, 'a': 1e-12, 'c': 10000.0, 'f': 1e-09, 'k': 1000000000.0, 'm': 1000.0, 'n': 0.001, 'p': 1e-06, 'u': 1.0, 'un': 1000000.0, 'y': 1e-18, 'z': 1e-15}, 'un': {'E': 1e+18, 'G': 1000000000.0, 'M': 1000000.0, 'P': 1000000000000000.0, 'T': 1000000000000.0, 'Y': 1e+24, 'Z': 1e+21, 'a': 1e-18, 'c': 0.01, 'f': 1e-15, 'k': 1000.0, 'm': 0.001, 'n': 1e-09, 'p': 1e-12, 'u': 1e-06, 'un': 1.0, 'y': 1e-24, 'z': 1e-21}, 'y': {'E': 1e+42, 'G': 1e+33, 'M': 1e+30, 'P': 1e+39, 'T': 1e+36, 'Y': 1e+48, 'Z': 1e+45, 'a': 1000000.0, 'c': 1e+22, 'f': 1000000000.0, 'k': 1e+27, 'm': 1e+21, 'n': 1000000000000000.0, 'p': 1000000000000.0, 'u': 1e+18, 'un': 1e+24, 'y': 1.0, 'z': 1000.0}, 'z': {'E': 1e+39, 'G': 1e+30, 'M': 1e+27, 'P': 1e+36, 'T': 1e+33, 'Y': 1e+45, 'Z': 1e+42, 'a': 1000.0, 'c': 1e+19, 'f': 1000000.0, 'k': 1e+24, 'm': 1e+18, 'n': 1000000000000.0, 'p': 1000000000.0, 'u': 1000000000000000.0, 'un': 1e+21, 'y': 0.001, 'z': 1.0}}¶
Unit conversion dictionary for orders of magnitude.
This dictionary provides conversion factors between different orders of magnitude. The structure is:
order[source_unit][target_unit] = conversion_factor- Supported Units:
Y, Z, E, P, T, G, M, k, un, c, m, u, n, p, f, a, z, y
Example Usage:
import OCDocker.Toolbox.Constants as occ # Convert from nano (n) to micro (u) factor = occ.order["n"]["u"] # Returns 1e-3 # Convert from micro (u) to base unit (un) factor = occ.order["u"]["un"] # Returns 1e-6
- Type:
dict[str, dict[str, float]]
- OCDocker.Toolbox.Constants.cal_to_J(cal)[source]¶
Convert calories to Joules.
- Parameters:
cal (float) – Value in calories.
- Returns:
Value in Joules.
- Return type:
float
- OCDocker.Toolbox.Constants.J_to_cal(J)[source]¶
Convert Joules to calories.
- Parameters:
J (float) – Value in Joules.
- Returns:
Value in calories.
- Return type:
float
- OCDocker.Toolbox.Constants.C_to_K(C)[source]¶
Convert Celsius to Kelvin.
- Parameters:
C (float) – Value in Celsius.
- Returns:
Value in Kelvin.
- Return type:
float
- OCDocker.Toolbox.Constants.K_to_C(K)[source]¶
Convert Kelvin to Celsius.
- Parameters:
K (float) – Value in Kelvin.
- Returns:
Value in Celsius.
- Return type:
float
- Raises:
ValueError – If Kelvin is negative.