23#include <boost/format.hpp>
24#include <boost/math/constants/constants.hpp>
41 std::string tasks_string = options.
get(
".tasks").
as<std::string>();
45 std::vector<std::string> tasks = tokenizedTasks.ToVector();
47 do_dft_input_ = std::find(tasks.begin(), tasks.end(),
"input") != tasks.end();
48 do_dft_run_ = std::find(tasks.begin(), tasks.end(),
"dft") != tasks.end();
49 do_dft_parse_ = std::find(tasks.begin(), tasks.end(),
"parse") != tasks.end();
50 do_gwbse_ = std::find(tasks.begin(), tasks.end(),
"gwbse") != tasks.end();
51 do_esp_ = std::find(tasks.begin(), tasks.end(),
"esp") != tasks.end();
61 std::cout <<
"\n... ... Writing job file: " <<
jobfile_ << std::flush;
63 ofs.open(
jobfile_, std::ofstream::out);
65 throw std::runtime_error(
"\nERROR: bad file handle: " +
jobfile_);
67 ofs <<
"<jobs>" << std::endl;
70 const std::vector<Segment>& segments = top.
Segments();
71 for (
const Segment& segment : segments) {
72 Index id = segment.getId();
77 pInput.
add(
"segment", (boost::format(
"%1$s") % segment.getId()).str());
78 pSegment.
setAttribute<std::string>(
"type", segment.getType());
85 ofs <<
"</jobs>" << std::endl;
88 std::cout <<
" with " << jobCount <<
" jobs" << std::flush;
92 const std::string& errormessage) {
101 ofs.open(logfile, std::ofstream::out);
102 if (!ofs.is_open()) {
103 throw std::runtime_error(
"Bad file handle: " + logfile);
105 ofs << logger << std::endl;
113 std::vector<tools::Property*> lSegments = job_input_.
Select(
"segment");
114 Index segId = lSegments.front()->getAttribute<
Index>(
"id");
115 std::string segType = lSegments.front()->getAttribute<std::string>(
"type");
116 std::string qmgeo_state =
"n";
117 if (lSegments.front()->exists(
"qm_geometry")) {
118 qmgeo_state = lSegments.front()->getAttribute<std::string>(
"qm_geometry");
129 <<
TimeStamp() <<
" Evaluating site " << seg.
getId() << std::flush;
132 std::filesystem::path arg_path;
133 std::string eqm_work_dir =
"OR_FILES";
134 std::string frame_dir =
135 "frame_" + boost::lexical_cast<std::string>(top.
getStep());
136 std::string orb_file =
137 (boost::format(
"%1%_%2%%3%") %
"molecule" % segId %
".orb").str();
138 std::string mol_dir = (boost::format(
"%1%%2%%3%") %
"molecule" %
"_" % segId).str();
139 std::string package_append =
"workdir_" +
Identify();
140 std::string work_dir =
141 (arg_path / eqm_work_dir / package_append / frame_dir / mol_dir)
147 std::string segName = seg.
getType();
159 std::string
package = package_options_.get(".name").as<std::string>();
161 qmpackage->setLog(&dft_logger);
162 qmpackage->setRunDir(work_dir);
167 std::filesystem::create_directories(work_dir);
168 qmpackage->WriteInputFile(orbitals);
172 bool run_dft_status = qmpackage->Run();
173 if (!run_dft_status) {
174 std::string output =
"DFT run failed";
182 bool parse_log_status = qmpackage->ParseLogFile(orbitals);
183 if (!parse_log_status) {
184 std::string output =
"log incomplete; ";
188 bool parse_orbitals_status = qmpackage->ParseMOsFile(orbitals);
189 if (!parse_orbitals_status) {
190 std::string output =
"orbfile failed; ";
195 if (qmpackage->getPackageName() ==
"orca") {
196 std::string DIR = eqm_work_dir +
"/molecules/" + frame_dir;
197 std::filesystem::create_directories(DIR);
198 std::string gbw_file =
199 (boost::format(
"%1%_%2%%3%") %
"molecule" % segId %
".gbw").str();
200 std::string GBWFILE = DIR +
"/" + gbw_file;
202 <<
"Copying MO data to " << gbw_file << std::flush;
203 std::string GBWFILE_workdir =
206 std::filesystem::copy_file(
207 GBWFILE_workdir, GBWFILE,
208 std::filesystem::copy_options::overwrite_existing);
212 qmpackage->CleanUp();
218 std::string ORB_FILE =
219 eqm_work_dir +
"/molecules/" + frame_dir +
"/" + orb_file;
221 <<
TimeStamp() <<
" Loading DFT data from " << ORB_FILE << std::flush;
240 }
catch (std::runtime_error& error) {
241 std::string errormessage(error.what());
255 std::string mps_file = (boost::format(
"%1%_%2%_%3%.mps") % segType % segId %
258 std::filesystem::create_directories(ESPDIR);
259 seg2.
WriteMPS(ESPDIR +
"/" + mps_file,
262 <<
"Written charges to " << (ESPDIR +
"/" + mps_file) << std::flush;
263 segment_summary.
add(
"partialcharges", (ESPDIR +
"/" + mps_file));
264 }
catch (std::runtime_error& error) {
265 std::string errormessage(error.what());
271 << seg.
getId() << std::flush;
275 std::string DIR = eqm_work_dir +
"/molecules/" + frame_dir;
276 std::filesystem::create_directories(DIR);
277 std::string ORBFILE = DIR +
"/" + orb_file;
const std::string & getType() const
void WriteMPS(std::string filename, std::string header) const
void WriteJobFile(const Topology &top)
tools::Property package_options_
void SetJobToFailed(Job::JobResult &jres, Logger &pLog, const std::string &errormessage)
void WriteLoggerToFile(const std::string &logfile, Logger &logger)
Job::JobResult EvalJob(const Topology &top, Job &job, QMThread &opThread)
tools::Property esp_options_
tools::Property gwbse_options_
void ParseSpecificOptions(const tools::Property &user_options)
std::string Identify() const
Calculator name.
void Initialize(tools::Property &options)
std::string GetStateString() const
StaticSegment Extractingcharges(const Orbitals &orbitals) const
Electronic excitations from GW-BSE.
void addoutput(tools::Property &summary)
void Initialize(tools::Property &options)
void setLogger(Logger *pLog)
void setError(std::string error)
void setOutput(std::string output)
void setStatus(JobStatus stat)
tools::Property & getInput()
void ToStream(std::ofstream &ofs) const
Logger is used for thread-safe output of messages.
void setPreface(Log::Level level, const std::string &preface)
void setMultithreading(bool maverick)
container for molecular orbitals
const QMMolecule & QMAtoms() const
void ReadFromCpt(const std::string &filename)
void WriteToCpt(const std::string &filename) const
typename std::vector< Job >::value_type Job
Identifier for QMstates. Strings like S1 are converted into enum +zero indexed int.
void LoadMappingFile(const std::string &mapfile)
AtomContainer map(const Segment &seg, const SegId &segid) const
Timestamp returns the current time as a string Example: cout << TimeStamp()
Container for segments and box and atoms.
std::vector< Segment > & Segments()
Segment & getSegment(Index id)
#define XTP_LOG(level, log)
Charge transport classes.
SegmentMapper< QMMolecule > QMMapper
ClassicalSegment< StaticSite > StaticSegment
Provides a means for comparing floating point numbers.
static Level current_level