cantera/interfaces/python/Cantera/elements.py
Ray Speth 6cb4bd93ce Cleaned up whitespace in all Python files using reindent.py
4 spaces per indentation level, no tabs, no trailing whitespace,
and a single newline at end of each file.
2012-02-27 18:13:05 +00:00

24 lines
584 B
Python
Executable file

"""
Atomic elements.
"""
def elementMoles(s, element):
"""Number of moles of an element in one mole of a solution.
s -- an object representing a solution.
element -- the symbol for an element in 's'.
"""
# see if 'element' corresponds to a symbol for one of the elements
# in s. If it does not, return zero moles.
try:
m = s.elementIndex(element)
if m < 0.0: return 0.0
except:
return 0.0
x = s.moleFractions()
moles = 0.0
for k in range(s.nSpecies()):
moles += x[k]*s.nAtoms(k,m)
return moles