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 =
139 (boost::format(
"%1%%2%%3%") %
"molecule" %
"_" % segId).str();
140 std::string package_append =
"workdir_" +
Identify();
141 std::string work_dir =
142 (arg_path / eqm_work_dir / package_append / frame_dir / mol_dir)
148 std::string segName = seg.
getType();
160 std::string
package = package_options_.get(".name").as<std::string>();
162 qmpackage->setLog(&dft_logger);
163 qmpackage->setRunDir(work_dir);
168 std::filesystem::create_directories(work_dir);
169 qmpackage->WriteInputFile(orbitals);
173 bool run_dft_status = qmpackage->Run();
174 if (!run_dft_status) {
175 std::string output =
"DFT run failed";
183 bool parse_log_status = qmpackage->ParseLogFile(orbitals);
184 if (!parse_log_status) {
185 std::string output =
"log incomplete; ";
189 bool parse_orbitals_status = qmpackage->ParseMOsFile(orbitals);
190 if (!parse_orbitals_status) {
191 std::string output =
"orbfile failed; ";
196 if (qmpackage->getPackageName() ==
"orca") {
197 std::string DIR = eqm_work_dir +
"/molecules/" + frame_dir;
198 std::filesystem::create_directories(DIR);
199 std::string gbw_file =
200 (boost::format(
"%1%_%2%%3%") %
"molecule" % segId %
".gbw").str();
201 std::string GBWFILE = DIR +
"/" + gbw_file;
203 <<
"Copying MO data to " << gbw_file << std::flush;
204 std::string GBWFILE_workdir =
207 std::filesystem::copy_file(
208 GBWFILE_workdir, GBWFILE,
209 std::filesystem::copy_options::overwrite_existing);
213 qmpackage->CleanUp();
219 std::string ORB_FILE =
220 eqm_work_dir +
"/molecules/" + frame_dir +
"/" + orb_file;
222 <<
TimeStamp() <<
" Loading DFT data from " << ORB_FILE << std::flush;
233 (boost::format(
"\nGWBSE INF ...")).str());
235 (boost::format(
"\nGWBSE ERR ...")).str());
237 (boost::format(
"\nGWBSE WAR ...")).str());
239 (boost::format(
"\nGWBSE DBG ...")).str());
245 }
catch (std::runtime_error& error) {
246 std::string errormessage(error.what());
260 std::string mps_file = (boost::format(
"%1%_%2%_%3%.mps") % segType %
263 std::filesystem::create_directories(ESPDIR);
264 seg2.
WriteMPS(ESPDIR +
"/" + mps_file,
267 <<
"Written charges to " << (ESPDIR +
"/" + mps_file) << std::flush;
268 segment_summary.
add(
"partialcharges", (ESPDIR +
"/" + mps_file));
269 }
catch (std::runtime_error& error) {
270 std::string errormessage(error.what());
276 << seg.
getId() << std::flush;
280 std::string DIR = eqm_work_dir +
"/molecules/" + frame_dir;
281 std::filesystem::create_directories(DIR);
282 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 and derived one-particle data.
const QMMolecule & QMAtoms() const
Return read-only access to the molecular geometry.
void ReadFromCpt(const std::string &filename)
Read the orbital container from a checkpoint file on disk.
void WriteToCpt(const std::string &filename) const
Write the orbital container to a checkpoint file on disk.
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