votca 2024.2-dev
Loading...
Searching...
No Matches
coupling.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2023 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#pragma once
21#ifndef VOTCA_XTP_COUPLING_H
22#define VOTCA_XTP_COUPLING_H
23
24// Local VOTCA includes
26#include "votca/xtp/logger.h"
28
29namespace votca {
30namespace xtp {
31
32class Coupling final : public QMTool {
33 public:
34 Coupling() = default;
35 ~Coupling() = default;
36
37 std::string Identify() const { return "coupling"; }
38
39 protected:
40 void ParseOptions(const tools::Property &user_options);
41 bool Run();
42
43 private:
44 std::string MOsA_, MOsB_, MOsAB_;
45 std::string logA_, logB_, logAB_;
46
49
50 std::string output_file_;
51
53};
54
56
57 MOsA_ = options.get(".moleculeA.orbitals").as<std::string>();
58 MOsB_ = options.get(".moleculeB.orbitals").as<std::string>();
59 MOsAB_ = options.get(".dimerAB.orbitals").as<std::string>();
60
61 logA_ = options.get(".moleculeA.log").as<std::string>();
62 logB_ = options.get(".moleculeB.log").as<std::string>();
63 logAB_ = options.get(".dimerAB.log").as<std::string>();
64
65 output_file_ = options.ifExistsReturnElseReturnDefault<std::string>(
66 "output", job_name_ + "_coupling.xml");
67
68 package_options_ = options.get(".dftpackage");
69 dftcoupling_options_ = options.get(".dftcoupling");
70
72}
73
75
78
79 log_.setCommonPreface("\n... ...");
80
81 // get the corresponding object from the QMPackageFactory
82 std::unique_ptr<QMPackage> qmpackage =
83 std::unique_ptr<QMPackage>(QMPackageFactory().Create(
84 package_options_.get("name").as<std::string>()));
85 qmpackage->setLog(&log_);
86 qmpackage->Initialize(package_options_);
87 qmpackage->setRunDir(".");
88 Orbitals orbitalsA, orbitalsB, orbitalsAB;
89
90 qmpackage->setLogFileName(logA_);
91 bool parse_logA_status = qmpackage->ParseLogFile(orbitalsA);
92 if (!parse_logA_status) {
94 << "Failed to read log of molecule A" << std::flush;
95 }
96
97 qmpackage->setLogFileName(logB_);
98 bool parse_logB_status = qmpackage->ParseLogFile(orbitalsB);
99 if (!parse_logB_status) {
101 << "Failed to read log of molecule B" << std::flush;
102 }
103
104 qmpackage->setLogFileName(logAB_);
105 bool parse_logAB_status = qmpackage->ParseLogFile(orbitalsAB);
106 if (!parse_logAB_status) {
108 << "Failed to read log of molecule AB" << std::flush;
109 }
110
111 qmpackage->setMOsFileName(MOsA_);
112 bool parse_orbitalsA_status = qmpackage->ParseMOsFile(orbitalsA);
113 if (!parse_orbitalsA_status) {
115 << "Failed to read orbitals of molecule A" << std::flush;
116 }
117
118 qmpackage->setMOsFileName(MOsB_);
119 bool parse_orbitalsB_status = qmpackage->ParseMOsFile(orbitalsB);
120 if (!parse_orbitalsB_status) {
122 << "Failed to read orbitals of molecule B" << std::flush;
123 }
124
125 qmpackage->setMOsFileName(MOsAB_);
126 bool parse_orbitalsAB_status = qmpackage->ParseMOsFile(orbitalsAB);
127 if (!parse_orbitalsAB_status) {
129 << "Failed to read orbitals of dimer AB" << std::flush;
130 }
131
132 DFTcoupling dftcoupling;
133 dftcoupling.setLogger(&log_);
134 dftcoupling.Initialize(dftcoupling_options_);
135
136 dftcoupling.CalculateCouplings(orbitalsA, orbitalsB, orbitalsAB);
137 std::cout << log_;
138
139 // output the results
140 tools::Property summary;
141 tools::Property &job_output = summary.add("output", "");
142 tools::Property &pair_summary = job_output.add("pair", "");
143 dftcoupling.Addoutput(pair_summary, orbitalsA, orbitalsB);
144 std::ofstream ofs(output_file_, std::ofstream::out);
145 ofs << job_output;
146 ofs.close();
147
148 return true;
149}
150
151} // namespace xtp
152} // namespace votca
153
154#endif // VOTCA_XTP_COUPLING_H
class to manage program options with xml serialization functionality
Definition property.h:55
Property & add(const std::string &key, const std::string &value)
add a new property to structure
Definition property.cc:108
Property & get(const std::string &key)
get existing property
Definition property.cc:79
T as() const
return value as type
Definition property.h:283
T ifExistsReturnElseReturnDefault(const std::string &key, T defaultvalue) const
Definition property.h:321
void setLogger(Logger *pLog)
std::string logAB_
Definition coupling.h:45
std::string Identify() const
Calculator name.
Definition coupling.h:37
std::string MOsAB_
Definition coupling.h:44
std::string logA_
Definition coupling.h:45
tools::Property dftcoupling_options_
Definition coupling.h:48
std::string logB_
Definition coupling.h:45
std::string MOsB_
Definition coupling.h:44
void ParseOptions(const tools::Property &user_options)
Definition coupling.h:55
std::string output_file_
Definition coupling.h:50
tools::Property package_options_
Definition coupling.h:47
std::string MOsA_
Definition coupling.h:44
Evaluates electronic coupling elements.
Definition dftcoupling.h:38
void Initialize(tools::Property &) override
void Addoutput(tools::Property &type_summary, const Orbitals &orbitalsA, const Orbitals &orbitalsB) const override
void CalculateCouplings(const Orbitals &orbitalsA, const Orbitals &orbitalsB, const Orbitals &orbitalsAB) override
evaluates electronic couplings
Logger is used for thread-safe output of messages.
Definition logger.h:164
void setReportLevel(Log::Level ReportLevel)
Definition logger.h:185
void setMultithreading(bool maverick)
Definition logger.h:186
void setCommonPreface(const std::string &preface)
Definition logger.h:198
container for molecular orbitals
Definition orbitals.h:46
std::string job_name_
Definition qmtool.h:50
#define XTP_LOG(level, log)
Definition logger.h:40
base class for all analysis tools
Definition basebead.h:33
static Level current_level
Definition globals.h:30