-
Notifications
You must be signed in to change notification settings - Fork 197
docs: define CALYPSO model deviation arguments #1960
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -621,16 +621,240 @@ def model_devi_amber_args() -> list[Argument]: | |
| ] | ||
|
|
||
|
|
||
| def _is_scalar_or_singleton(value) -> bool: | ||
| """Accept legacy one-item lists while rejecting ambiguous CALYPSO values.""" | ||
| return not isinstance(value, list) or len(value) == 1 | ||
|
|
||
|
|
||
| def model_devi_calypso_jobs_args() -> Argument: | ||
| """Return native CALYPSO structure-generation settings.""" | ||
| return Argument( | ||
| "model_devi_jobs", | ||
| list, | ||
| repeat=True, | ||
| optional=False, | ||
| doc=( | ||
| "CALYPSO generation settings. Each entry applies to the iterations " | ||
| "listed in times. An empty list is accepted in external-input mode." | ||
| ), | ||
| sub_fields=[ | ||
| Argument( | ||
| "times", | ||
| list[int], | ||
| optional=False, | ||
| doc="Iteration indices that use this generation setup.", | ||
| ), | ||
| Argument( | ||
| "NameOfAtoms", | ||
| list[str], | ||
| optional=False, | ||
| doc="Element symbols for all generated species.", | ||
| ), | ||
| Argument( | ||
| "NumberOfAtoms", | ||
| list[int], | ||
| optional=False, | ||
| doc="Atoms of each species in one formula unit.", | ||
| ), | ||
| Argument( | ||
| "NumberOfFormula", | ||
| list[int], | ||
| optional=True, | ||
| default=[1, 1], | ||
| doc="Inclusive minimum and maximum formula units per cell.", | ||
| ), | ||
| Argument( | ||
| "Volume", | ||
| [None, float, int, list[float], list[int]], | ||
| optional=True, | ||
| extra_check=_is_scalar_or_singleton, | ||
| extra_check_errmsg="Volume must be a scalar or a one-item list.", | ||
| doc="Volume per formula unit in cubic Angstrom.", | ||
| ), | ||
| Argument( | ||
| "DistanceOfIon", | ||
| list[list[float]], | ||
| optional=False, | ||
| doc="Square matrix of minimum inter-species distances in Angstrom.", | ||
| ), | ||
| Argument( | ||
| "PsoRatio", | ||
| [float, int, list[float], list[int]], | ||
| optional=True, | ||
| default=0.6, | ||
| extra_check=_is_scalar_or_singleton, | ||
| extra_check_errmsg="PsoRatio must be a scalar or a one-item list.", | ||
| doc="Fraction of structures generated by particle-swarm optimization.", | ||
| ), | ||
| Argument( | ||
| "PopSize", | ||
| [int, list[int]], | ||
| optional=True, | ||
| default=30, | ||
| extra_check=_is_scalar_or_singleton, | ||
| extra_check_errmsg="PopSize must be an integer or a one-item list.", | ||
| doc="CALYPSO population size.", | ||
| ), | ||
| Argument( | ||
| "MaxStep", | ||
| [int, list[int]], | ||
| optional=True, | ||
| default=5, | ||
| extra_check=_is_scalar_or_singleton, | ||
| extra_check_errmsg="MaxStep must be an integer or a one-item list.", | ||
| doc="Maximum particle-swarm optimization steps.", | ||
| ), | ||
| Argument( | ||
| "ICode", | ||
| [int, list[int]], | ||
| optional=True, | ||
| default=1, | ||
| extra_check=_is_scalar_or_singleton, | ||
| extra_check_errmsg="ICode must be an integer or a one-item list.", | ||
| doc="CALYPSO local-optimization interface code.", | ||
| ), | ||
| Argument( | ||
| "Split", | ||
| str, | ||
| optional=True, | ||
| default="T", | ||
| doc="CALYPSO Split flag, written as 'T' or 'F'.", | ||
| ), | ||
| Argument( | ||
| "VSC", | ||
| str, | ||
| optional=True, | ||
| default="F", | ||
| doc="Variable-stoichiometry flag, written as 'T' or 'F'.", | ||
|
Comment on lines
+717
to
+728
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Restrict CALYPSO flags to Strict validation currently accepts any string for 🤖 Prompt for AI Agents |
||
| ), | ||
| Argument( | ||
| "MaxNumAtom", | ||
| [int, list[int]], | ||
| optional=True, | ||
| extra_check=_is_scalar_or_singleton, | ||
| extra_check_errmsg="MaxNumAtom must be an integer or a one-item list.", | ||
| doc="Maximum atoms per cell when VSC is enabled.", | ||
| ), | ||
| Argument( | ||
| "CtrlRange", | ||
| list[list[int]], | ||
| optional=True, | ||
| doc="Per-species atom-count ranges when VSC is enabled.", | ||
| ), | ||
| Argument( | ||
| "PSTRESS", | ||
| list[float], | ||
| optional=True, | ||
| default=[0.001], | ||
| doc="Target pressures in GPa; one CALYPSO directory is made per value.", | ||
| ), | ||
| Argument( | ||
| "fmax", | ||
| [float, int, list[float], list[int]], | ||
| optional=True, | ||
| default=0.01, | ||
| extra_check=_is_scalar_or_singleton, | ||
| extra_check_errmsg="fmax must be a scalar or a one-item list.", | ||
| doc="Force convergence threshold in eV/Angstrom.", | ||
| ), | ||
| Argument( | ||
| "task_min", | ||
| int, | ||
| optional=True, | ||
| doc="Per-job override of the minimum number of labeling tasks.", | ||
| ), | ||
| Argument( | ||
| "model_devi_f_trust_lo", | ||
| [float, dict], | ||
| optional=True, | ||
| doc="Per-job lower force-deviation threshold.", | ||
| ), | ||
| Argument( | ||
| "model_devi_f_trust_hi", | ||
| [float, dict], | ||
| optional=True, | ||
| doc="Per-job upper force-deviation threshold.", | ||
| ), | ||
| Argument( | ||
| "model_devi_v_trust_lo", | ||
| [float, dict], | ||
| optional=True, | ||
| doc="Per-job lower virial-deviation threshold.", | ||
| ), | ||
| Argument( | ||
| "model_devi_v_trust_hi", | ||
| [float, dict], | ||
| optional=True, | ||
| doc="Per-job upper virial-deviation threshold.", | ||
| ), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| def model_devi_calypso_args() -> list[Argument]: | ||
| """Return model-deviation arguments supported by CALYPSO workflows.""" | ||
| common_names = { | ||
| "model_devi_skip", | ||
| "model_devi_f_trust_lo", | ||
| "model_devi_f_trust_hi", | ||
| "model_devi_v_trust_lo", | ||
| "model_devi_v_trust_hi", | ||
| "model_devi_adapt_trust_lo", | ||
| "model_devi_numb_candi_f", | ||
| "model_devi_numb_candi_v", | ||
| "model_devi_perc_candi_f", | ||
| "model_devi_perc_candi_v", | ||
| "model_devi_clean_traj", | ||
| "shuffle_poscar", | ||
| } | ||
| common_args = [ | ||
| argument for argument in model_devi_lmp_args() if argument.name in common_names | ||
| ] | ||
| return [ | ||
| model_devi_calypso_jobs_args(), | ||
| *common_args, | ||
| Argument( | ||
| "model_devi_dt", | ||
| float, | ||
| optional=True, | ||
| doc="Accepted for compatibility; CALYPSO does not run MD timesteps.", | ||
| ), | ||
| Argument( | ||
| "calypso_input_path", | ||
| str, | ||
| optional=True, | ||
| doc="Directory containing user-provided CALYPSO input.dat files.", | ||
| ), | ||
| Argument( | ||
| "model_devi_max_iter", | ||
| int, | ||
| optional=True, | ||
| doc="Last iteration generated when calypso_input_path is used.", | ||
| ), | ||
| Argument( | ||
| "vsc", | ||
| bool, | ||
| optional=True, | ||
| default=False, | ||
| doc="Use variable-stoichiometry input files in external-input mode.", | ||
| ), | ||
| ] | ||
|
|
||
|
|
||
| def model_devi_args() -> list[Variant]: | ||
| doc_model_devi_engine = "Engine for the model deviation task." | ||
| doc_amber = "Amber DPRc engine. The command argument in the machine file should be path to sander." | ||
| doc_calypso = ( | ||
| "CALYPSO crystal-structure generation and model-deviation workflow. " | ||
| "It supports native per-iteration settings or external input.dat files." | ||
| ) | ||
| return [ | ||
| Variant( | ||
| "model_devi_engine", | ||
| [ | ||
| Argument("lammps", dict, model_devi_lmp_args(), doc="LAMMPS"), | ||
| Argument("amber", dict, model_devi_amber_args(), doc=doc_amber), | ||
| Argument("calypso", dict, [], doc="TODO: add doc"), | ||
| Argument("calypso", dict, model_devi_calypso_args(), doc=doc_calypso), | ||
| Argument("gromacs", dict, [], doc="TODO: add doc"), | ||
| ], | ||
| default_tag="lammps", | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Require an external input directory when
model_devi_jobsis empty.The schema accepts an empty
model_devi_jobslist withoutcalypso_input_path. This passes strict validation despite having neither native job settings nor external input. Enforce the native/external mode relationship and add a rejection test.Also applies to: 823-826
🤖 Prompt for AI Agents