46 {
47 if (!initial || !final_state) {
48 throw std::runtime_error("GPSurrogateJob::runFromMatter: null Matter");
49 }
50
51 auto true_params = std::make_shared<Parameters>(
params);
52 true_params->main_options.job =
params.sub_job;
53 auto true_job =
55 auto pyparams = std::make_shared<Parameters>(
params);
57
58 initial->setPotential(
pot);
59 final_state->setPotential(
pot);
61 *initial, *final_state,
params.neb_options.image_count);
65 magic_enum::enum_name<PotType>(
pot->getType()));
67
68
69 auto surpot = eonc::helpers::create::makeSurrogatePotential(
71 surpot->train_optimize(features, targets);
72 auto neb = std::make_unique<NudgedElasticBand>(initial, final_state,
73 *pyparams, surpot);
74 auto status_neb{neb->compute()};
75 bool job_not_finished{true};
76 size_t n_gp{0};
77 double unc_conv{pyparams->gp_uncertainty};
78 while (job_not_finished) {
79 n_gp++;
80 if (n_gp > 750) {
82 break;
83 }
84 EONC_LOG_TRACE(
"Must handle update to the GP, update number {}", n_gp);
85 auto [maxUnc, maxIndex] =
87 auto [feature, target] =
91 surpot->train_optimize(features, targets);
92 pyparams->nebClimbingImageMethod = false;
93 pyparams->optimizer_options.converged_force =
94 params.optimizer_options.converged_force * 0.8;
95 for (auto &&obj : neb->path) {
96 obj->setPotential(surpot);
97 }
98 if (!(pyparams->gp_linear_path_always)) {
100 neb = std::make_unique<NudgedElasticBand>(neb->path, *pyparams, surpot);
101 } else {
103 neb = std::make_unique<NudgedElasticBand>(initial, final_state, *pyparams,
104 surpot);
105 }
106 status_neb = neb->compute();
107
108 std::string nebFilename(std::format("neb_final_gpr_{:03d}.con", n_gp));
111 neb->path, neb->tangent, neb->eigenmode_solvers, neb->numImages,
112 params.debug_options.estimate_neb_eigenvalues, nebFilename,
113 static_cast<size_t>(n_gp)))) {
114 throw std::runtime_error("Failed to write file: " + nebFilename);
115 }
118 break;
119 } else {
120 continue;
121 }
122 }
123 neb->printImageData();
124 neb->findExtrema();
125
126 std::shared_ptr<NudgedElasticBand> out(neb.release());
127
128
129
130
131 return out;
132}
#define EONC_LOG_TRACE(...)
Convenience macro for one-shot logging without storing a logger.
void addVectorRow(MatrixXd &data, const Eigen::VectorXd &newrow)
std::vector< Matter > linearPath(const Matter &initImg, const Matter &finalImg, const size_t nimgs)
MatrixXd get_targets(std::vector< Matter > &matobjs, std::shared_ptr< Potential > true_pot)
MatrixXd get_features(const std::vector< Matter > &matobjs)
bool accuratePES(std::vector< std::shared_ptr< Matter > > &matobjs, std::shared_ptr< Potential > true_pot)
std::pair< double, Eigen::VectorXd::Index > getMaxUncertainty(const std::vector< std::shared_ptr< Matter > > &matobjs)
std::vector< Matter > getMidSlice(const std::vector< Matter > &matobjs)
std::pair< Eigen::VectorXd, Eigen::VectorXd > getNewDataPoint(const std::vector< std::shared_ptr< Matter > > &matobjs, std::shared_ptr< Potential > true_pot)
std::unique_ptr< Job > makeJob(std::unique_ptr< Parameters > params)
eonc::io::IoStatus writePathCon(const std::vector< std::shared_ptr< Matter > > &path, const std::vector< std::shared_ptr< AtomMatrix > > &tangent, const std::vector< std::shared_ptr< EigenmodeStrategy > > &eigenmode_solvers, long numImages, bool estimateEigenvalues, std::string filename, std::optional< size_t > bandIndex)
Write a NEB band as a multi-frame .con via readcon ConFrameBuilder::clone().