Loading...
Searching...
No Matches
RGPotEngine.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <memory>
5#include <string>
6
8 std::string backend;
9 std::string basis{"sto-3g"};
10 std::string theory{"scf"};
11 std::string scf_type{"rhf"};
12 std::string functional{"BLYP"};
13 double cutoff_ry{70.0};
14 int charge{0};
16 std::string engine_path;
17 std::string engine_library;
18 std::string engine_root;
19 std::string title;
20 int memory_mb{0};
21 std::string scratch_dir;
22 // NWChem inputBlocks, or CPMD text appended to inputBlocks.
23 std::string input_block;
24 std::string permanent_dir; // CPMD FILEPATH for RESTART files (cpmdc)
25 // CPMDParams file. When set, scalar method keys are not written over it.
26 std::string params_path;
27 int ranks_per_image{0}; // cpmdc: ranks per calculator group, 0 = off
28 // Metatomic (backend=metatomic): dlopen libmetatomic_engine.so
29 std::string model_path;
30 std::string device{"cpu"};
31 std::string length_unit{"angstrom"};
33 bool check_consistency{false};
36 // XTB (backend=xtb): dlopen libxtb_engine.so — not native -Dwith_xtb link
37 std::string xtb_paramset{"GFN2xTB"}; // GFNFF / GFN0xTB / GFN1xTB / GFN2xTB
38 double xtb_accuracy{1.0};
41 double xtb_charge{0.0};
42 int xtb_uhf{0};
43};
44
47public:
48 explicit RGPotEngine(const RGPotEngineOptions &opt);
50 RGPotEngine(const RGPotEngine &) = delete;
51 RGPotEngine &operator=(const RGPotEngine &) = delete;
52
53 [[nodiscard]] const std::string &backend() const noexcept { return backend_; }
54 [[nodiscard]] bool available() const;
55 void force(long N, const double *R, const int *atomicNrs, double *F,
56 double *U, const double *box) const;
57
60 [[nodiscard]] int calculatorGroups() const noexcept;
61 [[nodiscard]] int calculatorIndex() const noexcept;
63 [[nodiscard]] int calculatorWorld() const noexcept;
65 [[nodiscard]] int worldRank() const noexcept;
68 void broadcastFromDriver(void *data, std::size_t bytes) const;
71 void finalizeMpiAtExit() const;
76 void armGroupedExit() const;
78 [[nodiscard]] static bool mpiAbortRequested() noexcept;
80 void shutdownModule() noexcept;
87 bool shareResult(int owner, long N, double *F, double *U, bool ok,
88 std::string &error) const;
89
90private:
91 struct Impl;
92 std::unique_ptr<Impl> impl_;
93 std::string backend_;
94};
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
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 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:53
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_
Definition RGPotEngine.h:92
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_
Definition RGPotEngine.h:93
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:11
std::string title
Definition RGPotEngine.h:19
std::string xtb_paramset
Definition RGPotEngine.h:37
std::string basis
Definition RGPotEngine.h:9
std::string scratch_dir
Definition RGPotEngine.h:21
std::string engine_path
Definition RGPotEngine.h:16
std::string params_path
Definition RGPotEngine.h:26
std::string backend
Definition RGPotEngine.h:8
std::string extensions_directory
Definition RGPotEngine.h:32
std::string engine_library
Definition RGPotEngine.h:17
double xtb_electronic_temperature
Definition RGPotEngine.h:39
std::string permanent_dir
Definition RGPotEngine.h:24
std::string functional
Definition RGPotEngine.h:12
std::string length_unit
Definition RGPotEngine.h:31
bool torch_determinism_strict
Definition RGPotEngine.h:35
std::string device
Definition RGPotEngine.h:30
std::string model_path
Definition RGPotEngine.h:29
std::string engine_root
Definition RGPotEngine.h:18
double uncertainty_threshold
Definition RGPotEngine.h:34
std::string theory
Definition RGPotEngine.h:10
std::string input_block
Definition RGPotEngine.h:23