[cig-commits] [commit] add_gibbs_energy: Added compositional array construction (c2a30cf)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Dec 11 17:11:35 PST 2014


Repository : https://github.com/geodynamics/burnman

On branch  : add_gibbs_energy
Link       : https://github.com/geodynamics/burnman/compare/0000000000000000000000000000000000000000...2148b324d3e8aa7b527f831eb397590942563008

>---------------------------------------------------------------

commit c2a30cf0f94bbaa3e4a74b46fa85c8347fcf5c87
Author: Bob Myhill <myhill.bob at gmail.com>
Date:   Wed Sep 3 02:18:17 2014 +0200

    Added compositional array construction


>---------------------------------------------------------------

c2a30cf0f94bbaa3e4a74b46fa85c8347fcf5c87
 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