Loading...
Searching...
No Matches
eonc::config Namespace Reference

Typedefs

using GD = eonc::params_ssot::GeneratedDefaults

Functions

int load_ini (const INIReader &ini, Parameters &params)
 Parse all INI sections into the Parameters struct.
void validate_and_link (Parameters &params)
 Resolve cross-group defaults and time unit conversions.
json to_json (const Parameters &params)
 Serialize all Parameters to JSON.
static std::string lowerCopy (std::string value)
static std::vector< double > temperaturesFromJson (const json &value)
static void readPathIntegralKeys (const json &s, Parameters &p)
static void readBathKeys (const json &s, Parameters &p)
void from_json (const nlohmann::json &j, Parameters &params)
 Deserialize JSON into Parameters, then resolve computed fields.
int load_json (std::string_view json_str, Parameters &params)
 Load Parameters from a JSON string. Returns 0 on success.
JobType job_from_ssot (std::string_view j)
PotType pot_from_ssot (std::string_view pot)
OptType opt_from_ssot (std::string_view m)
void apply_ssot_defaults (Parameters &params)
 Apply SSoT defaults for covered groups (Main, Potential, Optimizer, Structure Comparison, Process Search).
bool ssot_has_field (const char *section, const char *key)
 Return true if section‍/*key* (snake_case INI name) is declared in the Cap'n Proto L0 catalog for covered groups.

Typedef Documentation

◆ GD

Function Documentation

◆ apply_ssot_defaults()

void eonc::config::apply_ssot_defaults ( Parameters & params)

Apply SSoT defaults for covered groups (Main, Potential, Optimizer, Structure Comparison, Process Search).

Safe to call after construction; does not clear uncovered groups.

Definition at line 106 of file ParametersSSOT.cpp.

106 {
114 std::string(GD::MAIN_INI_FILENAME);
116 std::string(GD::MAIN_CON_FILENAME);
127 std::string(GD::MAIN_INPUT_FORMAT);
131
145 std::string(GD::POTENTIAL_EXT_POT_PATH);
152
166
173
187
205 std::string(GD::OPTIMIZER_LBFGS_SECANT);
207 std::string(GD::OPTIMIZER_LBFGS_PRECON);
209 std::string(GD::OPTIMIZER_LBFGS_STEP);
211 std::string(GD::OPTIMIZER_LBFGS_H0);
213 std::string(GD::OPTIMIZER_LBFGS_ACCEPT);
227 std::string(GD::OPTIMIZER_XTSCI_METHOD);
229 std::string(GD::OPTIMIZER_XTSCI_QN_STEP);
231 std::string(GD::OPTIMIZER_XTSCI_PRECON);
233 std::string(GD::OPTIMIZER_XTSCI_ACCEPT);
237 std::string(GD::OPTIMIZER_XTSCI_MANIFOLD);
239 std::string(GD::OPTIMIZER_XTSCI_METHOD);
241 std::string(GD::OPTIMIZER_OPT_BACKEND);
242
255
261#include "eon/generated/ParametersSSOTApply.inc"
262}
PotType pot_from_ssot(std::string_view pot)
JobType job_from_ssot(std::string_view j)
OptType opt_from_ssot(std::string_view m)
static structure_comparison_options_t & structure_comparison_options(Parameters &p)
static main_options_t & main_options(Parameters &p)
static process_search_options_t & process_search_options(Parameters &p)
static optimizer_options_t & optimizer_options(Parameters &p)
static potential_options_t & potential_options(Parameters &p)
double defaultVacuum
Vacuum (Angstrom) on every side of the box built when neither the file nor cell supplies one.
bool pbc
Periodicity of that fallback cell.
std::string inputFormat
Chemfiles format substituted for a .con request.
shared_flag writeConForces
Opt-in "Forces of Component" sections in written .con frames (enables force+energy co-load on restart...
std::string cell
Fallback cell when a foreign file carries none: "a b c" or nine row-major lattice numbers.
struct eonc::optimizer_options_t::sd_t sd
std::string backend
"eon" or "rgmin".
struct eonc::optimizer_options_t::quickmin_t quickmin
struct eonc::optimizer_options_t::xtsci_t xtsci
struct eonc::optimizer_options_t::cg_t cg
struct eonc::optimizer_options_t::lbfgs_t lbfgs
static constexpr auto PROCESS_SEARCH_MINIMIZATION_OFFSET
static constexpr auto STRUCTURE_COMPARISON_CHECK_ROTATION
static constexpr auto STRUCTURE_COMPARISON_DISTANCE_DIFFERENCE
static constexpr auto STRUCTURE_COMPARISON_NEIGHBOR_CUTOFF
static constexpr auto OPTIMIZER_LBFGS_MAX_INVERSE_CURVATURE
static constexpr auto STRUCTURE_COMPARISON_REMOVE_TRANSLATION
static constexpr auto STRUCTURE_COMPARISON_INDISTINGUISHABLE_ATOMS
static constexpr auto OPTIMIZER_QUICKMIN_STEEPEST_DESCENT
static constexpr auto OPTIMIZER_CG_MAX_ITER_BEFORE_RESET
static constexpr auto OPTIMIZER_LBFGS_INVERSE_CURVATURE
static constexpr auto STRUCTURE_COMPARISON_ENERGY_DIFFERENCE
static constexpr auto OPTIMIZER_CG_LINE_SEARCH_MAX_ITER
static constexpr auto OPTIMIZER_CG_KNOCK_OUT_MAX_MOVE
double pairSwitchWidth
Width (Angstrom) of the C^2 quintic switch that takes the lj, ljcluster and morse_pt pair terms to ze...
double pairCutoff
Cutoff (Angstrom) of the lj, ljcluster and morse_pt pair terms.

◆ from_json()

void eonc::config::from_json ( const json & j,
Parameters & p )

Deserialize JSON into Parameters, then resolve computed fields.

Definition at line 493 of file ParametersJSON.cpp.

493 {
494 // [Main]
495 if (j.contains("Main")) {
496 auto &m = j.at("Main");
497 if (m.contains("job"))
499 m.at("job"), ParametersLoadAccess::main_options(p).job);
500 JSON_OPT(m, "random_seed",
502 JSON_OPT(m, "temperature",
504 JSON_OPT(m, "quiet", ParametersLoadAccess::main_options(p).quiet);
505 JSON_OPT(m, "write_log", ParametersLoadAccess::main_options(p).writeLog);
506 JSON_OPT(m, "checkpoint", ParametersLoadAccess::main_options(p).checkpoint);
507 JSON_OPT(m, "ini_filename",
509 JSON_OPT(m, "con_filename",
511 JSON_OPT(m, "finite_difference",
512 ParametersLoadAccess::main_options(p).finiteDifference);
513 JSON_OPT(m, "max_force_calls",
514 ParametersLoadAccess::main_options(p).maxForceCalls);
515 JSON_OPT(m, "remove_net_force",
516 ParametersLoadAccess::main_options(p).removeNetForce);
517 {
518 bool writeConForces =
520 JSON_OPT(m, "write_con_forces", writeConForces);
522 }
524 auto inputFormat = main.inputFormat;
525 auto cell = main.cell;
526 auto pbc = main.pbc;
527 auto vacuum = main.defaultVacuum;
528 JSON_OPT(m, "input_format", inputFormat);
529 JSON_OPT(m, "cell", cell);
530 JSON_OPT(m, "pbc", pbc);
531 JSON_OPT(m, "default_vacuum", vacuum);
532 // Readers consult the process copies, not this object.
533 eonc::io::publish_structure_input(inputFormat, cell, pbc, vacuum);
534 main.inputFormat = std::move(inputFormat);
535 main.cell = std::move(cell);
536 main.pbc = pbc;
537 main.defaultVacuum = vacuum;
538 }
539
540 // [Potential]
541 if (j.contains("Potential")) {
542 auto &s = j.at("Potential");
543 if (s.contains("potential"))
545 enum_from_json(s.at("potential"),
547 JSON_OPT(s, "mpi_poll_period",
549 JSON_OPT(s, "lammps_logging",
551 JSON_OPT(s, "lammps_threads",
553 JSON_OPT(s, "emt_rasmussen",
555 JSON_OPT(s, "log_potential",
557 JSON_OPT(s, "ext_pot_path",
559 JSON_OPT(s, "potentials_path",
561 JSON_OPT(s, "pair_switch_width",
562 ParametersLoadAccess::potential_options(p).pairSwitchWidth);
563 JSON_OPT(s, "pair_cutoff",
565 }
566
567 // [Structure Comparison]
568 if (j.contains("Structure Comparison")) {
569 auto &s = j.at("Structure Comparison");
570 JSON_OPT(s, "distance_difference",
572 .distance_difference);
573 JSON_OPT(
574 s, "neighbor_cutoff",
576 JSON_OPT(
577 s, "check_rotation",
579 JSON_OPT(s, "indistinguishable_atoms",
581 .indistinguishable_atoms);
582 JSON_OPT(s, "energy_difference",
584 .energy_difference);
585 JSON_OPT(s, "remove_translation",
587 .remove_translation);
588 }
589
590 // [Optimizer]
591 if (j.contains("Optimizer")) {
592 auto &s = j.at("Optimizer");
593 if (s.contains("opt_method"))
595 enum_from_json(s.at("opt_method"),
597 JSON_OPT(s, "convergence_metric",
598 ParametersLoadAccess::optimizer_options(p).convergence_metric);
599 for (char &c :
600 ParametersLoadAccess::optimizer_options(p).convergence_metric) {
601 c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
602 }
604 ParametersLoadAccess::optimizer_options(p).convergence_metric)) {
606 std::string(*label);
607 } else {
608 throw std::invalid_argument(std::format(
609 "unknown convergence_metric: {}",
610 ParametersLoadAccess::optimizer_options(p).convergence_metric));
611 }
612 JSON_OPT(s, "opt_backend",
614 for (char &c : ParametersLoadAccess::optimizer_options(p).backend) {
615 c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
616 }
617 if (ParametersLoadAccess::optimizer_options(p).backend != "eon" &&
618 ParametersLoadAccess::optimizer_options(p).backend != "rgmin") {
619 throw std::invalid_argument(
620 std::format("unknown opt_backend: {} (eon, rgmin)",
622 }
623 JSON_OPT(s, "max_iterations",
625 JSON_OPT(s, "max_move",
627 JSON_OPT(s, "converged_force",
628 ParametersLoadAccess::optimizer_options(p).converged_force);
629 JSON_OPT(s, "time_step",
630 ParametersLoadAccess::optimizer_options(p).time_step_input);
631 JSON_OPT(s, "max_time_step",
632 ParametersLoadAccess::optimizer_options(p).max_time_step_input);
633 if (s.contains("LBFGS")) {
634 auto &l = s.at("LBFGS");
635 JSON_OPT(l, "memory",
637 JSON_OPT(
638 l, "inverse_curvature",
639 ParametersLoadAccess::optimizer_options(p).lbfgs.inverse_curvature);
640 JSON_OPT(l, "max_inverse_curvature",
642 .lbfgs.max_inverse_curvature);
643 JSON_OPT(l, "auto_scale",
644 ParametersLoadAccess::optimizer_options(p).lbfgs.auto_scale);
645 JSON_OPT(l, "angle_reset",
646 ParametersLoadAccess::optimizer_options(p).lbfgs.angle_reset);
647 JSON_OPT(l, "distance_reset",
648 ParametersLoadAccess::optimizer_options(p).lbfgs.distance_reset);
649 JSON_OPT(l, "curvature",
650 ParametersLoadAccess::optimizer_options(p).lbfgs.curvature);
651 JSON_OPT(l, "project_rigid",
652 ParametersLoadAccess::optimizer_options(p).lbfgs.project_rigid);
653 JSON_OPT(l, "secant",
655 JSON_OPT(l, "precon",
657 JSON_OPT(l, "step",
660 JSON_OPT(l, "accept",
662 JSON_OPT(l, "extra_updates",
663 ParametersLoadAccess::optimizer_options(p).lbfgs.extra_updates);
664 JSON_OPT(l, "cautious_eps",
665 ParametersLoadAccess::optimizer_options(p).lbfgs.cautious_eps);
666 JSON_OPT(l, "cautious_alpha",
667 ParametersLoadAccess::optimizer_options(p).lbfgs.cautious_alpha);
668 JSON_OPT(l, "precon_A",
670 JSON_OPT(l, "precon_mu",
671 ParametersLoadAccess::optimizer_options(p).lbfgs.precon_mu);
672 JSON_OPT(l, "precon_rcut",
673 ParametersLoadAccess::optimizer_options(p).lbfgs.precon_rcut);
674 }
675 if (s.contains("Xtsci")) {
676 auto &x = s.at("Xtsci");
677 JSON_OPT(x, "method",
679 }
680 JSON_OPT(s, "xtsci_method",
682 }
683
684 // [Dynamics] Thermostat names on this object match the ini file.
685 // A later Thermostat object overrides the same keys.
686 if (j.contains("Dynamics")) {
687 auto &s = j.at("Dynamics");
688 JSON_OPT(s, "time_step",
689 ParametersLoadAccess::dynamics_options(p).time_step_input);
690 JSON_OPT(s, "time", ParametersLoadAccess::dynamics_options(p).time_input);
691 readBathKeys(s, p);
692 }
693
694 // [Thermostat]
695 if (j.contains("Thermostat")) {
696 readBathKeys(j.at("Thermostat"), p);
697 }
698
699 // [Nudged Elastic Band]
700 if (j.contains("Nudged Elastic Band")) {
701 auto &s = j.at("Nudged Elastic Band");
702 JSON_OPT(s, "images", ParametersLoadAccess::neb_options(p).image_count);
703 JSON_OPT(s, "max_iterations",
704 ParametersLoadAccess::neb_options(p).max_iterations);
705 if (s.contains("opt_method"))
707 s.at("opt_method"), ParametersLoadAccess::neb_options(p).opt_method);
708 JSON_OPT(s, "converged_force",
709 ParametersLoadAccess::neb_options(p).force_tolerance);
710 JSON_OPT(s, "solid_state",
711 ParametersLoadAccess::neb_options(p).solid_state.enabled);
712 JSON_OPT(s, "solid_state_weight",
713 ParametersLoadAccess::neb_options(p).solid_state.weight);
714 JSON_OPT(s, "solid_state_pressure",
715 ParametersLoadAccess::neb_options(p).solid_state.pressure);
716 JSON_OPT(s, "band_precon",
717 ParametersLoadAccess::neb_options(p).band.precon);
718 JSON_OPT(s, "band_precon_mu",
719 ParametersLoadAccess::neb_options(p).band.precon_mu);
720 JSON_OPT(s, "band_stepper",
721 ParametersLoadAccess::neb_options(p).band.stepper);
722 JSON_OPT(s, "temperature",
723 ParametersLoadAccess::neb_options(p).quantum_temperature);
724 JSON_OPT(s, "tunnel_wall_points",
725 ParametersLoadAccess::neb_options(p).tunnel_wall_points);
726 if (s.contains("spring")) {
727 auto &sp = s.at("spring");
728 JSON_OPT(sp, "constant",
729 ParametersLoadAccess::neb_options(p).spring.constant);
730 JSON_OPT(sp, "elastic_band",
731 ParametersLoadAccess::neb_options(p).spring.use_elastic_band);
732 JSON_OPT(sp, "doubly_nudged",
733 ParametersLoadAccess::neb_options(p).spring.doubly_nudged);
734 JSON_OPT(sp, "geometric",
735 ParametersLoadAccess::neb_options(p).spring.geometric);
736 }
737 if (s.contains("climbing_image")) {
738 auto &ci = s.at("climbing_image");
739 JSON_OPT(ci, "enabled",
740 ParametersLoadAccess::neb_options(p).climbing_image.enabled);
741 JSON_OPT(
742 ci, "converged_only",
743 ParametersLoadAccess::neb_options(p).climbing_image.converged_only);
744 JSON_OPT(ci, "band_slack",
745 ParametersLoadAccess::neb_options(p).climbing_image.band_slack);
746 }
747 if (s.contains("zoom")) {
748 auto &z = s.at("zoom");
750 JSON_OPT(z, "enabled", zoom.enabled);
751 JSON_OPT(z, "alpha", zoom.alpha);
752 JSON_OPT(z, "offset", zoom.offset);
753 if (z.contains("mode")) {
754 zoom.mode = enum_from_json(z.at("mode"), zoom.mode);
755 }
756 JSON_OPT(z, "activation_threshold", zoom.activation_threshold);
757 if (z.contains("interpolation")) {
758 zoom.interpolation =
759 enum_from_json(z.at("interpolation"), zoom.interpolation);
760 }
761 JSON_OPT(z, "stability_count", zoom.stability_count);
762 JSON_OPT(z, "max_iterations", zoom.max_iterations);
763 }
764 }
765
766 // [Dimer]
767 if (j.contains("Dimer")) {
768 auto &s = j.at("Dimer");
769 JSON_OPT(s, "rotation_angle",
770 ParametersLoadAccess::dimer_options(p).rotation_angle);
771 JSON_OPT(s, "improved", ParametersLoadAccess::dimer_options(p).improved);
772 JSON_OPT(s, "converged_angle",
773 ParametersLoadAccess::dimer_options(p).converged_angle);
774 JSON_OPT(s, "max_iterations",
775 ParametersLoadAccess::dimer_options(p).max_iterations);
776 if (s.contains("opt_method"))
778 enum_from_json(s.at("opt_method"),
780 if (s.contains("rotation_backend"))
782 s.at("rotation_backend"),
784 JSON_OPT(s, "lor_residual_tol",
785 ParametersLoadAccess::dimer_options(p).lor_residual_tol);
786 }
787
788 // [Saddle Search]
789 if (j.contains("Saddle Search")) {
790 auto &s = j.at("Saddle Search");
791 JSON_OPT(s, "method",
793 JSON_OPT(s, "min_mode_method",
795 JSON_OPT(s, "max_energy",
797 JSON_OPT(s, "max_iterations",
799 JSON_OPT(s, "displace_magnitude",
800 ParametersLoadAccess::saddle_search_options(p).displace_magnitude);
801 JSON_OPT(s, "displace_radius",
804 JSON_OPT(s, "prfo_refine", prfo.enabled);
805 JSON_OPT(s, "prfo_refine_force", prfo.force);
806 JSON_OPT(s, "prfo_refine_max_iterations", prfo.max_iterations);
807 JSON_OPT(s, "irc_after",
809 JSON_OPT(s, "irc_step_size",
811 JSON_OPT(
812 s, "irc_converged_force",
814 JSON_OPT(s, "irc_max_steps",
816 }
817
818 // [Serve]
819 if (j.contains("Serve")) {
820 auto &s = j.at("Serve");
822 if (s.contains("port"))
824 s.at("port").get<uint16_t>();
825 if (s.contains("replicas"))
827 s.at("replicas").get<size_t>();
828 if (s.contains("gateway_port"))
830 s.at("gateway_port").get<uint16_t>();
831 JSON_OPT(s, "endpoints", ParametersLoadAccess::serve_options(p).endpoints);
832 }
833
834 // [Debug]
835 if (j.contains("Debug")) {
836 auto &s = j.at("Debug");
837 JSON_OPT(s, "write_movies",
839 JSON_OPT(s, "write_movies_interval",
840 ParametersLoadAccess::debug_options(p).write_movies_interval);
841 JSON_OPT(s, "write_deprecated_outs",
842 ParametersLoadAccess::debug_options(p).write_deprecated_outs);
843 }
844
845 // [Hessian] phva_atoms wins over the legacy atom_list, as in the ini.
846 if (j.contains("Hessian")) {
847 auto &s = j.at("Hessian");
849 if (s.contains("phva_atoms")) {
850 h.phva_atoms = lowerCopy(s.at("phva_atoms").get<std::string>());
851 } else if (s.contains("atom_list")) {
852 h.phva_atoms = lowerCopy(s.at("atom_list").get<std::string>());
853 }
854 JSON_OPT(s, "zero_freq_value", h.zero_freq_value);
855 if (s.contains("fd_scheme")) {
856 h.fd_scheme = lowerCopy(s.at("fd_scheme").get<std::string>());
857 }
858 JSON_OPT(s, "resume", h.resume);
859 JSON_OPT(s, "checkpoint_path", h.checkpoint_path);
860 JSON_OPT(s, "write_modes", h.write_modes);
861 }
862
863 // [Instanton]
864 if (j.contains("Instanton")) {
865 auto &s = j.at("Instanton");
867 JSON_OPT(s, "mode", o.mode);
868 JSON_OPT(s, "reactant_filename", o.reactant_filename);
869 JSON_OPT(s, "product_filename", o.product_filename);
870 JSON_OPT(s, "initial_path", o.initial_path);
871 JSON_OPT(s, "initial_ring", o.initial_ring);
872 JSON_OPT(s, "physical_bath_filename", o.physical_bath_filename);
873 JSON_OPT(s, "beads", o.beads);
874 JSON_OPT(s, "beta_hbar_omega", o.beta_hbar_omega);
875 JSON_OPT(s, "max_iterations", o.max_iterations);
876 JSON_OPT(s, "force_tolerance", o.force_tolerance);
877 JSON_OPT(s, "hessian_stride", o.hessian_stride);
878 JSON_OPT(s, "saddle_filename", o.saddle_filename);
879 JSON_OPT(s, "temperature", o.temperature);
880 if (s.contains("temperatures")) {
881 o.temperatures = temperaturesFromJson(s.at("temperatures"));
882 }
883 JSON_OPT(s, "half_ring", o.half_ring);
884 JSON_OPT(s, "symmetrize", o.symmetrize);
885 if (s.contains("initial_hessians")) {
886 o.initial_hessians = s.at("initial_hessians").get<std::string>();
887 }
888 if (o.initial_hessians != "saddle" &&
889 o.initial_hessians != "finite_difference") {
890 throw std::invalid_argument(
891 "[Instanton] initial_hessians must be saddle or "
892 "finite_difference, not " +
893 o.initial_hessians);
894 }
895 JSON_OPT(s, "newton_limit", o.newton_limit);
896 if (o.newton_limit < 0) {
897 throw std::invalid_argument(
898 "[Instanton] newton_limit must be nonnegative");
899 }
900 JSON_OPT(s, "reactant_hessian_filename", o.reactant_hessian_filename);
901 JSON_OPT(s, "saddle_hessian_filename", o.saddle_hessian_filename);
902 JSON_OPT(s, "lanczos_step", o.lanczos_step);
903 if (!(o.lanczos_step > 0.0) || !std::isfinite(o.lanczos_step)) {
904 throw std::invalid_argument("[Instanton] lanczos_step must be finite and "
905 "positive in sqrt(amu) Angstrom");
906 }
907 JSON_OPT(s, "physical_hessian_step", o.physical_hessian_step);
908 if (!(o.physical_hessian_step > 0.0) ||
909 !std::isfinite(o.physical_hessian_step)) {
910 throw std::invalid_argument(
911 "[Instanton] physical_hessian_step must be finite and positive "
912 "in sqrt(amu) Angstrom");
913 }
914 JSON_OPT(s, "energy_shift", o.energy_shift);
915 if (s.contains("discretization")) {
916 o.discretization.clear();
917 for (const auto &item : s.at("discretization")) {
918 o.discretization.push_back(item.get<double>());
919 }
920 }
921 if (s.contains("friction")) {
922 o.friction = lowerCopy(s.at("friction").get<std::string>());
923 }
924 if (o.friction != "none" && o.friction != "implicit" &&
925 o.friction != "explicit") {
926 throw std::invalid_argument(
927 "[Instanton] friction must be none, implicit or explicit, not " +
928 o.friction);
929 }
930 JSON_OPT(s, "friction_eta", o.friction_eta);
931 if (s.contains("friction_eta_beads")) {
932 o.friction_eta_beads.clear();
933 for (const auto &item : s.at("friction_eta_beads")) {
934 o.friction_eta_beads.push_back(item.get<double>());
935 }
936 }
937 JSON_OPT(s, "collapse_fraction", o.collapse_fraction);
938 if (!(o.collapse_fraction >= 0.0 && o.collapse_fraction < 1.0)) {
939 throw std::invalid_argument(
940 "[Instanton] collapse_fraction must be in [0, 1)");
941 }
942 JSON_OPT(s, "rotation_zero_fraction", o.rotation_zero_fraction);
943 if (!(o.rotation_zero_fraction > 0.0)) {
944 throw std::invalid_argument(
945 "[Instanton] rotation_zero_fraction must be positive");
946 }
947 JSON_OPT(s, "bead_ladder", o.bead_ladder);
948 JSON_OPT(s, "hessian_final", o.hessian_final);
949 if (s.contains("springs")) {
950 o.springs = lowerCopy(s.at("springs").get<std::string>());
951 }
952 if (o.springs != "trotter" && o.springs != "eco") {
953 throw std::invalid_argument(
954 "[Instanton] springs must be trotter or eco, not " + o.springs);
955 }
956 if (o.mode != "splitting" && o.mode != "rate") {
957 throw std::invalid_argument("[Instanton] mode must be splitting or "
958 "rate, not " +
959 o.mode);
960 }
961 JSON_OPT(s, "pi_planes", o.pi_planes);
962 JSON_OPT(s, "pi_beads", o.pi_beads);
963 JSON_OPT(s, "pi_equilibration_steps", o.pi_equilibration_steps);
964 JSON_OPT(s, "pi_sampling_steps", o.pi_sampling_steps);
965 JSON_OPT(s, "pi_time_step", o.pi_time_step);
966 if (s.contains("pi_thermostat")) {
967 o.pi_thermostat = lowerCopy(s.at("pi_thermostat").get<std::string>());
968 }
969 JSON_OPT(s, "pi_gle_file", o.pi_gle_file);
970 JSON_OPT(s, "pi_pile_tau", o.pi_pile_tau);
971 JSON_OPT(s, "pi_pile_scale", o.pi_pile_scale);
972 JSON_OPT(s, "pi_seed", o.pi_seed);
973 if (s.contains("pi_direction")) {
974 o.pi_direction = lowerCopy(s.at("pi_direction").get<std::string>());
975 }
976 JSON_OPT(s, "pi_reactant_extent", o.pi_reactant_extent);
977 JSON_OPT(s, "pi_recrossing_parents", o.pi_recrossing_parents);
978 JSON_OPT(s, "pi_recrossing_children", o.pi_recrossing_children);
979 JSON_OPT(s, "pi_recrossing_time", o.pi_recrossing_time);
980 JSON_OPT(s, "pi_recrossing_spacing", o.pi_recrossing_spacing);
982 }
983
984 // The ini loader derives these from the femtosecond inputs whether or
985 // not the keys are present; validate_and_link does not.
986 {
988 const double timeUnit = ParametersLoadAccess::constants(p).timeUnit;
989 th.andersen_tcol = timeUnit > 0.0 ? th.andersen_tcol_input / timeUnit : 0.0;
990 th.path_pile_tau = timeUnit > 0.0 ? th.path_pile_tau_input / timeUnit : 0.0;
991 }
992
993 project_ssot_json_read(j, p);
994
995 // Resolve computed fields
997}
int main(int argc, char **argv)
#define JSON_OPT(j, key, target)
static E enum_from_json(const json &j, E fallback)
static std::string lowerCopy(std::string value)
static void readBathKeys(const json &s, Parameters &p)
void validate_and_link(Parameters &params)
Resolve cross-group defaults and time unit conversions.
static std::vector< double > temperaturesFromJson(const json &value)
std::optional< std::string_view > convergenceMetricLabel(std::string_view metric)
Display label for a force-convergence metric, or nullopt when the name is none of the four the optimi...
void publish_structure_input(std::string format, const std::string &cell, bool pbc, double vacuum)
Publish [Main] input_format, cell, pbc, and default_vacuum to the process-wide readers.
void validateOptions(const instanton_options_t &o)
Throws std::invalid_argument on an inconsistent [Instanton] pi_* key.
Definition PIQTSTJob.cpp:31
static potential_options_t & potential_options(Parameters &p)
static thermostat_options_t & thermostat_options(Parameters &p)
static dimer_options_t & dimer_options(Parameters &p)
static constants_t & constants(Parameters &p)
static debug_options_t & debug_options(Parameters &p)
static hessian_options_t & hessian_options(Parameters &p)
static instanton_options_t & instanton_options(Parameters &p)
static saddle_search_options_t & saddle_search_options(Parameters &p)
static dynamics_options_t & dynamics_options(Parameters &p)
static neb_options_t & neb_options(Parameters &p)
static serve_options_t & serve_options(Parameters &p)
DimerRotationBackend rotation_backend
struct eonc::neb_options_t::zoom_options_t zoom
struct eonc::saddle_search_options_t::prfo_refine_t prfo_refine

◆ job_from_ssot()

JobType eonc::config::job_from_ssot ( std::string_view j)

Definition at line 24 of file ParametersSSOT.cpp.

24 {
25 if (j == "process_search")
27 if (j == "minimization")
29 if (j == "saddle_search")
31 if (j == "basin_hopping")
33 if (j == "parallel_replica" || j == "unbiased_parallel_replica")
35 if (j == "nudged_elastic_band")
37 if (j == "dynamics" || j == "molecular_dynamics")
38 return JobType::Dynamics;
39 if (j == "hessian")
40 return JobType::Hessian;
41 if (j == "point")
42 return JobType::Point;
43 if (j == "prefactor")
44 return JobType::Prefactor;
45 if (j == "monte_carlo")
47 if (j == "structure_comparison")
49 if (j == "gp_surrogate")
51 if (j == "safe_hyperdynamics")
53 if (j == "tad")
54 return JobType::TAD;
55 if (j == "replica_exchange")
57 if (j == "finite_difference" || j == "finite_differences")
59 if (j == "global_optimization")
61 if (j == "instanton")
62 return JobType::Instanton;
64}

◆ load_ini()

int eonc::config::load_ini ( const INIReader & ini,
Parameters & params )

Parse all INI sections into the Parameters struct.

Returns 0 on success, nonzero on error.

Definition at line 47 of file ParametersINI.cpp.

47 {
48 int error = 0;
49
50 // [Main] //
51
53 magic_enum::enum_cast<JobType>(ini.Get("Main", "job", ""),
54 magic_enum::case_insensitive)
55 .value_or(JobType::Unknown);
57 ini.GetReal("Main", "temperature",
58 ParametersLoadAccess::main_options(params).temperature);
60 ini.GetInteger("Main", "random_seed",
61 ParametersLoadAccess::main_options(params).randomSeed);
63 ini.GetBoolean("Main", "checkpoint",
64 ParametersLoadAccess::main_options(params).checkpoint);
65 ParametersLoadAccess::main_options(params).quiet = ini.GetBoolean(
66 "Main", "quiet", ParametersLoadAccess::main_options(params).quiet);
67 ParametersLoadAccess::main_options(params).writeLog = ini.GetBoolean(
68 "Main", "write_log", ParametersLoadAccess::main_options(params).writeLog);
70 ini.GetBoolean("Main", "write_con_forces",
71 ParametersLoadAccess::main_options(params).writeConForces);
72 // Process-wide io mode; same pattern as the RNG seeding below.
74 ParametersLoadAccess::main_options(params).writeConForces);
75 // Structure reads do not see Parameters, so the stored values are
76 // published process-wide. Output stays .con.
77 {
79 const auto inputFormat = ini.Get("Main", "input_format", main.inputFormat);
80 const auto cell = ini.Get("Main", "cell", main.cell);
81 const auto pbc = ini.GetBoolean("Main", "pbc", main.pbc);
82 const auto vacuum =
83 ini.GetReal("Main", "default_vacuum", main.defaultVacuum);
84 eonc::io::publish_structure_input(inputFormat, cell, pbc, vacuum);
85 main.inputFormat = inputFormat;
86 main.cell = cell;
87 main.pbc = pbc;
88 main.defaultVacuum = vacuum;
89 }
91 ini.GetReal("Main", "finite_difference",
92 ParametersLoadAccess::main_options(params).finiteDifference);
93 // Initialize random generator
94 if (ParametersLoadAccess::main_options(params).randomSeed < 0) {
95 unsigned i = static_cast<unsigned>(std::time(nullptr));
98 } else {
100 }
102 ini.GetInteger("Main", "max_force_calls",
103 ParametersLoadAccess::main_options(params).maxForceCalls);
105 ini.GetBoolean("Main", "remove_net_force",
106 ParametersLoadAccess::main_options(params).removeNetForce);
107 ParametersLoadAccess::main_options(params).parallel = ini.GetBoolean(
108 "Main", "parallel", ParametersLoadAccess::main_options(params).parallel);
109
110 // [Potential] //
111
112 std::string potTok = ini.Get("Potential", "potential", "");
113 // Schema / old configs: ase_nwcem is ASE_NWCHEM; socket_nwchem is
114 // SocketNWChem (magic_enum already matches the latter).
115 if (potTok == "ase_nwcem" || potTok == "ASE_NWCEM") {
116 potTok = "ase_nwchem";
117 }
119 magic_enum::enum_cast<PotType>(potTok, magic_enum::case_insensitive)
120 .value_or(PotType::UNKNOWN);
122 "Potential", "mpi_poll_period",
123 ParametersLoadAccess::potential_options(params).MPIPollPeriod);
125 ini.GetBoolean(
126 "Potential", "lammps_logging",
127 ParametersLoadAccess::potential_options(params).LAMMPSLogging);
129 static_cast<int>(ini.GetInteger(
130 "Potential", "lammps_threads",
131 ParametersLoadAccess::potential_options(params).LAMMPSThreads));
133 "Potential", "emt_rasmussen",
134 ParametersLoadAccess::potential_options(params).EMTRasmussen);
136 ini.Get("Potential", "ext_pot_path",
137 ParametersLoadAccess::potential_options(params).extPotPath);
139 ini.Get("Potential", "potentials_path",
140 ParametersLoadAccess::potential_options(params).potentialsPath);
142 "Potential", "pair_switch_width",
143 ParametersLoadAccess::potential_options(params).pairSwitchWidth);
145 ini.GetReal("Potential", "pair_cutoff",
146 ParametersLoadAccess::potential_options(params).pairCutoff);
147
148 if (params.potential_options().potential == PotType::MPI ||
151 } else {
153 }
155 "Potential", "log_potential",
156 ParametersLoadAccess::potential_options(params).LogPotential);
158 "Potential", "thread_safe",
159 ParametersLoadAccess::potential_options(params).thread_safe);
160
161 // [AMS]
162 if (params.potential_options().potential == PotType::AMS) {
164 "AMS", "engine", ParametersLoadAccess::ams_options(params).engine);
166 ini.Get("AMS", "forcefield",
167 ParametersLoadAccess::ams_options(params).forcefield);
169 ini.Get("AMS", "resources",
170 ParametersLoadAccess::ams_options(params).resources);
172 "AMS", "model", ParametersLoadAccess::ams_options(params).model);
174 ini.Get("AMS", "xc", ParametersLoadAccess::ams_options(params).xc);
176 "AMS", "basis", ParametersLoadAccess::ams_options(params).basis);
177 }
178 // [AMS_IO]
181 "AMS_IO", "engine", ParametersLoadAccess::ams_options(params).engine);
183 ini.Get("AMS_IO", "forcefield",
184 ParametersLoadAccess::ams_options(params).forcefield);
186 "AMS_IO", "model", ParametersLoadAccess::ams_options(params).model);
188 ini.Get("AMS_IO", "xc", ParametersLoadAccess::ams_options(params).xc);
189 }
190 // [AMS_ENV]
194 ini.Get("AMS_ENV", "amshome",
195 ParametersLoadAccess::ams_options(params).env.amshome);
197 ini.Get("AMS_ENV", "scm_tmpdir",
198 ParametersLoadAccess::ams_options(params).env.scm_tmpdir);
200 ini.Get("AMS_ENV", "scmlicense",
201 ParametersLoadAccess::ams_options(params).env.scmlicense);
203 ini.Get("AMS_ENV", "scm_pythondir",
204 ParametersLoadAccess::ams_options(params).env.scm_pythondir);
206 ini.Get("AMS_ENV", "amsbin",
207 ParametersLoadAccess::ams_options(params).env.amsbin);
209 ini.Get("AMS_ENV", "amsresources",
210 ParametersLoadAccess::ams_options(params).env.amsresources);
211 }
212 // [XTBPot]
213 if (params.potential_options().potential == PotType::XTB) {
215 ini.Get("XTBPot", "paramset",
216 ParametersLoadAccess::xtb_options(params).paramset);
217 ParametersLoadAccess::xtb_options(params).acc = ini.GetReal(
218 "XTBPot", "accuracy", ParametersLoadAccess::xtb_options(params).acc);
220 ini.GetReal("XTBPot", "electronic_temperature",
221 ParametersLoadAccess::xtb_options(params).elec_temperature);
223 ini.GetInteger("XTBPot", "max_iterations",
224 ParametersLoadAccess::xtb_options(params).maxiter);
225 ParametersLoadAccess::xtb_options(params).uhf = ini.GetInteger(
226 "XTBPot", "uhf", ParametersLoadAccess::xtb_options(params).uhf);
227 ParametersLoadAccess::xtb_options(params).charge = ini.GetReal(
228 "XTBPot", "charge", ParametersLoadAccess::xtb_options(params).charge);
229 }
230 // [ZBLPot]
231 if (params.potential_options().potential == PotType::ZBL) {
233 ini.GetReal("ZBLPot", "cut_inner",
234 ParametersLoadAccess::zbl_options(params).cut_inner);
236 ini.GetReal("ZBLPot", "cut_global",
237 ParametersLoadAccess::zbl_options(params).cut_global);
238 if (ParametersLoadAccess::zbl_options(params).cut_inner >
239 ParametersLoadAccess::zbl_options(params).cut_global) {
240 throw std::runtime_error(
241 "Switching function must begin before the global cutoff!");
242 }
243 }
244 // [D3Pot] / [D4Pot]: rgpot 3.1 Grimme DFT-D
248 ini.Get("D3Pot", "functional",
249 ini.Get("D4Pot", "functional",
251 ParametersLoadAccess::dftd_options(params).atm = ini.GetBoolean(
252 "D3Pot", "atm",
253 ini.GetBoolean("D4Pot", "atm",
256 ini.Get("D3Pot", "damping",
257 ParametersLoadAccess::dftd_options(params).d3_damping);
259 ini.GetReal("D4Pot", "charge",
260 ParametersLoadAccess::dftd_options(params).d4_charge);
261 }
262 if (params.potential_options().potential == PotType::EXPR) {
264 ini.Get("ExprPot", "expression",
265 ParametersLoadAccess::expr_options(params).expression);
267 "ExprPot", "terms", ParametersLoadAccess::expr_options(params).terms);
268 }
270 ParametersLoadAccess::mopac_options(params).charge = static_cast<int>(
271 ini.GetInteger("MOPACPot", "charge",
273 ParametersLoadAccess::mopac_options(params).spin = static_cast<int>(
274 ini.GetInteger("MOPACPot", "spin",
276 ParametersLoadAccess::mopac_options(params).model = static_cast<int>(
277 ini.GetInteger("MOPACPot", "model",
280 ini.Get("MOPACPot", "engine_path",
281 ParametersLoadAccess::mopac_options(params).engine_path);
282 }
283 // [SocketNWChemPot]
284 // The section is stored even when another potential is selected. A
285 // later switch still sees the socket path and the unix mode.
286 {
288 ini.Get("SocketNWChemPot", "host",
290 ParametersLoadAccess::socket_nwchem_options(params).port = ini.GetInteger(
291 "SocketNWChemPot", "port",
294 ini.GetInteger(
295 "SocketNWChemPot", "mem_in_gb",
298 ini.Get("SocketNWChemPot", "nwchem_settings",
300 .nwchem_settings);
302 ini.Get("SocketNWChemPot", "unix_socket_path",
304 .unix_socket_path);
306 ini.GetBoolean("SocketNWChemPot", "unix_socket_mode",
308 .unix_socket_mode);
310 ini.GetBoolean("SocketNWChemPot", "make_template_input",
312 .make_template_input);
313 }
314
315 // [RgpotPot] scalars, alias order, and the cpmd / XTBPot overlays are
316 // projected from schema/eon_params.capnp.
317 project_ssot_ini(ini, params);
318
319 // [Debug] //
320
322 ini.GetBoolean("Debug", "write_movies",
323 ParametersLoadAccess::debug_options(params).write_movies);
325 ini.GetInteger(
326 "Debug", "write_movies_interval",
327 ParametersLoadAccess::debug_options(params).write_movies_interval);
329 ini.GetBoolean(
330 "Debug", "write_deprecated_outs",
331 ParametersLoadAccess::debug_options(params).write_deprecated_outs);
333 ini.GetBoolean(
334 "Debug", "estimate_neb_eigenvalues",
335 ParametersLoadAccess::debug_options(params).estimate_neb_eigenvalues);
337 toLowerCase(ini.Get("Debug", "neb_mmf_estimator",
339
340 // [Structure Comparison] //
341
344 ini.GetReal("Structure Comparison", "distance_difference",
346 .distance_difference);
348 ini.GetReal("Structure Comparison", "neighbor_cutoff",
350 .neighbor_cutoff);
352 ini.GetBoolean("Structure Comparison", "check_rotation",
354 .check_rotation);
356 ini.GetReal("Structure Comparison", "energy_difference",
358 .energy_difference);
361 ini.GetBoolean("Structure Comparison", "indistinguishable_atoms",
363 .indistinguishable_atoms);
366 ini.GetBoolean("Structure Comparison", "remove_translation",
368 .remove_translation);
369
370 // [Process Search] //
371
373 ini.GetBoolean(
374 "Process Search", "minimize_first",
375 ParametersLoadAccess::process_search_options(params).minimize_first);
377 ini.GetReal("Process Search", "minimization_offset",
379 .minimization_offset);
381 ini.GetBoolean(
382 "Process Search", "known_saddles",
384
385 // [Optimizers] //
386 auto inp_optMethod =
387 magic_enum::enum_cast<OptType>(ini.Get("Optimizer", "opt_method", "none"),
388 magic_enum::case_insensitive)
389 .value_or(OptType::Unknown);
390 if (inp_optMethod != OptType::None) {
391 ParametersLoadAccess::optimizer_options(params).method = inp_optMethod;
392 }
394 ini.Get("Optimizer", "opt_backend",
396 if (ParametersLoadAccess::optimizer_options(params).backend != "eon" &&
397 ParametersLoadAccess::optimizer_options(params).backend != "rgmin") {
398 EONC_LOG_ERROR("unknown [Optimizer] opt_backend {} (eon, rgmin)",
400 error = 1;
401 }
402
404 toLowerCase(ini.Get(
405 "Optimizer", "convergence_metric",
408 ParametersLoadAccess::optimizer_options(params).convergence_metric)) {
410 *label;
411 } else {
413 "unknown convergence_metric {}",
414 ParametersLoadAccess::optimizer_options(params).convergence_metric);
415 error = 1;
416 }
417
418 if (ini.HasSection("Refine")) {
420 magic_enum::enum_cast<OptType>(ini.Get("Refine", "opt_method", ""),
421 magic_enum::case_insensitive)
422 .value_or(OptType::None);
424 ini.GetReal(
425 "Refine", "threshold",
426 ParametersLoadAccess::optimizer_options(params).refine.threshold);
427 }
428
430 "Optimizer", "converged_force",
431 ParametersLoadAccess::optimizer_options(params).converged_force);
433 static_cast<size_t>(ini.GetInteger(
434 "Optimizer", "max_iterations",
435 ParametersLoadAccess::optimizer_options(params).max_iterations));
437 ini.GetReal("Optimizer", "max_move",
439 // Handle each optimizer separately
440 if (ini.HasSection("QuickMin")) {
442 ini.GetReal(
443 "QuickMin", "time_step",
444 ParametersLoadAccess::optimizer_options(params).time_step_input);
449 ini.GetBoolean("Optimizer", "qm_steepest_descent",
451 .quickmin.steepest_descent);
452 }
453 if (ini.HasSection("FIRE")) {
454 EONC_LOG_WARNING("Overwriting QuickMin timestep with Fire timestep!!");
456 ini.GetReal(
457 "FIRE", "time_step",
458 ParametersLoadAccess::optimizer_options(params).time_step_input);
463 ini.GetReal("FIRE", "time_step_max",
465 .max_time_step_input);
469 }
470 // 2014 optbench INI puts lbfgs_* on [Optimizer]. Prefer [LBFGS] when present.
471 {
472 const char *lbfgs_sec = ini.HasSection("LBFGS") ? "LBFGS" : "Optimizer";
474 ini.GetInteger(
475 lbfgs_sec, "lbfgs_memory",
476 ParametersLoadAccess::optimizer_options(params).lbfgs.memory);
478 ini.GetReal(lbfgs_sec, "lbfgs_inverse_curvature",
480 .lbfgs.inverse_curvature);
483 ini.GetReal(lbfgs_sec, "lbfgs_max_inverse_curvature",
485 .lbfgs.max_inverse_curvature);
487 lbfgs.auto_scale =
488 ini.GetBoolean(lbfgs_sec, "lbfgs_auto_scale", lbfgs.auto_scale);
489 lbfgs.angle_reset =
490 ini.GetBoolean(lbfgs_sec, "lbfgs_angle_reset", lbfgs.angle_reset);
491 lbfgs.distance_reset =
492 ini.GetBoolean(lbfgs_sec, "lbfgs_distance_reset", lbfgs.distance_reset);
493 lbfgs.curvature =
494 toLowerCase(ini.Get(lbfgs_sec, "lbfgs_curvature", lbfgs.curvature));
495 lbfgs.project_rigid =
496 ini.GetBoolean(lbfgs_sec, "lbfgs_project_rigid", lbfgs.project_rigid);
497 lbfgs.secant =
498 toLowerCase(ini.Get(lbfgs_sec, "lbfgs_secant", lbfgs.secant));
499 lbfgs.precon =
500 toLowerCase(ini.Get(lbfgs_sec, "lbfgs_precon", lbfgs.precon));
501 lbfgs.step = toLowerCase(ini.Get(lbfgs_sec, "lbfgs_step", lbfgs.step));
502 lbfgs.h0 = toLowerCase(ini.Get(lbfgs_sec, "lbfgs_h0", lbfgs.h0));
503 lbfgs.accept =
504 toLowerCase(ini.Get(lbfgs_sec, "lbfgs_accept", lbfgs.accept));
505 lbfgs.extra_updates =
506 ini.GetInteger(lbfgs_sec, "lbfgs_extra_updates", lbfgs.extra_updates);
507 lbfgs.cautious_eps =
508 ini.GetReal(lbfgs_sec, "lbfgs_cautious_eps", lbfgs.cautious_eps);
509 lbfgs.cautious_alpha =
510 ini.GetReal(lbfgs_sec, "lbfgs_cautious_alpha", lbfgs.cautious_alpha);
511 lbfgs.precon_A = ini.GetReal(lbfgs_sec, "lbfgs_precon_A", lbfgs.precon_A);
512 lbfgs.precon_mu =
513 ini.GetReal(lbfgs_sec, "lbfgs_precon_mu", lbfgs.precon_mu);
514 lbfgs.precon_rcut =
515 ini.GetReal(lbfgs_sec, "lbfgs_precon_rcut", lbfgs.precon_rcut);
516 }
517 {
519 xtsci.method =
520 toLowerCase(ini.Get("Optimizer", "xtsci_method", xtsci.method));
521 if (ini.HasSection("Xtsci")) {
522 xtsci.method = toLowerCase(ini.Get(
523 "Xtsci", "method", ini.Get("Xtsci", "xtsci_method", xtsci.method)));
524 xtsci.qn_step = toLowerCase(ini.Get("Xtsci", "qn_step", xtsci.qn_step));
525 xtsci.precon = toLowerCase(ini.Get("Xtsci", "precon", xtsci.precon));
526 xtsci.accept = toLowerCase(ini.Get("Xtsci", "accept", xtsci.accept));
527 xtsci.highs =
528 ini.GetBoolean("Xtsci", "highs",
529 ini.GetBoolean("Xtsci", "xtsci_highs", xtsci.highs));
530 xtsci.manifold = toLowerCase(
531 ini.Get("Xtsci", "manifold",
532 ini.Get("Xtsci", "xtsci_manifold", xtsci.manifold)));
533 }
534 xtsci.highs = ini.GetBoolean("Optimizer", "xtsci_highs", xtsci.highs);
536 }
537 if (ini.HasSection("CG")) {
539 ini.GetBoolean(
540 "CG", "cg_no_overshooting",
541 ParametersLoadAccess::optimizer_options(params).cg.no_overshooting);
543 ini.GetBoolean("CG", "cg_knock_out_max_move",
545 .cg.knock_out_max_move);
547 ini.GetBoolean(
548 "CG", "cg_line_search",
549 ParametersLoadAccess::optimizer_options(params).cg.line_search);
551 ini.GetReal(
552 "CG", "cg_line_converged",
553 ParametersLoadAccess::optimizer_options(params).cg.line_converged);
555 ini.GetInteger("CG", "cg_max_iter_before_reset",
557 .cg.max_iter_before_reset);
559 ini.GetInteger("CG", "cg_max_iter_line_search",
561 .cg.line_search_max_iter);
562 }
563 if (ini.HasSection("SD")) {
565 ini.GetReal("SD", "sd_alpha",
568 ini.GetBoolean(
569 "SD", "sd_twopoint",
570 ParametersLoadAccess::optimizer_options(params).sd.two_point);
571 }
572
573 // [Dimer] //
574
576 ini.GetReal("Dimer", "finite_angle",
577 ParametersLoadAccess::dimer_options(params).rotation_angle);
579 ini.GetBoolean("Dimer", "improved",
580 ParametersLoadAccess::dimer_options(params).improved);
582 ini.GetReal("Dimer", "converged_angle",
583 ParametersLoadAccess::dimer_options(params).converged_angle);
585 "Dimer", "max_iterations",
586 ParametersLoadAccess::dimer_options(params).max_iterations);
587 if (auto dimerOpt = magic_enum::enum_cast<OptType>(
588 ini.Get("Dimer", "opt_method", "cg"), magic_enum::case_insensitive);
589 dimerOpt && *dimerOpt != OptType::Unknown && *dimerOpt != OptType::None) {
591 }
593 ini.GetInteger("Dimer", "rotations_min",
594 ParametersLoadAccess::dimer_options(params).rotations_min);
596 ini.GetInteger("Dimer", "rotations_max",
597 ParametersLoadAccess::dimer_options(params).rotations_max);
599 ini.GetReal("Dimer", "torque_min",
600 ParametersLoadAccess::dimer_options(params).torque_min);
602 ini.GetReal("Dimer", "torque_max",
603 ParametersLoadAccess::dimer_options(params).torque_max);
605 "Dimer", "remove_rotation",
606 ParametersLoadAccess::dimer_options(params).remove_rotation);
608 ini.GetReal("Dimer", "lor_residual_tol",
609 ParametersLoadAccess::dimer_options(params).lor_residual_tol);
610 {
611 const auto rotTok =
612 toLowerCase(ini.Get("Dimer", "rotation_backend", "classical"));
614 magic_enum::enum_cast<DimerRotationBackend>(
615 rotTok, magic_enum::case_insensitive)
617 }
618
619 // GP Surrogate Parameters
621 ini.GetBoolean("Surrogate", "use_surrogate", false);
622 if (ParametersLoadAccess::gp_surrogate_options(params).enabled) {
626 }
628 "Surrogate", "gp_uncertainty",
630 if (ini.HasSection("Surrogate")) {
632 magic_enum::enum_cast<PotType>(ini.Get("Surrogate", "potential", ""),
633 magic_enum::case_insensitive)
634 .value_or(PotType::UNKNOWN);
636 throw std::runtime_error("We only support catlearn for GP right now");
637 }
638 }
639 // [CatLearn]
640 if (ini.HasSection("CatLearn")) {
642 ini.Get("CatLearn", "catl_path", "");
644 ini.Get("CatLearn", "model", "catl_model");
646 ini.Get("CatLearn", "prior", "catl_prior");
648 ini.GetBoolean("CatLearn", "use_derivatives", "catl_deriv");
650 ini.GetBoolean("CatLearn", "use_fingerprint", "catl_fingerprint");
651 ParametersLoadAccess::catlearn_options(params).parallel = ini.GetBoolean(
652 "CatLearn", "parallel_hyperparameter_opt", "catl_parallel");
653 }
654 // [ASE_ORCA]
655 if (ini.HasSection("ASE_ORCA")) {
657 ini.Get("ASE_ORCA", "orca_path", "");
659 ini.Get("ASE_ORCA", "nproc", "1");
661 ini.Get("ASE_ORCA", "simpleinput", "");
663 static_cast<int>(ini.GetInteger("ASE_ORCA", "charge", 0));
665 static_cast<int>(ini.GetInteger("ASE_ORCA", "multiplicity", 1));
666 }
667 // [ASE_NWCHEM]
668 if (ini.HasSection("ASE_NWCHEM")) {
670 ini.Get("ASE_NWCHEM", "nwchem_path", "");
672 ini.Get("ASE_NWCHEM", "nproc", "1");
674 ini.Get("ASE_NWCHEM", "mpi_launcher",
675 ParametersLoadAccess::ase_nwchem_options(params).mpi_launcher);
677 ini.Get("ASE_NWCHEM", "multiplicity", "");
679 ini.GetReal("ASE_NWCHEM", "scf_thresh", 1e-5);
681 ini.GetInteger("ASE_NWCHEM", "scf_maxiter", 200);
683 ini.Get("ASE_NWCHEM", "basis",
686 ini.Get("ASE_NWCHEM", "memory",
688 }
689 // [Metatomic]
690 if (ini.HasSection("Metatomic")) {
692 ini.Get("Metatomic", "model_path", "");
694 ini.Get("Metatomic", "device", "cpu");
696 ini.Get("Metatomic", "length_unit", "angstrom");
698 ini.Get("Metatomic", "extensions_directory", "");
700 ini.GetBoolean("Metatomic", "check_consistency", false);
702 ini.GetReal("Metatomic", "uncertainty_threshold", -1.0);
704 ini.Get("Metatomic", "energy_output",
705 ParametersLoadAccess::metatomic_options(params).energy_output);
707 ini.Get("Metatomic", "energy_uncertainty_output",
709 .energy_uncertainty_output);
711 ini.Get("Metatomic", "force_output",
712 ParametersLoadAccess::metatomic_options(params).force_output);
714 ini.GetBoolean("Metatomic", "non_conservative", false);
716 ini.GetBoolean("Metatomic", "random_rotation", false);
718 static_cast<long>(
719 ini.GetInteger("Metatomic", "n_symmetry_rotations", 0));
721 ini.GetBoolean("Metatomic", "deterministic", true);
723 ini.GetBoolean("Metatomic", "deterministic_strict", false);
724 auto &_variant = ParametersLoadAccess::metatomic_options(params).variant;
725 _variant.base = ini.Get("Metatomic", "variant_base", "");
726 _variant.energy = ini.Get("Metatomic", "variant_energy", "");
727 _variant.energy_uncertainty =
728 ini.Get("Metatomic", "variant_energy_uncertainty", "");
729 _variant.force = ini.Get("Metatomic", "variant_force", "");
730 }
731 // [Serve]
732 if (ini.HasSection("Serve")) {
734 "Serve", "host", ParametersLoadAccess::serve_options(params).host);
736 static_cast<uint16_t>(ini.GetInteger(
737 "Serve", "port", ParametersLoadAccess::serve_options(params).port));
738 ParametersLoadAccess::serve_options(params).replicas = static_cast<size_t>(
739 ini.GetInteger("Serve", "replicas",
740 ParametersLoadAccess::serve_options(params).replicas));
742 static_cast<uint16_t>(ini.GetInteger(
743 "Serve", "gateway_port",
744 ParametersLoadAccess::serve_options(params).gateway_port));
746 ini.Get("Serve", "endpoints",
747 ParametersLoadAccess::serve_options(params).endpoints);
748 }
749
750 // GP_NEB only
752 ini.GetBoolean("Surrogate", "gp_linear_path_always",
754 .linear_path_always);
755 // [Lanczos] //
756
758 ini.GetReal("Lanczos", "tolerance",
759 ParametersLoadAccess::lanczos_options(params).tolerance);
761 "Lanczos", "max_iterations",
762 ParametersLoadAccess::lanczos_options(params).max_iterations);
764 ini.GetBoolean("Lanczos", "quit_early",
765 ParametersLoadAccess::lanczos_options(params).quit_early);
766 if (ini.HasValue("Lanczos", "phva_atoms")) {
768 toLowerCase(ini.Get("Lanczos", "phva_atoms", "All"));
769 }
770
771 // [Davidson] //
773 ini.GetReal("Davidson", "tolerance",
776 ini.GetInteger(
777 "Davidson", "max_iterations",
778 ParametersLoadAccess::davidson_options(params).max_iterations);
780 ini.GetBoolean("Davidson", "diagonal_preconditioner",
782 .diagonal_preconditioner);
783 if (ini.HasValue("Davidson", "phva_atoms")) {
785 toLowerCase(ini.Get("Davidson", "phva_atoms", "All"));
786 }
787
788 // [ARTn] //
790 ini.GetReal("ARTn", "push_step_size",
791 ParametersLoadAccess::artn_options(params).push_step_size);
793 ini.GetReal("ARTn", "force_threshold",
794 ParametersLoadAccess::artn_options(params).force_threshold);
796 ini.GetInteger("ARTn", "max_iterations",
797 ParametersLoadAccess::artn_options(params).max_iterations);
798 ParametersLoadAccess::artn_options(params).ninit = ini.GetInteger(
799 "ARTn", "ninit", ParametersLoadAccess::artn_options(params).ninit);
801 ini.Get("ARTn", "nperp_limitation",
802 ParametersLoadAccess::artn_options(params).nperp_limitation);
804 "ARTn", "lanczos_min_size",
805 ParametersLoadAccess::artn_options(params).lanczos_min_size);
806 ParametersLoadAccess::artn_options(params).nsmooth = ini.GetInteger(
807 "ARTn", "nsmooth", ParametersLoadAccess::artn_options(params).nsmooth);
809 "ARTn", "filin", ParametersLoadAccess::artn_options(params).filin);
810
811 // [IRA] //
813 ini.GetReal("IRA", "distance_threshold",
814 ParametersLoadAccess::ira_options(params).distance_threshold);
816 ini.GetReal("IRA", "symmetry_threshold",
817 ParametersLoadAccess::ira_options(params).symmetry_threshold);
818 ParametersLoadAccess::ira_options(params).use_pbc = ini.GetBoolean(
819 "IRA", "use_pbc", ParametersLoadAccess::ira_options(params).use_pbc);
820
821 // [GPR Dimer] //
823 "GPR Dimer", "finite_angle",
824 ParametersLoadAccess::gpr_dimer_options(params).rotation_angle);
826 "GPR Dimer", "converged_angle",
827 ParametersLoadAccess::gpr_dimer_options(params).converged_angle);
829 ini.GetReal(
830 "GPR Dimer", "relaxation_converged_angle",
831 ParametersLoadAccess::gpr_dimer_options(params).relax_conv_angle);
833 static_cast<long>(ini.GetInteger(
834 "GPR Dimer", "max_initial_rotation_iterations",
835 ParametersLoadAccess::gpr_dimer_options(params).init_rotations_max));
837 static_cast<long>(ini.GetInteger(
838 "GPR Dimer", "max_relaxation_rotation_iterations",
839 ParametersLoadAccess::gpr_dimer_options(params).relax_rotations_max));
841 static_cast<long>(ini.GetInteger(
842 "GPR Dimer", "divisor_t_dimer",
843 ParametersLoadAccess::gpr_dimer_options(params).divisor_t_dimer_gp));
845 .max_outer_iterations = static_cast<long>(ini.GetInteger(
846 "GPR Dimer", "max_outer_iterations",
847 ParametersLoadAccess::gpr_dimer_options(params).max_outer_iterations));
849 .max_inner_iterations = static_cast<long>(ini.GetInteger(
850 "GPR Dimer", "max_inner_iterations",
851 ParametersLoadAccess::gpr_dimer_options(params).max_inner_iterations));
853 ini.GetReal(
854 "GPR Dimer", "max_midpoint_displacement",
855 ParametersLoadAccess::gpr_dimer_options(params).midpoint_max_disp);
857 ini.Get("GPR Dimer", "rotation_opt_method",
858 ParametersLoadAccess::gpr_dimer_options(params).rot_opt_method);
860 ini.Get("GPR Dimer", "translation_opt_method",
861 ParametersLoadAccess::gpr_dimer_options(params).trans_opt_method);
863 "GPR Dimer", "active_radius",
864 ParametersLoadAccess::gpr_dimer_options(params).active_radius);
866 ini.GetReal("GPR Dimer", "dimer_separation",
869 ini.GetReal("GPR Dimer", "convex_region_step_size",
872 ini.GetReal("GPR Dimer", "max_step_size",
875 "GPR Dimer", "ratio_at_limit",
876 ParametersLoadAccess::gpr_dimer_options(params).ratio_at_limit);
878 "GPR Dimer", "nogp_initial_rotations",
879 ParametersLoadAccess::gpr_dimer_options(params).init_rot_gp);
881 ini.GetBoolean(
882 "GPR Dimer", "nogp_init_translations",
883 ParametersLoadAccess::gpr_dimer_options(params).init_trans_gp);
885 ini.GetBoolean(
886 "GPR Dimer", "has_many_iterations",
887 ParametersLoadAccess::gpr_dimer_options(params).many_iterations);
888 // GPR Params
890 ini.Get("GPR Dimer", "hyperparameter_opt_method",
892 .gpr_params.hyper_opt_method);
894 ini.GetReal(
895 "GPR Dimer", "gpr_variance",
896 ParametersLoadAccess::gpr_dimer_options(params).gpr_params.sigma2);
898 ini.GetReal("GPR Dimer", "gpr_jitter_variance",
900 .gpr_params.jitter_sigma2);
902 ini.GetReal("GPR Dimer", "gpr_noise_variance",
904 .gpr_params.noise_sigma2);
906 ini.GetReal(
907 "GPR Dimer", "prior_mean",
908 ParametersLoadAccess::gpr_dimer_options(params).gpr_params.prior_mu);
910 ini.GetReal("GPR Dimer", "prior_variance",
912 .gpr_params.prior_sigma2);
914 ini.GetReal(
915 "GPR Dimer", "prior_degrees_of_freedom",
916 ParametersLoadAccess::gpr_dimer_options(params).gpr_params.prior_nu);
917 // GPR Optimization Parameters
919 ini.GetBoolean("GPR Dimer", "check_derivatives",
921 .opt_params.check_derivatives);
923 static_cast<int>(
924 ini.GetInteger("GPR Dimer", "opt_max_iterations",
926 .opt_params.max_iterations));
928 ini.GetReal(
929 "GPR Dimer", "opt_tol_func",
930 ParametersLoadAccess::gpr_dimer_options(params).opt_params.tol_func);
932 ini.GetReal(
933 "GPR Dimer", "opt_tol_sol",
934 ParametersLoadAccess::gpr_dimer_options(params).opt_params.tol_sol);
936 ini.GetReal("GPR Dimer", "opt_lambda_limit",
938 .opt_params.lambda_limit);
940 ini.GetReal("GPR Dimer", "opt_lambda_init",
942 .opt_params.lambda_init);
943 // GPR Debugging Parameters
945 static_cast<int>(
946 ini.GetInteger("GPR Dimer", "report_level",
948 .debug_params.report_level));
950 static_cast<int>(
951 ini.GetInteger("GPR Dimer", "debug_level",
953 .debug_params.debug_level));
955 ini.Get(
956 "GPR Dimer", "debug_output_directory",
957 ParametersLoadAccess::gpr_dimer_options(params).debug_params.out_dir);
959 ini.Get("GPR Dimer", "debug_position_basename",
961 .debug_params.pos_file);
963 ini.Get("GPR Dimer", "debug_energy_basename",
965 .debug_params.energy_file);
967 ini.Get("GPR Dimer", "debug_gradient_basename",
969 .debug_params.grad_file);
972 ini.GetReal("GPR Dimer", "debug_midpoint_offset",
974 .debug_params.offset_mid_point);
976 "GPR Dimer", "debug_y_step",
977 ParametersLoadAccess::gpr_dimer_options(params).debug_params.dy);
979 "GPR Dimer", "debug_z_step",
980 ParametersLoadAccess::gpr_dimer_options(params).debug_params.dz);
981 // GPR Prune
983 ini.GetBoolean("GPR Dimer", "use_prune",
985 .prune_params.use_prune);
987 static_cast<int>(ini.GetInteger(
988 "GPR Dimer", "start_prune_at",
989 ParametersLoadAccess::gpr_dimer_options(params).prune_params.begin));
991 static_cast<int>(ini.GetInteger(
992 "GPR Dimer", "nprune_vals",
993 ParametersLoadAccess::gpr_dimer_options(params).prune_params.n_vals));
995 ini.GetReal("GPR Dimer", "prune_threshold",
997 .prune_params.threshold);
998
999 // [Prefactor] //
1000
1002 "Prefactor", "default_value",
1003 ParametersLoadAccess::prefactor_options(params).default_value);
1005 ini.GetReal("Prefactor", "max_value",
1006 ParametersLoadAccess::prefactor_options(params).max_value);
1008 ini.GetReal("Prefactor", "min_value",
1009 ParametersLoadAccess::prefactor_options(params).min_value);
1011 "Prefactor", "within_radius",
1012 ParametersLoadAccess::prefactor_options(params).within_radius);
1014 ini.GetReal(
1015 "Prefactor", "min_displacement",
1016 ParametersLoadAccess::prefactor_options(params).min_displacement);
1017 ParametersLoadAccess::prefactor_options(params).rate = toLowerCase(
1018 ini.Get("Prefactor", "rate_estimation",
1021 ini.Get("Prefactor", "configuration",
1024 ini.GetBoolean(
1025 "Prefactor", "all_free_atoms",
1026 ParametersLoadAccess::prefactor_options(params).all_free_atoms);
1028 ini.Get("Prefactor", "filter_scheme",
1031 "Prefactor", "filter_fraction",
1032 ParametersLoadAccess::prefactor_options(params).filter_fraction);
1033
1034 // [Hessian] //
1035 // Prefer phva_atoms; accept legacy atom_list when phva_atoms is absent.
1036 if (ini.HasValue("Hessian", "phva_atoms")) {
1038 toLowerCase(ini.Get("Hessian", "phva_atoms", "All"));
1039 } else if (ini.HasValue("Hessian", "atom_list")) {
1041 toLowerCase(ini.Get("Hessian", "atom_list", "All"));
1042 }
1044 "Hessian", "zero_freq_value",
1045 ParametersLoadAccess::hessian_options(params).zero_freq_value);
1047 ini.Get("Hessian", "fd_scheme",
1050 ini.GetBoolean("Hessian", "resume",
1053 ini.Get("Hessian", "checkpoint_path",
1054 ParametersLoadAccess::hessian_options(params).checkpoint_path);
1056 ini.GetBoolean("Hessian", "write_modes",
1057 ParametersLoadAccess::hessian_options(params).write_modes);
1058
1059 // [Nudged Elastic Band] //
1060 const std::string neb_section = "Nudged Elastic Band";
1061
1063 ini.GetInteger(neb_section, "images",
1064 ParametersLoadAccess::neb_options(params).image_count);
1066 ini.GetBoolean(
1067 neb_section, "solid_state",
1068 ParametersLoadAccess::neb_options(params).solid_state.enabled);
1070 ini.GetReal(neb_section, "solid_state_weight",
1071 ParametersLoadAccess::neb_options(params).solid_state.weight);
1073 neb_section, "solid_state_pressure",
1074 ParametersLoadAccess::neb_options(params).solid_state.pressure);
1076 neb_section, "temperature",
1077 ParametersLoadAccess::neb_options(params).quantum_temperature);
1079 neb_section, "tunnel_wall_points",
1080 ParametersLoadAccess::neb_options(params).tunnel_wall_points);
1081 if (ParametersLoadAccess::neb_options(params).tunnel_wall_points < 0) {
1082 throw std::invalid_argument(
1083 "[Nudged Elastic Band] tunnel_wall_points must be 0 or more");
1084 }
1085 ParametersLoadAccess::neb_options(params).max_iterations = ini.GetInteger(
1086 neb_section, "max_iterations",
1087 ParametersLoadAccess::optimizer_options(params).max_iterations);
1089 neb_section, "converged_force",
1090 ParametersLoadAccess::optimizer_options(params).converged_force);
1091 auto neb_optMethod =
1092 magic_enum::enum_cast<OptType>(ini.Get(neb_section, "opt_method", "none"),
1093 magic_enum::case_insensitive)
1094 .value_or(OptType::Unknown);
1095 if (neb_optMethod != OptType::None) {
1096 ParametersLoadAccess::neb_options(params).opt_method = neb_optMethod;
1097 }
1098 ParametersLoadAccess::neb_options(params).mmf_peaks.enabled = ini.GetBoolean(
1099 neb_section, "setup_mmf_peaks",
1100 ParametersLoadAccess::neb_options(params).mmf_peaks.enabled);
1102 neb_section, "mmf_peak_tolerance",
1103 ParametersLoadAccess::neb_options(params).mmf_peaks.tolerance);
1105 ini.GetBoolean(neb_section, "match_endpoints",
1106 ParametersLoadAccess::neb_options(params).match_endpoints);
1107 ParametersLoadAccess::neb_options(params).match_method = toLowerCase(
1108 ini.Get(neb_section, "match_method",
1110
1112 ini.GetReal(neb_section, "spring",
1113 ParametersLoadAccess::neb_options(params).spring.constant);
1115 ini.GetBoolean(
1116 neb_section, "elastic_band",
1117 ParametersLoadAccess::neb_options(params).spring.use_elastic_band);
1119 ini.GetBoolean(
1120 neb_section, "doubly_nudged",
1121 ParametersLoadAccess::neb_options(params).spring.doubly_nudged);
1123 ini.GetBoolean(
1124 neb_section, "doubly_nudged_switching",
1125 ParametersLoadAccess::neb_options(params).spring.use_switching);
1126
1128 ini.GetBoolean(
1129 neb_section, "energy_weighted",
1130 ParametersLoadAccess::neb_options(params).spring.weighting.enabled);
1132 ini.GetReal(
1133 neb_section, "ew_trigger",
1134 ParametersLoadAccess::neb_options(params).spring.weighting.trigger);
1136 ini.GetReal(
1137 neb_section, "ew_ksp_min",
1138 ParametersLoadAccess::neb_options(params).spring.weighting.k_min);
1140 ini.GetReal(
1141 neb_section, "ew_ksp_max",
1142 ParametersLoadAccess::neb_options(params).spring.weighting.k_max);
1143
1144 ParametersLoadAccess::neb_options(params).spring.geometric = ini.GetBoolean(
1145 neb_section, "geometric_spring",
1146 ParametersLoadAccess::neb_options(params).spring.geometric);
1147 ParametersLoadAccess::neb_options(params).band.precon = toLowerCase(
1148 ini.Get(neb_section, "band_precon",
1151 ini.GetReal(neb_section, "band_precon_mu",
1152 ParametersLoadAccess::neb_options(params).band.precon_mu);
1153 ParametersLoadAccess::neb_options(params).band.stepper = toLowerCase(
1154 ini.Get(neb_section, "band_stepper",
1156 ParametersLoadAccess::neb_options(params).spring.om.enabled = ini.GetBoolean(
1157 neb_section, "onsager_machlup",
1158 ParametersLoadAccess::neb_options(params).spring.om.enabled);
1160 ini.GetBoolean(
1161 neb_section, "om_optimize_k",
1162 ParametersLoadAccess::neb_options(params).spring.om.optimize_k);
1164 ini.GetReal(neb_section, "om_k_scale",
1165 ParametersLoadAccess::neb_options(params).spring.om.k_scale);
1167 ini.GetReal(neb_section, "om_k_min",
1168 ParametersLoadAccess::neb_options(params).spring.om.k_min);
1170 ini.GetReal(neb_section, "om_k_max",
1171 ParametersLoadAccess::neb_options(params).spring.om.k_max);
1172
1174 ini.GetBoolean(
1175 neb_section, "climbing_image_method",
1176 ParametersLoadAccess::neb_options(params).climbing_image.enabled);
1178 ini.GetBoolean(neb_section, "climbing_image_converged_only",
1180 .climbing_image.converged_only);
1182 ini.GetReal(
1183 neb_section, "climbing_image_band_slack",
1184 ParametersLoadAccess::neb_options(params).climbing_image.band_slack);
1186 ini.GetBoolean(neb_section, "old_tangent",
1188 .climbing_image.use_old_tangent);
1190 ini.GetReal(neb_section, "ci_after",
1192 .climbing_image.trigger_force);
1194 ini.GetReal(neb_section, "ci_after_rel",
1196 .climbing_image.trigger_factor);
1197
1199 oci.use_mmf = ini.GetBoolean(neb_section, "ci_mmf", oci.use_mmf);
1200 oci.trigger_force =
1201 ini.GetReal(neb_section, "ci_mmf_after", oci.trigger_force);
1202 oci.trigger_factor =
1203 ini.GetReal(neb_section, "ci_mmf_after_rel", oci.trigger_factor);
1204 oci.max_steps = ini.GetInteger(neb_section, "ci_mmf_nsteps", oci.max_steps);
1205 oci.ci_stability_count = ini.GetInteger(
1206 neb_section, "ci_mmf_ci_stability_count", oci.ci_stability_count);
1207 oci.angle_tol = ini.GetReal(neb_section, "ci_mmf_angle", oci.angle_tol);
1208 oci.restore_unhelpful = ini.GetBoolean(
1209 neb_section, "ci_mmf_restore_unhelpful", oci.restore_unhelpful);
1210
1211 auto &zoom = ParametersLoadAccess::neb_options(params).zoom;
1212 zoom.enabled = ini.GetBoolean(neb_section, "zoom_neb", zoom.enabled);
1213 zoom.alpha = ini.GetReal(neb_section, "zoom_alpha", zoom.alpha);
1214 zoom.offset = ini.GetInteger(neb_section, "zoom_offset", zoom.offset);
1215 zoom.mode = magic_enum::enum_cast<neb_options_t::zoom_options_t::Mode>(
1216 ini.Get(neb_section, "zoom_mode",
1217 std::string(magic_enum::enum_name(zoom.mode))),
1218 magic_enum::case_insensitive)
1219 .value_or(zoom.mode);
1220 zoom.activation_threshold =
1221 ini.GetReal(neb_section, "zoom_after", zoom.activation_threshold);
1222 zoom.interpolation =
1223 magic_enum::enum_cast<neb_options_t::zoom_options_t::Interpolation>(
1224 ini.Get(neb_section, "zoom_interpolation",
1225 std::string(magic_enum::enum_name(zoom.interpolation))),
1226 magic_enum::case_insensitive)
1227 .value_or(zoom.interpolation);
1228 zoom.stability_count =
1229 ini.GetInteger(neb_section, "zoom_ci_stability", zoom.stability_count);
1230 zoom.max_iterations =
1231 ini.GetInteger(neb_section, "zoom_max_iterations", zoom.max_iterations);
1232
1234 init.method =
1235 magic_enum::enum_cast<NEBInit>(ini.Get(neb_section, "initializer", ""),
1236 magic_enum::case_insensitive)
1237 .value_or(NEBInit::LINEAR);
1238 init.input_path = ini.Get(neb_section, "initial_path_in", init.input_path);
1239 init.max_iterations =
1240 ini.GetInteger(neb_section, "init_max_iterations", init.max_iterations);
1241 init.nsteps = ini.GetInteger(neb_section, "init_nsteps", init.nsteps);
1242 init.max_move = ini.GetReal(neb_section, "init_max_move", init.max_move);
1243 init.force_tolerance =
1244 ini.GetReal(neb_section, "init_force_threshold", init.force_tolerance);
1245 init.sidpp_alpha =
1246 ini.GetReal(neb_section, "sidpp_growth_alpha", init.sidpp_alpha);
1247 init.sidpp_frontier_tol =
1248 ini.GetReal(neb_section, "sidpp_frontier_tol", init.sidpp_frontier_tol);
1249 init.sidpp_reparam =
1250 ini.GetBoolean(neb_section, "sidpp_reparameterize", init.sidpp_reparam);
1251 init.sidpp_ideal_ksp =
1252 ini.GetBoolean(neb_section, "sidpp_ideal_ksp", init.sidpp_ideal_ksp);
1253 auto neb_ipath_optMethod =
1254 magic_enum::enum_cast<OptType>(
1255 ini.Get(neb_section, "ipath_opt_method", "none"),
1256 magic_enum::case_insensitive)
1257 .value_or(OptType::Unknown);
1258 if (neb_ipath_optMethod != OptType::None) {
1260 neb_ipath_optMethod;
1261 }
1262 init.oversampling =
1263 ini.GetBoolean(neb_section, "oversampling", init.oversampling);
1264 init.oversampling_factor = ini.GetInteger(neb_section, "oversampling_factor",
1265 init.oversampling_factor);
1266
1267 ParametersLoadAccess::neb_options(params).endpoints.minimize = ini.GetBoolean(
1268 neb_section, "minimize_endpoints",
1269 ParametersLoadAccess::neb_options(params).endpoints.minimize);
1271 ini.GetBoolean(
1272 neb_section, "minimize_endpoints_for_ipath",
1273 ParametersLoadAccess::neb_options(params).endpoints.use_path_file);
1274
1275 // [Dynamics] //
1276
1278 "Dynamics", "time_step",
1279 ParametersLoadAccess::dynamics_options(params).time_step_input);
1284 ini.GetReal("Dynamics", "time",
1285 ParametersLoadAccess::dynamics_options(params).time_input);
1289 if (ParametersLoadAccess::dynamics_options(params).time_step > 0.0) {
1291 static_cast<long>(std::floor(
1293 ParametersLoadAccess::dynamics_options(params).time_step +
1294 0.5));
1295 } else {
1297 }
1299 toLowerCase(ini.Get("Dynamics", "thermostat", "andersen"));
1301 "Dynamics", "andersen_alpha",
1302 ParametersLoadAccess::thermostat_options(params).andersen_alpha);
1304 ini.GetReal(
1305 "Dynamics", "andersen_collision_period",
1306 ParametersLoadAccess::thermostat_options(params).andersen_tcol_input);
1311 ini.GetReal("Dynamics", "nose_mass",
1314 ini.GetReal("Dynamics", "langevin_friction",
1316 .langevin_friction_input);
1320 {
1322 th.path_beads = ini.GetInteger("Dynamics", "path_beads", th.path_beads);
1323 th.path_springs =
1324 toLowerCase(ini.Get("Dynamics", "path_springs", th.path_springs));
1325 th.path_eco_omega_max =
1326 ini.GetReal("Dynamics", "path_eco_omega_max", th.path_eco_omega_max);
1327 th.path_gle_file = ini.Get("Dynamics", "path_gle_file", th.path_gle_file);
1328 th.path_pile_tau_input =
1329 ini.GetReal("Dynamics", "path_pile_tau", th.path_pile_tau_input);
1330 const double timeUnit = ParametersLoadAccess::constants(params).timeUnit;
1331 th.path_pile_tau = timeUnit > 0.0 ? th.path_pile_tau_input / timeUnit : 0.0;
1332 th.path_pile_scale =
1333 ini.GetReal("Dynamics", "path_pile_scale", th.path_pile_scale);
1334 const long seed = ini.GetInteger("Dynamics", "path_seed",
1335 static_cast<long>(th.path_seed));
1336 if (seed < 0) {
1337 throw std::invalid_argument("[Dynamics] path_seed must be non-negative");
1338 }
1339 th.path_seed = static_cast<std::uint64_t>(seed);
1340 if (th.path_springs != "trotter" && th.path_springs != "eco") {
1341 throw std::invalid_argument(
1342 "[Dynamics] path_springs must be trotter or eco, not " +
1343 th.path_springs);
1344 }
1345 }
1346
1347 // [Parallel Replica]
1348
1350 ini.GetBoolean(
1351 "Parallel Replica", "stop_after_transition",
1354 ini.GetBoolean("Parallel Replica", "refine_transition",
1356 .refine_transition);
1358 ini.GetBoolean("Parallel Replica", "dephase_loop_stop",
1360 .dephase_loop_stop);
1362 ini.GetReal("Parallel Replica", "dephase_time",
1364 .dephase_time_input);
1370 ini.GetInteger("Parallel Replica", "dephase_loop_max",
1372 .dephase_loop_max);
1375 ini.GetReal("Parallel Replica", "state_check_interval",
1377 .state_check_interval_input);
1383 ini.GetReal("Parallel Replica", "state_save_interval",
1385 .state_check_interval_input);
1391 ini.GetReal("Parallel Replica", "post_transition_time",
1393 .corr_time_input);
1397
1398 // [Temperature Accelerated Dynamics] //
1399
1401 ini.GetReal("TAD", "low_temperature",
1402 ParametersLoadAccess::tad_options(params).low_temperature);
1404 ini.GetReal("TAD", "min_prefactor",
1405 ParametersLoadAccess::tad_options(params).min_prefactor);
1407 ini.GetReal("TAD", "confidence",
1408 ParametersLoadAccess::tad_options(params).confidence);
1409
1410 // [Replica Exchange] //
1411
1414 toLowerCase(ini.Get("Replica Exchange", "temperature_distribution",
1418 ini.GetInteger(
1419 "Replica Exchange", "replicas",
1422 ini.GetInteger("Replica Exchange", "exchange_trials",
1424 .exchange_trials);
1426 ini.GetReal("Replica Exchange", "sampling_time",
1428 .sampling_time_input);
1434 ini.GetReal("Replica Exchange", "temperature_low",
1435 ParametersLoadAccess::main_options(params).temperature);
1437 ini.GetReal("Replica Exchange", "temperature_high",
1439 .temperature_high);
1441 ini.GetReal("Replica Exchange", "exchange_period",
1443 .exchange_period_input);
1448
1449 // [Hyperdynamics] //
1450
1452 ini.GetReal(
1453 "Hyperdynamics", "bb_rmd_time",
1454 ParametersLoadAccess::hyperdynamics_options(params).rmd_time_input);
1459 toLowerCase(ini.Get(
1460 "Hyperdynamics", "bb_boost_atomlist",
1463 ini.GetReal("Hyperdynamics", "bb_dvmax",
1466 ini.GetReal("Hyperdynamics", "bb_stretch_threshold",
1469 ini.GetReal("Hyperdynamics", "bb_ds_curvature",
1472 ini.GetReal("Hyperdynamics", "bb_rcut",
1475 toLowerCase(ini.Get(
1476 "Hyperdynamics", "bias_potential",
1478
1479 // [Saddle Search] //
1480
1482 ini.Get("Saddle Search", "method",
1485 toLowerCase(ini.Get(
1486 "Saddle Search", "min_mode_method",
1489 ini.GetReal("Saddle Search", "displace_magnitude",
1491 .displace_magnitude);
1493 ini.GetReal(
1494 "Saddle Search", "displace_radius",
1495 ParametersLoadAccess::saddle_search_options(params).displace_radius);
1497 "Saddle Search", "max_energy",
1500 ini.GetInteger(
1501 "Saddle Search", "max_iterations",
1502 ParametersLoadAccess::optimizer_options(params).max_iterations);
1505 ini.GetBoolean("Saddle Search", "nonnegative_displacement_abort",
1507 .nonnegative_displacement_abort);
1509 ini.GetReal("Saddle Search", "max_single_displace",
1511 .max_single_displace);
1513 ini.GetReal(
1514 "Saddle Search", "converged_force",
1515 ParametersLoadAccess::optimizer_options(params).converged_force);
1517 ini.GetReal(
1518 "Saddle Search", "perp_force_ratio",
1519 ParametersLoadAccess::saddle_search_options(params).perp_force_ratio);
1521 toLowerCase(ini.Get("Saddle Search", "client_displace_type",
1524 ini.GetInteger("Saddle Search", "nonlocal_count_abort",
1526 .nonlocal_count_abort);
1528 ini.GetReal("Saddle Search", "nonlocal_distance_abort",
1530 .nonlocal_distance_abort);
1531 if (params.saddle_search_options().displace_type !=
1543 }
1544 // Parse comma-separated atom list
1545 {
1546 std::string atomListStr =
1547 ini.Get("Saddle Search", "displace_atom_list", "");
1548 if (!atomListStr.empty()) {
1549 std::stringstream ss(atomListStr);
1550 std::string token;
1551 while (std::getline(ss, token, ',')) {
1552 size_t start = token.find_first_not_of(" \t");
1553 size_t end = token.find_last_not_of(" \t");
1554 if (start != std::string::npos) {
1556 .displace_atom_list.push_back(
1557 std::stol(token.substr(start, end - start + 1)));
1558 }
1559 }
1560 }
1561 }
1563 ini.GetBoolean("Saddle Search", "confine_positive",
1565 .confine_positive.enabled);
1567 .confine_positive.enabled) {
1570 ini.GetBoolean("Saddle Search", "bowl_breakout",
1572 .confine_positive.bowl_breakout);
1575 ini.GetInteger("Saddle Search", "bowl_active_atoms",
1577 .confine_positive.bowl_active);
1580 ini.GetReal("Saddle Search", "confine_positive_min_move",
1582 .confine_positive.min_force);
1585 ini.GetReal("Saddle Search", "confine_positive_scale_ratio",
1587 .confine_positive.scale_ratio);
1589 ini.GetReal("Saddle Search", "confine_positive_boost",
1591 .confine_positive.boost);
1594 ini.GetInteger("Saddle Search", "confine_positive_min_active",
1596 .confine_positive.min_active);
1597 }
1601 ini.GetReal("Saddle Search", "dynamics_temperature",
1603 .dynamics.temperature);
1606 ini.GetReal("Saddle Search", "dynamics_state_check_interval",
1608 .dynamics.state_check_interval_input);
1616 ini.GetReal("Saddle Search", "dynamics_record_interval",
1618 .dynamics.record_interval_input);
1625 ini.GetBoolean("Saddle Search", "dynamics_linear_interpolation",
1627 .dynamics.linear_interpolation);
1629 ini.GetBoolean(
1630 "Saddle Search", "remove_rotation",
1631 ParametersLoadAccess::saddle_search_options(params).remove_rotation);
1634 ini.GetReal("Saddle Search", "dynamics_max_init_curvature",
1636 .dynamics.max_init_curvature);
1639 ini.GetReal("Saddle Search", "zero_mode_abort_curvature",
1641 .zero_mode_abort_curvature);
1643 prfo.enabled = ini.GetBoolean("Saddle Search", "prfo_refine", prfo.enabled);
1644 prfo.force = ini.GetReal("Saddle Search", "prfo_refine_force", prfo.force);
1645 prfo.max_iterations = ini.GetInteger(
1646 "Saddle Search", "prfo_refine_max_iterations", prfo.max_iterations);
1647 {
1649 irc.after = ini.GetBoolean("Saddle Search", "irc_after", irc.after);
1650 irc.step_size =
1651 ini.GetReal("Saddle Search", "irc_step_size", irc.step_size);
1652 irc.converged_force = ini.GetReal("Saddle Search", "irc_converged_force",
1653 irc.converged_force);
1654 irc.max_steps =
1655 ini.GetInteger("Saddle Search", "irc_max_steps", irc.max_steps);
1656 }
1657
1658 // [Basin Hopping] //
1659
1661 ini.GetReal(
1662 "Basin Hopping", "displacement",
1663 ParametersLoadAccess::basin_hopping_options(params).displacement);
1665 ini.GetReal("Basin Hopping", "push_apart_distance",
1667 .push_apart_distance);
1670 ini.GetReal("Basin Hopping", "initial_random_structure_probability",
1672 .initial_random_structure_probability);
1674 ini.GetInteger("Basin Hopping", "steps",
1677 ini.GetInteger(
1678 "Basin Hopping", "quenching_steps",
1679 ParametersLoadAccess::basin_hopping_options(params).quenching_steps);
1681 ini.GetBoolean("Basin Hopping", "single_atom_displace",
1683 .single_atom_displace);
1685 ini.GetBoolean("Basin Hopping", "significant_structure",
1687 .significant_structure);
1689 toLowerCase(ini.Get("Basin Hopping", "displacement_algorithm",
1692 if (params.basin_hopping_options().displacement_algorithm != "standard" &&
1693 params.basin_hopping_options().displacement_algorithm != "linear" &&
1694 params.basin_hopping_options().displacement_algorithm != "quadratic") {
1695 EONC_LOG_ERROR("unknown displacement_algorithm {}",
1697 .displacement_algorithm);
1698 error = 1;
1699 }
1702 toLowerCase(ini.Get("Basin Hopping", "displacement_distribution",
1705 if (params.basin_hopping_options().displacement_distribution != "uniform" &&
1706 params.basin_hopping_options().displacement_distribution != "gaussian") {
1707 EONC_LOG_ERROR("unknown displacement_distribution {}",
1709 .displacement_distribution);
1710 error = 1;
1711 }
1713 ini.GetReal(
1714 "Basin Hopping", "swap_probability",
1715 ParametersLoadAccess::basin_hopping_options(params).swap_probability);
1717 "Basin Hopping", "jump_max",
1720 ini.GetInteger(
1721 "Basin Hopping", "jump_steps",
1724 ini.GetBoolean("Basin Hopping", "adjust_displacement",
1726 .adjust_displacement);
1728 ini.GetInteger(
1729 "Basin Hopping", "adjust_period",
1730 ParametersLoadAccess::basin_hopping_options(params).adjust_period);
1732 ini.GetReal(
1733 "Basin Hopping", "adjust_fraction",
1734 ParametersLoadAccess::basin_hopping_options(params).adjust_fraction);
1736 ini.GetReal(
1737 "Basin Hopping", "target_ratio",
1738 ParametersLoadAccess::basin_hopping_options(params).target_ratio);
1740 ini.GetBoolean(
1741 "Basin Hopping", "write_unique",
1742 ParametersLoadAccess::basin_hopping_options(params).write_unique);
1744 "Basin Hopping", "stop_energy",
1746
1747 // [Global Optimization] //
1748
1750 .move_method = toLowerCase(ini.Get(
1751 "Global Optimization", "move_method",
1754 toLowerCase(
1755 ini.Get("Global Optimization", "decision_method",
1757 .decision_method));
1758 if (params.global_optimization_options().decision_method != "npew" &&
1759 params.global_optimization_options().decision_method != "boltzmann") {
1760 EONC_LOG_ERROR("unknown decision_method {}",
1762 .decision_method);
1763 error = 1;
1764 }
1766 ini.GetInteger(
1767 "Global Optimization", "steps",
1770 "Global Optimization", "beta",
1773 "Global Optimization", "alpha",
1776 ini.GetInteger(
1777 "Global Optimization", "mdmin",
1780 ini.GetReal("Global Optimization", "target_energy",
1782 .target_energy);
1783
1784 // [BGSD] //
1785
1786 ParametersLoadAccess::bgsd_options(params).alpha = ini.GetReal(
1787 "BGSD", "alpha", ParametersLoadAccess::bgsd_options(params).alpha);
1788 ParametersLoadAccess::bgsd_options(params).beta = ini.GetReal(
1789 "BGSD", "beta", ParametersLoadAccess::bgsd_options(params).beta);
1791 ini.GetReal("BGSD", "gradientfinitedifference",
1793 .gradient_finite_difference);
1795 ini.GetReal(
1796 "BGSD", "grad2energyconvergence",
1797 ParametersLoadAccess::bgsd_options(params).grad2energy_convergence);
1799 ini.GetReal(
1800 "BGSD", "grad2forceconvergence",
1801 ParametersLoadAccess::bgsd_options(params).grad2force_convergence);
1802
1803 // [Monte Carlo] //
1804
1806 ini.GetReal("Monte Carlo", "step_size",
1808 ParametersLoadAccess::monte_carlo_options(params).steps = static_cast<int>(
1809 ini.GetInteger("Monte Carlo", "steps",
1811
1812 // [Instanton] //
1813 {
1815 o.mode = ini.Get("Instanton", "mode", o.mode);
1816 o.reactant_filename =
1817 ini.Get("Instanton", "reactant_filename", o.reactant_filename);
1818 o.product_filename =
1819 ini.Get("Instanton", "product_filename", o.product_filename);
1820 o.initial_path = ini.Get("Instanton", "initial_path", o.initial_path);
1821 o.initial_ring = ini.Get("Instanton", "initial_ring", o.initial_ring);
1822 o.physical_bath_filename = ini.Get("Instanton", "physical_bath_filename",
1823 o.physical_bath_filename);
1824 o.beads = ini.GetInteger("Instanton", "beads", o.beads);
1825 o.beta_hbar_omega =
1826 ini.GetReal("Instanton", "beta_hbar_omega", o.beta_hbar_omega);
1827 o.max_iterations =
1828 ini.GetInteger("Instanton", "max_iterations", o.max_iterations);
1829 o.force_tolerance =
1830 ini.GetReal("Instanton", "force_tolerance", o.force_tolerance);
1831 o.hessian_stride =
1832 ini.GetInteger("Instanton", "hessian_stride", o.hessian_stride);
1833 o.saddle_filename =
1834 ini.Get("Instanton", "saddle_filename", o.saddle_filename);
1835 o.temperature = ini.GetReal("Instanton", "temperature", o.temperature);
1836 o.temperatures.clear();
1837 {
1838 const std::string list = ini.Get("Instanton", "temperatures", "");
1839 std::stringstream ss(list);
1840 std::string token;
1841 while (std::getline(ss, token, ',')) {
1842 const size_t start = token.find_first_not_of(" \t");
1843 const size_t end = token.find_last_not_of(" \t");
1844 if (start == std::string::npos) {
1845 continue;
1846 }
1847 try {
1848 o.temperatures.push_back(
1849 std::stod(token.substr(start, end - start + 1)));
1850 } catch (const std::exception &) {
1851 throw std::invalid_argument(
1852 "[Instanton] temperatures must be comma-separated kelvin "
1853 "values, not " +
1854 token);
1855 }
1856 }
1857 }
1858 o.half_ring = ini.GetBoolean("Instanton", "half_ring", o.half_ring);
1859 o.symmetrize = ini.GetBoolean("Instanton", "symmetrize", o.symmetrize);
1860 o.initial_hessians =
1861 ini.Get("Instanton", "initial_hessians", o.initial_hessians);
1862 if (o.initial_hessians != "saddle" &&
1863 o.initial_hessians != "finite_difference") {
1864 throw std::invalid_argument("[Instanton] initial_hessians must be saddle "
1865 "or finite_difference, not " +
1866 o.initial_hessians);
1867 }
1868 o.newton_limit =
1869 ini.GetInteger64("Instanton", "newton_limit", o.newton_limit);
1870 if (o.newton_limit < 0) {
1871 throw std::invalid_argument(
1872 "[Instanton] newton_limit must be nonnegative");
1873 }
1874 o.reactant_hessian_filename = ini.Get(
1875 "Instanton", "reactant_hessian_filename", o.reactant_hessian_filename);
1876 o.saddle_hessian_filename = ini.Get("Instanton", "saddle_hessian_filename",
1877 o.saddle_hessian_filename);
1878 o.lanczos_step = ini.GetReal("Instanton", "lanczos_step", o.lanczos_step);
1879 if (!(o.lanczos_step > 0.0) || !std::isfinite(o.lanczos_step)) {
1880 throw std::invalid_argument("[Instanton] lanczos_step must be finite and "
1881 "positive in sqrt(amu) Angstrom");
1882 }
1883 o.physical_hessian_step = ini.GetReal("Instanton", "physical_hessian_step",
1884 o.physical_hessian_step);
1885 if (!(o.physical_hessian_step > 0.0) ||
1886 !std::isfinite(o.physical_hessian_step)) {
1887 throw std::invalid_argument(
1888 "[Instanton] physical_hessian_step must be finite and positive "
1889 "in sqrt(amu) Angstrom");
1890 }
1891 o.energy_shift = ini.GetReal("Instanton", "energy_shift", o.energy_shift);
1892 o.discretization.clear();
1893 {
1894 const std::string list = ini.Get("Instanton", "discretization", "");
1895 std::stringstream ss(list);
1896 std::string token;
1897 while (std::getline(ss, token, ',')) {
1898 const size_t start = token.find_first_not_of(" \t");
1899 const size_t end = token.find_last_not_of(" \t");
1900 if (start == std::string::npos) {
1901 continue;
1902 }
1903 try {
1904 o.discretization.push_back(
1905 std::stod(token.substr(start, end - start + 1)));
1906 } catch (const std::exception &) {
1907 throw std::invalid_argument(
1908 "[Instanton] discretization must be comma-separated positive "
1909 "link weights, not " +
1910 token);
1911 }
1912 }
1913 }
1914 o.friction = toLowerCase(ini.Get("Instanton", "friction", o.friction));
1915 if (o.friction != "none" && o.friction != "implicit" &&
1916 o.friction != "explicit") {
1917 throw std::invalid_argument(
1918 "[Instanton] friction must be none, implicit or explicit, not " +
1919 o.friction);
1920 }
1921 o.friction_eta = ini.GetReal("Instanton", "friction_eta", o.friction_eta);
1922 {
1923 const std::string list = ini.Get("Instanton", "friction_eta_beads", "");
1924 o.friction_eta_beads.clear();
1925 size_t start = 0;
1926 while (start < list.size()) {
1927 const size_t comma = list.find(',', start);
1928 const std::string token =
1929 list.substr(start, comma == std::string::npos ? std::string::npos
1930 : comma - start);
1931 if (!token.empty()) {
1932 try {
1933 o.friction_eta_beads.push_back(std::stod(token));
1934 } catch (const std::exception &) {
1935 throw std::invalid_argument(
1936 "[Instanton] friction_eta_beads must be comma-separated "
1937 "numbers, not " +
1938 token);
1939 }
1940 }
1941 if (comma == std::string::npos) {
1942 break;
1943 }
1944 start = comma + 1;
1945 }
1946 }
1947 o.collapse_fraction =
1948 ini.GetReal("Instanton", "collapse_fraction", o.collapse_fraction);
1949 if (!(o.collapse_fraction >= 0.0 && o.collapse_fraction < 1.0)) {
1950 throw std::invalid_argument(
1951 "[Instanton] collapse_fraction must be in [0, 1)");
1952 }
1953 o.rotation_zero_fraction = ini.GetReal(
1954 "Instanton", "rotation_zero_fraction", o.rotation_zero_fraction);
1955 if (!(o.rotation_zero_fraction > 0.0)) {
1956 throw std::invalid_argument(
1957 "[Instanton] rotation_zero_fraction must be positive");
1958 }
1959 o.bead_ladder = ini.GetBoolean("Instanton", "bead_ladder", o.bead_ladder);
1960 o.hessian_final = ini.Get("Instanton", "hessian_final", o.hessian_final);
1961 o.springs = toLowerCase(ini.Get("Instanton", "springs", o.springs));
1962 if (o.springs != "trotter" && o.springs != "eco") {
1963 throw std::invalid_argument(
1964 "[Instanton] springs must be trotter or eco, not " + o.springs);
1965 }
1966 if (o.mode != "splitting" && o.mode != "rate") {
1967 throw std::invalid_argument("[Instanton] mode must be splitting or rate, "
1968 "not " +
1969 o.mode);
1970 }
1971 o.pi_planes = ini.GetInteger("Instanton", "pi_planes", o.pi_planes);
1972 o.pi_beads = ini.GetInteger("Instanton", "pi_beads", o.pi_beads);
1973 o.pi_equilibration_steps = ini.GetInteger(
1974 "Instanton", "pi_equilibration_steps", o.pi_equilibration_steps);
1975 o.pi_sampling_steps =
1976 ini.GetInteger("Instanton", "pi_sampling_steps", o.pi_sampling_steps);
1977 o.pi_time_step = ini.GetReal("Instanton", "pi_time_step", o.pi_time_step);
1978 o.pi_thermostat =
1979 toLowerCase(ini.Get("Instanton", "pi_thermostat", o.pi_thermostat));
1980 o.pi_gle_file = ini.Get("Instanton", "pi_gle_file", o.pi_gle_file);
1981 o.pi_pile_tau = ini.GetReal("Instanton", "pi_pile_tau", o.pi_pile_tau);
1982 o.pi_pile_scale =
1983 ini.GetReal("Instanton", "pi_pile_scale", o.pi_pile_scale);
1984 o.pi_seed = ini.GetInteger("Instanton", "pi_seed", o.pi_seed);
1985 o.pi_direction =
1986 toLowerCase(ini.Get("Instanton", "pi_direction", o.pi_direction));
1987 o.pi_reactant_extent =
1988 ini.GetReal("Instanton", "pi_reactant_extent", o.pi_reactant_extent);
1989 o.pi_recrossing_parents = ini.GetInteger(
1990 "Instanton", "pi_recrossing_parents", o.pi_recrossing_parents);
1991 o.pi_recrossing_children = ini.GetInteger(
1992 "Instanton", "pi_recrossing_children", o.pi_recrossing_children);
1993 o.pi_recrossing_time =
1994 ini.GetReal("Instanton", "pi_recrossing_time", o.pi_recrossing_time);
1995 o.pi_recrossing_spacing = ini.GetInteger(
1996 "Instanton", "pi_recrossing_spacing", o.pi_recrossing_spacing);
1998 }
1999
2000 // [OH_TST] //
2001
2003 ini.Get("OH_TST", "reactant_filename",
2004 ParametersLoadAccess::oh_tst_options(params).reactant_filename);
2006 ini.Get("OH_TST", "product_filename",
2007 ParametersLoadAccess::oh_tst_options(params).product_filename);
2009 ini.GetReal("OH_TST", "time_step",
2010 ParametersLoadAccess::oh_tst_options(params).time_step);
2012 ini.GetInteger("OH_TST", "equil_steps",
2013 ParametersLoadAccess::oh_tst_options(params).equil_steps);
2015 ini.GetInteger("OH_TST", "sample_steps",
2016 ParametersLoadAccess::oh_tst_options(params).sample_steps);
2018 ini.GetInteger("OH_TST", "max_planes",
2019 ParametersLoadAccess::oh_tst_options(params).max_planes);
2021 ini.GetReal("OH_TST", "plane_mass",
2022 ParametersLoadAccess::oh_tst_options(params).plane_mass);
2024 ini.GetReal("OH_TST", "alpha_rot",
2025 ParametersLoadAccess::oh_tst_options(params).alpha_rot);
2027 ini.GetReal("OH_TST", "plane_time_step",
2028 ParametersLoadAccess::oh_tst_options(params).plane_time_step);
2029 ParametersLoadAccess::oh_tst_options(params).ds_max = ini.GetReal(
2030 "OH_TST", "ds_max", ParametersLoadAccess::oh_tst_options(params).ds_max);
2032 ini.GetReal("OH_TST", "dtheta_max",
2033 ParametersLoadAccess::oh_tst_options(params).dtheta_max);
2035 ini.GetReal("OH_TST", "force_tol",
2036 ParametersLoadAccess::oh_tst_options(params).force_tol);
2037 ParametersLoadAccess::oh_tst_options(params).s_init = ini.GetReal(
2038 "OH_TST", "s_init", ParametersLoadAccess::oh_tst_options(params).s_init);
2040 ini.GetInteger(
2041 "OH_TST", "reactant_md_steps",
2042 ParametersLoadAccess::oh_tst_options(params).reactant_md_steps);
2044 ini.Get("OH_TST", "symmetry_products",
2045 ParametersLoadAccess::oh_tst_options(params).symmetry_products);
2047 ini.GetReal("OH_TST", "max_delta_a",
2048 ParametersLoadAccess::oh_tst_options(params).max_delta_a);
2050 ini.Get("OH_TST", "thermostat",
2053 ini.Get("OH_TST", "gle_a_file",
2054 ParametersLoadAccess::oh_tst_options(params).gle_a_file);
2056 ini.GetBoolean("OH_TST", "pmf_scan",
2057 ParametersLoadAccess::oh_tst_options(params).pmf_scan);
2059 ini.GetInteger("OH_TST", "scan_planes",
2060 ParametersLoadAccess::oh_tst_options(params).scan_planes);
2061
2062 return error;
2063}
#define EONC_LOG_ERROR(...)
Definition EonLogger.h:328
#define EONC_LOG_WARNING(...)
Definition EonLogger.h:322
const gp_surrogate_options_t & gp_surrogate_options() const
const potential_options_t & potential_options() const
const saddle_search_options_t & saddle_search_options() const
const global_optimization_options_t & global_optimization_options() const
const basin_hopping_options_t & basin_hopping_options() const
const char DISP_RANDOM[]
Definition EpiCenters.h:24
const char DISP_LISTED_ATOMS[]
Definition EpiCenters.h:25
const char DISP_NOT_FCC_OR_HCP[]
Definition EpiCenters.h:21
const char DISP_MIN_COORDINATED[]
Definition EpiCenters.h:22
const char DISP_LOAD[]
Definition EpiCenters.h:20
const char DISP_LAST_ATOM[]
Definition EpiCenters.h:23
std::string error()
Definition DynLib.h:82
void set_write_con_forces(bool enabled) noexcept
Whether written .con frames carry "Forces of Component" sections.
double random(long newSeed=0)
static main_options_t & main_options(Parameters &p)
static gp_surrogate_options_t & gp_surrogate_options(Parameters &p)
static lanczos_options_t & lanczos_options(Parameters &p)
static ase_nwchem_options_t & ase_nwchem_options(Parameters &p)
static hyperdynamics_options_t & hyperdynamics_options(Parameters &p)
static monte_carlo_options_t & monte_carlo_options(Parameters &p)
static xtb_options_t & xtb_options(Parameters &p)
static socket_nwchem_options_t & socket_nwchem_options(Parameters &p)
static replica_exchange_options_t & replica_exchange_options(Parameters &p)
static dftd_options_t & dftd_options(Parameters &p)
static ase_orca_options_t & ase_orca_options(Parameters &p)
static ira_options_t & ira_options(Parameters &p)
static oh_tst_options_t & oh_tst_options(Parameters &p)
static gpr_dimer_options_t & gpr_dimer_options(Parameters &p)
static prefactor_options_t & prefactor_options(Parameters &p)
static bgsd_options_t & bgsd_options(Parameters &p)
static ams_options_t & ams_options(Parameters &p)
static tad_options_t & tad_options(Parameters &p)
static artn_options_t & artn_options(Parameters &p)
static expr_options_t & expr_options(Parameters &p)
static global_optimization_options_t & global_optimization_options(Parameters &p)
static mopac_options_t & mopac_options(Parameters &p)
static metatomic_options_t & metatomic_options(Parameters &p)
static davidson_options_t & davidson_options(Parameters &p)
static basin_hopping_options_t & basin_hopping_options(Parameters &p)
static parallel_replica_options_t & parallel_replica_options(Parameters &p)
static catlearn_options_t & catlearn_options(Parameters &p)
static zbl_options_t & zbl_options(Parameters &p)
struct eonc::ams_options_t::env_t env
bool diagonal_preconditioner
Heuristic | (H v)_i / v_i | preconditioner (not true diag(H); off by default).
std::string phva_atoms
PHVA mobile/active set for the Ritz space; "All" = all free atoms.
struct eonc::gpr_dimer_options_t::prune_params_t prune_params
struct eonc::gpr_dimer_options_t::gpr_params_t gpr_params
struct eonc::gpr_dimer_options_t::debug_params_t debug_params
struct eonc::gpr_dimer_options_t::opt_params_t opt_params
struct eonc::metatomic_options_t::variants_t variant
double band_slack
When converged_only is on, the rest of the band may still be this many times the force tolerance.
struct eonc::neb_options_t::climbing_image_options_t::hybrid_dimer_t ocineb
double pressure
Hydrostatic pressure in eV/Angstrom^3.
struct eonc::neb_options_t::spring_options_t::energy_weighting_t weighting
bool geometric
Parallel force k (d_next^2 - d_prev^2).
struct eonc::neb_options_t::spring_options_t::onsager_machlup_t om
std::string match_method
"ira" uses IRACompare. "hungarian" is accepted and falls back to ira.
struct eonc::neb_options_t::climbing_image_options_t climbing_image
struct eonc::neb_options_t::band_options_t band
struct eonc::neb_options_t::endpoint_options_t endpoints
struct eonc::neb_options_t::spring_options_t spring
struct eonc::neb_options_t::solid_state_options_t solid_state
double quantum_temperature
Temperature in kelvin for the harmonic quantum free-energy profile.
bool match_endpoints
Permute+rotate the reactant onto the product before interpolation.
long tunnel_wall_points
Force calls past each end minimum of the converged band, along its end segment continued outward,...
struct eonc::neb_options_t::path_initialization_t initialization
struct eonc::neb_options_t::mmf_peak_options_t mmf_peaks
struct eonc::optimizer_options_t::refine_t refine
bool thread_safe
When false, NEB/dimer/process_search never share one Potential across threads, even if the backend re...
struct eonc::saddle_search_options_t::dynamics_t dynamics
std::vector< long > displace_atom_list
struct eonc::saddle_search_options_t::confine_positive_t confine_positive
struct eonc::saddle_search_options_t::irc_t irc

◆ load_json()

int eonc::config::load_json ( std::string_view json_str,
Parameters & params )

Load Parameters from a JSON string. Returns 0 on success.

Definition at line 999 of file ParametersJSON.cpp.

999 {
1000 try {
1001 auto j = json::parse(json_str);
1002 from_json(j, params);
1003 return 0;
1004 } catch (const json::exception &e) {
1005 return 1;
1006 } catch (const std::invalid_argument &) {
1007 return 1;
1008 }
1009}
void from_json(const json &j, Parameters &p)
Deserialize JSON into Parameters, then resolve computed fields.

◆ lowerCopy()

std::string eonc::config::lowerCopy ( std::string value)
static

Definition at line 414 of file ParametersJSON.cpp.

414 {
415 for (char &ch : value) {
416 ch = static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
417 }
418 return value;
419}

◆ opt_from_ssot()

OptType eonc::config::opt_from_ssot ( std::string_view m)

Definition at line 88 of file ParametersSSOT.cpp.

88 {
89 if (m == "cg")
90 return OptType::CG;
91 if (m == "lbfgs")
92 return OptType::LBFGS;
93 if (m == "qm" || m == "quickmin")
94 return OptType::QM;
95 if (m == "sd")
96 return OptType::SD;
97 if (m == "fire")
98 return OptType::FIRE;
99 if (m == "xtsci")
100 return OptType::XTSCI;
101 return OptType::CG;
102}

◆ pot_from_ssot()

PotType eonc::config::pot_from_ssot ( std::string_view pot)

Definition at line 66 of file ParametersSSOT.cpp.

66 {
67 if (pot == "lj")
68 return PotType::LJ;
69 if (pot == "eam_al")
70 return PotType::EAM_AL;
71 if (pot == "emt")
72 return PotType::EMT;
73 if (pot == "lammps")
74 return PotType::LAMMPS;
75 if (pot == "morse_pt")
76 return PotType::MORSE_PT;
77 if (pot == "metatomic")
78 return PotType::METATOMIC;
79 if (pot == "xtb")
80 return PotType::XTB;
81 if (pot == "rgpot")
82 return PotType::RGPOT;
83 if (pot == "ext_pot")
84 return PotType::EXT_POT;
85 return PotType::LJ;
86}

◆ readBathKeys()

void eonc::config::readBathKeys ( const json & s,
Parameters & p )
static

Definition at line 478 of file ParametersJSON.cpp.

478 {
480 if (s.contains("thermostat")) {
481 th.kind = lowerCopy(s.at("thermostat").get<std::string>());
482 }
483 if (s.contains("kind")) {
484 th.kind = lowerCopy(s.at("kind").get<std::string>());
485 }
486 JSON_OPT(s, "andersen_alpha", th.andersen_alpha);
487 JSON_OPT(s, "andersen_collision_period", th.andersen_tcol_input);
488 JSON_OPT(s, "nose_mass", th.nose_mass);
489 JSON_OPT(s, "langevin_friction", th.langevin_friction_input);
491}
static void readPathIntegralKeys(const json &s, Parameters &p)

◆ readPathIntegralKeys()

void eonc::config::readPathIntegralKeys ( const json & s,
Parameters & p )
static

Definition at line 454 of file ParametersJSON.cpp.

454 {
456 JSON_OPT(s, "path_beads", th.path_beads);
457 if (s.contains("path_springs")) {
458 th.path_springs = lowerCopy(s.at("path_springs").get<std::string>());
459 if (th.path_springs != "trotter" && th.path_springs != "eco") {
460 throw std::invalid_argument(
461 "[Dynamics] path_springs must be trotter or eco, not " +
462 th.path_springs);
463 }
464 }
465 JSON_OPT(s, "path_eco_omega_max", th.path_eco_omega_max);
466 JSON_OPT(s, "path_gle_file", th.path_gle_file);
467 JSON_OPT(s, "path_pile_tau", th.path_pile_tau_input);
468 JSON_OPT(s, "path_pile_scale", th.path_pile_scale);
469 if (s.contains("path_seed")) {
470 const long seed = s.at("path_seed").get<long>();
471 if (seed < 0) {
472 throw std::invalid_argument("[Dynamics] path_seed must be non-negative");
473 }
474 th.path_seed = static_cast<std::uint64_t>(seed);
475 }
476}

◆ ssot_has_field()

bool eonc::config::ssot_has_field ( const char * section,
const char * key )

Return true if section‍/*key* (snake_case INI name) is declared in the Cap'n Proto L0 catalog for covered groups.

Definition at line 264 of file ParametersSSOT.cpp.

264 {
265 if (!section || !key)
266 return false;
267 std::string id = std::string(section) + "." + key;
268 return field_index().count(id) > 0;
269}

◆ temperaturesFromJson()

std::vector< double > eonc::config::temperaturesFromJson ( const json & value)
static

Definition at line 421 of file ParametersJSON.cpp.

421 {
422 if (value.is_array()) {
423 return value.get<std::vector<double>>();
424 }
425 if (!value.is_string()) {
426 throw std::invalid_argument(
427 "[Instanton] temperatures must be a list or a comma-separated "
428 "string");
429 }
430 std::vector<double> out;
431 std::stringstream ss(value.get<std::string>());
432 std::string token;
433 while (std::getline(ss, token, ',')) {
434 const size_t start = token.find_first_not_of(" \t");
435 const size_t end = token.find_last_not_of(" \t");
436 if (start == std::string::npos) {
437 continue;
438 }
439 try {
440 out.push_back(std::stod(token.substr(start, end - start + 1)));
441 } catch (const std::exception &) {
442 throw std::invalid_argument(
443 "[Instanton] temperatures must be comma-separated kelvin "
444 "values, not " +
445 token);
446 }
447 }
448 return out;
449}

◆ to_json()

nlohmann::json eonc::config::to_json ( const Parameters & p)

Serialize all Parameters to JSON.

Definition at line 54 of file ParametersJSON.cpp.

54 {
55 json j;
56
57 // [Main]
58 j["Main"] = {
67 {"finite_difference",
70 {"remove_net_force",
72 {"write_con_forces",
78 };
79
80 // [Potential]
81 j["Potential"] = {
82 {"potential",
84 {"mpi_poll_period",
86 {"lammps_logging",
88 {"lammps_threads",
90 {"emt_rasmussen",
92 {"log_potential",
95 {"potentials_path",
97 {"pair_switch_width",
100 };
101
102 // [Structure Comparison]
103 j["Structure Comparison"] = {
104 {"distance_difference",
107 {"neighbor_cutoff",
109 {"check_rotation",
111 {"indistinguishable_atoms",
114 {"energy_difference",
116 {"remove_translation",
119 };
120
121 // [Optimizer]
122 j["Optimizer"] = {
123 {"opt_method",
126 {"convergence_metric",
128 {"max_iterations",
131 {"converged_force",
134 {"max_time_step",
136 };
137 j["Optimizer"]["LBFGS"] = {
139 {"inverse_curvature",
141 {"max_inverse_curvature",
143 {"auto_scale",
145 {"angle_reset",
147 {"distance_reset",
150 {"project_rigid",
157 {"extra_updates",
159 {"cautious_eps",
161 {"cautious_alpha",
165 {"precon_rcut",
167 };
168 j["Optimizer"]["Xtsci"] = {
175 };
176
177 // [Dynamics]
178 j["Dynamics"] = {
181 };
182
183 // [Thermostat]
184 j["Thermostat"] = {
186 {"andersen_alpha",
188 {"andersen_collision_period",
191 {"langevin_friction",
194 {"path_springs",
196 {"path_eco_omega_max",
198 {"path_gle_file",
200 {"path_pile_tau",
202 {"path_pile_scale",
205 };
206
207 // [Nudged Elastic Band]
208 j["Nudged Elastic Band"] = {
211 {"opt_method",
215 {"solid_state_weight",
217 {"solid_state_pressure",
220 {"band_precon_mu", ParametersLoadAccess::neb_options(p).band.precon_mu},
223 {"tunnel_wall_points",
225 };
226 j["Nudged Elastic Band"]["spring"] = {
228 {"elastic_band",
230 {"doubly_nudged",
233 };
234 j["Nudged Elastic Band"]["climbing_image"] = {
236 {"converged_only",
238 {"band_slack",
240 };
241 {
242 const auto &zoom = ParametersLoadAccess::neb_options(p).zoom;
243 j["Nudged Elastic Band"]["zoom"] = {
244 {"enabled", zoom.enabled},
245 {"alpha", zoom.alpha},
246 {"offset", zoom.offset},
247 {"mode", enum_to_json(zoom.mode)},
248 {"activation_threshold", zoom.activation_threshold},
249 {"interpolation", enum_to_json(zoom.interpolation)},
250 {"stability_count", zoom.stability_count},
251 {"max_iterations", zoom.max_iterations},
252 };
253 }
254
255 // [Dimer]
256 j["Dimer"] = {
259 {"converged_angle",
262 {"opt_method",
264 {"rotation_backend",
266 {"lor_residual_tol",
268 };
269
270 // [Saddle Search]
271 j["Saddle Search"] = {
273 {"min_mode_method",
276 {"max_iterations",
278 {"displace_magnitude",
280 {"displace_radius",
282 {"prfo_refine",
284 {"prfo_refine_force",
286 {"prfo_refine_max_iterations",
290 {"irc_step_size",
292 {"irc_converged_force",
294 {"irc_max_steps",
296 };
297
298 // [Prefactor]
299 j["Prefactor"] = {
300 {"default_value",
304 };
305
306 // [Lanczos]
307 j["Lanczos"] = {
309 {"max_iterations",
313 };
314
315 // [Davidson]
316 j["Davidson"] = {
318 {"max_iterations",
320 {"diagonal_preconditioner",
323 };
324
325 // [Hessian]
326 j["Hessian"] = {
328 {"zero_freq_value",
332 {"checkpoint_path",
335 };
336
337 // [Instanton]
338 {
340 j["Instanton"] = {
341 {"mode", o.mode},
342 {"reactant_filename", o.reactant_filename},
343 {"product_filename", o.product_filename},
344 {"initial_path", o.initial_path},
345 {"initial_ring", o.initial_ring},
346 {"physical_bath_filename", o.physical_bath_filename},
347 {"beads", o.beads},
348 {"beta_hbar_omega", o.beta_hbar_omega},
349 {"max_iterations", o.max_iterations},
350 {"force_tolerance", o.force_tolerance},
351 {"hessian_stride", o.hessian_stride},
352 {"saddle_filename", o.saddle_filename},
353 {"temperature", o.temperature},
354 {"temperatures", o.temperatures},
355 {"half_ring", o.half_ring},
356 {"symmetrize", o.symmetrize},
357 {"initial_hessians", o.initial_hessians},
358 {"newton_limit", o.newton_limit},
359 {"lanczos_step", o.lanczos_step},
360 {"reactant_hessian_filename", o.reactant_hessian_filename},
361 {"saddle_hessian_filename", o.saddle_hessian_filename},
362 {"physical_hessian_step", o.physical_hessian_step},
363 {"energy_shift", o.energy_shift},
364 {"discretization", o.discretization},
365 {"friction", o.friction},
366 {"friction_eta", o.friction_eta},
367 {"friction_eta_beads", o.friction_eta_beads},
368 {"collapse_fraction", o.collapse_fraction},
369 {"rotation_zero_fraction", o.rotation_zero_fraction},
370 {"bead_ladder", o.bead_ladder},
371 {"hessian_final", o.hessian_final},
372 {"springs", o.springs},
373 {"pi_planes", o.pi_planes},
374 {"pi_beads", o.pi_beads},
375 {"pi_equilibration_steps", o.pi_equilibration_steps},
376 {"pi_sampling_steps", o.pi_sampling_steps},
377 {"pi_time_step", o.pi_time_step},
378 {"pi_thermostat", o.pi_thermostat},
379 {"pi_gle_file", o.pi_gle_file},
380 {"pi_pile_tau", o.pi_pile_tau},
381 {"pi_pile_scale", o.pi_pile_scale},
382 {"pi_seed", o.pi_seed},
383 {"pi_direction", o.pi_direction},
384 {"pi_reactant_extent", o.pi_reactant_extent},
385 {"pi_recrossing_parents", o.pi_recrossing_parents},
386 {"pi_recrossing_children", o.pi_recrossing_children},
387 {"pi_recrossing_time", o.pi_recrossing_time},
388 {"pi_recrossing_spacing", o.pi_recrossing_spacing},
389 };
390 }
391
392 // [Debug]
393 j["Debug"] = {
395 {"write_movies_interval",
397 {"write_deprecated_outs",
399 };
400
401 // [Serve]
402 j["Serve"] = {
408 };
409
410 project_ssot_json_write(j, p);
411 return j;
412}
nlohmann::json json
static json enum_to_json(E val)

◆ validate_and_link()

void eonc::config::validate_and_link ( Parameters & params)

Resolve cross-group defaults and time unit conversions.

Called after INI (or JSON) loading to finalize computed fields.

Definition at line 2065 of file ParametersINI.cpp.

2065 {
2066 // Time unit conversions
2067 double tu = ParametersLoadAccess::constants(params).timeUnit;
2072
2077 if (ParametersLoadAccess::dynamics_options(params).time_step > 0.0) {
2079 static_cast<long>(std::floor(
2081 ParametersLoadAccess::dynamics_options(params).time_step +
2082 0.5));
2083 } else {
2085 }
2086
2089 tu;
2090
2094 tu;
2098 tu;
2102 tu;
2105 tu;
2106
2110 tu;
2113
2116
2121 tu;
2125 tu;
2126
2127 // Cross-group defaults
2132}