[cig-commits] [commit] validate_MT_params: Parameter validation for modified tait (3865304)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Fri Dec 12 18:23:59 PST 2014
Repository : https://github.com/geodynamics/burnman
On branch : validate_MT_params
Link : https://github.com/geodynamics/burnman/compare/357942f1f591773d43448484a9f8de2ba8078d98...564a6a9a1c97824b3c6f65cf4d8d6d70235a9599
>---------------------------------------------------------------
commit 38653045e003301ae8acc82a02fa65a645f33b39
Author: Bob Myhill <myhill.bob at gmail.com>
Date: Fri Dec 12 17:23:03 2014 -0800
Parameter validation for modified tait
>---------------------------------------------------------------
38653045e003301ae8acc82a02fa65a645f33b39
burnman/eos/modified_tait.py | 58 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/burnman/eos/modified_tait.py b/burnman/eos/modified_tait.py
index f11687d..5598336 100644
--- a/burnman/eos/modified_tait.py
+++ b/burnman/eos/modified_tait.py
@@ -287,3 +287,61 @@ class MT(eos.EquationOfState):
at ambient pressure [Pa]
"""
return (params['Cp'][0]*np.log(temperature) + params['Cp'][1]*temperature - 0.5*params['Cp'][2]/np.power(temperature,2.) - 2.0*params['Cp'][3]/np.sqrt(temperature)) - (params['Cp'][0]*np.log(T_0) + params['Cp'][1]*T_0 - 0.5*params['Cp'][2]/(T_0*T_0) - 2.0*params['Cp'][3]/np.sqrt(T_0))
+
+
+ def validate_parameters(self, params):
+ """
+ Check for existence and validity of the parameters
+ """
+
+ #if G and Gprime are not included this is presumably deliberate,
+ #as we can model density and bulk modulus just fine without them,
+ #so just add them to the dictionary as nans
+ if 'H_0' not in params:
+ params['H_0'] = float('nan')
+ if 'S_0' not in params:
+ params['S_0'] = float('nan')
+ if 'G_0' not in params:
+ params['G_0'] = float('nan')
+ if 'Gprime_0' not in params:
+ params['Gprime_0'] = float('nan')
+
+ #check that all the required keys are in the dictionary
+ expected_keys = ['H_0', 'S_0', 'V_0', 'Cp', 'a_0', 'K_0', 'Kprime_0', 'Kdprime_0', 'n', 'molar_mass']
+ for k in expected_keys:
+ if k not in params:
+ raise KeyError('params object missing parameter : ' + k)
+
+ #now check that the values are reasonable. I mostly just
+ #made up these values from experience, and we are only
+ #raising a warning. Better way to do this? [IR]
+ if params['G_0'] is not float('nan') and (params['G_0'] < 0. or params['G_0'] > 1.e13):
+ warnings.warn( 'Unusual value for G_0', stacklevel=2 )
+ if params['Gprime_0'] is not float('nan') and (params['Gprime_0'] < -5. or params['Gprime_0'] > 10.):
+ warnings.warn( 'Unusual value for Gprime_0', stacklevel=2 )
+
+ # no test for H_0
+ if params['S_0'] is not float('nan') and params['S_0'] < 0.:
+ warnings.warn( 'Unusual value for S_0', stacklevel=2 )
+ if params['V_0'] < 1.e-7 or params['V_0'] > 1.e-3:
+ warnings.warn( 'Unusual value for V_0', stacklevel=2 )
+
+
+ if self.heat_capacity_p0(T_0,params) < 0.:
+ warnings.warn( 'Negative heat capacity at T_0', stacklevel=2 )
+ if self.heat_capacity_p0(2000.,params) < 0.:
+ warnings.warn( 'Negative heat capacity at 2000K', stacklevel=2 )
+
+ if params['a_0'] < 0. or params['a_0'] > 1.e-3:
+ warnings.warn( 'Unusual value for a_0', stacklevel=2 )
+ if params['K_0'] < 1.e9 or params['K_0'] > 1.e13:
+ warnings.warn( 'Unusual value for K_0', stacklevel=2 )
+ if params['Kprime_0'] < 0. or params['Kprime_0'] > 10.:
+ warnings.warn( 'Unusual value for Kprime_0', stacklevel=2 )
+ # no test for Kdprime_0
+
+ if params['n'] < 1. or params['n'] > 100. or not float(params['n']).is_integer():
+ warnings.warn( 'Unusual value for n', stacklevel=2 )
+ if params['molar_mass'] < 0.001 or params['molar_mass'] > 1.:
+ warnings.warn( 'Unusual value for molar_mass', stacklevel=2 )
+
More information about the CIG-COMMITS
mailing list