Skip to content

Add injectable potentials to allow per-element PAW path and potType override#69

Merged
pmrv merged 4 commits intocalculatorfrom
injectable-potentials
Apr 21, 2026
Merged

Add injectable potentials to allow per-element PAW path and potType override#69
pmrv merged 4 commits intocalculatorfrom
injectable-potentials

Conversation

@pmrv
Copy link
Copy Markdown
Contributor

@pmrv pmrv commented Apr 20, 2026

Adds an optional potentials: dict[str, {potential, potType}] parameter to get_paw_from_structure, get_paw_from_chemical_symbols, set_base_parameters, and SphinxDft.__init__. Elements absent from the dict fall back to the existing get_potential_path / AtomPAW default.

@pmrv pmrv requested a review from samwaseda April 20, 2026 20:02
@github-actions
Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on branch pyiron/sphinx_parser/injectable-potentials

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 20, 2026

Not up to standards ⛔

🔴 Issues 5 minor

Alerts:
⚠ 5 issues (≤ 0 issues of at least minor severity)

Results:
5 new issues

Category Results
Documentation 5 minor

View in Codacy

🟢 Metrics 10 complexity · 0 duplication

Metric Results
Complexity 10
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@pmrv pmrv force-pushed the injectable-potentials branch from 2f7410f to 8248965 Compare April 20, 2026 20:04
pmrv and others added 2 commits April 20, 2026 16:06
…verride

Adds an optional `potentials: dict[str, {potential, potType}]` parameter
to `get_paw_from_structure`, `get_paw_from_chemical_symbols`,
`set_base_parameters`, and `SphinxDft.__init__`. Elements absent from the
dict fall back to the existing `get_potential_path` / AtomPAW default.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pmrv pmrv force-pushed the injectable-potentials branch from 8248965 to fb23aa6 Compare April 20, 2026 20:10
Comment thread sphinx_parser/calculator.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.19%. Comparing base (eb838a3) to head (7f1d4fb).
⚠️ Report is 5 commits behind head on calculator.

Files with missing lines Patch % Lines
sphinx_parser/calculator.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           calculator      #69      +/-   ##
==============================================
+ Coverage       85.90%   86.19%   +0.28%     
==============================================
  Files               9        9              
  Lines             837      840       +3     
==============================================
+ Hits              719      724       +5     
+ Misses            118      116       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samwaseda samwaseda requested a review from Copilot April 21, 2026 09:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an optional per-element potentials override that lets callers inject custom PAW potential paths and potType values, while preserving the existing default behavior (JTH GGA PBE under $CONDA_PREFIX + AtomPAW) for elements not overridden.

Changes:

  • Extend PAW construction helpers to accept optional potentials overrides (get_paw_from_structure, get_paw_from_chemical_symbols).
  • Thread potentials through the main input-builder (set_base_parameters) and the ASE calculator (SphinxDft).
  • Add unit tests validating injected vs fallback potential behavior and forwarding.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sphinx_parser/potential.py Adds potentials support when building pawPot.species.
sphinx_parser/jobs.py Forwards potentials into PAW setup from base input parameters.
sphinx_parser/calculator.py Stores potentials on the calculator and forwards into input generation; adds/updates docstring.
tests/unit/test_potential.py Adds unit tests for injected potentials + fallback behavior.
tests/unit/test_jobs.py Adds test ensuring potentials is forwarded through set_base_parameters.
CLAUDE.md Adds repository overview/developer notes.
Comments suppressed due to low confidence (1)

sphinx_parser/jobs.py:18

  • set_base_parameters now accepts a potentials argument but the docstring’s Args section doesn’t mention it. Please document what potentials is expected to contain (per-element override schema) and how elements not present fall back to get_potential_path / default AtomPAW.
    ekt: float = 0.2,
    k_point_coords: list = [0.5, 0.5, 0.5],
    potentials=None,
):
    """
    Set the base parameters for the sphinx input file

    Args:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +37
potentials (dict[str, dict] | None): Optional per-element PAW potential
overrides. Each key is an element symbol; each value is a dict with:
- ``potential`` (Path | str): path to the potential file.
- ``potType`` (str): potential type, e.g. ``"AtomPAW"`` or
``"VASP"``.
Elements absent from this dict fall back to the JTH-GGA-PBE
potentials found under ``$CONDA_PREFIX``.
*args, **kwargs: Forwarded to :class:`ase.calculators.calculator.FileIOCalculator`.

Example::

calc = SphinxDft(directory="./run")

calc = SphinxDft(
directory="./run",
potentials={
"Fe": {"potential": Path("/pots/Fe_GGA.atomicdata"), "potType": "AtomPAW"},
"Al": {"potential": Path("/pots/Al_VASP.POTCAR"), "potType": "VASP"},
},
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

The new potType documentation/examples here use "VASP", but the rest of this PR’s usage/tests use "VaspPAW". If potType is case-sensitive, this docstring could mislead users—please clarify the valid potType values and align the examples with what the library actually expects.

Copilot uses AI. Check for mistakes.
Comment thread sphinx_parser/potential.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pmrv pmrv merged commit 9d1abe8 into calculator Apr 21, 2026
15 of 19 checks passed
@pmrv pmrv deleted the injectable-potentials branch April 21, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants