[cig-commits] [commit] add_gibbs_energy: Added molar mass calculator and data table (d29f046)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Dec 11 17:10:37 PST 2014


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

On branch  : add_gibbs_energy
Link       : https://github.com/geodynamics/burnman/compare/0000000000000000000000000000000000000000...2148b324d3e8aa7b527f831eb397590942563008

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

commit d29f04649bbda9571bab5118350ab46d9c3f8b77
Author: Bob Myhill <myhill.bob at gmail.com>
Date:   Sun Aug 10 23:37:17 2014 +0200

    Added molar mass calculator and data table


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

d29f04649bbda9571bab5118350ab46d9c3f8b77
 burnman/data/input_masses/atomic_masses.dat | 86 +++++++++++++++++++++++++++++
 burnman/modified_tait.py                    |  5 +-
 burnman/molar_mass.py                       | 47 ++++++++++++++++
 3 files changed, 134 insertions(+), 4 deletions(-)

diff --git a/burnman/data/input_masses/atomic_masses.dat b/burnman/data/input_masses/atomic_masses.dat
new file mode 100644
index 0000000..2e52ed3
--- /dev/null
+++ b/burnman/data/input_masses/atomic_masses.dat
@@ -0,0 +1,86 @@
+% Masses from NIST
+% Processed with `awk '{print substr($0,5, 4), substr($0,47,100)}' tmp  | sed 's/_//g' | awk '{print $1, $2/1000.}' | awk 'NF==2' | awk -F"(" '{print $1}' | grep -v '['`
+H 0.00100794
+He 0.0040026
+Li 0.006941
+Be 0.00901218
+B 0.010811
+C 0.0120107
+N 0.0140067
+O 0.0159994
+F 0.0189984
+Ne 0.0201797
+Na 0.0229898
+Mg 0.024305
+Al 0.0269815
+Si 0.0280855
+P 0.0309738
+S 0.032065
+Cl 0.035453
+Ar 0.039948
+K 0.0390983
+Ca 0.040078
+Sc 0.0449559
+Ti 0.047867
+V 0.0509415
+Cr 0.0519961
+Mn 0.054938
+Fe 0.055845
+Co 0.0589332
+Ni 0.0586934
+Cu 0.063546
+Zn 0.06538
+Ga 0.069723
+Ge 0.07264
+As 0.0749216
+Se 0.07896
+Br 0.079904
+Kr 0.083798
+Rb 0.0854678
+Sr 0.08762
+Y 0.0889058
+Zr 0.091224
+Nb 0.0929064
+Mo 0.09596
+Ru 0.10107
+Rh 0.102905
+Pd 0.10642
+Ag 0.107868
+Cd 0.112411
+In 0.114818
+Sn 0.11871
+Sb 0.12176
+Te 0.1276
+I 0.126904
+Xe 0.131293
+Cs 0.132905
+Ba 0.137327
+La 0.138905
+Ce 0.140116
+Pr 0.140908
+Nd 0.144242
+Sm 0.15036
+Eu 0.151964
+Gd 0.15725
+Tb 0.158925
+Dy 0.1625
+Ho 0.16493
+Er 0.167259
+Tm 0.168934
+Yb 0.173054
+Lu 0.174967
+Hf 0.17849
+Ta 0.180948
+W 0.18384
+Re 0.186207
+Os 0.19023
+Ir 0.192217
+Pt 0.195084
+Au 0.196967
+Hg 0.20059
+Tl 0.204383
+Pb 0.2072
+Bi 0.20898
+Th 0.232038
+Pa 0.231036
+U 0.238029
diff --git a/burnman/modified_tait.py b/burnman/modified_tait.py
index 4a93514..94c21be 100644
--- a/burnman/modified_tait.py
+++ b/burnman/modified_tait.py
@@ -45,9 +45,6 @@ class MTaitBase(eos.EquationOfState):
     and Holland and Powell (2011; followed here).
     """
 
-    #def __init__(self):
-    #    pass
-
     def grueneisen_parameter(self, pressure, temperature, volume, params):
         """
         Returns grueneisen parameter [unitless] as a function of pressure,
@@ -84,7 +81,7 @@ class MTaitBase(eos.EquationOfState):
         psubpth=pressure-Pth
         return params['K_0']*(1. + b(psubpth))*(a + (1.-a)*pow((1. + b(psubpth)), c))
 
-    #calculate the mgd shear modulus as a function of P, V, and T
+    #calculate the shear modulus as a function of P, V, and T
     def shear_modulus(self, pressure, temperature, volume, params):
         """
         Not implemented. 
diff --git a/burnman/molar_mass.py b/burnman/molar_mass.py
new file mode 100644
index 0000000..0edd27e
--- /dev/null
+++ b/burnman/molar_mass.py
@@ -0,0 +1,47 @@
+# BurnMan - a lower mantle toolkit
+# Copyright (C) 2012, 2013, Myhill, R., Heister, T., Unterborn, C., Rose, I. and Cottaar, S.
+# Released under GPL v2 or later.
+
+# This is a short standalone program which calculates the molar mass of a chemical formula specified as a command line argument.
+
+import sys
+import re
+
+if len(sys.argv) != 2:
+    print 'Usage:', sys.argv[0], '<formula>'
+    exit()
+
+formula=sys.argv[1]
+
+
+filename="data/input_masses/atomic_masses.dat"
+file = open(filename, "r")
+el_name = []
+el_mass = []
+
+i=0
+for line in file:
+    data="%".join(line.split("%")[:1]).split()
+    if data != []:
+        el_name.append(data[0])
+        el_mass.append(float(data[1]))
+file.close()
+
+# Loop over elements
+n=0.
+molar_mass=0.
+for element in re.findall('[A-Z][^A-Z]*', formula):
+    list=filter(None, re.split(r'(\d+)', element))
+    # Look up number of atoms of element
+    if len(list) == 1:
+        nel=1.
+    else: 
+        nel=float(list[1])
+    # Increment size of compound
+    n=n+nel
+
+    # Find atomic mass of element
+    molar_mass=molar_mass+nel*el_mass[el_name.index(list[0])]
+
+print 'number of atoms per formula unit:', n
+print 'molar mass of formula unit:', molar_mass, 'kg'



More information about the CIG-COMMITS mailing list