[cig-commits] [commit] master: Add a burnman.constants file to import the scipy constants (a1bfc7b)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Tue Dec 9 09:24:07 PST 2014


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

On branch  : master
Link       : https://github.com/geodynamics/burnman/compare/2e2f4397422a6bb0384190ea8064f8b8b0be0e97...d4a00047c3fa7097111958d0b97cb77140ee94e3

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

commit a1bfc7b9747dd2a06bdfdd7ca4722031ea8979bd
Author: ian-r-rose <ian.r.rose at gmail.com>
Date:   Mon Dec 8 09:51:28 2014 -0800

    Add a burnman.constants file to import the scipy constants


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

a1bfc7b9747dd2a06bdfdd7ca4722031ea8979bd
 burnman/__init__.py     | 1 +
 burnman/constants.py    | 5 +++++
 burnman/debye.py        | 2 +-
 burnman/partitioning.py | 6 ++----
 burnman/tools.py        | 4 ++--
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/burnman/__init__.py b/burnman/__init__.py
index b63b3b3..be71201 100644
--- a/burnman/__init__.py
+++ b/burnman/__init__.py
@@ -50,3 +50,4 @@ import geotherm
 #miscellaneous
 import tools
 from partitioning import calculate_partition_coefficient,calculate_phase_percents
+import constants
diff --git a/burnman/constants.py b/burnman/constants.py
new file mode 100644
index 0000000..97af1ac
--- /dev/null
+++ b/burnman/constants.py
@@ -0,0 +1,5 @@
+import scipy.constants as constants
+
+R = gas_constant = constants.gas_constant
+N_A = Avogadro = constants.Avogadro
+k = Boltzmann = constants.Boltzmann 
diff --git a/burnman/debye.py b/burnman/debye.py
index d394add..8f0d6e4 100644
--- a/burnman/debye.py
+++ b/burnman/debye.py
@@ -5,7 +5,7 @@
 import numpy as np
 import scipy.integrate as integrate
 from numpy.polynomial.chebyshev import Chebyshev
-from scipy.constants import gas_constant
+from burnman.constants import gas_constant
 
 """
 Functions for the Debye model.  Note that this is not Mie-Grueneisen-Debye,
diff --git a/burnman/partitioning.py b/burnman/partitioning.py
index acf258a..a99d7c3 100644
--- a/burnman/partitioning.py
+++ b/burnman/partitioning.py
@@ -3,13 +3,11 @@
 # Released under GPL v2 or later.
 
 import numpy as np
-from scipy.constants import gas_constant, Avogadro
+from burnman.constants import gas_constant, N_A
 
 # TODO: add up weight percent and check <100 and tell them how much
 
 molar_mass = {'Fe':55.845/1000., 'Mg':24.305/1000., 'O':15.999/1000., 'Al':26.982/1000., 'Ca':40.078/1000., 'Si':28.085/1000.} # kg/mol
-boltzmann_constant = 1.3806503e-23 # in m^2 kg s^-2 K^-1
-
 lower_mantle_mass = 4.043e24*.75 # in kg
 
 
@@ -18,7 +16,7 @@ lower_mantle_mass = 4.043e24*.75 # in kg
 # convert weight percentage (amount, 1.00 = 100%) of a given element to molar mass
 def weight_pct_to_mol(element, amount):
 
-    return amount * lower_mantle_mass / molar_mass[element] * Avogadro
+    return amount * lower_mantle_mass / molar_mass[element] * N_A 
 
 
 def calculate_phase_percents(inp):
diff --git a/burnman/tools.py b/burnman/tools.py
index bb705c4..56b5bb2 100644
--- a/burnman/tools.py
+++ b/burnman/tools.py
@@ -7,7 +7,7 @@ import bisect
 import os
 import pkgutil
 import numpy as np
-from scipy.constants import Avogadro
+from burnman.constants import N_A
 
 def pretty_print_table(table,use_tabs=False):
     """
@@ -91,5 +91,5 @@ def molar_volume_from_unit_cell_volume(unit_cell_v, z):
     NOT number of atoms per molecular formula), and calculates
     the molar volume, as expected by the equations of state.
     """
-    return  unit_cell_v*Avogadro/1e30/z
+    return  unit_cell_v*N_A/1e30/z
 



More information about the CIG-COMMITS mailing list