[cig-commits] [commit] inversion, master, validate_MT_params: Calculate Gibbs and Helmholtz in the mineral class, but fail silently if they are not implemented/unable. (0173631)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Fri Dec 12 18:25:00 PST 2014
Repository : https://github.com/geodynamics/burnman
On branches: inversion,master,validate_MT_params
Link : https://github.com/geodynamics/burnman/compare/80c2a295c42dfdb38f83f6c1334bf7d8f97a8463...409647ff05dfad6a686198cac1481bd46b5e2e62
>---------------------------------------------------------------
commit 01736310111bab8fb5e6cefda54e69c135dee394
Author: ian-r-rose <ian.r.rose at gmail.com>
Date: Thu Aug 28 17:46:42 2014 -0700
Calculate Gibbs and Helmholtz in the mineral class, but fail silently if they are not implemented/unable.
>---------------------------------------------------------------
01736310111bab8fb5e6cefda54e69c135dee394
burnman/mineral.py | 20 ++++++++++++++++++--
burnman/modified_tait.py | 2 +-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/burnman/mineral.py b/burnman/mineral.py
index dffdf93..aaa58c4 100644
--- a/burnman/mineral.py
+++ b/burnman/mineral.py
@@ -141,8 +141,18 @@ class Mineral(Material):
self.C_v = self.method.heat_capacity_v(self.pressure, self.temperature, self.V, self.params)
self.C_p = self.method.heat_capacity_p(self.pressure, self.temperature, self.V, self.params)
self.alpha = self.method.thermal_expansivity(self.pressure, self.temperature, self.V, self.params)
- if (self.params.has_key('H_0') and self.params.has_key('S_0')):
- self.gibbs = self.method.gibbs_free_energy(self.pressure, self.temperature, self.params)
+
+ # Attempt to calculate the gibbs free energy and helmholtz free energy, but don't complain if the
+ # equation of state does not calculate it, or if the mineral params do not have the requisite entries.
+ try:
+ self.gibbs = self.method.gibbs_free_energy(self.pressure, self.temperature, self.V, self.params)
+ except (KeyError, NotImplementedError):
+ self.gibbs = float('nan')
+ try:
+ self.helmholtz = self.method.helmholtz_free_energy(self.pressure, self.temperature, self.V, self.params)
+ except (KeyError, NotImplementedError):
+ self.helmholtz = float('nan')
+
if (self.params.has_key('G_0') and self.params.has_key('Gprime_0')):
self.G = self.method.shear_modulus(self.pressure, self.temperature, self.V, self.params)
@@ -230,3 +240,9 @@ class Mineral(Material):
Returns Gibbs free energy of the mineral [J]
"""
return self.gibbs
+
+ def helmholtz_free_energy(self):
+ """
+ Returns Gibbs free energy of the mineral [J]
+ """
+ return self.helmholtz
diff --git a/burnman/modified_tait.py b/burnman/modified_tait.py
index d87ad84..7be5e53 100644
--- a/burnman/modified_tait.py
+++ b/burnman/modified_tait.py
@@ -202,7 +202,7 @@ class MT(eos.EquationOfState):
K_S = K_T*(1. + gr * alpha * temperature)
return K_S
- def gibbs_free_energy(self,pressure,temperature,params):
+ def gibbs_free_energy(self,pressure,temperature,volume,params):
"""
Returns the gibbs free energy [J/mol] as a function of pressure [Pa]
and temperature [K].
More information about the CIG-COMMITS
mailing list