Skip to content

Commit

Permalink
Merge pull request #58 from pkienzle/fix-use-iupac-abundance
Browse files Browse the repository at this point in the history
Use IUPAC tables for atomic weight and isotopic abundance
  • Loading branch information
pkienzle authored Feb 13, 2024
2 parents 1b63ee5 + 55ce71c commit 7492849
Show file tree
Hide file tree
Showing 16 changed files with 873 additions and 163 deletions.
10 changes: 6 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
include LICENSE.txt
include doc
include periodictable/xsf/*
include periodictable/activation.dat
graft doc
prune doc/sphinx/_build
prune doc/sphinx/build
exclude build dist *.pyc
prune */__pycache__
prune */*/__pycache__
prune */*/*/__pycache__
#recursive-exclude __pycache__ *
#exclude build dist *.pyc __pycache__/*
49 changes: 29 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ Extensible periodic table of the elements
This package provides a periodic table of the elements with
support for mass, density and xray/neutron scattering information.

Masses, densities and natural abundances come from the
NIST Physics Laboratory, but do not represent a critical
evaluation by NIST scientists.

Neutron scattering calculations use values collected by the
Atomic Institute of the Austrian Universities. These values
do corresponding to those from other packages, though there
are some differences depending to the tables used. Bound
coherent neutron scattering for gold in particular is significantly
different from older value: 7.63(6) as measured in 1974
compared to 7.90(7) as measured in 1990.

X-ray scattering calculations use a combination of empirical and
theoretical values from the LBL Center for X-ray Optics. These
values differ from those given in other sources such as the
International Tables for Crystallography, Volume C, and so may
give different results from other packages.
Atomic Institute of the Austrian Universities as they appear in the neutron
data booklet, with support for some energy dependent scattering
in rare earth elements given by Lynn and Seeger (1990). X-ray scattering
calculations use a combination of empirical and theoretical values from
the LBL Center for X-ray Optics.

Tabulated values differ from those given in other sources such as the
International Tables for Crystallography, Volume C, and so computed
cross sections may give different results from other packages.

Neutron activation calculations are based on Shleien (1998), with
isotopes important to health physics. They do not perform a full
activation analysis, but instead give a gross estimate of the amount
of activation expected for a sample in the beam.

Install using::

Expand Down Expand Up @@ -62,17 +60,28 @@ Known issues
isotope proportions and density computed in neutron_sld(). This may change
in a future release.

* The mass and composition tables are out of date. This package uses tables
from 1997 but IUPAC produced new tables in 2009.

* Incoherent scattering calculations for energy-dependent rare earth elements
is underestimated. The calculation requires bound incoherent scattering
lengths (b_i) and the bound coherent lengths (b_c), but only b_c is
length (b_i) but only the bound coherent scattering length (b_c) is
included.

Change history
==============

1.7.0 2023-07-??
----------------

Modified:

* Move to IAEA AME2020 for isotope mass
* Move to IUPAC CIAAW 2021 for atomic weight and isotopic abundance
* Li-6:Li-7 mass ratio changed from 12.2 to 19.6 (delta = 2.7%)
* Isotope percentage changed by 0.1 to 0.5 for B, Zn, Ge, Se, Mo, Er, Yb, Pt, Hg
* Atomic weight changed by 0.04% for Zn, 0.02% for S and 0.01% for Li, Ge, Se, Mo
* Neutron b_c changed for Zn-70 from 6.9 to 6.0 (fixes a typo in the original table)
* Fix typos in uncertainties in the neutron table (Zr-90, Te-124, Ba-138, Sm-147)


1.6.1 2022-05-18
----------------

Expand Down
7 changes: 5 additions & 2 deletions doc/sphinx/guide/data_sources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ Data Sources
Physical constants
`NIST Physics Laboratory - Constants, units and uncertainty <http://physics.nist.gov/cuu/index.html>`_

Atomic and isotope mass
`NIST Physics Laboratory - Atomic weights and isotope composition <http://physics.nist.gov/PhysRefData/Compositions/>`_
Isotope mass
`IAEA Atomic Mass Data Center AME2020 <https://www-nds.iaea.org/amdc/>`_

Atomic weight and isotope abundance
`IUPAC commission on isotope abundances and atomic weights <https://www.ciaaw.org>`_

Atomic density
*ILL Neutron Data Booklet*
Expand Down
12 changes: 6 additions & 6 deletions doc/sphinx/guide/formula_grammar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ A formula string is translated into a formula using
* Specific mass can be giving with count follwed by mass units:

>>> print(formula("5g NaCl // 50mL H2O@1"))
NaCl(H2O)32.4407
NaCl(H2O)32.4395

Density will be required for materials given by volume. Mass will be
stored in the *total_mass* attribute of the resulting formula.

* Multilayers can be specified by thickness:

>>> print(formula("1 um Si // 5 nm Cr // 10 nm Au"))
Si119.99CrAu1.41722
Si119.992CrAu1.41722

Density will be required for each layer. Thickness will be stored in
the *total_thickness* attribute of the resulting formula. Thickness can
Expand All @@ -135,7 +135,7 @@ A formula string is translated into a formula using
20:80 by volume with D2O:

>>> print(formula("20vol% (10 wt% [email protected] // H2O@1) // D2O@1n"))
NaCl(H2O)29.1966(D2O)122.794
NaCl(H2O)29.1956(D2O)122.79

* Empty formulas are supported, e.g., for air or vacuum:

Expand Down Expand Up @@ -257,7 +257,7 @@ Note that this is different from a 2:1 mixture by weight:

>>> mix = mix_by_weight(H2O,2,D2O,1)
>>> print(f"{mix} {mix.density:.4g}")
(H2O)2.2234D2O 1.035
(H2O)2.22339D2O 1.035

Except in the simplest of cases, the density of the mixture cannot be
computed from the densities of the components, and the resulting density
Expand All @@ -273,8 +273,8 @@ compute molar mass and neutron/xray scattering length density:
>>> import periodictable
>>> SiO2 = periodictable.formula('SiO2')
>>> hydrated = SiO2 + periodictable.formula('3H2O')
>>> print(f"{hydrated} mass {hydrated.mass}")
SiO2(H2O)3 mass 114.13014
>>> print(f"{hydrated} mass {hydrated.mass:.3f}")
SiO2(H2O)3 mass 114.128
>>> rho,mu,inc = periodictable.neutron_sld('SiO2+3H2O',density=1.5,wavelength=4.75)
>>> print(f"{hydrated} neutron sld {rho:.3g}")
SiO2(H2O)3 neutron sld 0.849
Expand Down
6 changes: 3 additions & 3 deletions doc/sphinx/guide/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Access particular elements by name:

>>> from periodictable import hydrogen
>>> print("H mass %s %s"%(hydrogen.mass, hydrogen.mass_units))
H mass 1.00794 u
H mass 1.008 u

Access particular elements as symbols:

Expand Down Expand Up @@ -54,7 +54,7 @@ Import all elements:
>>> print(periodictable.H)
H
>>> print(periodictable.H.mass)
1.00794
1.008

Deuterium and tritium are special isotopes named D and T
some neutron information is available as 'n':
Expand All @@ -64,7 +64,7 @@ some neutron information is available as 'n':
>>> print("D mass %s"%D.mass)
D mass 2.01410177784
>>> print("neutron mass %s"%n.mass)
neutron mass 1.00866491597
neutron mass 1.0086649159

Process all the elements:

Expand Down
12 changes: 8 additions & 4 deletions periodictable/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
#: electron radius r_e (m)
electron_radius = 2.8179402894e-15 #(58) m

# From NIST Reference on Constants, Units, and Uncertainty
# [CODATA] From NIST Reference on Constants, Units, and Uncertainty
# http://physics.nist.gov/cuu/index.html
# neutron mass = 1.008 664 915 97(43) u
# atomic mass constant m_u = 1.660 538 782(83) x 10-27 kg
# [AME2020] "The Ame2020 atomic mass evaluation (II)"
# by M.Wang, W.J.Huang, F.G.Kondev, G.Audi and S.Naimi
# Chinese Physics C45, 030003, March 2021.
#: neutron mass (u)
neutron_mass = 1.00866491597 #(43) u
neutron_mass = 1.00866491590 #(47) u [AME 2020]
neutron_mass_unc = 0.00000000047
#neutron_mass = 1.00866491597 #(43) u [CODATA 2010?]
#neutron_mass = 1.00866491595 #(49) u [CODATA 2018]
#: atomic mass constant (kg / u)
atomic_mass_constant = 1.660538782e-27 #(83) kg / u
#: electron mass (u)
Expand Down
2 changes: 1 addition & 1 deletion periodictable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def list(self, *props, **kw):
>>> from periodictable import elements
>>> elements.list('symbol', 'mass', 'density',
... format="%-2s: %6.2f u %5.2f g/cm^3") # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... format="%-2s: %6.2f u %6.2f g/cm^3") # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
H : 1.01 u 0.07 g/cm^3
He: 4.00 u 0.12 g/cm^3
Li: 6.94 u 0.53 g/cm^3
Expand Down
15 changes: 10 additions & 5 deletions periodictable/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,14 @@ def fasta_table():
rows += [v for k, v in sorted(NUCLEIC_ACID_COMPONENTS.items())]
rows += [Sequence("beta casein", beta_casein)]

print("%20s %7s %7s %7s %5s %5s %5s %5s %5s %5s"
print("%25s %7s %7s %7s %5s %5s %5s %5s %5s %5s"
% ("name", "M(H2O)", "M(D2O)", "volume",
"den", "#el", "xray", "nH2O", "nD2O", "%D2O match"))
for v in rows:
protons = sum(num*el.number for el, num in v.natural_formula.atoms.items())
electrons = protons - v.charge
Xsld = xray_sld(v.formula, wavelength=elements.Cu.K_alpha)
print("%20s %7.1f %7.1f %7.1f %5.2f %5d %5.2f %5.2f %5.2f %5.1f"%(
print("%25s %7.1f %7.1f %7.1f %5.2f %5d %5.2f %5.2f %5.2f %5.1f"%(
v.name, v.mass, v.Dmass, v.cell_volume, v.natural_formula.density,
electrons, Xsld[0], v.sld, v.Dsld, v.D2Omatch))

Expand All @@ -499,11 +499,15 @@ def test():
# name Hmass Dmass vol den #el xray Hsld Dsld
# =========== ======= ======= ======= ===== ===== ===== ===== =====
# beta casein 23561.9 23880.9 30872.9 1.27 12614 11.55 1.68 2.75
# ... updated for new mass table [2023-08]
# same 23562.3 23881.2 same 1.27 same 1.68 2.75
seq = Sequence("beta casein", beta_casein)
assert abs(seq.mass - 23561.9) < 0.1
assert abs(seq.Dmass - 23880.9) < 0.1
density = seq.mass/avogadro_number/seq.cell_volume*1e24
#print(seq.mass, seq.Dmass, density, seq.sld, seq.Dsld)
assert abs(seq.mass - 23562.3) < 0.1
assert abs(seq.Dmass - 23881.2) < 0.1
assert abs(seq.cell_volume - 30872.9) < 0.1
assert abs(seq.mass/avogadro_number/seq.cell_volume*1e24 - 1.267) < 0.01
assert abs(density - 1.267) < 0.01
assert abs(seq.sld - 1.68) < 0.01
assert abs(seq.Dsld - 2.75) < 0.01

Expand All @@ -516,3 +520,4 @@ def test():

if __name__ == "__main__":
fasta_table()
#test()
Loading

0 comments on commit 7492849

Please sign in to comment.