-
Notifications
You must be signed in to change notification settings - Fork 2
ENH: Add an adaptive displacement list for atoms #209
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
base: main
Are you sure you want to change the base?
Conversation
607ba35 to
14291e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Introduce a mechanism to run and cache per-state atom displacement scripts and wire it through the AKMC workflow, reducing redundant executions.
- Add a new
get_displacement_atom_listinStateto generate/cache atom lists via an external script - Introduce a new
displace_atom_kmc_state_scriptconfig field and propagate its use inakmcandexplorer - Implement a
_utilsmodule to securely run the external script and parse its output
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| meson.build | Register new _utils.py in install sources |
| eon/superbasinscheme.py | Refactor e_global_min calculation into two steps for clarity |
| eon/state.py | Added get_displacement_atom_list with caching to state metadata |
| eon/schema.py | Added displace_atom_kmc_state_script field to SaddleSearchConfig |
| eon/explorer.py | Load cached atom list and include it in generated job ini changes |
| eon/displace.py | (Accidental) debug print and new imports |
| eon/config.yaml | Document new script option under Saddle Search |
| eon/config.py | Parse new displace_atom_kmc_state_script from config file |
| eon/akmc.py | Invoke state-based script per AKMC state and assign its output |
| eon/_utils.py | New helper module to run and handle external atom list scripts |
Comments suppressed due to low confidence (2)
eon/_utils.py:1
- This new utility module contains nontrivial logic for running external scripts—consider adding unit tests to cover success, script-not-found, and error cases.
from pathlib import Path
eon/akmc.py:79
displace_atom_listis not defined in the config schema. This assignment won't be validated or propagated; consider adding it to the schema or using an existing field.
config.displace_atom_list = atom_list
| try: | ||
| # The list is stored as a string, so we need to parse it. | ||
| atom_list_str = self.info.get("Saddle Search", "displace_atom_list") | ||
| return atom_list_str |
Copilot
AI
Jul 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method is annotated to return List[int] but returns a raw string. Consider parsing the comma-separated string into a list of ints or updating the return type.
| return atom_list_str | |
| return list(map(int, atom_list_str.split(','))) if atom_list_str else [] |
| # Merge potential files into invariants | ||
| invariants = dict(invariants, **io.load_potfiles(self.config.path_pot)) | ||
|
|
||
| atom_list_str = str(self.state.info.get("Saddle Search", "displace_atom_list", "")) |
Copilot
AI
Jul 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly reading the raw setting here bypasses the new get_displacement_atom_list logic. Consider calling that method to ensure generation and proper parsing.
| atom_list_str = str(self.state.info.get("Saddle Search", "displace_atom_list", "")) | |
| atom_list_str = str(self.get_displacement_atom_list()) |
eon/displace.py
Outdated
| #raise DisplaceError("Listed atoms are all frozen") | ||
| raise DisplaceError("Listed atoms are all frozen") | ||
|
|
||
| print(self.listed_atoms) |
Copilot
AI
Jul 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a leftover debug print. Replace with logger.debug or remove to avoid cluttering standard output.
| print(self.listed_atoms) | |
| logger.debug(f"Listed atoms: {self.listed_atoms}") |
| import sys | ||
| import subprocess | ||
| import tempfile | ||
| from pathlib import Path |
Copilot
AI
Jul 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports (sys, subprocess, tempfile, Path) look unused in this module. Consider removing them to keep dependencies clean.
| import sys | |
| import subprocess | |
| import tempfile | |
| from pathlib import Path |
i.e.
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/users/home/rog32/Git/Github/QueensU/cuTvaccancy/.pixi/envs/default/lib/python3.13/site-packages/eon/akmc.py", line 296, in kmc_step
superbasining.register_transition(current_state, next_state)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/users/home/rog32/Git/Github/QueensU/cuTvaccancy/.pixi/envs/default/lib/python3.13/site-packages/eon/superbasinscheme.py", line 262, in register_transition
e_global_min = min ( e_min , ( state.get_energy() for state in start_statelist ) )
TypeError: '<' not supported between instances of 'generator' and 'float'
aefabb8 to
bda0f92
Compare
Closes #208. Basically this also technically allows stuff like APE.
cc @iz1ng (might be of interest, server side change).
This isn't currently very efficient since it runs the script twice when it should only run it once (per new set of jobs), but that can be fixed in post.Now the list of atoms is part of the metadata for the state, so it is a bit more efficient, though each client search no longer gets a dynamic update, just the standard displacement one.