21#include <boost/format.hpp>
46 if (options.
exists(
"states")) {
47 std::string parse_string = options.
get(
".states").
as<std::string>();
53 const std::string& Mapstring) {
54 Tokenizer split_options(Mapstring,
", \t\n");
55 std::map<std::string, QMState> type2level;
56 for (
const std::string& substring : split_options) {
58 std::vector<std::string> segmentpnumber = tok.
ToVector();
59 if (segmentpnumber.size() != 2) {
60 throw std::runtime_error(
"Parser iqm: Segment and exciton labels:" +
61 substring +
"are not separated properly");
65 throw std::runtime_error(
"State to calculate must be a transition state");
67 std::string segmentname = segmentpnumber[0];
68 type2level[segmentname] = state;
85 std::vector<Property*> segment_list = job_input.
Select(
"segment");
86 Index ID_A = segment_list.front()->getAttribute<
Index>(
"id");
87 std::string type_A = segment_list.front()->getAttribute<std::string>(
"type");
88 std::string mps_fileA =
89 segment_list.front()->getAttribute<std::string>(
"mps_file");
90 Index ID_B = segment_list.back()->getAttribute<
Index>(
"id");
91 std::string type_B = segment_list.back()->getAttribute<std::string>(
"type");
92 std::string mps_fileB =
93 segment_list.back()->getAttribute<std::string>(
"mps_file");
96 if (type_A != seg_A.getType()) {
97 throw std::runtime_error(
"SegmentA: type " + seg_A.getType() +
98 " and type in jobfile " + type_A +
99 " do not agree for ID:" + std::to_string(ID_A));
102 if (type_B != seg_B.
getType()) {
103 throw std::runtime_error(
"SegmentB: type " + seg_B.
getType() +
104 " and type in jobfile " + type_B +
105 " do not agree for ID:" + std::to_string(ID_B));
109 if (pair ==
nullptr) {
110 throw std::runtime_error(
111 "pair between segments " + std::to_string(seg_A.getId()) +
":" +
112 std::to_string(seg_B.
getId()) +
" not found in neighborlist ");
116 <<
" [" << ID_A <<
":" << ID_B <<
"]" << std::flush;
126 Property& job_output = job_summary.
add(
"output",
"");
127 Property& pair_summary = job_output.
add(
"pair",
"");
128 std::string nameA = seg_A.getType();
129 std::string nameB = seg_B.
getType();
134 Property& coupling_summary = pair_summary.
add(
"Coupling",
"");
147 }
catch (std::out_of_range&) {
148 std::string errormessage =
149 "Map does not have segment of type: " + elementname;
150 errormessage +=
"\n segments in map are:";
152 errormessage +=
"\n\t" + s.first;
154 throw std::runtime_error(errormessage);
161 std::cout <<
"\n... ... Writing job file " <<
jobfile_ << std::flush;
163 ofs.open(
jobfile_, std::ofstream::out);
164 if (!ofs.is_open()) {
165 throw std::runtime_error(
"\nERROR: bad file handle: " +
jobfile_);
169 if (nblist.
size() == 0) {
170 std::cout <<
"\n... ... No pairs in neighbor list, skip." << std::flush;
175 std::string tag =
"";
177 for (
const QMPair* pair : nblist) {
179 Index id1 = pair->Seg1()->getId();
180 std::string name1 = pair->Seg1()->getType();
181 Index id2 = pair->Seg2()->getId();
182 std::string name2 = pair->Seg2()->getType();
187 std::string mps_file1 =
188 (boost::format(
"MP_FILES/%s_%s.mps") % name1 % state1.
ToString())
190 std::string mps_file2 =
191 (boost::format(
"MP_FILES/%s_%s.mps") % name2 % state2.
ToString())
197 pInput.
add(
"segment", boost::lexical_cast<std::string>(id1));
200 pSegment1.
setAttribute<std::string>(
"mps_file", mps_file1);
202 pInput.
add(
"segment", boost::lexical_cast<std::string>(id2));
204 pSegment2.setAttribute<
Index>(
"id", id2);
205 pSegment2.setAttribute<std::string>(
"mps_file", mps_file2);
217 std::cout <<
"\n... ... In total " << jobCount <<
" jobs" << std::flush;
226 std::vector<Property*> jobProps = xml.
Select(
"jobs.job");
228 Index updated_jobs = 0;
229 Index incomplete_jobs = 0;
232 for (
const Property* prop : jobProps) {
234 if (prop->exists(
"output") && prop->exists(
"output.pair")) {
235 const Property& poutput = prop->
get(
"output.pair");
242 if (qmp ==
nullptr) {
244 <<
"No pair " << idA <<
":" << idB
245 <<
" found in the neighbor list. Ignoring" << std::flush;
248 const Property& pCoupling = poutput.
get(
"Coupling");
249 double jAB = pCoupling.
getAttribute<
double>(
"jABstatic");
262 << jobProps.size() <<
":" << updated_jobs <<
":"
263 << incomplete_jobs << std::flush;
pair_type * FindPair(element_type e1, element_type e2)
const std::string & getType() const
std::map< std::string, QMState > FillParseMaps(const std::string &Mapstring)
void ReadJobFile(Topology &top)
void ParseSpecificOptions(const tools::Property &user_options)
std::map< std::string, QMState > statemap_
QMState GetElementFromMap(const std::string &elementname) const
Job::JobResult EvalJob(const Topology &top, Job &job, QMThread &opThread)
void WriteJobFile(const Topology &top)
void setOutput(std::string output)
void setStatus(JobStatus stat)
tools::Property & getInput()
Logger is used for thread-safe output of messages.
void setReportLevel(Log::Level ReportLevel)
void setJeff2(double Jeff2, QMStateType state)
const PairType & getType() const
Identifier for QMstates. Strings like S1 are converted into enum +zero indexed int.
std::string ToString() const
bool isTransition() const
Timestamp returns the current time as a string Example: cout << TimeStamp()
Container for segments and box and atoms.
Segment & getSegment(Index id)
Mediates interaction between polar and static sites.
double CalcStaticEnergy(const S1 &segment1, const S2 &segment2) const
#define XTP_LOG(level, log)
base class for all analysis tools
static Level current_level