[cig-commits] [commit] split_mt: Changed set_method reset algorithm (bd8b3a9)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Jan 5 10:02:14 PST 2015


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

On branch  : split_mt
Link       : https://github.com/geodynamics/burnman/compare/60cfe9963b732f74ddd162297b7fa6d6ff6eae3f...bd8b3a9ea891dbc57e449c581f3cc3d6f889921f

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

commit bd8b3a9ea891dbc57e449c581f3cc3d6f889921f
Author: Bob Myhill <myhill.bob at gmail.com>
Date:   Mon Jan 5 19:01:57 2015 +0100

    Changed set_method reset algorithm


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

bd8b3a9ea891dbc57e449c581f3cc3d6f889921f
 burnman/eos/hp.py                           |  2 +-
 burnman/eos/modified_tait.py                |  2 +-
 burnman/mineral.py                          | 14 ++++++--------
 misc/ref/endmember_benchmarks.py.out        |  4 ++--
 misc/ref/example_compare_all_methods.py.out | 10 ++++------
 misc/ref/example_fit_data.py.out            |  4 ++--
 misc/ref/paper_fit_data.py.out              |  8 ++++----
 7 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/burnman/eos/hp.py b/burnman/eos/hp.py
index e71192a..f21dc4c 100644
--- a/burnman/eos/hp.py
+++ b/burnman/eos/hp.py
@@ -135,7 +135,7 @@ class HP_TMT(eos.EquationOfState):
         Returns the gibbs free energy [J/mol] as a function of pressure [Pa]
         and temperature [K].
         """
-       # Calculate temperature and pressure integrals
+        # Calculate temperature and pressure integrals
         a, b, c = mt.tait_constants(params)
         Pth=self.__relative_thermal_pressure(temperature,params)
 
diff --git a/burnman/eos/modified_tait.py b/burnman/eos/modified_tait.py
index f00ae00..bc8012a 100644
--- a/burnman/eos/modified_tait.py
+++ b/burnman/eos/modified_tait.py
@@ -56,7 +56,7 @@ class MT(eos.EquationOfState):
     An instance "m" of a Mineral can be assigned this 
     equation of state with the command m.set_method('mt')
     (or by initialising the class with the param 
-    equation_of_state = 'mt'
+    equation_of_state = 'mt').
     """
 
     def volume(self, pressure,temperature,params):
diff --git a/burnman/mineral.py b/burnman/mineral.py
index 4f7f22a..5ed89c2 100644
--- a/burnman/mineral.py
+++ b/burnman/mineral.py
@@ -65,16 +65,14 @@ class Mineral(Material):
             raise Exception("Please derive your method from object (see python old style classes)")
 
         if self.method is not None and type(new_method) is not type(self.method):
-            # Reset everything but params
-            for key, elem in self.__dict__.items():
-                if key != 'params':
-                    elem = float('nan')
-
-            # Set new EoS
-            self.params['equation_of_state']=equation_of_state
 
             # Warn user that they are changing the EoS
-            warnings.warn('Overriding database equation of state. From ' + self.method.__class__.__name__ + ' to ' + new_method.__class__.__name__, stacklevel=2)
+            warnings.warn('Warning, you are changing the method to ' + new_method.__class__.__name__ + ' even though the material is designed to be used with the method ' + self.method.__class__.__name__ + '.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).', stacklevel=2)
+
+            try:
+                self.pressure=self.temperature=float('nan')
+            except AttributeError:
+                pass
 
         self.method = new_method
 
diff --git a/misc/ref/endmember_benchmarks.py.out b/misc/ref/endmember_benchmarks.py.out
index edcf29a..f8d371a 100644
--- a/misc/ref/endmember_benchmarks.py.out
+++ b/misc/ref/endmember_benchmarks.py.out
@@ -1,4 +1,4 @@
-<stdin>:55: UserWarning: Overriding database equation of state. From HP_TMT to MT
+<stdin>:55: UserWarning: Warning, you are changing the method to MT even though the material is designed to be used with the method HP_TMT.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
 Benchmarks for SLB2011 database with method slb3
 ['H', 'S', 'V', 'C_p', 'alpha', 'beta', 'rho']
 [0.00017156026591432655, 0.0002055800239183733, -6.4391026211448567e-05, 0.00014642709264959587, 0.00027680790069709911, 0.0043841690680523288, -0.0013546021287755491, -0.00014635661915870913]
@@ -21,7 +21,7 @@ Benchmarks for HP2011 database with method hp_tmt
 Maximum error in HP2011 database:
 alpha : 2.82198466083e-05 % at 0.0001 GPa and 1000.0 K
 
-Benchmarks for HP2011 database with method mt
+Benchmarks for HP2011 database with method hp_tmt
 ['V', 'beta', 'rho']
 [7.7820925661860693e-07, 3.5713065344384812e-05, -2.292568834341453e-05]
 [4.0270311222739116e-06, 3.7028365245184261e-08, -2.2393157908795917e-05]
diff --git a/misc/ref/example_compare_all_methods.py.out b/misc/ref/example_compare_all_methods.py.out
index 1480ecf..6818d31 100644
--- a/misc/ref/example_compare_all_methods.py.out
+++ b/misc/ref/example_compare_all_methods.py.out
@@ -1,12 +1,10 @@
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From SLB2 to MGD3
+BURNMAN/burnman/composite.py: UserWarning: Warning, you are changing the method to MGD3 even though the material is designed to be used with the method SLB2.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
   phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From MGD3 to SLB2
+BURNMAN/burnman/composite.py: UserWarning: Warning, you are changing the method to SLB3 even though the material is designed to be used with the method SLB2.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
   phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From SLB2 to SLB3
+BURNMAN/burnman/composite.py: UserWarning: Warning, you are changing the method to BM2 even though the material is designed to be used with the method SLB2.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
   phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From SLB3 to BM2
-  phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From BM2 to BM3
+BURNMAN/burnman/composite.py: UserWarning: Warning, you are changing the method to BM3 even though the material is designed to be used with the method SLB2.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
   phase.set_method(method)
 Calculations are done for:
 Composite:
diff --git a/misc/ref/example_fit_data.py.out b/misc/ref/example_fit_data.py.out
index e03a3f4..370864f 100644
--- a/misc/ref/example_fit_data.py.out
+++ b/misc/ref/example_fit_data.py.out
@@ -1,5 +1,5 @@
-<stdin>:76: UserWarning: Overriding database equation of state. From BM2 to BM3
-<stdin>:85: UserWarning: Overriding database equation of state. From BM3 to BM2
+<stdin>:76: UserWarning: Warning, you are changing the method to BM3 even though the material is designed to be used with the method BM2.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
+<stdin>:85: UserWarning: Warning, you are changing the method to BM2 even though the material is designed to be used with the method BM3.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
 Optimization terminated successfully.
          Current function value: 14212.177931
          Iterations: 109
diff --git a/misc/ref/paper_fit_data.py.out b/misc/ref/paper_fit_data.py.out
index 5f64f4b..77ba840 100644
--- a/misc/ref/paper_fit_data.py.out
+++ b/misc/ref/paper_fit_data.py.out
@@ -1,9 +1,9 @@
-<stdin>:88: UserWarning: Overriding database equation of state. From BM2 to BM3
-<stdin>:97: UserWarning: Overriding database equation of state. From BM3 to BM2
+<stdin>:88: UserWarning: Warning, you are changing the method to BM3 even though the material is designed to be used with the method BM2.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
+<stdin>:97: UserWarning: Warning, you are changing the method to BM2 even though the material is designed to be used with the method BM3.  This does not overwrite any mineral attributes other than temperature and pressure, which are set to nan. Stale attributes will be preserved unless they are refreshed (for example, by set_state).
 Optimization terminated successfully.
          Current function value: 14212.177931
-         Iterations: 117
-         Function evaluations: 255
+         Iterations: 116
+         Function evaluations: 246
 2nd order fit: G =  173.346204684 GPa	G' =  1.52206197715
 Optimization terminated successfully.
          Current function value: 16309.293866



More information about the CIG-COMMITS mailing list