51 {
52 if (!initial || !final_state) {
53 throw std::runtime_error("GPSurrogateJob::runFromMatter: null Matter");
54 }
55
56 auto true_params = std::make_shared<Parameters>(
params);
58 params.gp_surrogate_options().sub_job;
60 std::make_unique<Parameters>(*true_params), *
runtime_);
61 auto pyparams = std::make_shared<Parameters>(
params);
64
65 initial->setPotential(
pot);
66 final_state->setPotential(
pot);
68 *initial, *final_state,
params.neb_options().image_count);
72 magic_enum::enum_name<PotType>(
pot->getType()));
74
75
78 surpot->train_optimize(features, targets);
79 auto neb = std::make_unique<NudgedElasticBand>(initial, final_state,
80 *pyparams, surpot);
81 auto status_neb{neb->compute()};
82 bool job_not_finished{true};
83 size_t n_gp{0};
84 while (job_not_finished) {
85 n_gp++;
86 if (n_gp > 750) {
88 break;
89 }
90 EONC_LOG_TRACE(
"Must handle update to the GP, update number {}", n_gp);
91 auto [maxUnc, maxIndex] =
93 auto [feature, target] =
97 surpot->train_optimize(features, targets);
100 params.optimizer_options().converged_force * 0.8;
101 for (auto &&obj : neb->path) {
102 obj->setPotential(surpot);
103 }
104 if (!(pyparams->gp_surrogate_options().linear_path_always)) {
106 std::vector<Matter> previous;
107 previous.reserve(neb->path.size());
108 for (const auto &image : neb->path) {
109 previous.push_back(*image);
110 }
111 neb = std::make_unique<NudgedElasticBand>(std::move(previous), *pyparams,
112 surpot);
113 } else {
115 neb = std::make_unique<NudgedElasticBand>(initial, final_state, *pyparams,
116 surpot);
117 }
118 status_neb = neb->compute();
119
120 std::string nebFilename(std::format("neb_final_gpr_{:03d}.con", n_gp));
123 neb->path, neb->tangent, neb->eigenmode_solvers, neb->numImages,
124 params.debug_options().estimate_neb_eigenvalues, nebFilename,
125 static_cast<size_t>(n_gp), neb->reactantEnergy))) {
126 throw std::runtime_error("Failed to write file: " + nebFilename);
127 }
130 break;
131 } else {
132 continue;
133 }
134 }
135 neb->printImageData();
136 neb->findExtrema();
137
138 std::shared_ptr<NudgedElasticBand> out(neb.release());
139
140
141
142
143 return out;
144}
#define EONC_LOG_TRACE(...)
Convenience macro for one-shot logging without storing a logger.
Runtime * runtime_
Always valid: either owned_runtime_.get() or a caller-owned Runtime.
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, Runtime &runtime)
Borrow: caller keeps Runtime alive.
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, double referenceEnergy)
Write a NEB band as a multi-frame .con via readcon ConFrameBuilder::clone().
std::shared_ptr< eonc::SurrogatePotential > makeSurrogatePotential(eonc::PotType a_ptype, const eonc::Parameters &a_params, Args &&...a_args)
static neb_options_t & neb_options(Parameters &p)
static optimizer_options_t & optimizer_options(Parameters &p)
static potential_options_t & potential_options(Parameters &p)
struct eonc::neb_options_t::climbing_image_options_t climbing_image