Skip to content

Commit 7c6a2aa

Browse files
committed
docs: define CALYPSO model deviation arguments
Coding-Agent: Codex Codex-Version: codex-cli 0.149.0 Model: gpt-5.6-sol Reasoning-Effort: xhigh
1 parent d5ce577 commit 7c6a2aa

2 files changed

Lines changed: 273 additions & 1 deletion

File tree

dpgen/generator/arginfo.py

Lines changed: 206 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,221 @@ def model_devi_amber_args() -> list[Argument]:
621621
]
622622

623623

624+
def model_devi_calypso_jobs_args() -> Argument:
625+
"""Return native CALYPSO structure-generation settings."""
626+
return Argument(
627+
"model_devi_jobs",
628+
list,
629+
repeat=True,
630+
optional=False,
631+
doc=(
632+
"CALYPSO generation settings. Each entry applies to the iterations "
633+
"listed in times. An empty list is accepted in external-input mode."
634+
),
635+
sub_fields=[
636+
Argument(
637+
"times",
638+
list[int],
639+
optional=False,
640+
doc="Iteration indices that use this generation setup.",
641+
),
642+
Argument(
643+
"NameOfAtoms",
644+
list[str],
645+
optional=False,
646+
doc="Element symbols for all generated species.",
647+
),
648+
Argument(
649+
"NumberOfAtoms",
650+
list[int],
651+
optional=False,
652+
doc="Atoms of each species in one formula unit.",
653+
),
654+
Argument(
655+
"NumberOfFormula",
656+
list[int],
657+
optional=True,
658+
default=[1, 1],
659+
doc="Inclusive minimum and maximum formula units per cell.",
660+
),
661+
Argument(
662+
"Volume",
663+
[None, float, int],
664+
optional=True,
665+
doc="Volume per formula unit in cubic Angstrom.",
666+
),
667+
Argument(
668+
"DistanceOfIon",
669+
list[list[float]],
670+
optional=False,
671+
doc="Square matrix of minimum inter-species distances in Angstrom.",
672+
),
673+
Argument(
674+
"PsoRatio",
675+
float,
676+
optional=True,
677+
default=0.6,
678+
doc="Fraction of structures generated by particle-swarm optimization.",
679+
),
680+
Argument(
681+
"PopSize",
682+
int,
683+
optional=True,
684+
default=30,
685+
doc="CALYPSO population size.",
686+
),
687+
Argument(
688+
"MaxStep",
689+
int,
690+
optional=True,
691+
default=5,
692+
doc="Maximum particle-swarm optimization steps.",
693+
),
694+
Argument(
695+
"ICode",
696+
int,
697+
optional=True,
698+
default=1,
699+
doc="CALYPSO local-optimization interface code.",
700+
),
701+
Argument(
702+
"Split",
703+
str,
704+
optional=True,
705+
default="T",
706+
doc="CALYPSO Split flag, written as 'T' or 'F'.",
707+
),
708+
Argument(
709+
"VSC",
710+
str,
711+
optional=True,
712+
default="F",
713+
doc="Variable-stoichiometry flag, written as 'T' or 'F'.",
714+
),
715+
Argument(
716+
"MaxNumAtom",
717+
int,
718+
optional=True,
719+
doc="Maximum atoms per cell when VSC is enabled.",
720+
),
721+
Argument(
722+
"CtrlRange",
723+
list[list[int]],
724+
optional=True,
725+
doc="Per-species atom-count ranges when VSC is enabled.",
726+
),
727+
Argument(
728+
"PSTRESS",
729+
list[float],
730+
optional=True,
731+
default=[0.001],
732+
doc="Target pressures in GPa; one CALYPSO directory is made per value.",
733+
),
734+
Argument(
735+
"fmax",
736+
float,
737+
optional=True,
738+
default=0.01,
739+
doc="Force convergence threshold in eV/Angstrom.",
740+
),
741+
Argument(
742+
"task_min",
743+
int,
744+
optional=True,
745+
doc="Per-job override of the minimum number of labeling tasks.",
746+
),
747+
Argument(
748+
"model_devi_f_trust_lo",
749+
[float, dict],
750+
optional=True,
751+
doc="Per-job lower force-deviation threshold.",
752+
),
753+
Argument(
754+
"model_devi_f_trust_hi",
755+
[float, dict],
756+
optional=True,
757+
doc="Per-job upper force-deviation threshold.",
758+
),
759+
Argument(
760+
"model_devi_v_trust_lo",
761+
[float, dict],
762+
optional=True,
763+
doc="Per-job lower virial-deviation threshold.",
764+
),
765+
Argument(
766+
"model_devi_v_trust_hi",
767+
[float, dict],
768+
optional=True,
769+
doc="Per-job upper virial-deviation threshold.",
770+
),
771+
],
772+
)
773+
774+
775+
def model_devi_calypso_args() -> list[Argument]:
776+
"""Return model-deviation arguments supported by CALYPSO workflows."""
777+
common_names = {
778+
"model_devi_skip",
779+
"model_devi_f_trust_lo",
780+
"model_devi_f_trust_hi",
781+
"model_devi_v_trust_lo",
782+
"model_devi_v_trust_hi",
783+
"model_devi_adapt_trust_lo",
784+
"model_devi_numb_candi_f",
785+
"model_devi_numb_candi_v",
786+
"model_devi_perc_candi_f",
787+
"model_devi_perc_candi_v",
788+
"model_devi_clean_traj",
789+
"shuffle_poscar",
790+
}
791+
common_args = [
792+
argument for argument in model_devi_lmp_args() if argument.name in common_names
793+
]
794+
return [
795+
model_devi_calypso_jobs_args(),
796+
*common_args,
797+
Argument(
798+
"model_devi_dt",
799+
float,
800+
optional=True,
801+
doc="Accepted for compatibility; CALYPSO does not run MD timesteps.",
802+
),
803+
Argument(
804+
"calypso_input_path",
805+
str,
806+
optional=True,
807+
doc="Directory containing user-provided CALYPSO input.dat files.",
808+
),
809+
Argument(
810+
"model_devi_max_iter",
811+
int,
812+
optional=True,
813+
doc="Last iteration generated when calypso_input_path is used.",
814+
),
815+
Argument(
816+
"vsc",
817+
bool,
818+
optional=True,
819+
default=False,
820+
doc="Use variable-stoichiometry input files in external-input mode.",
821+
),
822+
]
823+
824+
624825
def model_devi_args() -> list[Variant]:
625826
doc_model_devi_engine = "Engine for the model deviation task."
626827
doc_amber = "Amber DPRc engine. The command argument in the machine file should be path to sander."
828+
doc_calypso = (
829+
"CALYPSO crystal-structure generation and model-deviation workflow. "
830+
"It supports native per-iteration settings or external input.dat files."
831+
)
627832
return [
628833
Variant(
629834
"model_devi_engine",
630835
[
631836
Argument("lammps", dict, model_devi_lmp_args(), doc="LAMMPS"),
632837
Argument("amber", dict, model_devi_amber_args(), doc=doc_amber),
633-
Argument("calypso", dict, [], doc="TODO: add doc"),
838+
Argument("calypso", dict, model_devi_calypso_args(), doc=doc_calypso),
634839
Argument("gromacs", dict, [], doc="TODO: add doc"),
635840
],
636841
default_tag="lammps",

tests/test_calypso_arginfo.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""Validate CALYPSO model-deviation parameter documentation."""
2+
3+
import unittest
4+
5+
from dargs import Argument
6+
7+
from dpgen.generator.arginfo import model_devi_args
8+
9+
10+
class TestCalypsoArginfo(unittest.TestCase):
11+
def setUp(self):
12+
self.arginfo = Argument("model_devi", dict, sub_variants=model_devi_args())
13+
self.selection = {
14+
"model_devi_skip": 0,
15+
"model_devi_f_trust_lo": 0.05,
16+
"model_devi_f_trust_hi": 0.15,
17+
"model_devi_clean_traj": True,
18+
}
19+
20+
def test_native_mode(self):
21+
data = {
22+
"model_devi_engine": "calypso",
23+
**self.selection,
24+
"model_devi_dt": 0.002,
25+
"shuffle_poscar": False,
26+
"model_devi_jobs": [
27+
{
28+
"times": [0, 1],
29+
"NameOfAtoms": ["Mg", "Al"],
30+
"NumberOfAtoms": [1, 1],
31+
"NumberOfFormula": [1, 2],
32+
"Volume": 30.0,
33+
"DistanceOfIon": [[1.4, 1.5], [1.5, 1.4]],
34+
"PsoRatio": 0.6,
35+
"PopSize": 30,
36+
"MaxStep": 5,
37+
"ICode": 1,
38+
"Split": "T",
39+
"VSC": "T",
40+
"MaxNumAtom": 20,
41+
"CtrlRange": [[1, 10], [1, 10]],
42+
"PSTRESS": [0.0, 100.0],
43+
"fmax": 0.01,
44+
"task_min": 1,
45+
}
46+
],
47+
}
48+
49+
normalized = self.arginfo.normalize_value(data)
50+
self.arginfo.check_value(normalized, strict=True)
51+
52+
def test_external_input_mode(self):
53+
data = {
54+
"model_devi_engine": "calypso",
55+
**self.selection,
56+
"model_devi_jobs": [],
57+
"calypso_input_path": "calypso_input",
58+
"model_devi_max_iter": 20,
59+
"vsc": True,
60+
}
61+
62+
normalized = self.arginfo.normalize_value(data)
63+
self.arginfo.check_value(normalized, strict=True)
64+
65+
66+
if __name__ == "__main__":
67+
unittest.main()

0 commit comments

Comments
 (0)