cantera/interfaces/python/Cantera/elements.py
Ray Speth 2528df0f75 Reorganized source tree structure
These changes make it unnecessary to copy header files around during
the build process, which tends to confuse IDEs and debuggers. The
headers which comprise Cantera's external C++ interface are now in
the 'include' directory.

All of the samples and demos are now in the 'samples' subdirectory.
2012-02-12 02:27:14 +00:00

24 lines
577 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