[cig-commits] [commit] split_mt: Changed set_method reset algorithm to just reset P and T and updated warning (74daca2)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Jan 5 05:37:21 PST 2015


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

On branch  : split_mt
Link       : https://github.com/geodynamics/burnman/compare/e2d8657f7d6d508877bb5b35eddaf65f2e244c87...74daca25ab1fe10d144e12b2b358ace333269c4f

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

commit 74daca25ab1fe10d144e12b2b358ace333269c4f
Author: Bob Myhill <myhill.bob at gmail.com>
Date:   Mon Jan 5 14:36:57 2015 +0100

    Changed set_method reset algorithm to just reset P and T and updated warning


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

74daca25ab1fe10d144e12b2b358ace333269c4f
 burnman/mineral.py                          | 11 ++---------
 misc/ref/endmember_benchmarks.py.out        |  2 +-
 misc/ref/example_compare_all_methods.py.out | 10 +++++-----
 misc/ref/example_fit_data.py.out            |  4 ++--
 tests/test_endmembers.py                    |  3 +++
 5 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/burnman/mineral.py b/burnman/mineral.py
index 0a7a6fc..0c907b3 100644
--- a/burnman/mineral.py
+++ b/burnman/mineral.py
@@ -67,22 +67,15 @@ class Mineral(Material):
         if self.method is not None and type(new_method) is not type(self.method):
 
             # 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('Overriding database equation of state from ' + self.method.__class__.__name__ + ' to ' + new_method.__class__.__name__ + '. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.', stacklevel=2)
 
             # Set new EoS
             self.params['equation_of_state']=equation_of_state
 
             try:
-                P=self.pressure
-                T=self.temperature
                 self.pressure=self.temperature=float('nan')
-
-                self.method = new_method
-
-                # Reset state
-                self.set_state(P, T)
             except AttributeError:
-                warnings.warn('State not yet set', stacklevel=2)
+                pass
 
         self.method = new_method
 
diff --git a/misc/ref/endmember_benchmarks.py.out b/misc/ref/endmember_benchmarks.py.out
index edcf29a..4890cf8 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: Overriding database equation of state from HP_TMT to MT. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
 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]
diff --git a/misc/ref/example_compare_all_methods.py.out b/misc/ref/example_compare_all_methods.py.out
index 1480ecf..822add4 100644
--- a/misc/ref/example_compare_all_methods.py.out
+++ b/misc/ref/example_compare_all_methods.py.out
@@ -1,12 +1,12 @@
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From SLB2 to MGD3
+BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state from SLB2 to MGD3. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
   phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From MGD3 to SLB2
+BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state from MGD3 to SLB2. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
   phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From SLB2 to SLB3
+BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state from SLB2 to SLB3. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
   phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From SLB3 to BM2
+BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state from SLB3 to BM2. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
   phase.set_method(method)
-BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state. From BM2 to BM3
+BURNMAN/burnman/composite.py: UserWarning: Overriding database equation of state from BM2 to BM3. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
   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..72e99df 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: Overriding database equation of state from BM2 to BM3. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
+<stdin>:85: UserWarning: Overriding database equation of state from BM3 to BM2. This does not overwrite any mineral attributes other than temperature and pressure. Non-implemented attributes of the old method will remain unchanged unless they are explicitly changed by the user.
 Optimization terminated successfully.
          Current function value: 14212.177931
          Iterations: 109
diff --git a/tests/test_endmembers.py b/tests/test_endmembers.py
index 90a1e23..a6814f6 100644
--- a/tests/test_endmembers.py
+++ b/tests/test_endmembers.py
@@ -37,6 +37,7 @@ class test_endmembers(BurnManTest):
         fo.set_state(1.e5, 298.15)
         volume1=fo.V
         fo.set_method('mt')
+        fo.set_state(1.e5, 298.15)
         volume2=fo.V
         self.assertArraysAlmostEqual([volume1], [volume2])
 
@@ -45,6 +46,7 @@ class test_endmembers(BurnManTest):
         fo.set_state(1.e9, 298.15)
         volume1=fo.V
         fo.set_method('mt')
+        fo.set_state(1.e9, 298.15)
         volume2=fo.V
         self.assertArraysAlmostEqual([volume1], [volume2])
 
@@ -53,6 +55,7 @@ class test_endmembers(BurnManTest):
         fo.set_state(1.e9, 298.15)
         K1=fo.K_T
         fo.set_method('mt')
+        fo.set_state(1.e9, 298.15)
         K2=fo.K_T
         self.assertArraysAlmostEqual([K1], [K2])
 



More information about the CIG-COMMITS mailing list