air.py
Go to the documentation of this file.
1 from atomicdata import *
2 from util import *
3
4 compositions = {
5  # Don't include argon (neon, etc.) because it isn't otherwise in the model
6  'nitrogen': { 'N': 2 },
7  'oxygen': { 'O': 2 },
8  'water': { 'H': 2, 'O': 1 },
9  'carbon dioxide': { 'C': 1, 'O': 2 },
10 }
11
12 fractions = {
13  # Take the mole fractions from Wikipedia "Atmospheric chemistry" and convert
14  # to number proportional to mass fractions
15  'nitrogen': 0.78084 * 2 * 14.007,
16  'oxygen': 0.20946 * 2 * 15.999,
17
18  # I think this is the right ballpark for our moderate humidity
19  'water': 0.007 * (2 * 1.008 + 15.999),
20
21  'carbon dioxide': 400e-6 * (12.011 + 2 * 15.999),
22 }
23
24
25 def tot_weight(compos):
26  weight = 0
27  for element, number in compos.items():
28  weight += number * atomic_weight[element]
29  return weight
30
32  tions = 0
33  for material, fraction in fractions.items():
34  tions += fraction
35  return tions
36
37 def elem_frac(compos, elem):
38  if elem in compos:
39  return compos[elem] * atomic_weight[elem] / tot_weight(compos)
40  else:
41  return 0
42
43 def elem_frac_total(elem):
44  frac = 0
45  for material, compos in compositions.items():
46  frac += elem_frac(compos, elem) * fractions[material]
47  return frac / tot_fractions()
48
50  return make_composition("air", fractions, compositions)
def elem_frac_total(elem)
Definition: air.py:43
def tot_weight(compos)
Definition: air.py:25
def tot_fractions()
Definition: air.py:31
def air_composition()
Definition: air.py:49
def make_composition(name, fractions, compositions)
Definition: util.py:46
def elem_frac(compos, elem)
Definition: air.py:37