Skip to content

Nexus: Refactor periodic_table.py#5832

Open
brockdyer03 wants to merge 8 commits intoQMCPACK:developfrom
brockdyer03:refactor_periodic_table
Open

Nexus: Refactor periodic_table.py#5832
brockdyer03 wants to merge 8 commits intoQMCPACK:developfrom
brockdyer03:refactor_periodic_table

Conversation

@brockdyer03
Copy link
Contributor

Proposed changes

This PR updates nexus/periodic_table.py in several ways:

  • Use a more compact data layout for element data (line count as the metric)
  • Prevent editing element data after initialization
  • Remove unused/uncited data (e.g. melting point, atomic radius, etc.)
  • Update atomic mass and isotope data with up to date sources (IUPAC, NIST)
  • Add support for all elements
  • Strengthen is_element() function.
  • Provide easier call syntax for accessing elements (e.g. instead of ptable.elements[1].atomic_weight you can do Elements(1).atomic_weight or Elements("H").atomic_weight among other things)
  • Provide a dummy element that can act as a placeholder or potentially a catch-all.
  • Write comprehensive docstrings with usage examples
  • Add comprehensive tests (only missing tests for errors)

Note on updated atomic weights

One "problem" that may arise here is that the updated atomic weights are slightly different than the historic weights. I have updated the relevant tests, but I will note that calculations that use Nexus's atomic weights may be slightly different.

What type(s) of changes does this code introduce?

  • New feature
  • Refactoring (no functional changes, no api changes)
  • Testing changes (e.g. new unit/integration/performance tests)
  • Documentation or build script changes

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

Laptop, Fedora 43, Python 3.14.2, Numpy 2.4.2

Checklist

    • I have read the pull request guidance and develop docs
    • This PR is up to date with the current state of 'develop'
    • This PR adds tests to cover any new code, or to catch a bug that is being fixed
    • Documentation has been added (if appropriate)

@brockdyer03 brockdyer03 self-assigned this Feb 24, 2026
@brockdyer03 brockdyer03 added nexus documentation refactor python Pull requests that update python code labels Feb 24, 2026
Copy link
Contributor

@prckent prckent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering what is the sourcing for all the magic numbers in the periodic_table.py file?
Ideally it comes from NIST, we can add a citation, and it was automated so that the prospect of introduced errors is minimal..

@jtkrogel
Copy link
Contributor

Note: this PR depends on Python 3.10 and so issue #5816 must be resolved first.

Copy link
Contributor

@jtkrogel jtkrogel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation nexus python Pull requests that update python code refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants