20#include <pybind11/embed.h>
21#include <pybind11/stl.h>
24namespace py = pybind11;
30 const std::map<std::string, std::string>& dict) {
33 const std::string& xmlFile = dict.at(
"xmlFile");
34 const std::string& stateFile = dict.at(
"stateFile");
35 Index nThreads = std::stol(dict.at(
"nThreads"));
36 Index firstFrame = std::stol(dict.at(
"firstFrame"));
37 Index nFrames = std::stol(dict.at(
"nFrames"));
38 bool save = boost::lexical_cast<bool>(
"0");
48 .
get(
"options." + calculatorName);
52 calc.
Initialize(calculatorName, nThreads, options);
53 calc.
Run(stateFile, nFrames, firstFrame, save);
61 std::cout <<
"Calculator has been Initialized\n";
65 Index firstFrame,
bool save) {
68 std::vector<Index> frames = statsav.
getFrames();
70 throw std::runtime_error(
"stateFile " + stateFile +
" not found.");
73 std::cout <<
"Initializing calculator\n";
74 std::cout << frames.size() <<
" frames in stateFile, Ids are: ";
75 for (
Index frame : frames) {
76 std::cout << frame <<
" ";
79 if (firstFrame <
Index(frames.size())) {
80 std::cout <<
"Starting at frame " << frames[firstFrame] << std::endl;
82 std::cout <<
"First frame:" << firstFrame
83 <<
" is larger than number of frames:" <<
Index(frames.size())
88 if ((firstFrame + nFrames) >
Index(frames.size())) {
89 nFrames =
Index(frames.size()) - firstFrame;
92 for (
Index i = firstFrame; i < nFrames; i++) {
93 std::cout <<
"Evaluating frame " << frames[i] << std::endl;
99 std::cout <<
"Changes have not been written to state file." << std::endl;
void Run(const std::string &statefile, Index nFrames, Index firstFrame, bool save)
void Initialize(const std::string &calculatorName, Index nThreads, votca::tools::Property prop)
std::unique_ptr< xtp::QMCalculator > calculator_
void Initialize(const tools::Property &opt) final
Initializes a calculator from an XML file with options.
bool EvaluateFrame(Topology &top)
virtual bool WriteToStateFile() const =0
Topology ReadFrame(Index frameid) const
void WriteFrame(const Topology &top)
std::vector< Index > getFrames() const
Container for segments and box and atoms.
void call_calculator(const std::string &calculatorName, const std::map< std::string, std::string > &dict)
Construct a new pybind11 module object to invoke a votca-xtp Calculator.
base class for all analysis tools