Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reconcile 2.0-pre with master #89

Merged
merged 36 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f371063
restore exception raised when 'b' mode production activity produces n…
May 19, 2022
1297b3a
check activation calculation completes for all elements
May 19, 2022
bc73cd2
Nicer error message for trans-uranic xray sld failure. Refs #56
Apr 3, 2023
d7ac5e6
`scattering` already returns None if not self.has_sld
jfkcooper Jun 23, 2023
585117b
changed isotope masses and reference to where they came from
jfkcooper Jun 23, 2023
ddb3e60
revert code change and update docstring
jfkcooper Jun 26, 2023
3351925
Use older ubuntu to test python 2.7 and 3.6
Jul 6, 2023
a6b7cc9
Drop tests for python below 3.8
Jul 6, 2023
9365566
Merge pull request #57 from jfkcooper/updated_isotope_masses
pkienzle Jul 6, 2023
c6b980e
Update tests for new element masses
Jul 6, 2023
3c99287
Use AME2020 for neutron mass
Jul 7, 2023
b653710
Use IUPAC CIAAW tables for abundance and atomic weight
Jul 7, 2023
45b65e3
Start noting changes to mass tables
Jul 7, 2023
64de891
Move uncertainty parser to util so it can be used for other tables
Aug 22, 2023
c7e55da
Fix typos in ATI tables: Zr[90].neutron.b_c changes from 6.9 to 6.0
Aug 22, 2023
f020397
Use uncertainty parser for neutron table, but ignore uncertainty for now
Aug 22, 2023
c32f3d1
Fix typo in 56-Ba-138 total scattering uncertainty
Aug 23, 2023
bba9695
Fix tests which broke because of updated tables
Aug 23, 2023
ee2f2d3
Fix build issues with docs?
Aug 25, 2023
58c3d08
Update docs
Aug 25, 2023
9605ef1
Fix doc syntax
Aug 25, 2023
1cc5bcc
Allow wt%/vol% in addition to %wt/%vol
Jan 27, 2024
f1f09c8
change %wt/%vol to wt%/vol% in docs
Jan 27, 2024
4178b40
fix markup warning in docs
Jan 29, 2024
1b63ee5
Merge pull request #65 from pkienzle/fix-allow-wtvol-percent
pkienzle Feb 13, 2024
fed2097
Merge branch 'master' into fix-use-iupac-abundance
pkienzle Feb 13, 2024
55ce71c
fix precision in mass example
Feb 13, 2024
7492849
Merge pull request #58 from pkienzle/fix-use-iupac-abundance
pkienzle Feb 13, 2024
d72a009
MAINT: fixes for np2
andyfaff May 1, 2024
8123cd5
Merge pull request #81 from andyfaff/nan
pkienzle Jul 8, 2024
996e087
Update actions versions
bmaranville Jul 8, 2024
b36d7bf
Merge pull request #83 from bmaranville/master
pkienzle Jul 9, 2024
4b26186
Remove element Z=0 (neutron) from table. Refs #45
Oct 2, 2024
c352dc2
Merge branch 'master' into reconcile
Oct 7, 2024
71c43ee
Pb-208 activation cross section in mbarns rather than barns
Oct 7, 2024
3d43e6c
Test from installed wheel (#91)
pkienzle Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 55 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,44 @@ on:
branches: [ master ]

jobs:
test:
build-wheel:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Build the wheel
run: |
python -m pip install build
python -m build

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/*.whl

- name: Run the tests
run: |
python -m pip install numpy pyparsing pytest pytest-cov
pytest -v

- name: Build the docs
run: |
python -m pip install matplotlib sphinx
python -m pip install dist/periodictable*.whl
make -j 4 -C doc/sphinx SPHINXOPTS="-W --keep-going" html

# Test the wheel on different platforms
test:
runs-on: ${{ matrix.cfg.os }}
needs: build-wheel

strategy:
matrix:
cfg:
Expand All @@ -19,27 +54,34 @@ jobs:
- { os: ubuntu-latest, py: 3.11, doc: 1 }
- { os: windows-latest, py: 3.11 }
- { os: macos-latest, py: 3.11 }
fail-fast: false

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.cfg.py }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.cfg.py }}

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install wheel setuptools
python -m pip install numpy scipy matplotlib pytest pytest-cov
- name: Download the wheel
uses: actions/download-artifact@v4
with:
name: wheel
path: dist

- name: Install the wheel
run: python -m pip install dist/periodictable*.whl
shell: bash

- name: Test with pytest
- name: Install Python dependencies
run: |
pytest -v
python -m pip install pytest pytest-cov

- name: check that the docs build (linux only)
if: matrix.cfg.doc == 1
# Change into the test directory to test the wheel so that the
# source directory is not on the path. Full tests with coverage are
# run before building the wheel.
- name: Test wheel with pytest
run: |
python -m pip install sphinx
make -j 4 -C doc/sphinx SPHINXOPTS="-W --keep-going" html
cd test
pytest -v --pyargs --import-mode=append periodictable . ../doc/sphinx/guide
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include LICENSE.txt
include README.rst
graft doc
graft periodictable/xsf
include periodictable/activation.dat
prune doc
prune doc/sphinx/_build
prune doc/sphinx/build
prune */__pycache__
Expand Down
6 changes: 2 additions & 4 deletions doc/sphinx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ help:
clean:
-rm -rf _build/* build/* plots/*.pyc plots/*.png

html: build
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
@echo
@echo "Build finished. The HTML pages are in _build/html."
Expand Down Expand Up @@ -66,7 +66,7 @@ qthelp:
@echo "To view the help file:"
@echo "# assistant -collectionFile _build/qthelp/Periodic Table.qhc"

latex: build
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
@echo
@echo "Build finished; the LaTeX files are in _build/latex."
Expand All @@ -92,5 +92,3 @@ doctest:
@echo "Testing of doctests in the sources finished, look at the " \
"results in _build/doctest/output.txt."

build:
cd ../.. && python setup.py build
2 changes: 1 addition & 1 deletion doc/sphinx/guide/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The simplest solution is to load it directly when your package is imported.
In the current example, this could be done by adding the following
line to the end of the file::

init(periodictable.core.elements)
init(periodictable.core.default_table())

This would be fine for the current example because the table size is
small and load time is fast. For large tables, you may wish to
Expand Down
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
2 changes: 1 addition & 1 deletion periodictable/activation.dat
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ Tl 505 81 Tl 205 Tl-205 70.5 Tl-206 4.19 m act n 0.1 0.7 0.069833333 4.19 m
Pb 506 82 Pb 204 Pb-204 1.4 Pb-203 51.88 h "n,2n" y 0.00245 51.88 51.88 h "IAEA156, fission averaged"
Pb 507 82 Pb 204 Pb-204 1.4 Pb-204m 66.9 m "n,n'" y 0.38 1.115 66.90 m "IAEA156, fission averaged"
Pb 508 82 Pb 204 Pb-204 1.4 Pb-205 14000000 y act n 0.661 1.7 1.2264E+11 14.0 My
Pb 509 82 Pb 208 Pb-208 52.3 Pb-209 3.3 h act n 0.487 3.3 3.30 h
Pb 509 82 Pb 208 Pb-208 52.3 Pb-209 3.3 h act n 0.000487 3.3 3.30 h
Bi 510 83 Bi 209 Bi-209 100 Bi-210ms 3500000 y ms 0 act n 0.019 30660000000 3.5 My
Bi 511 83 Bi 209 Bi-209 100 Bi-210t 5.01 d t act n 0.014 120.24 5.01 d 0.054 0.2
Bi 512 83 Bi 209 Bi-209 100 Po-210 138.38 d b n 0.014 3321.12 138.4 d 120.24
Expand Down
1 change: 1 addition & 0 deletions periodictable/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ def activity(isotope, mass, env, exposure, rest_times):
* AK1495 (Au-198 => Au-199 2n) target should be Au-197
* AN1428 (Tm-169 => Tm-171 2n) t1/2 updated to Tm-171 rather than Tm-172
* AN1420 (Er-162 => Ho-163 b) t1/2 updated to 4570 y from 10 y
* AT1508 (Pb-208 => Pb-209 act) Thermal (b) x1000 to convert from mbarns to barns
"""
# TODO: is the table missing 1-H => 3-H ?
# 0nly activations which produce radioactive daughter products are
Expand Down
1 change: 0 additions & 1 deletion periodictable/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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
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
17 changes: 16 additions & 1 deletion periodictable/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,17 +538,32 @@ def fasta_table():
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))

beta_casein = "RELEELNVPGEIVESLSSSEESITRINKKIEKFQSEEQQQTEDELQDKIHPFAQTQSLVYPFPGPIPNSLPQNIPPLTQTPVVVPPFLQPEVMGVSKVKEAMAPKHKEMPFPKYPVEPFTESQSLTLTDVENLHLPLPLLQSWMHQPHQPLPPTVMFPPQSVLSLSQSKVLPVPQKAVPYPQRDMPIQAFLLYQEPVLGPVRGPFPIIV"

## Uncomment to show package path on CI infrastructure
#def doctestpath():
# """
# Checking import path for doctests::
#
# >>> import periodictable
# >>> print(f"Path to imported periodictable in docstr is {periodictable.__file__}")
# some path printed here
# """

def test():
from periodictable.constants import avogadro_number
from .formulas import formula
elements = default_table()

## Uncomment to show package path on CI infrastructure
#import periodictable
#print(f"Path to imported periodictable in package is {periodictable.__file__}")
#print(fail_test)

# Beta casein results checked against Duncan McGillivray's spreadsheet
# name Hmass Dmass vol den #el xray Hsld Dsld
# =========== ======= ======= ======= ===== ===== ===== ===== =====
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
16 changes: 5 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 Expand Up @@ -1999,3 +1991,5 @@ def main():

if __name__ == "__main__":
main()
#coherent_comparison_table(tol=0.5)
#incoherent_comparison_table(tol=0.5)
Loading