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

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Jan 5 09:55:58 PST 2015


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

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

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

commit 60cfe9963b732f74ddd162297b7fa6d6ff6eae3f
Author: Bob Myhill <myhill.bob at gmail.com>
Date:   Mon Jan 5 18:54:49 2015 +0100

    Changed set_method reset algorithm


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

60cfe9963b732f74ddd162297b7fa6d6ff6eae3f
 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 ++++----
 5 files changed, 18 insertions(+), 22 deletions(-)

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