23#include <boost/format.hpp>
24#include <boost/math/constants/constants.hpp>
43 std::string tasks_string = options.
get(
".tasks").
as<std::string>();
47 std::vector<std::string> tasks = tokenizedTasks.ToVector();
49 do_dft_input_ = std::find(tasks.begin(), tasks.end(),
"input") != tasks.end();
50 do_dft_run_ = std::find(tasks.begin(), tasks.end(),
"dft") != tasks.end();
51 do_dft_parse_ = std::find(tasks.begin(), tasks.end(),
"parse") != tasks.end();
52 do_gwbse_ = std::find(tasks.begin(), tasks.end(),
"gwbse") != tasks.end();
53 do_esp_ = std::find(tasks.begin(), tasks.end(),
"esp") != tasks.end();
63 std::cout <<
"\n... ... Writing job file: " <<
jobfile_ << std::flush;
65 ofs.open(
jobfile_, std::ofstream::out);
67 throw std::runtime_error(
"\nERROR: bad file handle: " +
jobfile_);
69 ofs <<
"<jobs>" << std::endl;
72 const std::vector<Segment>& segments = top.
Segments();
73 for (
const Segment& segment : segments) {
74 Index id = segment.getId();
79 pInput.
add(
"segment", (format(
"%1$s") % segment.getId()).str());
80 pSegment.
setAttribute<std::string>(
"type", segment.getType());
87 ofs <<
"</jobs>" << std::endl;
90 std::cout <<
" with " << jobCount <<
" jobs" << std::flush;
94 const std::string& errormessage) {
103 ofs.open(logfile, std::ofstream::out);
104 if (!ofs.is_open()) {
105 throw std::runtime_error(
"Bad file handle: " + logfile);
107 ofs << logger << std::endl;
115 std::vector<tools::Property*> lSegments = job_input_.
Select(
"segment");
116 Index segId = lSegments.front()->getAttribute<
Index>(
"id");
117 std::string segType = lSegments.front()->getAttribute<std::string>(
"type");
118 std::string qmgeo_state =
"n";
119 if (lSegments.front()->exists(
"qm_geometry")) {
120 qmgeo_state = lSegments.front()->getAttribute<std::string>(
"qm_geometry");
131 <<
TimeStamp() <<
" Evaluating site " << seg.
getId() << std::flush;
134 std::filesystem::path arg_path;
135 std::string eqm_work_dir =
"OR_FILES";
136 std::string frame_dir =
137 "frame_" + boost::lexical_cast<std::string>(top.
getStep());
138 std::string orb_file =
139 (format(
"%1%_%2%%3%") %
"molecule" % segId %
".orb").str();
140 std::string mol_dir = (format(
"%1%%2%%3%") %
"molecule" %
"_" % segId).str();
141 std::string package_append =
"workdir_" +
Identify();
142 std::string work_dir =
143 (arg_path / eqm_work_dir / package_append / frame_dir / mol_dir)
149 std::string segName = seg.
getType();
161 std::string
package = package_options_.get(".name").as<std::string>();
163 qmpackage->setLog(&dft_logger);
164 qmpackage->setRunDir(work_dir);
169 std::filesystem::create_directories(work_dir);
170 qmpackage->WriteInputFile(orbitals);
174 bool run_dft_status = qmpackage->Run();
175 if (!run_dft_status) {
176 std::string output =
"DFT run failed";
184 bool parse_log_status = qmpackage->ParseLogFile(orbitals);
185 if (!parse_log_status) {
186 std::string output =
"log incomplete; ";
190 bool parse_orbitals_status = qmpackage->ParseMOsFile(orbitals);
191 if (!parse_orbitals_status) {
192 std::string output =
"orbfile failed; ";
197 if (qmpackage->getPackageName() ==
"orca") {
198 std::string DIR = eqm_work_dir +
"/molecules/" + frame_dir;
199 std::filesystem::create_directories(DIR);
200 std::string gbw_file =
201 (format(
"%1%_%2%%3%") %
"molecule" % segId %
".gbw").str();
202 std::string GBWFILE = DIR +
"/" + gbw_file;
204 <<
"Copying MO data to " << gbw_file << std::flush;
205 std::string GBWFILE_workdir =
208 std::filesystem::copy_file(
209 GBWFILE_workdir, GBWFILE,
210 std::filesystem::copy_options::overwrite_existing);
214 qmpackage->CleanUp();
220 std::string ORB_FILE =
221 eqm_work_dir +
"/molecules/" + frame_dir +
"/" + orb_file;
223 <<
TimeStamp() <<
" Loading DFT data from " << ORB_FILE << std::flush;
242 }
catch (std::runtime_error& error) {
243 std::string errormessage(error.what());
257 std::string mps_file = (format(
"%1%_%2%_%3%.mps") % segType % segId %
260 std::filesystem::create_directories(ESPDIR);
261 seg2.
WriteMPS(ESPDIR +
"/" + mps_file,
264 <<
"Written charges to " << (ESPDIR +
"/" + mps_file) << std::flush;
265 segment_summary.
add(
"partialcharges", (ESPDIR +
"/" + mps_file));
266 }
catch (std::runtime_error& error) {
267 std::string errormessage(error.what());
273 << seg.
getId() << std::flush;
277 std::string DIR = eqm_work_dir +
"/molecules/" + frame_dir;
278 std::filesystem::create_directories(DIR);
279 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
base class for all analysis tools
static Level current_level