[cig-commits] [commit] master: Use eps instead of zero for temperature check (1b2984b)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri Dec 12 15:48:35 PST 2014


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

On branch  : master
Link       : https://github.com/geodynamics/burnman/compare/e7f78ff83a8092bc07fea4398232e73406e7cbbb...6111717707e0bd07c31d999c20c7a56db163ff48

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

commit 1b2984b69863fab49f90fea712198753aacc71d9
Author: ian-r-rose <ian.r.rose at gmail.com>
Date:   Fri Dec 12 12:47:19 2014 -0800

    Use eps instead of zero for temperature check


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

1b2984b69863fab49f90fea712198753aacc71d9
 burnman/debye.py        | 13 ++++++-------
 burnman/eos/einstein.py |  7 ++++---
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/burnman/debye.py b/burnman/debye.py
index a513254..b1fc227 100644
--- a/burnman/debye.py
+++ b/burnman/debye.py
@@ -114,8 +114,8 @@ def thermal_energy(T, debye_T, n):
     the Debye temperature, and n, the number of atoms per molecule.
     Returns thermal energy in J/mol
     """
-    if T == 0:
-        return 0
+    if T <= eps:
+        return 0.
     E_th = 3.*n*constants.gas_constant*T * debye_fn_cheb(debye_T/T)
     return E_th
 
@@ -123,8 +123,8 @@ def heat_capacity_v(T,debye_T,n):
     """
     Heat capacity at constant volume.  In J/K/mol
     """
-    if T ==0:
-        return 0
+    if T <= eps:
+        return 0.
     x = debye_T/T
     C_v = 3.0*n*constants.gas_constant* ( 4.0*debye_fn_cheb(x) - 3.0*x/(np.exp(x)-1.0) )
     return C_v
@@ -137,10 +137,9 @@ def helmholtz_free_energy(T, debye_T, n):
     calculating relative differences in F, this should cancel anyways.
     In Joules.
     """
-    if T ==0:
-        return 0
+    if T <= eps:
+        return 0.
     x = debye_T/T
     F = n * constants.gas_constant * T * ( 3.0 * np.log( 1.0 - np.exp(-x)) - debye_fn_cheb(x) )
     return F
 
-
diff --git a/burnman/eos/einstein.py b/burnman/eos/einstein.py
index 66fa392..0d059fd 100644
--- a/burnman/eos/einstein.py
+++ b/burnman/eos/einstein.py
@@ -9,6 +9,7 @@ import burnman.constants as constants
 Functions for the Einstein model of a solid.
 """
 
+eps = np.finfo(np.float).eps
 
 def thermal_energy(T, einstein_T, n):
     """
@@ -16,7 +17,7 @@ def thermal_energy(T, einstein_T, n):
     the Einstein temperature, and n, the number of atoms per molecule.
     Returns thermal energy in J/mol
     """
-    if T == 0:
+    if T <= eps:
         return 3.*n*constants.gas_constant*einstein_T*0.5 # zero point energy
     x = einstein_T/T
     E_th = 3.*n*constants.gas_constant*einstein_T*( 0.5 + 1. / (np.exp( x ) - 1.0) ) # include the zero point energy
@@ -27,8 +28,8 @@ def heat_capacity_v(T,einstein_T,n):
     """
     Heat capacity at constant volume.  In J/K/mol
     """
-    if T ==0:
-        return 0
+    if T <= eps:
+        return 0.
     x = einstein_T/T
     C_v = 3.0*n*constants.gas_constant* ( x * x * np.exp( x ) / np.power( np.exp( x ) - 1.0, 2.0 ) )
     return C_v



More information about the CIG-COMMITS mailing list