Loading...
Searching...
No Matches
gpr::cli Namespace Reference

Functions

std::string modelPath (const std::string &value)
std::string modelPath (const char *value)
template<class Args, class Store>
void addPotentialOptions (Argum::Parser &parser, Args &args, Store store)
template<class Args>
pot::RgpotRequest potentialRequest (const Args &args)

Function Documentation

◆ addPotentialOptions()

template<class Args, class Store>
void gpr::cli::addPotentialOptions ( Argum::Parser & parser,
Args & args,
Store store )

Register the shared oracle interface with the same parser as the driver. store owns text for drivers whose geometry arguments use C strings.

Definition at line 30 of file PotentialOptions.h.

31{
32 using Argum::Option;
33 auto text = [&](const char* flag, const char* help, std::string& target,
34 const char* parameter = "") {
35 parser.add(Option(flag).argName("VALUE").help(help).handler(
36 [&args, &target, parameter](std::string_view value) {
37 target = value;
38 if (*parameter) args.potential_overrides.insert(parameter);
39 }));
40 };
41 auto integer = [&](const char* flag, const char* help, int& target,
42 const char* parameter = "") {
43 parser.add(Option(flag).argName("N").help(help).handler(
44 [&args, &target, parameter](std::string_view value) {
45 target = Argum::parseIntegral<int>(value);
46 if (*parameter) args.potential_overrides.insert(parameter);
47 }));
48 };
49 parser.add(
50 Option("--potential")
51 .argName("NAME")
52 .help("rgpot backend; --list-potentials shows compiled support")
53 .handler([&args](std::string_view value) {
54 args.potential = value;
55 args.potential_set = true;
56 }));
57 parser.add(Option("--list-potentials")
58 .help("list rgpot backends and build requirements")
59 .handler([] {
60 std::cout << pot::formatPotentialCatalog();
61 std::exit(0);
62 }));
63 parser.add(
64 Option("--potential-config")
65 .argName("FILE")
66 .help("rgpot PotentialConfig as an unpacked Cap'n Proto message")
67 .handler([&args](std::string_view value) {
68 args.potential_config = value;
69 args.potential_set = true;
70 }));
71 parser.add(Option("--model")
72 .argName("PATH")
73 .help("metatomic .pt or UMA .pt2 model")
74 .handler([&args, store](std::string_view value) {
75 if constexpr (std::is_same_v<decltype(args.model_path),
76 std::string>)
77 args.model_path = value;
78 else
79 args.model_path = store(value);
80 args.potential_overrides.insert("model_path");
81 }));
82 text("--device", "model device: cpu or cuda", args.device, "device");
83 text("--task-name", "UMA task head (default omol)", args.task_name,
84 "task_name");
85 integer("--uma-charge", "UMA total charge", args.uma_charge, "charge");
86 integer("--uma-spin", "UMA spin multiplicity", args.uma_spin, "spin");
87 integer("--mopac-charge", "OpenMOPAC total charge", args.mopac_charge,
88 "charge");
89 integer("--mopac-spin", "OpenMOPAC spin excitations, not multiplicity",
90 args.mopac_spin, "spin");
91 integer("--mopac-model", "OpenMOPAC model (4 = AM1)", args.mopac_model,
92 "model");
93 text("--potential-library", "explicit engine library path",
94 args.potential_library);
95 text("--potential-params",
96 "engine parameters message passed unread to the engine library; "
97 "loads any engine plugin without a table entry",
98 args.potential_params);
99 text("--engine-dir", "directory containing engine libraries",
100 args.engine_dir);
101 text("--lammps-params", "LAMMPS pair style, coefficients and atom types",
102 args.lammps_params);
103 integer("--cpmd-scf-max-iter", "maximum CPMD SCF steps per evaluation",
104 args.cpmd_scf_max_iter);
105 parser.add(
106 Option("--cpmd-scf-convergence")
107 .argName("TOL")
108 .help("CPMD orbital convergence threshold")
109 .handler([&args](std::string_view value) {
110 args.cpmd_scf_convergence =
111 Argum::parseFloatingPoint<double>(value);
112 if (!(args.cpmd_scf_convergence > 0) ||
113 !std::isfinite(args.cpmd_scf_convergence))
114 throw std::invalid_argument(
115 "--cpmd-scf-convergence must be finite and positive");
116 }));
117 integer("--cp2k-max-scf", "maximum CP2K inner SCF steps per OT cycle",
118 args.cp2k_max_scf);
119 parser.add(Option("--cp2k-eps-scf")
120 .argName("TOL")
121 .help("CP2K EPS_SCF convergence threshold")
122 .handler([&args](std::string_view value) {
123 args.cp2k_eps_scf =
124 Argum::parseFloatingPoint<double>(value);
125 if (!(args.cp2k_eps_scf > 0) ||
126 !std::isfinite(args.cp2k_eps_scf))
127 throw std::invalid_argument(
128 "--cp2k-eps-scf must be finite and positive");
129 }));
130 parser.add(Option("--oracle-path")
131 .argName("engine|direct")
132 .help("engine plugin or compiled rgpot backend; default "
133 "selects the available route")
134 .handler([&args](std::string_view value) {
135 if (value != "engine" && value != "direct")
136 throw std::invalid_argument(
137 "--oracle-path must be engine or direct");
138 args.oracle_path = value;
139 }));
140}
std::string formatPotentialCatalog()

◆ modelPath() [1/2]

std::string gpr::cli::modelPath ( const char * value)
inline

Definition at line 22 of file PotentialOptions.h.

23{
24 return value ? value : "";
25}

◆ modelPath() [2/2]

std::string gpr::cli::modelPath ( const std::string & value)
inline

Definition at line 18 of file PotentialOptions.h.

19{
20 return value;
21}

◆ potentialRequest()

template<class Args>
pot::RgpotRequest gpr::cli::potentialRequest ( const Args & args)

Definition at line 143 of file PotentialOptions.h.

144{
145 pot::RgpotRequest request;
146 request.potential = args.potential;
147 request.config = args.potential_config.empty()
148 ? args.potential_parameters
149 : pot::readPotentialConfig(args.potential_config);
150 request.overrides = args.potential_overrides;
151 request.model_path = modelPath(args.model_path);
152 request.device = args.device;
153 request.task_name = args.task_name;
154 request.charge = args.uma_charge;
155 request.spin = args.uma_spin;
156 request.mopac_charge = args.mopac_charge;
157 request.mopac_spin = args.mopac_spin;
158 request.mopac_model = args.mopac_model;
159 request.basis = args.nwchem_basis;
160 request.xc = args.nwchem_dft_xc;
161 request.molecular_charge = args.nwchem_charge;
162 request.multiplicity = args.nwchem_multiplicity;
163 request.thread_count = args.linalg_threads;
164 pot::applyRgpotConfig(request);
165 return request;
166}
std::string modelPath(const std::string &value)
std::vector< unsigned char > readPotentialConfig(const std::string &path)
void applyRgpotConfig(RgpotRequest &request)
Resolve shared model settings from the typed configuration for reporting.
Backend inputs shared by the path and single-ended drivers.
std::string basis
std::set< std::string > overrides
Constructor fields explicitly supplied on the command line.
std::string task_name
std::string model_path
std::string potential
std::vector< unsigned char > config
std::string device