Skip to content

Commit

Permalink
Remove element Z=0 (neutron) from table. Refs #45
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Kienzle committed Oct 2, 2024
1 parent 5e3a96e commit 4b26186
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 45 deletions.
7 changes: 1 addition & 6 deletions doc/sphinx/guide/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@ Import all elements:
>>> print(periodictable.H.mass)
1.008

Deuterium and tritium are special isotopes named D and T
some neutron information is available as 'n':
Deuterium and tritium are special isotopes named D and T:

.. doctest::

>>> print("D mass %s"%D.mass)
D mass 2.01410177784
>>> print("neutron mass %s"%n.mass)
neutron mass 1.0086649159

Process all the elements:

Expand All @@ -73,7 +70,6 @@ Process all the elements:
>>> import periodictable
>>> for el in periodictable.elements: # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... print("%s %s"%(el.symbol,el.name))
n neutron
H hydrogen
He helium
...
Expand All @@ -86,7 +82,6 @@ Another example for processing all elements:
>>> from periodictable import elements
>>> for el in elements: # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... print("%s %s"%(el.symbol,el.number))
n 0
H 1
He 2
...
Expand Down
6 changes: 2 additions & 4 deletions periodictable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ class PeriodicTable(object):
56-Fe
Deuterium and tritium are defined as 'D' and 'T'. Some
neutron properties are available in ``elements[0]``.
Deuterium and tritium are defined as 'D' and 'T'.
To show all the elements in the table, use the iterator:
Expand All @@ -198,7 +197,6 @@ class PeriodicTable(object):
>>> from periodictable import *
>>> for el in elements: # lists the element symbols
... print("%s %s"%(el.symbol, el.name)) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
n neutron
H hydrogen
He helium
...
Expand Down Expand Up @@ -606,7 +604,7 @@ def _make_isotope_ion(table, Z, n, c):
element_base = {
# number: name symbol common_ions uncommon_ions
# ion info comes from Wikipedia: list of oxidation states of the elements.
0: ['Neutron', 'n', [], []],
# 0: ['Neutron', 'n', [], []],
1: ['Hydrogen', 'H', [-1, 1], []],
2: ['Helium', 'He', [], [1, 2]], # +1,+2 http://periodic.lanl.gov/2.shtml
3: ['Lithium', 'Li', [1], []],
Expand Down
3 changes: 2 additions & 1 deletion periodictable/covalent_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def init(table, reload=False):
return
table.properties.append('covalent_radius')

table[0].covalent_radius = 0.20
# neutron covalent radius of 0.20 A ? Not sure where that value came from
# table[0].covalent_radius = 0.20
Element.covalent_radius_units = 'angstrom'
Element.covalent_radius = None
Element.covalent_radius_uncertainty = None
Expand Down
5 changes: 2 additions & 3 deletions periodictable/crystal_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@


crystal_structures = [\
None, #X
{'symmetry': 'diatom', 'd': 0.74}, #H
{'symmetry': 'atom'}, #He
{'symmetry': 'BCC', 'a': 3.49}, #Li
Expand Down Expand Up @@ -155,5 +154,5 @@ def init(table, reload=False):
return
table.properties.append('crystal_structure')

for Z, struct in enumerate(crystal_structures):
table[Z].crystal_structure = struct
for k, struct in enumerate(crystal_structures):
table[k+1].crystal_structure = struct
3 changes: 1 addition & 2 deletions periodictable/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def init(table, reload=False):
el.density_caveat = ""

element_densities = dict(
# TODO: stop pretending that a bare neutron is element zero.
n=None,
# n=None, # No longer using element 0 for a bare neutron
H=(0.0708, "T=-252.87"),
He=(0.122, "T=-268.93"),
Li=0.534,
Expand Down
14 changes: 7 additions & 7 deletions periodictable/mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ def init(table, reload=False):
#iso._abundance, iso._abundance_unc = parse_uncertainty(p)
iso._abundance, iso._abundance_unc = 0, 0

# A single neutron is an isotope of element 0
from .constants import neutron_mass, neutron_mass_unc
el = table[0]
el._mass, el._mass_unc = neutron_mass, neutron_mass_unc
iso = el.add_isotope(1)
iso._mass, iso._mass_unc = neutron_mass, neutron_mass_unc
iso._abundance, iso._abundance_unc = 100, 0
# # A single neutron is an isotope of element 0
# from .constants import neutron_mass, neutron_mass_unc
# el = table[0]
# el._mass, el._mass_unc = neutron_mass, neutron_mass_unc
# iso = el.add_isotope(1)
# iso._mass, iso._mass_unc = neutron_mass, neutron_mass_unc
# iso._abundance, iso._abundance_unc = 100, 0

# Parse element mass table where each line looks like:
# z El element mass(unc)|[low,high]|- note note ...
Expand Down
14 changes: 7 additions & 7 deletions periodictable/mass_2001.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def init(table, reload=False):
iso._mass, iso._mass_unc = parse_uncertainty(m)
iso._abundance,iso._abundance_unc = parse_uncertainty(p) if p else (0,0)

# A single neutron is an isotope of element 0
from .constants import neutron_mass
el = table[0]
el._mass = neutron_mass
iso = el.add_isotope(1)
iso._mass = neutron_mass
iso._abundance = 100
# # A single neutron is an isotope of element 0
# from .constants import neutron_mass
# el = table[0]
# el._mass = neutron_mass
# iso = el.add_isotope(1)
# iso._mass = neutron_mass
# iso._abundance = 100

# z-El-n,iso_mass(unc),abundance%(unc),element_mass(unc)
massdata = """\
Expand Down
14 changes: 3 additions & 11 deletions periodictable/nsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ def init(table, reload=False):
symbol = parts[1]
isotope_number = int(parts[2]) if len(parts) == 3 else 0

if Z == 0: # Skip row 0-n-1
continue

# Fetch element from the table and check that the symbol matches
element = table[Z]
assert element.symbol == symbol, \
Expand All @@ -576,13 +579,6 @@ def init(table, reload=False):
# it can calculate sld.
nsf._number_density = element.number_density # N/cm^3 = N/cm^3


# For new elements, clear out 'neutron' attribute for isotopes
# This protects against isotope using the element data when
# they don't have any specific neutron data.
#if isotope_number == 0 or not hasattr(element,'neutron'):
# for iso in element: iso.neutron = None

if isotope_number == 0:
# Bulk values using laboratory abundances of isotopes
element.neutron = nsf
Expand Down Expand Up @@ -1876,8 +1872,6 @@ def coherent_comparison_table(table=None, tol=None):
>>> coherent_comparison_table (tol=0.5) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
Comparison of (4 pi |b_c|^2/100) and coherent
n 172.03 43.01 300.0%
1-n 172.03 43.01 300.0%
Sc 18.40 19.00 -3.2%
45-Sc 18.40 19.00 -3.2%
65-Cu 13.08 14.10 -7.2%
Expand Down Expand Up @@ -1908,8 +1902,6 @@ def total_comparison_table(table=None, tol=None):
>>> total_comparison_table (tol=0.1)
Comparison of total cross section to (coherent + incoherent)
n 43.01 ----
1-n 43.01 ----
84-Kr 6.60 ----
149-Sm 200.00 200.50 -0.2%
Eu 9.20 9.07 1.4%
Expand Down
4 changes: 2 additions & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test():

# Check that "for el in elements" works and for iso in el works
els = tuple(el for el in elements)
assert els[0].number == 0
assert els[1].number == 1
assert els[0].number == 1
assert els[1].number == 2
isotopes = tuple(iso for iso in O)
assert isotopes[0].isotope == 12 # 12 is the first oxygen isotope listed

Expand Down
2 changes: 0 additions & 2 deletions test/test_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def test():
assert abs(periodictable.Pb[206].abundance - Pb_206_abundance) < 1e-14
assert abs(periodictable.Pb[209].abundance - Pb_209_abundance) < 1e-14
assert periodictable.Pb.mass == Pb_mass
from periodictable.constants import neutron_mass
assert periodictable.n.mass == neutron_mass

# Check abundance totals to 0% or 100%
for el in periodictable.elements:
Expand Down

0 comments on commit 4b26186

Please sign in to comment.