zephyrus.composition
composition
composition.py
Element masses, chemical-formula parsing, and composition handling.
Author: Mara Attia
parse_formula(name)
Element counts of a simple molecular formula string.
Parses formulas of the kind atmospheric chemistry codes emit, for
example 'CO2' -> {'C': 1, 'O': 2}. Trailing annotations after an
underscore are stripped, because species names such as 'O_1',
'N_2D', or 'S8_l_s' denote excited states or condensates of the
same stoichiometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Molecular formula, e.g., |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Element symbol to integer count. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the string cannot be parsed as a formula or contains an element
outside |
Source code in src/zephyrus/composition.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
species_mass_amu(name)
Molecular mass of a formula string, in atomic mass units.
Source code in src/zephyrus/composition.py
108 109 110 | |
atomize(vmr)
Element mole fractions of an atomized composition.
Reduces molecular volume mixing ratios to the mole fractions of their constituent atoms, which is the composition a fully dissociated gas would have. Used where escape physics operates on atoms: at the XUV wind base, where molecules are photodissociated well below the level where the wind is launched (Murray-Clay et al. 2009, ApJ 693, 23).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vmr
|
dict
|
Species name to mole fraction. Need not sum to 1; the result is renormalized. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Element symbol to mole fraction, summing to 1. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no species carries a positive mole fraction. |
Source code in src/zephyrus/composition.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
mean_particle_mass(element_fractions)
Mean particle mass of an atomized composition, in kg.
element_fractions maps element symbols to mole fractions summing
to 1, as returned by :func:atomize.
Source code in src/zephyrus/composition.py
150 151 152 153 154 155 156 | |