From 4b26186649803d41353d3fb3afd40c4ce3683083 Mon Sep 17 00:00:00 2001 From: Paul Kienzle Date: Wed, 2 Oct 2024 13:53:29 -0400 Subject: [PATCH] Remove element Z=0 (neutron) from table. Refs #45 --- doc/sphinx/guide/using.rst | 7 +------ periodictable/core.py | 6 ++---- periodictable/covalent_radius.py | 3 ++- periodictable/crystal_structure.py | 5 ++--- periodictable/density.py | 3 +-- periodictable/mass.py | 14 +++++++------- periodictable/mass_2001.py | 14 +++++++------- periodictable/nsf.py | 14 +++----------- test/test_core.py | 4 ++-- test/test_mass.py | 2 -- 10 files changed, 27 insertions(+), 45 deletions(-) diff --git a/doc/sphinx/guide/using.rst b/doc/sphinx/guide/using.rst index da7872e..ad45a35 100644 --- a/doc/sphinx/guide/using.rst +++ b/doc/sphinx/guide/using.rst @@ -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: @@ -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 ... @@ -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 ... diff --git a/periodictable/core.py b/periodictable/core.py index 526516f..7c775a8 100644 --- a/periodictable/core.py +++ b/periodictable/core.py @@ -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: @@ -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 ... @@ -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], []], diff --git a/periodictable/covalent_radius.py b/periodictable/covalent_radius.py index 37d2d70..91c43c3 100644 --- a/periodictable/covalent_radius.py +++ b/periodictable/covalent_radius.py @@ -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 diff --git a/periodictable/crystal_structure.py b/periodictable/crystal_structure.py index 20554b7..3a39124 100644 --- a/periodictable/crystal_structure.py +++ b/periodictable/crystal_structure.py @@ -42,7 +42,6 @@ crystal_structures = [\ - None, #X {'symmetry': 'diatom', 'd': 0.74}, #H {'symmetry': 'atom'}, #He {'symmetry': 'BCC', 'a': 3.49}, #Li @@ -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 diff --git a/periodictable/density.py b/periodictable/density.py index be85ed6..43f602e 100644 --- a/periodictable/density.py +++ b/periodictable/density.py @@ -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, diff --git a/periodictable/mass.py b/periodictable/mass.py index 5fbcaed..760ecfb 100644 --- a/periodictable/mass.py +++ b/periodictable/mass.py @@ -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 ... diff --git a/periodictable/mass_2001.py b/periodictable/mass_2001.py index c4ec2a6..565e7a2 100644 --- a/periodictable/mass_2001.py +++ b/periodictable/mass_2001.py @@ -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 = """\ diff --git a/periodictable/nsf.py b/periodictable/nsf.py index ef35a9b..d42acad 100644 --- a/periodictable/nsf.py +++ b/periodictable/nsf.py @@ -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, \ @@ -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 @@ -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% @@ -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% diff --git a/test/test_core.py b/test/test_core.py index 1e3498d..5c9abba 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -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 diff --git a/test/test_mass.py b/test/test_mass.py index e98a25d..531c39d 100644 --- a/test/test_mass.py +++ b/test/test_mass.py @@ -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: