38 {
39 std::vector<std::string> paths;
42 if (const char *e = std::getenv("RGPOT_XTB_ENGINE"))
43 if (e && *e)
44 paths.emplace_back(e);
45 if (const char *e = std::getenv("XTB_ENGINE"))
46 if (e && *e)
47 paths.emplace_back(e);
48 paths.emplace_back("libxtb_engine.so");
49 auto add_dirs = [&](const char *env) {
50 if (!env)
51 return;
52 std::string s(env);
53 size_t i = 0;
54 while (i < s.size()) {
55 auto j = s.find(':', i);
56 if (j == std::string::npos)
57 j = s.size();
58 if (j > i) {
59 std::string d = s.substr(i, j - i);
60 if (!d.empty() && d.back() != '/')
61 d += '/';
62 paths.push_back(d + "libxtb_engine.so");
63 }
64 i = j + 1;
65 }
66 };
67 add_dirs(std::getenv("EON_POTENTIALS_PATH"));
68 add_dirs(std::getenv("RGPOT_ENGINE_PATH"));
69
70 std::string last_dlerr;
71 for (const auto &p : paths) {
72 m_lib = open_lib(p.c_str());
74 break;
75#ifndef _WIN32
76 if (const char *e = dlerror())
77 last_dlerr = e;
78#endif
79 }
81 std::string msg = "RGPOT(xtb): libxtb_engine.so not found "
82 "(set RGPOT_XTB_ENGINE or [RgpotPot] engine_path)";
83 if (!last_dlerr.empty())
84 msg += std::string("; last dlerror: ") + last_dlerr;
85 throw std::runtime_error(msg);
86 }
87
88 auto abi =
89 reinterpret_cast<int (*)()
>(load_sym(
m_lib,
"rgpot_xtb_abi_version"));
98 throw std::runtime_error("RGPOT(xtb): engine C ABI missing/mismatch");
99 }
100 char err[1024]{};
112 throw std::runtime_error(std::string("RGPOT(xtb): create failed: ") + err);
113 }
114}
void(*)(RgpotXtbPot *) destroy_fn
RgpotXtbPot *(*)(const RgpotXtbConfig *, char *, size_t) create_fn
int(*)(RgpotXtbPot *, long, const double *, const int *, double *, double *, double *, const double *) force_fn
int method
RGPOT_XTB_METHOD_*.
double electronic_temperature
Kelvin.
double electronic_temperature
struct RgpotXtbConfig RgpotXtbConfig
#define RGPOT_XTB_ABI_VERSION