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("librgpot_xtb_engine.so");
49 paths.emplace_back("libxtb_engine.so");
50 auto add_dirs = [&](const char *env) {
51 if (!env)
52 return;
53 std::string s(env);
54 size_t i = 0;
55 while (i < s.size()) {
56 auto j = s.find(':', i);
57 if (j == std::string::npos)
58 j = s.size();
59 if (j > i) {
60 std::string d = s.substr(i, j - i);
61 if (!d.empty() && d.back() != '/')
62 d += '/';
63 paths.push_back(d + "librgpot_xtb_engine.so");
64 paths.push_back(d + "libxtb_engine.so");
65 }
66 i = j + 1;
67 }
68 };
69 add_dirs(std::getenv("EON_POTENTIALS_PATH"));
70 add_dirs(std::getenv("RGPOT_ENGINE_PATH"));
71
72 std::string last_dlerr;
73 for (const auto &p : paths) {
74 m_lib = open_lib(p.c_str());
76 break;
77#ifndef _WIN32
78 if (const char *e = dlerror())
79 last_dlerr = e;
80#endif
81 }
83 std::string msg = "RGPOT(xtb): librgpot_xtb_engine.so not found "
84 "(set RGPOT_XTB_ENGINE or [RgpotPot] engine_path)";
85 if (!last_dlerr.empty())
86 msg += std::string("; last dlerror: ") + last_dlerr;
87 throw std::runtime_error(msg);
88 }
89
90 auto abi =
91 reinterpret_cast<int (*)()
>(load_sym(
m_lib,
"rgpot_xtb_abi_version"));
100 throw std::runtime_error("RGPOT(xtb): engine C ABI missing/mismatch");
101 }
102 char err[1024]{};
114 throw std::runtime_error(std::string("RGPOT(xtb): create failed: ") + err);
115 }
116}
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