[cig-commits] [commit] inversion, master, validate_MT_params: Updated process chemistry to accept fractions (e43ade1)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Fri Dec 12 18:26:58 PST 2014
Repository : https://github.com/geodynamics/burnman
On branches: inversion,master,validate_MT_params
Link : https://github.com/geodynamics/burnman/compare/80c2a295c42dfdb38f83f6c1334bf7d8f97a8463...409647ff05dfad6a686198cac1481bd46b5e2e62
>---------------------------------------------------------------
commit e43ade1baaeafdf9ef7c780dae19ef4aba801b28
Author: Bob Myhill <myhill.bob at gmail.com>
Date: Tue Dec 9 10:47:52 2014 -0800
Updated process chemistry to accept fractions
>---------------------------------------------------------------
e43ade1baaeafdf9ef7c780dae19ef4aba801b28
burnman/processchemistry.py | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/burnman/processchemistry.py b/burnman/processchemistry.py
index eca5eba..11e8b71 100644
--- a/burnman/processchemistry.py
+++ b/burnman/processchemistry.py
@@ -31,17 +31,16 @@ def dictionarize_formula(formula):
convert it into a dictionary
"""
f=dict()
- for element in re.findall('[A-Z][^A-Z]*', formula):
- list=filter(None, re.split(r'(\d+)', element))
- # Look up number of atoms of element
- if len(list) == 1:
- nel=1.
+ elements=re.findall('[A-Z][^A-Z]*',formula)
+ for element in elements:
+ element_name=re.split('[0-9][^A-Z]*',element)[0]
+ element_atoms=re.findall('[0-9][^A-Z]*',element)
+ if len(element_atoms) == 0:
+ element_atoms=Fraction(1.0)
else:
- nel=float(list[1])
- if list[0] not in f:
- f[list[0]]=nel
- else:
- f[list[0]]=nel+f[list[0]]
+ element_atoms=Fraction(element_atoms[0])
+ f[element_name]=f.get(element_name, 0.0) + element_atoms
+
return f
def formula_mass(formula, atomic_masses):
More information about the CIG-COMMITS
mailing list