Loading...
Searching...
No Matches
GPSurrogateJob.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include "HelperFunctions.h"
15#include "Job.h"
16#include "Parameters.h"
17
18#include "PyGuard.h"
19#include <format>
20#include <pybind11/eigen.h>
21
22#include "NudgedElasticBand.h"
23
24namespace eonc {
25
26class GPSurrogateJob : public Job {
27public:
28 GPSurrogateJob(std::unique_ptr<Parameters> parameters, Runtime &rt)
29 : Job(std::move(parameters), rt) {
31#ifndef NDEBUG
32 py::module_ sys_mod = py::module_::import("sys");
33 py::module_ ipdb_mod = py::module_::import("ipdb");
34 sys_mod.attr("breakpointhook") = ipdb_mod.attr("set_trace");
35#endif // NDEBUG
36 }
37 GPSurrogateJob(std::shared_ptr<Potential> potPassed,
38 const Parameters &parameters)
39 : Job(potPassed, parameters) {
41#ifndef NDEBUG
42 py::module_ sys_mod = py::module_::import("sys");
43 py::module_ ipdb_mod = py::module_::import("ipdb");
44 sys_mod.attr("breakpointhook") = ipdb_mod.attr("set_trace");
45#endif // NDEBUG
46 }
47 ~GPSurrogateJob() = default;
48 std::vector<std::string> run() override;
50 std::shared_ptr<NudgedElasticBand>
51 runFromMatter(std::shared_ptr<Matter> initial,
52 std::shared_ptr<Matter> final_state);
53
54private:
56 std::unique_ptr<NudgedElasticBand> neb);
57 std::vector<std::string> returnFiles;
58};
59
60namespace helpers::surrogate {
61MatrixXd get_features(const std::vector<Matter> &matobjs);
62MatrixXd get_features(const std::vector<std::shared_ptr<Matter>> &matobjs);
63MatrixXd get_targets(std::vector<std::shared_ptr<Matter>> &matobjs,
64 std::shared_ptr<Potential> true_pot);
65MatrixXd get_targets(std::vector<Matter> &matobjs,
66 std::shared_ptr<Potential> true_pot);
67Eigen::VectorXd make_target(Matter &m1, std::shared_ptr<Potential> true_pot);
68std::pair<Eigen::VectorXd, Eigen::VectorXd>
69getNewDataPoint(const std::vector<std::shared_ptr<Matter>> &matobjs,
70 std::shared_ptr<Potential> true_pot);
71std::vector<Matter> getMidSlice(const std::vector<Matter> &matobjs);
72bool accuratePES(std::vector<std::shared_ptr<Matter>> &matobjs,
73 std::shared_ptr<Potential> true_pot);
74std::pair<double, Eigen::VectorXd::Index>
75getMaxUncertainty(const std::vector<std::shared_ptr<Matter>> &matobjs);
76} // namespace helpers::surrogate
77
78namespace helpers::eigen {
79MatrixXd vertCat(const MatrixXd &m1, const MatrixXd &m2);
80void addVectorRow(MatrixXd &data, const Eigen::VectorXd &newrow);
81// Modifies data
82} // namespace helpers::eigen
83
84} // namespace eonc
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, eOnStorageOrder > MatrixXd
Definition Eigen.h:33
The job class is used to serve as an abstract class for all jobs, as well as to call a job at runtime...
std::shared_ptr< NudgedElasticBand > runFromMatter(std::shared_ptr< Matter > initial, std::shared_ptr< Matter > final_state)
Matter-first NEB surrogate path (endpoints as Matter).
GPSurrogateJob(std::unique_ptr< Parameters > parameters, Runtime &rt)
std::vector< std::string > run() override
Virtual run; used solely for dynamic dispatch.
GPSurrogateJob(std::shared_ptr< Potential > potPassed, const Parameters &parameters)
std::vector< std::string > returnFiles
void saveData(NudgedElasticBand::NEBStatus status, std::unique_ptr< NudgedElasticBand > neb)
~GPSurrogateJob()=default
Job(std::unique_ptr< Parameters > parameters, Runtime &rt)
Borrow: caller keeps Runtime alive (CLI stack / Python Session).
Definition Job.h:76
Move-only composition root for process resources (dlopen loaders and the potential registry).
Definition Runtime.h:27
MatrixXd vertCat(const MatrixXd &m1, const MatrixXd &m2)
void addVectorRow(MatrixXd &data, const Eigen::VectorXd &newrow)
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)
Eigen::VectorXd make_target(Matter &m1, std::shared_ptr< Potential > true_pot)
RAII resource manager for the ARTn C library with global synchronization.
void ensure_interpreter()
Definition NbGuard.h:21