[cig-commits] [commit] master: modernizing examples (b6346f5)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Jan 14 11:04:10 PST 2015


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

On branch  : master
Link       : https://github.com/geodynamics/burnman/compare/9422ec507c1a8dfaa6745252962af04a4a149b78...e2bd60d6a01c90c93947fd1c0ed132d06cbadbd2

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

commit b6346f5ba901d85ede58c3badee709d8cd368e55
Author: sannecottaar <sanne.cottaar at gmail.com>
Date:   Wed Jan 7 14:21:27 2015 +0100

    modernizing examples


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

b6346f5ba901d85ede58c3badee709d8cd368e55
 examples/example_averaging.py   |  8 ++---
 examples/example_composition.py | 66 +++++++++++++++++++----------------------
 examples/example_geotherms.py   | 16 ++++++----
 examples/example_optimize_pv.py |  2 ++
 examples/example_woutput.py     | 10 +++++--
 5 files changed, 54 insertions(+), 48 deletions(-)

diff --git a/examples/example_averaging.py b/examples/example_averaging.py
index 84c347f..8cc3afa 100644
--- a/examples/example_averaging.py
+++ b/examples/example_averaging.py
@@ -56,12 +56,12 @@ if __name__ == "__main__":
     amount_perovskite = 0.6
 
     rock = burnman.Composite([amount_perovskite, 1.0-amount_perovskite],
-                             [minerals.SLB_2005.mg_perovskite(),
-                              minerals.SLB_2005.periclase()])
+                             [minerals.SLB_2011.mg_perovskite(),
+                              minerals.SLB_2011.periclase()])
 
-    perovskitite = minerals.SLB_2005.mg_perovskite()
+    perovskitite = minerals.SLB_2011.mg_perovskite()
 
-    periclasite = minerals.SLB_2005.periclase()
+    periclasite = minerals.SLB_2011.periclase()
 
     #seismic model for comparison:
     # pick from .prem() .slow() .fast() (see burnman/seismic.py)
diff --git a/examples/example_composition.py b/examples/example_composition.py
index 1ea9534..2b43a08 100644
--- a/examples/example_composition.py
+++ b/examples/example_composition.py
@@ -15,18 +15,10 @@ composition. Here we present a couple of examples:
 
 1. Two minerals mixed in simple mole fractions. Can be chosen from the BurnMan
    libraries or from user defined minerals (see example_user_input_material)
-2. Two minerals mixed in simple mole fractions with user-defined Fe
-   partitioning
-3. The user can input wt% of each cation (Mg, Fe and Si) and BurnMan will
-   calculate Fe partitioning along a :math:`P, T` profile (see
-   example_partition_coef.py)
-4. A mixture of three minerals.
-
-In compositions 2, 3, and 4 of the above inputs, BurnMan will mix the mineral
-physical paremeters of end member minerals (pure Mg and Fe) of the user's
-choice using either volumetric (moduli) or molar averaging (all others) at
-room pressure and temperature (see example_user_input_material.py for
-information on these parameters).
+2. Example with three minerals
+3. Using preset solid solutions
+4. Defining your own solid solution
+
 
 To turn a method of mineral creation "on" the first if statement above the
 method must be set to True, with all others set to False.
@@ -38,11 +30,13 @@ example_spintransition.py for explanation of how to implement this
 
 * :doc:`mineral_database`
 * :class:`burnman.composite.Composite`
-
+* :class:`burnman.minerals.Mineral`
+* :class:`burnman.solidsolution.SolidSolution`
 
 *Demonstrates:*
 
 * Different ways to define a composite
+* Using minerals and solid solutions
 * Compare computations to seismic models
 
 """
@@ -72,36 +66,36 @@ if __name__ == "__main__":
                                  [minerals.SLB_2011.mg_perovskite(),
                                   minerals.SLB_2011.periclase()])
 
-    #Example 2: specify fixed iron content
+
+    #Example 2: three materials
     if False:
-        amount_perovskite = 0.95
-        rock = burnman.Composite([amount_perovskite, 1.0-amount_perovskite],
-                                 [minerals.SLB_2011.mg_fe_perovskite(0.2),
-                                  minerals.SLB_2011.ferropericlase(0.2)])
+        rock = burnman.Composite([0.7, 0.2, 0.1],
+                                 [minerals.SLB_2011.fe_perovskite(),
+                                  minerals.SLB_2011.ferropericlase(0.5),
+                                  minerals.SLB_2011.stishovite()])
 
-    #Example 3: input weight percentages
-    #See comments in example_partition_coef.py for references to
-    #partition coefficent calculation
 
+    #Example 3: Mixing solid solutions
     if False:
-        weight_percents = {'Mg':0.213, 'Fe': 0.08, 'Si':0.27, 'Ca':0., 'Al':0.}
-        Kd_0 = .59 #Fig 5 Nakajima et al 2012
-
-        phase_fractions,relative_molar_percent = burnman. \
-            calculate_phase_percents(weight_percents)
-        iron_content = lambda p,t: burnman.calculate_partition_coefficient \
-                (p,t,relative_molar_percent,Kd_0)
+        # Defining a rock using a predefined solid solution from the mineral library database.
+        preset_solidsolution=minerals.SLB_2011.mg_fe_perovskite()
+        # The line below is optional to see which endmembers (and in which order) are in the solid solution
+        #print preset_solidsolution.endmembers
+        #Set molar_fraction of mg_perovskite, fe_perovskite and al_perovskite
+        preset_solidsolution.set_composition([0.9,0.1,0.]) # Set molar_fraction of mg_perovskite, fe_perovskite and al_perovskite
+        rock = burnman.Composite([0.8, 0.2], phases=[preset_solidsolution, minerals.SLB_2011.periclase()])
 
-        rock = burnman.Composite([phase_fractions['pv'], phase_fractions['fp']],
-                                 [minerals.mg_fe_perovskite_pt_dependent(iron_content,0),
-                                  minerals.ferropericlase_pt_dependent(iron_content,1)])
 
-    #Example 4: three materials
+    #Example 4: Defining your own solid solution
     if False:
-        rock = burnman.Composite([0.7, 0.2, 0.1],
-                                 [minerals.SLB_2011.fe_perovskite(),
-                                  minerals.SLB_2011.ferropericlase(0.5),
-                                  minerals.SLB_2011.stishovite()])
+        # Define a new SolidSolution with mg and fe perovskite endmembers
+        new_solidsolution = burnman.SolidSolution([[minerals.SLB_2011.mg_perovskite()],
+                                          [minerals.SLB_2011.fe_perovskite()]])
+        # Set molar fraction of endmembers
+        new_solidsolution.set_composition([0.9,0.1])
+        rock=burnman.Composite([0.8, 0.2], [new_solidsolution, minerals.SLB_2011.periclase()])
+
+
 
 
     #seismic model for comparison:
diff --git a/examples/example_geotherms.py b/examples/example_geotherms.py
index d0dd968..4491bad 100644
--- a/examples/example_geotherms.py
+++ b/examples/example_geotherms.py
@@ -14,7 +14,7 @@ These are:
 3. Watson and Baxter, 2007 :cite:`Watson2007`
 4. linear extrapolation
 5. Read in from file from user
-6. Adiabatic from potential temperature and choice of mineral (pyrolite in this example)
+6. Adiabatic from potential temperature and choice of mineral 
 
 *Uses:*
 
@@ -69,15 +69,21 @@ if __name__ == "__main__":
     #geotherm for an assemblage of minerals
     #based on self compression of the composite rock.
     #First we need to define an assemblage
-    pyrolite = burnman.Composite([0.7, 0.3],
-                                 [minerals.SLB_2005.mg_fe_perovskite(0.1),
-                                  minerals.SLB_2005.ferropericlase(0.4)])
+    amount_perovskite = 0.8
+    fe_pv=0.05
+    fe_pc=0.2
+    pv=minerals.SLB_2011.mg_fe_perovskite()
+    pc=minerals.SLB_2011.ferropericlase()
+    pv.set_composition([1.-fe_pv,fe_pv,0.])
+    pc.set_composition([1.-fe_pc,fe_pc])
+    example_rock = burnman.Composite( [amount_perovskite, 1.0-amount_perovskite], [pv,pc] )
+    
     #next, define an anchor temperature at which we are starting.
     #Perhaps 1500 K for the upper mantle
     T0 = 1500.
     #then generate temperature values using the self consistent function.
     # This takes more time than the above methods
-    temperature5 = burnman.geotherm.adiabatic(pressures, T0, pyrolite)
+    temperature5 = burnman.geotherm.adiabatic(pressures, T0, example_rock)
 
     #you can also look at burnman/geotherm.py to see how the geotherms are implemented
 
diff --git a/examples/example_optimize_pv.py b/examples/example_optimize_pv.py
index 754c950..0e3a676 100644
--- a/examples/example_optimize_pv.py
+++ b/examples/example_optimize_pv.py
@@ -49,6 +49,8 @@ if __name__ == "__main__":
     temperature = burnman.geotherm.brown_shankland(seis_p)
 
     def material_error(amount_perovskite):
+        #Define composition using the values from Murakami et al. 2012 (Note: fe_perovskite and fe_periclase do not represent pure iron
+        #endmembers here, but contain 6% and 20% Fe respectively. 
         rock = burnman.Composite([amount_perovskite, 1.0-amount_perovskite],
                                  [minerals.Murakami_etal_2012.fe_perovskite(),
                                   minerals.Murakami_etal_2012.fe_periclase()])
diff --git a/examples/example_woutput.py b/examples/example_woutput.py
index 6e3aea3..59f85e7 100644
--- a/examples/example_woutput.py
+++ b/examples/example_woutput.py
@@ -43,9 +43,13 @@ if __name__ == "__main__":
 
     #specify material
     amount_perovskite = 0.95
-    rock = burnman.Composite([amount_perovskite, 1.0-amount_perovskite],
-                             [minerals.SLB_2005.mg_fe_perovskite(0.7),
-                              minerals.SLB_2005.ferropericlase(0.5)])
+    fe_pv=0.05
+    fe_pc=0.2
+    pv=minerals.SLB_2011.mg_fe_perovskite()
+    pc=minerals.SLB_2011.ferropericlase()
+    pv.set_composition([1.-fe_pv,fe_pv,0.])
+    pc.set_composition([1.-fe_pc,fe_pc])
+    rock = burnman.Composite( [amount_perovskite, 1.0-amount_perovskite], [pv,pc] )
     
     #define some pressure range
     pressures = np.arange(25e9,130e9,5e9)



More information about the CIG-COMMITS mailing list