[cig-commits] [commit] add_thermodynamic_potentials: Added compositional array construction (65b5223)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Tue Dec 9 09:55:29 PST 2014
Repository : https://github.com/geodynamics/burnman
On branch : add_thermodynamic_potentials
Link : https://github.com/geodynamics/burnman/compare/2e5646d93cedbbf8eae54cc37cffc14e0aa85180...d5ddad03ff9f30f5a4efaddb4e3ec585ea1a7c51
>---------------------------------------------------------------
commit 65b522313e40454bf7ac7f1df48498cd33b04a11
Author: Bob Myhill <myhill.bob at gmail.com>
Date: Wed Sep 3 02:18:17 2014 +0200
Added compositional array construction
>---------------------------------------------------------------
65b522313e40454bf7ac7f1df48498cd33b04a11
burnman/processchemistry.py | 49 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/burnman/processchemistry.py b/burnman/processchemistry.py
index 00d9545..b52d7fe 100644
--- a/burnman/processchemistry.py
+++ b/burnman/processchemistry.py
@@ -218,3 +218,52 @@ def ProcessSolidSolutionChemistry(formulae):
return solution_formulae, n_sites, sites, n_occupancies, endmember_occupancies, site_multiplicities
+
+def compositional_array(formulae):
+ """
+ Parameters
+ ----------
+ formulae : list of dictionaries
+ List of chemical formulae
+
+ Returns
+ -------
+ formula_array : 2D array of floats
+ Array of endmember formulae
+
+ elements : List of strings
+ List of elements
+ """
+ elements=[]
+ for formula in formulae:
+ for element in formula:
+ if element not in elements:
+ elements.append(element)
+
+ formula_array=ordered_compositional_array(formulae, elements)
+
+ return formula_array, elements
+
+
+def ordered_compositional_array(formulae, elements):
+ """
+ Parameters
+ ----------
+ formulae : list of dictionaries
+ List of chemical formulae
+
+ elements : List of strings
+ List of elements
+
+ Returns
+ -------
+ formula_array : 2D array of floats
+ Array of endmember formulae
+ """
+ formula_array=np.zeros(shape=(len(formulae), len(elements)))
+ for idx, formula in enumerate(formulae):
+ for element in formula:
+ assert(element in elements)
+ formula_array[idx][elements.index(element)]=formula[element]
+
+ return formula_array
More information about the CIG-COMMITS
mailing list