diff --git a/periodictable/core.py b/periodictable/core.py index 7c775a8..8294294 100644 --- a/periodictable/core.py +++ b/periodictable/core.py @@ -239,7 +239,10 @@ def __iter__(self): """ Process the elements in Z order """ - for _, el in sorted(self._element.items()): + # CRUFT: Since 3.7 dictionaries use insertion order, so no need to sort + elements = sorted(self._element.items()) + # Skipping the first entry (neutron) in the iterator + for _, el in elements[1:]: yield el def symbol(self, input): @@ -604,7 +607,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], []], @@ -764,7 +767,7 @@ def define_elements(table, namespace): for el in table: names[el.symbol] = el names[el.name] = el - for el in [table.D, table.T]: + for el in [table.D, table.T, table.n]: names[el.symbol] = el names[el.name] = el diff --git a/periodictable/density.py b/periodictable/density.py index 43f602e..ba4ba22 100644 --- a/periodictable/density.py +++ b/periodictable/density.py @@ -170,7 +170,7 @@ def init(table, reload=False): el.density_caveat = "" element_densities = dict( - # n=None, # No longer using element 0 for a bare neutron + 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 760ecfb..50d52f4 100644 --- a/periodictable/mass.py +++ b/periodictable/mass.py @@ -120,12 +120,12 @@ def init(table, reload=False): 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 + from .constants import neutron_mass, neutron_mass_unc + el = table.n + 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/nsf.py b/periodictable/nsf.py index de65288..da0d24a 100644 --- a/periodictable/nsf.py +++ b/periodictable/nsf.py @@ -567,9 +567,6 @@ 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, \ @@ -580,7 +577,7 @@ def init(table, reload=False): nsf._number_density = element.number_density # N/cm^3 = N/cm^3 if isotope_number == 0: - # Bulk values using laboratory abundances of isotopes + # Value for element using laboratory abundances of isotopes element.neutron = nsf else: # Values for the individual isotope diff --git a/test/test_nsf.py b/test/test_nsf.py index 8f5b760..dafa777 100644 --- a/test/test_nsf.py +++ b/test/test_nsf.py @@ -5,7 +5,7 @@ import periodictable from periodictable import elements, formula, nsf from periodictable.nsf import neutron_scattering, neutron_sld -from periodictable.constants import avogadro_number as N_A +from periodictable.constants import avogadro_number as N_A, neutron_mass def test(): H,He,D,O = elements.H,elements.He,elements.D,elements.O @@ -135,6 +135,19 @@ def test(): assert all(abs(v-w)<1e-14 for v,w in zip(xs,xs2)) assert abs(depth-depth2)<1e-14 +def test_bare_neutron(): + n = elements.n + assert n == elements[0] + assert n == periodictable.neutron + n_iso = elements[0][1] + assert n.mass == neutron_mass + assert n_iso.mass == neutron_mass + assert n.neutron.b_c == -37.0 + assert n.density is None + assert n.number_density is None + assert n.neutron.scattering()[0] is None + + def test_formula(): density = 2.52 M = formula('B4C', density=density)