eOn client
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
RgpotPot.cpp
Go to the documentation of this file.
1
/*
2
** This file is part of eOn.
3
*/
4
#include "
eon/potentials/Rgpot/RgpotPot.h
"
5
#include "
eon/potentials/Rgpot/RGPotEngine.h
"
6
7
#include <algorithm>
8
#include <cctype>
9
#include <cstdlib>
10
#include <iostream>
11
#include <string>
12
13
RgpotPot::RgpotPot
(
const
Parameters
&p)
14
:
Potential
(
PotType
::RGPOT, p) {
15
RGPotEngineOptions
opt;
16
const
auto
&o = p.
rgpot_options
;
17
opt.
backend
= o.backend;
18
opt.
basis
= o.basis;
19
opt.
theory
= o.theory;
20
opt.
scf_type
= o.scf_type;
21
opt.
functional
= o.functional;
22
opt.
cutoff_ry
= o.cutoff_ry;
23
opt.
charge
= o.charge;
24
opt.
multiplicity
= o.multiplicity;
25
opt.
engine_path
= o.engine_path;
26
opt.
engine_library
= o.engine_library;
27
opt.
engine_root
= o.engine_root;
28
opt.
title
= o.title;
29
opt.
memory_mb
= o.memory_mb;
30
opt.
scratch_dir
= o.scratch_dir;
31
opt.
input_block
= o.input_block;
32
opt.
model_path
= o.model_path;
33
opt.
device
= o.device;
34
opt.
length_unit
= o.length_unit;
35
opt.
extensions_directory
= o.extensions_directory;
36
opt.
check_consistency
= o.check_consistency;
37
opt.
uncertainty_threshold
= o.uncertainty_threshold;
38
opt.
torch_determinism_strict
= o.torch_determinism_strict;
39
opt.
xtb_paramset
= o.xtb_paramset;
40
opt.
xtb_accuracy
= o.xtb_accuracy;
41
opt.
xtb_electronic_temperature
= o.xtb_electronic_temperature;
42
opt.
xtb_max_iterations
= o.xtb_max_iterations;
43
opt.
xtb_charge
= o.xtb_charge;
44
opt.
xtb_uhf
= o.xtb_uhf;
45
46
// Env overrides (CI / benchmarks)
47
if
(
const
char
*e = std::getenv(
"RGPOT_BACKEND"
))
48
opt.
backend
= e;
49
if (
const
char
*e = std::getenv(
"RGPOT_NWCHEM_BASIS"
))
50
opt.
basis
= e;
51
if (
const
char
*e = std::getenv(
"RGPOT_NWCHEM_THEORY"
))
52
opt.
theory
= e;
53
if (
const
char
*e = std::getenv(
"RGPOT_NWCHEM_SCF_TYPE"
))
54
opt.
scf_type
= e;
55
// Engine-path env overrides are backend-scoped: NWCHEMC_LIBRARY must not
56
// leak into a cpmdc configure (CPMDPot resolves CPMDC_LIBRARY itself).
57
std::string backend_lc = opt.
backend
;
58
std::transform(backend_lc.begin(), backend_lc.end(), backend_lc.begin(),
59
[](
unsigned
char
c) { return std::tolower(c); });
60
if (backend_lc.rfind(
"nwchem"
, 0) == 0) {
61
if (const char *e = std::getenv(
"NWCHEMC_LIBRARY"
))
62
opt.engine_path = e;
63
else if (const char *e = std::getenv(
"RGPOT_NWCHEMC_ENGINE"
))
64
opt.engine_path = e;
65
}
else
if (backend_lc.rfind(
"cpmd"
, 0) == 0) {
66
if (const char *e = std::getenv(
"CPMDC_LIBRARY"
))
67
opt.engine_path = e;
68
else if (const char *e = std::getenv(
"RGPOT_CPMDC_ENGINE"
))
69
opt.engine_path = e;
70
}
else
if (backend_lc.rfind(
"meta"
, 0) == 0 || backend_lc ==
"mta"
) {
71
if (const char *e = std::getenv(
"RGPOT_METATOMIC_ENGINE"
))
72
opt.engine_path = e;
73
else if (const char *e = std::getenv(
"METATOMIC_ENGINE"
))
74
opt.engine_path = e;
75
if (const char *e = std::getenv(
"RGPOT_METATOMIC_MODEL"
))
76
opt.model_path = e;
77
}
else
if (backend_lc ==
"xtb"
|| backend_lc ==
"xtbpot"
||
78
backend_lc ==
"gfn"
|| backend_lc ==
"gfnxtb"
) {
79
if
(
const
char
*e = std::getenv(
"RGPOT_XTB_ENGINE"
))
80
opt.
engine_path
= e;
81
else
if
(
const
char
*e = std::getenv(
"XTB_ENGINE"
))
82
opt.
engine_path
= e;
83
if
(opt.
xtb_paramset
.empty() || opt.
xtb_paramset
==
"GFN2xTB"
) {
84
if
(!p.
xtb_options
.
paramset
.empty())
85
opt.
xtb_paramset
= p.
xtb_options
.
paramset
;
86
}
87
}
88
89
// Dual-read [Metatomic] when RGPOT backend is metatomic
90
if
((backend_lc.rfind(
"meta"
, 0) == 0 || backend_lc ==
"mta"
) &&
91
opt.
model_path
.empty())
92
opt.
model_path
= p.
metatomic_options
.
model_path
;
93
if ((backend_lc.rfind(
"meta"
, 0) == 0 || backend_lc ==
"mta"
) &&
94
opt.
device
==
"cpu"
&& !p.
metatomic_options
.
device
.empty())
95
opt.
device
= p.
metatomic_options
.
device
;
96
97
impl_
= std::make_unique<RGPotEngine>(opt);
98
backend_
=
impl_
->backend();
99
std::cout
100
<<
"RgpotPot: in-process rgpot backend="
<<
backend_
101
<<
" (dlopen: libnwchemc/libcpmdc/libmetatomic_engine/libxtb_engine)"
102
<< std::endl;
103
}
104
105
RgpotPot::~RgpotPot
() =
default
;
106
107
bool
RgpotPot::engineAvailable
()
const
{
return
impl_
&&
impl_
->available(); }
108
109
void
RgpotPot::force
(
long
N,
const
double
*R,
const
int
*atomicNrs,
double
*F,
110
double
*U,
double
*variance,
const
double
*box) {
111
(void)variance;
112
impl_
->force(N, R, atomicNrs, F, U, box);
113
}
RGPotEngine.h
RgpotPot.h
RgpotPot::engineAvailable
bool engineAvailable() const
Definition
RgpotPot.cpp:107
RgpotPot::backend_
std::string backend_
Definition
RgpotPot.h:46
RgpotPot::RgpotPot
RgpotPot(const Parameters &p)
Definition
RgpotPot.cpp:13
RgpotPot::impl_
std::unique_ptr< RGPotEngine > impl_
Definition
RgpotPot.h:45
RgpotPot::~RgpotPot
~RgpotPot() override
RgpotPot::force
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box) override
Definition
RgpotPot.cpp:109
eonc::Parameters
Definition
Parameters.h:28
eonc::Parameters::xtb_options
struct eonc::Parameters::xtb_options_t xtb_options
eonc::Parameters::rgpot_options
struct eonc::Parameters::rgpot_options_t rgpot_options
eonc::Parameters::metatomic_options
struct eonc::Parameters::metatomic_options_t metatomic_options
eonc::Potential::Potential
Potential(PotType a_ptype)
Definition
Potential.h:35
eonc::PotType
PotType
Definition
BaseStructures.h:36
RGPotEngineOptions
Definition
RGPotEngine.h:6
RGPotEngineOptions::xtb_uhf
int xtb_uhf
Definition
RGPotEngine.h:36
RGPotEngineOptions::scf_type
std::string scf_type
Definition
RGPotEngine.h:10
RGPotEngineOptions::check_consistency
bool check_consistency
Definition
RGPotEngine.h:27
RGPotEngineOptions::title
std::string title
Definition
RGPotEngine.h:18
RGPotEngineOptions::multiplicity
int multiplicity
Definition
RGPotEngine.h:14
RGPotEngineOptions::xtb_paramset
std::string xtb_paramset
Definition
RGPotEngine.h:31
RGPotEngineOptions::basis
std::string basis
Definition
RGPotEngine.h:8
RGPotEngineOptions::scratch_dir
std::string scratch_dir
Definition
RGPotEngine.h:20
RGPotEngineOptions::engine_path
std::string engine_path
Definition
RGPotEngine.h:15
RGPotEngineOptions::cutoff_ry
double cutoff_ry
Definition
RGPotEngine.h:12
RGPotEngineOptions::xtb_max_iterations
int xtb_max_iterations
Definition
RGPotEngine.h:34
RGPotEngineOptions::memory_mb
int memory_mb
Definition
RGPotEngine.h:19
RGPotEngineOptions::backend
std::string backend
Definition
RGPotEngine.h:7
RGPotEngineOptions::extensions_directory
std::string extensions_directory
Definition
RGPotEngine.h:26
RGPotEngineOptions::engine_library
std::string engine_library
Definition
RGPotEngine.h:16
RGPotEngineOptions::xtb_electronic_temperature
double xtb_electronic_temperature
Definition
RGPotEngine.h:33
RGPotEngineOptions::charge
int charge
Definition
RGPotEngine.h:13
RGPotEngineOptions::functional
std::string functional
Definition
RGPotEngine.h:11
RGPotEngineOptions::length_unit
std::string length_unit
Definition
RGPotEngine.h:25
RGPotEngineOptions::torch_determinism_strict
bool torch_determinism_strict
Definition
RGPotEngine.h:29
RGPotEngineOptions::device
std::string device
Definition
RGPotEngine.h:24
RGPotEngineOptions::model_path
std::string model_path
Definition
RGPotEngine.h:23
RGPotEngineOptions::xtb_accuracy
double xtb_accuracy
Definition
RGPotEngine.h:32
RGPotEngineOptions::engine_root
std::string engine_root
Definition
RGPotEngine.h:17
RGPotEngineOptions::uncertainty_threshold
double uncertainty_threshold
Definition
RGPotEngine.h:28
RGPotEngineOptions::theory
std::string theory
Definition
RGPotEngine.h:9
RGPotEngineOptions::input_block
std::string input_block
Definition
RGPotEngine.h:21
RGPotEngineOptions::xtb_charge
double xtb_charge
Definition
RGPotEngine.h:35
eonc::Parameters::metatomic_options_t::device
std::string device
Definition
Parameters.h:377
eonc::Parameters::metatomic_options_t::model_path
std::string model_path
Definition
Parameters.h:376
eonc::Parameters::xtb_options_t::paramset
std::string paramset
Definition
Parameters.h:102
client
potentials
Rgpot
RgpotPot.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf