Loading...
Searching...
No Matches
Parameters.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include "BaseStructures.h"
15#include <cstdio>
16#include <limits>
17#include <string>
18#include <vector>
19
20#ifdef EONMPI
21#include "mpi.h"
22#endif
23
26namespace eonc {
27
29
30public:
31 Parameters();
32 ~Parameters() = default;
33 Parameters(const Parameters &) = default;
34 int load(std::string filename);
35 int load(FILE *file);
36 int load_json(const std::string &json_str);
37 std::string to_json() const;
38
39 // Physical Constants
40 struct constants_t {
41 double kB{8.6173324e-5}; // eV/K
42 double timeUnit{10.1805055}; // fs
44
45 // [Main] //
48 long randomSeed{-1};
49 double temperature{300.0};
50 bool quiet{false};
51 bool writeLog{true};
52 bool checkpoint{false};
53 std::string iniFilename{"config.ini"};
54 std::string conFilename{"pos.con"};
55 double finiteDifference{0.01};
57 bool removeNetForce{true};
58 bool parallel{true}; // parallel force evaluation via std::jthread
62 bool writeConForces{false};
64
65 // [Potential] //
68 double MPIPollPeriod{0.25};
69 bool LAMMPSLogging{false};
71 bool EMTRasmussen{false};
72 bool LogPotential{false};
73 std::string extPotPath{"./ext_pot"};
74 std::string potentialsPath{
75 ""}; // colon-separated dirs for Fortran potential .so files
77#ifdef EONMPI
78 MPI_Comm MPIClientComm;
79#endif
81
82 // [AMS] and [AMS_IO] //
84 std::string engine;
85 std::string forcefield;
86 std::string model;
87 std::string resources;
88 std::string xc;
89 std::string basis;
90 struct env_t {
91 std::string amshome;
92 std::string scm_tmpdir;
93 std::string scmlicense;
94 std::string scm_pythondir;
95 std::string amsbin;
96 std::string amsresources;
97 } env;
99
100 // [XTBPot] //
102 std::string paramset{"GFNFF"};
103 double elec_temperature{0.0};
104 size_t maxiter{250};
105 double acc{1.0};
106 double charge{0.0};
107 int uhf{0};
109
110 // [ZBLPot] //
112 double cut_inner{2.0};
113 double cut_global{2.5};
115
116 // [SocketNWChemPot] //
118 std::string host{"127.0.0.1"};
119 int port{9999};
120 int mem_in_gb{2};
121 std::string nwchem_settings{"nwchem_settings.nwi"};
122 std::string unix_socket_path{"eon_nwchem"};
123 bool unix_socket_mode{false};
126
127 // [RgpotPot] — in-process rgpot (dlopen engines; no potserv). Packaging
128 // prefers metatomic/xtb via RGPOT over fat -Dwith_metatomic / -Dwith_xtb.
131 std::string backend{"nwchemc"};
132 std::string basis{"sto-3g"};
133 std::string theory{"scf"};
134 std::string scf_type{"rhf"};
135 std::string functional{"BLYP"};
136 double cutoff_ry{70.0};
137 int charge{0};
139 std::string engine_path{};
140 std::string engine_library{};
141 std::string engine_root{};
142 std::string title{};
143 int memory_mb{0};
144 std::string scratch_dir{};
145 std::string input_block{};
146 // Metatomic dlopen (backend=metatomic)
147 std::string model_path{};
148 std::string device{"cpu"};
149 std::string length_unit{"angstrom"};
150 std::string extensions_directory{};
151 bool check_consistency{false};
154 // XTB dlopen (backend=xtb); dual-read [XTBPot] when unset
155 std::string xtb_paramset{"GFN2xTB"};
156 double xtb_accuracy{1.0};
159 double xtb_charge{0.0};
160 int xtb_uhf{0};
162
163 // [Structure Comparison] //
172
173 // [Process Search] //
175 bool minimize_first{true};
176 double minimization_offset{0.2}; // resolved to optimizer_options.max_move
178
179 // [Saddle Search] //
182 long max_iterations{1000};
183 std::string method{"min_mode"};
184 std::string minmode_method{"dimer"};
185 std::string displace_type{"load"};
186 std::vector<long> displace_atom_list;
187 double max_energy{20.0};
190 double displace_radius{4.0};
191 double converged_force{0.0};
192 double perp_force_ratio{0.0};
196 bool remove_rotation{false};
198 struct dynamics_t {
199 double temperature{0.0};
201 double state_check_interval{0.0}; // computed: input / timeUnit
203 double record_interval{0.0}; // computed
208 bool enabled{false};
209 bool bowl_breakout{false};
210 long bowl_active{20};
211 double min_force{0.5};
212 double scale_ratio{0.9};
213 double boost{10.0};
214 long min_active{30};
217
218 // [Optimizer] //
221 std::string convergence_metric{"norm"};
223 size_t max_iterations{1000};
224 double max_move{0.2};
225 double converged_force{0.01};
226 double time_step_input{1.0};
227 double time_step{0.0}; // computed: input / timeUnit
229 double max_time_step{0.0}; // computed: input / timeUnit
234 struct lbfgs_t {
235 long memory{20};
236 double inverse_curvature{0.01};
238 bool auto_scale{true};
239 bool angle_reset{true};
240 bool distance_reset{true};
242 struct cg_t {
243 bool no_overshooting{false};
245 bool line_search{false};
246 double line_converged{0.1};
249 } cg;
253 struct sd_t {
254 double alpha{0.1};
255 bool two_point{false};
256 } sd;
258
259 // [Dimer] //
261 double rotation_angle{0.005};
262 bool improved{true};
263 double converged_angle{5.0};
264 long max_iterations{1000};
265 std::string opt_method{"cg"};
268 double torque_max{1.0};
269 double torque_min{0.1};
270 bool remove_rotation{false};
271 // Mode estimation for dimer: classical rotation loop, or FD min-mode
272 // (Lanczos/Davidson) replacing constrained IDimerRot / Dimer::rotate.
274 // LOR relative residual stop: ||F_perp|| / (|C_N|+1) < max(1e-3, this).
275 // Independent of classical torque_min (angular criterion).
276 double lor_residual_tol{0.1};
278
279 // [GPR Dimer] //
281 double rotation_angle{0.005};
282 double converged_angle{0.08};
283 double relax_conv_angle{0.001};
289 double midpoint_max_disp{0.5};
290 std::string rot_opt_method{"lbfgs"};
291 std::string trans_opt_method{"lbfgs"};
292 double active_radius{5.0};
293 double dimer_sep{0.01};
294 double conv_step{0.1};
295 double max_step{0.1};
296 double ratio_at_limit{0.66667};
297 bool init_rot_gp{false};
298 bool init_trans_gp{false};
299 bool many_iterations{true};
301 std::string hyper_opt_method{"scg"};
302 double sigma2{1e-8};
303 double jitter_sigma2{0.0};
304 double noise_sigma2{1e-8};
305 double prior_mu{0.0};
306 double prior_sigma2{1.0};
307 long prior_nu{20};
310 bool check_derivatives{false};
312 double tol_func{1e-4};
313 double tol_sol{1e-4};
314 long lambda_limit{static_cast<long>(1e17)};
315 long lambda_init{10};
318 bool use_prune{false};
319 int begin{8};
320 int n_vals{3};
321 double threshold{0.5};
326 std::string out_dir{"output"};
327 std::string pos_file{"position"};
328 std::string energy_file{"energy"};
329 std::string grad_file{"gradient"};
330 std::string out_ext{"dat"};
331 double offset_mid_point{3.0};
332 double dy{0.1};
333 double dz{0.1};
336
337 // [GP Surrogate] //
345
346 // [CatLearn] //
348 std::string path;
349 std::string model{"gp"};
350 std::string prior{"median"};
351 bool use_deriv{true};
352 bool use_fingerprint{false};
353 bool parallel{false};
355
356 // [ASE_ORCA] //
358 std::string path;
359 std::string nproc{"1"};
360 std::string simpleinput;
362
363 // [ASE_NWCHEM] //
365 std::string path;
366 std::string nproc{"1"};
367 // MPI launcher for ASE NWChem command (issue #193): "mpirun" or "srun".
368 std::string mpi_launcher{"mpirun"};
369 std::string multiplicity;
370 double scf_thresh{1e-5};
371 long scf_maxiter{200};
373
374 // [Metatomic] //
376 std::string model_path;
377 std::string device{"cpu"};
378 std::string length_unit{"angstrom"};
380 bool check_consistency{false};
382 // Literal model output keys (issue #215). When set, bypass pick_output
383 // variant resolution and use this key if present in model capabilities.
384 std::string energy_output;
386 // Literal non-conservative force output key (issue #296); empty uses
387 // pick_output("non_conservative_force", ...) when non_conservative.
388 std::string force_output;
389 // When true, read forces from non_conservative_force (with variants)
390 // instead of autograd on energy (issue #296).
391 bool non_conservative{false};
392 // Apply a fresh random SO(3) rotation per force() call and rotate forces
393 // back (issue #287 / PET-MAD broken-symmetry mitigation).
394 bool random_rotation{false};
395 // If >0, average energy/forces over this many random rotations for
396 // approximate O(3) symmetrization (issue #292). Overrides single-shot
397 // random_rotation when both are set.
399 // PyTorch determinism (JIT profiling off, deterministic algorithms,
400 // cudnn benchmark off). See
401 // rgoswami.me/snippets/pytorch-deterministic-regression/
402 bool deterministic{true};
403 // If true, fail on nondeterministic CUDA ops (needs
404 // CUBLAS_WORKSPACE_CONFIG).
406 struct variants_t {
407 std::string base;
408 std::string energy;
410 std::string force; // non_conservative_force variant (#296)
413
414 // [Lanczos] //
415 // phva_atoms: PHVA mobile/active set for the Krylov space (Li & Jensen).
416 // Not free/fixed — that is the optimizer mask on Matter. "All" = every free
417 // atom (historical default). Same polarity as [Hessian] phva_atoms.
419 double tolerance{0.01};
421 bool quit_early{true};
422 std::string phva_atoms{"All"};
424
425 // [Davidson] min-mode (alternative to dimer rotation / Lanczos)
427 double tolerance{0.01};
433 std::string phva_atoms{"All"};
435
436 // [Prefactor] //
438 double default_value{0.0};
439 double max_value{1e+21};
440 double min_value{1e+9};
441 double within_radius{3.3};
442 double min_displacement{0.25};
443 std::string rate{"htst"};
444 std::string configuration{"reactant"};
445 bool all_free_atoms{false};
446 std::string filter_scheme{"fraction"};
447 double filter_fraction{0.90};
449
450 // [Hessian] //
451 // phva_atoms: mobile/displaced atoms for FD (hybrid/PHVA-class active set),
452 // or "All" = every non-fixed atom. Intersected with free flags in HessianJob.
453 // free/fixed stays the optimizer mask and is not rewritten.
455 std::string phva_atoms{"All"};
456 double zero_freq_value{1e-6};
457 // FD scheme: "one_sided" (default, ~3M force evals) or "central" (~6M).
458 // Step size is Main.finite_difference (dx).
459 std::string fd_scheme{"one_sided"};
460 // If true and checkpoint_path is set, resume FD columns from checkpoint.
461 bool resume{false};
462 // Column checkpoint file (e.g. hessian.ckpt). Cleared on successful finish.
463 std::string checkpoint_path{""};
465
466 // [Nudged Elastic Band] //
468 long image_count{5};
469 long max_iterations{1000};
472 0.01}; // resolved to optimizer_options.converged_force
474 bool enabled{true};
475 double tolerance{0.05};
477
479 double constant{5.0};
480 bool use_elastic_band{false};
481 bool doubly_nudged{false};
482 bool use_switching{false};
483
485 bool enabled{false};
486 double trigger{10.0};
487 double k_min{0.97};
488 double k_max{9.7};
491 bool enabled{false};
492 bool optimize_k{true};
493 double k_scale{1.0};
494 double k_min{0.1};
495 double k_max{100.0};
496 } om;
498
500 bool enabled{true};
501 bool converged_only{true};
502 bool use_old_tangent{false};
503 double trigger_force{std::numeric_limits<double>::infinity()};
504 double trigger_factor{0.0};
505
507 bool use_mmf{false};
508 double trigger_force{0.1};
509 long max_steps{1000};
511 double angle_tol{0.7071}; // 1/sqrt(2): Householder stability bound
512 double trigger_factor{0.0};
515
531
536
538
539 // [Molecular Dynamics] //
541 double time_step_input{1.0};
542 double time_step{0.0}; // computed: input / timeUnit
543 double time_input{1000.0};
544 double time{0.0}; // computed: input / timeUnit
545 long steps{0}; // computed: time / time_step
547
548 // [Parallel Replica] //
551 bool auto_stop{false};
552 bool dephase_loop_stop{false};
553 double dephase_time_input{1000.0};
554 double dephase_time{0.0}; // computed: input / timeUnit
557 double state_check_interval{0.0}; // computed
559 double record_interval{0.0}; // computed
560 double corr_time_input{1000.0};
561 double corr_time{0.0}; // computed
563
564 // [Temperature Accelerated Dynamics] //
566 double low_temperature{300.0};
567 double min_prefactor{0.001};
568 double confidence{0.001};
570
571 // [Thermostat] //
573 std::string kind{"none"};
574 double andersen_alpha{1.0};
575 double andersen_tcol_input{100.0};
576 double andersen_tcol{0.0}; // computed
577 double nose_mass{1.0};
579 double langevin_friction{0.0}; // computed: input * timeUnit
581
582 // [Replica Exchange] //
584 std::string temperature_distribution{"exponential"};
585 long replicas{10};
586 long exchange_trials{10}; // resolved to replicas
587 double sampling_time_input{1000.0};
588 double sampling_time{0.0}; // computed
589 double temperature_high{0.0};
590 double temperature_low{0.0};
592 double exchange_period{0.0}; // computed
594
595 // [Bond Boost / Hyperdynamics] //
597 std::string bias_potential{"none"};
598 std::string boost_atom_list{"All"};
599 double rmd_time_input{100.0};
600 double rmd_time{0.0}; // computed
601 double dvmax{0.0};
602 double qrr{0.2};
603 double prr{0.95};
604 double qcut{3.0};
606
607 // [Basin Hopping] //
609 double displacement{0.5};
612 long steps{10000};
616 std::string displacement_algorithm{"standard"};
617 std::string displacement_distribution{"uniform"};
618 double swap_probability{0.0};
619 long jump_max{10};
620 long jump_steps{0};
623 double adjust_fraction{0.05};
624 double target_ratio{0.5};
625 bool write_unique{false};
626 double stop_energy{-std::numeric_limits<double>::max()};
628
629 // [Global Optimization] //
631 std::string move_method{"md"};
632 std::string decision_method{"npew"};
633 long steps{10000};
634 double beta{1.05};
635 double alpha{1.02};
636 long mdmin{3};
637 double target_energy{-1.0e50};
639
640 // [Monte Carlo] //
645
646 // [BGSD] //
648 double alpha{10.0};
649 double beta{0.2};
652 double grad2energy_convergence{0.000001};
655
656 // [Serve] //
658 std::string host{"localhost"};
659 uint16_t port{12345};
660 size_t replicas{1};
661 uint16_t gateway_port{0};
662 std::string endpoints;
664
665 // [ARTn] //
667 double push_step_size{0.3}; // maps to pARTn "push_step_size"
668 double force_threshold{0.05}; // maps to pARTn "forc_thr"
670 int ninit{-1}; // maps to pARTn "ninit" (-1 = use pARTn default): number
671 // of initial push steps before Lanczos eigenmode
672 // estimation. 0 skips the push (eOn supplies the mode);
673 // larger values let pARTn explore further from the
674 // minimum before switching to Lanczos.
675 std::string nperp_limitation{"default"}; // maps to pARTn "nperp_limitation"
677 -1}; // maps to pARTn "lanczos_min_size" (-1 = use default)
678 int nsmooth{-1}; // maps to pARTn "nsmooth" (-1 = use default)
680 3}; // maps to pARTn "nnewchance": retries when lowest eigval > 0
681 // (convex region). pARTn default is 0 (immediate fail), which
682 // is too aggressive for small clusters where Lanczos can
683 // momentarily settle on a positive eigenvalue before the
684 // unstable mode emerges. 3 retries is a reasonable default.
685 std::string filin{""}; // maps to pARTn "filin": path to an artn.in input
686 // file. Empty preserves pARTn's post-create default
687 // (NAN_STR sentinel "BBBB" set by artn_create in
688 // artn_api.f90), which tells m_setup_artn to skip
689 // reading any file. If set, pARTn opens the file
690 // with status="old" and errors out when absent.
692
693 // [IRA] //
699
700 // [Debug] //
708
709 // [OH_TST] //
710 // Optimized hyperplanar TST (Johannesson-Jonsson, JCP 115, 9644
711 // (2001)): reversible-work progression of a hyperplanar dividing
712 // surface with constrained thermostatted sampling.
714 std::string reactant_filename{"pos.con"};
715 std::string product_filename{"product.con"};
716 double time_step{1.0}; // fs, constrained sampling dynamics
717 long equil_steps{200}; // per-plane equilibration steps
718 long sample_steps{800}; // per-plane averaging steps
719 long max_planes{200}; // plane-progression iterations
720 double plane_mass{50.0}; // m_s, inertia of the s coordinate
721 double alpha_rot{50.0}; // rotational inertia of the normal
722 double plane_time_step{0.1}; // Verlet step for (s, n) updates
723 double ds_max{0.1}; // A, clamp on per-iteration plane moves
724 double dtheta_max{0.05}; // rad, clamp on per-iteration rotations
725 double force_tol{0.005}; // eV/A convergence on plane force
726 double s_init{0.05}; // starting fraction along the guideline
727 long reactant_md_steps{20000}; // unconstrained reactant trajectory
728 double max_delta_a{10.0}; // eV, divergence guard on the work
729 // Thermostat for the plane-constrained and reactant sampling:
730 // "andersen" (default) or "gle" (colored noise, Ceriotti-Bussi-
731 // Parrinello; drift matrix from gle_a_file, gle4md text layout,
732 // units of inverse internal time; a 1x1 [gamma] file degenerates
733 // to white-noise Langevin).
734 std::string thermostat{"andersen"};
735 std::string gle_a_file{""};
736 // Comma-separated .con files of the OTHER symmetry-equivalent
737 // product minima (Eqs 13-17): sampling is confined to the
738 // subregion of the primary product by half-line distances with
739 // mirror velocity reflection at the boundaries.
740 std::string symmetry_products{""};
741 // PMF-scan mode: hold the dividing plane normal fixed along the
742 // guideline and step s uniformly reactant->product instead of
743 // adaptively hunting the free-energy maximum. Robust where the
744 // adaptive progression pins at s=0 (a shallow doorway or a
745 // barrierless capture funnel whose A(s) has no interior maximum).
746 bool pmf_scan{false};
747 long scan_planes{40}; // uniform planes across the guideline
749
750};
751
752} // namespace eonc
753
754using eonc::Parameters;
struct eonc::Parameters::basin_hopping_options_t basin_hopping_options
struct eonc::Parameters::socket_nwchem_options_t socket_nwchem_options
struct eonc::Parameters::monte_carlo_options_t monte_carlo_options
struct eonc::Parameters::catlearn_options_t catlearn_options
struct eonc::Parameters::optimizer_options_t optimizer_options
struct eonc::Parameters::constants_t constants
struct eonc::Parameters::gp_surrogate_options_t gp_surrogate_options
int load_json(const std::string &json_str)
struct eonc::Parameters::global_optimization_options_t global_optimization_options
struct eonc::Parameters::neb_options_t neb_options
struct eonc::Parameters::hyperdynamics_options_t hyperdynamics_options
struct eonc::Parameters::ira_options_t ira_options
struct eonc::Parameters::gpr_dimer_options_t gpr_dimer_options
struct eonc::Parameters::tad_options_t tad_options
struct eonc::Parameters::ase_nwchem_options_t ase_nwchem_options
int load(std::string filename)
struct eonc::Parameters::thermostat_options_t thermostat_options
struct eonc::Parameters::structure_comparison_options_t structure_comparison_options
struct eonc::Parameters::dimer_options_t dimer_options
struct eonc::Parameters::ase_orca_options_t ase_orca_options
std::string to_json() const
struct eonc::Parameters::potential_options_t potential_options
Parameters(const Parameters &)=default
struct eonc::Parameters::replica_exchange_options_t replica_exchange_options
struct eonc::Parameters::debug_options_t debug_options
struct eonc::Parameters::oh_tst_options_t oh_tst_options
struct eonc::Parameters::xtb_options_t xtb_options
struct eonc::Parameters::artn_options_t artn_options
struct eonc::Parameters::ams_options_t ams_options
struct eonc::Parameters::rgpot_options_t rgpot_options
struct eonc::Parameters::zbl_options_t zbl_options
struct eonc::Parameters::saddle_search_options_t saddle_search_options
struct eonc::Parameters::davidson_options_t davidson_options
struct eonc::Parameters::metatomic_options_t metatomic_options
struct eonc::Parameters::prefactor_options_t prefactor_options
struct eonc::Parameters::hessian_options_t hessian_options
struct eonc::Parameters::process_search_options_t process_search_options
struct eonc::Parameters::dynamics_options_t dynamics_options
struct eonc::Parameters::lanczos_options_t lanczos_options
struct eonc::Parameters::bgsd_options_t bgsd_options
struct eonc::Parameters::main_options_t main_options
struct eonc::Parameters::parallel_replica_options_t parallel_replica_options
struct eonc::Parameters::serve_options_t serve_options
~Parameters()=default
RAII resource manager for the ARTn C library with global synchronization.
DimerRotationBackend
struct eonc::Parameters::ams_options_t::env_t env
std::string phva_atoms
PHVA mobile/active set for the Ritz space; "All" = all free atoms.
Definition Parameters.h:433
bool diagonal_preconditioner
Heuristic | (H v)_i / v_i | preconditioner (not true diag(H); off by default).
Definition Parameters.h:431
DimerRotationBackend rotation_backend
Definition Parameters.h:273
struct eonc::Parameters::gpr_dimer_options_t::gpr_params_t gpr_params
struct eonc::Parameters::gpr_dimer_options_t::debug_params_t debug_params
struct eonc::Parameters::gpr_dimer_options_t::prune_params_t prune_params
struct eonc::Parameters::gpr_dimer_options_t::opt_params_t opt_params
bool writeConForces
Opt-in "Forces of Component" sections in written .con frames (enables force+energy co-load on restart...
Definition Parameters.h:62
struct eonc::Parameters::metatomic_options_t::variants_t variant
struct eonc::Parameters::neb_options_t::climbing_image_options_t::hybrid_dimer_t ocineb
bool sidpp_ideal_ksp
Scale spring constant during growth.
Definition Parameters.h:526
double sidpp_frontier_tol
Convergence tol before adding images.
Definition Parameters.h:524
bool sidpp_reparam
Reparameterize after growth complete.
Definition Parameters.h:525
struct eonc::Parameters::neb_options_t::spring_options_t::onsager_machlup_t om
struct eonc::Parameters::neb_options_t::spring_options_t::energy_weighting_t weighting
struct eonc::Parameters::neb_options_t::endpoint_options_t endpoints
struct eonc::Parameters::neb_options_t::path_initialization_t initialization
struct eonc::Parameters::neb_options_t::climbing_image_options_t climbing_image
struct eonc::Parameters::neb_options_t::mmf_peak_options_t mmf_peaks
struct eonc::Parameters::neb_options_t::spring_options_t spring
struct eonc::Parameters::optimizer_options_t::quickmin_t quickmin
struct eonc::Parameters::optimizer_options_t::sd_t sd
struct eonc::Parameters::optimizer_options_t::refine_t refine
struct eonc::Parameters::optimizer_options_t::cg_t cg
struct eonc::Parameters::optimizer_options_t::lbfgs_t lbfgs
std::string backend
"nwchemc", "cpmdc", "metatomic", or "xtb"
Definition Parameters.h:131
struct eonc::Parameters::saddle_search_options_t::dynamics_t dynamics
struct eonc::Parameters::saddle_search_options_t::confine_positive_t confine_positive