Loading...
Searching...
No Matches
RGPotEngine.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <memory>
6#include <string>
7
9 std::string backend;
10 std::string basis{"sto-3g"};
11 std::string theory{"scf"};
12 std::string scf_type{"rhf"};
13 std::string functional{"BLYP"};
14 double cutoff_ry{70.0};
15 int charge{0};
17 std::string engine_path;
18 std::string engine_library;
19 std::string engine_root;
20 std::string title;
21 int memory_mb{0};
22 std::string scratch_dir;
23 // NWChem inputBlocks, or CPMD text appended to inputBlocks.
24 std::string input_block;
25 std::string permanent_dir; // CPMD FILEPATH for RESTART files (cpmdc)
26 // CPMDParams file. When set, scalar method keys are not written over it.
27 std::string params_path;
28 int ranks_per_image{0}; // cpmdc: ranks per calculator group, 0 = off
29 // Metatomic (backend=metatomic): dlopen libmetatomic_engine.so
30 std::string model_path;
31 std::string device{"cpu"};
32 std::string length_unit{"angstrom"};
34 bool check_consistency{false};
37 // XTB (backend=xtb): dlopen libxtb_engine.so — not native -Dwith_xtb link
38 std::string xtb_paramset{"GFN2xTB"}; // GFNFF / GFN0xTB / GFN1xTB / GFN2xTB
39 double xtb_accuracy{1.0};
42 double xtb_charge{0.0};
43 int xtb_uhf{0};
44 // UMA (backend=uma): dlopen libuma_engine.so through the generic engine
45 // C ABI. model_path is the AOTI package; charge and multiplicity ride
46 // the shared fields.
47 std::string task_name{"omol"};
48};
49
52std::string nwchemDftInputBlock(const std::string &theory,
53 const std::string &scfType, int multiplicity,
54 const std::string &existing);
55
58public:
59 explicit RGPotEngine(const RGPotEngineOptions &opt);
61 RGPotEngine(const RGPotEngine &) = delete;
62 RGPotEngine &operator=(const RGPotEngine &) = delete;
63
64 [[nodiscard]] const std::string &backend() const noexcept { return backend_; }
65 [[nodiscard]] bool available() const;
66 void force(long N, const double *R, const int *atomicNrs, double *F,
67 double *U, const double *box) const;
71 void selectOrbitals(std::int64_t key) const;
73 [[nodiscard]] bool keepsOrbitalsPerKey() const;
74
77 [[nodiscard]] int calculatorGroups() const noexcept;
78 [[nodiscard]] int calculatorIndex() const noexcept;
80 [[nodiscard]] int calculatorWorld() const noexcept;
82 [[nodiscard]] int worldRank() const noexcept;
85 void broadcastFromDriver(void *data, std::size_t bytes) const;
88 void finalizeMpiAtExit() const;
93 void armGroupedExit() const;
95 [[nodiscard]] static bool mpiAbortRequested() noexcept;
97 void shutdownModule() noexcept;
104 bool shareResult(int owner, long N, double *F, double *U, bool ok,
105 std::string &error) const;
106
107private:
108 // The engine call itself; force() adds the test failure hook after it.
109 void forceEngine(long N, const double *R, const int *atomicNrs, double *F,
110 double *U, const double *box) const;
111 struct Impl;
112 std::unique_ptr<Impl> impl_;
113 std::string backend_;
114};
std::string nwchemDftInputBlock(const std::string &theory, const std::string &scfType, int multiplicity, const std::string &existing)
NWChem input block for a DFT theory.
void selectOrbitals(std::int64_t key) const
Names the calculation the next force() belongs to (cpmdc: the engine keeps converged orbitals per key...
bool available() const
RGPotEngine(const RGPotEngineOptions &opt)
void broadcastFromDriver(void *data, std::size_t bytes) const
Collective on MPI_COMM_WORLD: every rank leaves with world rank 0's bytes.
static bool mpiAbortRequested() noexcept
True once rgpot asked for MPI_Abort at exit in this process.
RGPotEngine(const RGPotEngine &)=delete
bool keepsOrbitalsPerKey() const
True when the engine keeps converged orbitals per key.
void armGroupedExit() const
After MPI_Finalize, _Exit.
int calculatorGroups() const noexcept
Number of calculator groups the MPI world is split into (1 when ranks_per_image is off) and the group...
void forceEngine(long N, const double *R, const int *atomicNrs, double *F, double *U, const double *box) const
void shutdownModule() noexcept
Calls cpmdc_finalize while the engine is still mapped. MPI stays up.
int calculatorWorld() const noexcept
Ranks in the MPI world the groups were bound on (1 without MPI).
int calculatorIndex() const noexcept
RGPotEngine & operator=(const RGPotEngine &)=delete
const std::string & backend() const noexcept
Definition RGPotEngine.h:64
int worldRank() const noexcept
This process's rank in that world (0 without MPI).
void finalizeMpiAtExit() const
Registers MPI_Finalize at exit (once per process) when the world has more than one rank.
std::unique_ptr< Impl > impl_
bool shareResult(int owner, long N, double *F, double *U, bool ok, std::string &error) const
Collective on MPI_COMM_WORLD: every rank leaves with the energy and the 3N forces computed by the fir...
std::string backend_
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, const double *box) const
std::string scf_type
Definition RGPotEngine.h:12
std::string title
Definition RGPotEngine.h:20
std::string xtb_paramset
Definition RGPotEngine.h:38
std::string basis
Definition RGPotEngine.h:10
std::string scratch_dir
Definition RGPotEngine.h:22
std::string engine_path
Definition RGPotEngine.h:17
std::string params_path
Definition RGPotEngine.h:27
std::string backend
Definition RGPotEngine.h:9
std::string extensions_directory
Definition RGPotEngine.h:33
std::string engine_library
Definition RGPotEngine.h:18
double xtb_electronic_temperature
Definition RGPotEngine.h:40
std::string permanent_dir
Definition RGPotEngine.h:25
std::string functional
Definition RGPotEngine.h:13
std::string length_unit
Definition RGPotEngine.h:32
bool torch_determinism_strict
Definition RGPotEngine.h:36
std::string device
Definition RGPotEngine.h:31
std::string model_path
Definition RGPotEngine.h:30
std::string task_name
Definition RGPotEngine.h:47
std::string engine_root
Definition RGPotEngine.h:19
double uncertainty_threshold
Definition RGPotEngine.h:35
std::string theory
Definition RGPotEngine.h:11
std::string input_block
Definition RGPotEngine.h:24