[cig-commits] [commit] pull_39: Use scipy.constants for physical constants. (e11c770)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Mon Dec 8 12:30:17 PST 2014
Repository : https://github.com/geodynamics/burnman
On branch : pull_39
Link : https://github.com/geodynamics/burnman/compare/0000000000000000000000000000000000000000...ac2c35dff40d9f0fb90b442d0086964ebe5d5976
>---------------------------------------------------------------
commit e11c77076cd255d74e9703faff26971259afe650
Author: Ian Rose <ian.r.rose at gmail.com>
Date: Sun Dec 7 09:47:58 2014 -0800
Use scipy.constants for physical constants.
>---------------------------------------------------------------
e11c77076cd255d74e9703faff26971259afe650
burnman/debye.py | 3 ++-
burnman/partitioning.py | 5 ++---
burnman/tools.py | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/burnman/debye.py b/burnman/debye.py
index ab53cc5..d394add 100644
--- a/burnman/debye.py
+++ b/burnman/debye.py
@@ -5,6 +5,7 @@
import numpy as np
import scipy.integrate as integrate
from numpy.polynomial.chebyshev import Chebyshev
+from scipy.constants import gas_constant
"""
Functions for the Debye model. Note that this is not Mie-Grueneisen-Debye,
@@ -12,7 +13,7 @@ just Debye, so is pretty limited. Combine this with Mie-Grueneisen and
Birch-Murnaghan to get a full EOS
"""
-R = 8.314462175
+R = gas_constant
diff --git a/burnman/partitioning.py b/burnman/partitioning.py
index e92a8db..acf258a 100644
--- a/burnman/partitioning.py
+++ b/burnman/partitioning.py
@@ -3,13 +3,12 @@
# Released under GPL v2 or later.
import numpy as np
+from scipy.constants import gas_constant, Avogadro
# 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
-Av = 6.022141e23 # Avogadro constant in 1/mol
boltzmann_constant = 1.3806503e-23 # in m^2 kg s^-2 K^-1
-gas_constant = Av * boltzmann_constant # in J mol^-1 K^-1
lower_mantle_mass = 4.043e24*.75 # in kg
@@ -19,7 +18,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] * Av
+ return amount * lower_mantle_mass / molar_mass[element] * Avogadro
def calculate_phase_percents(inp):
diff --git a/burnman/tools.py b/burnman/tools.py
index 98b7f2e..bb705c4 100644
--- a/burnman/tools.py
+++ b/burnman/tools.py
@@ -7,6 +7,7 @@ import bisect
import os
import pkgutil
import numpy as np
+from scipy.constants import Avogadro
def pretty_print_table(table,use_tabs=False):
"""
@@ -90,6 +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.
"""
- N_a = 6.0221415e23
- return unit_cell_v*N_a/1e30/z
+ return unit_cell_v*Avogadro/1e30/z
More information about the CIG-COMMITS
mailing list