votca 2024.1-dev
Loading...
Searching...
No Matches
dftgwbse.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2023 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18// VOTCA includes
20
21// Local VOTCA includes
24#include "votca/xtp/segment.h"
26
27// Local private VOTCA includes
28#include "dftgwbse.h"
29
30namespace votca {
31namespace xtp {
32
34
35 // molecule coordinates
36 xyzfile_ = job_name_ + ".xyz";
37
38 // options for dft package
39 package_options_ = options.get(".dftpackage");
40
41 // GWBSEENGINE options
42 gwbseengine_options_ = options;
43
44 // lets get the archive file name from the xyz file name
45 archive_file_ = job_name_ + ".orb";
46
47 // XML OUTPUT
48 xml_output_ = job_name_ + "_summary.xml";
49
50 if (options.exists(".mpsfile")) {
51 mpsfile_ = options.get(".mpsfile").as<std::string>();
52 }
53
54 // check if guess is requested
55 if (options.exists(".guess")) {
56 guess_file_ = options.get(".guess").as<std::string>();
57 }
58
59 // register all QM packages
61}
62
64
66
68 log_.setCommonPreface("\n... ...");
69
70 // Get orbitals object
71 Orbitals orbitals;
72
73 if (!guess_file_.empty()) {
75 << "Reading guess from " << guess_file_ << std::flush;
76 orbitals.ReadFromCpt(guess_file_);
77 } else {
79 << "Reading structure from " << xyzfile_ << std::flush;
80 orbitals.QMAtoms().LoadFromFile(xyzfile_);
81 }
82
83 std::unique_ptr<QMPackage> qmpackage =
84 std::unique_ptr<QMPackage>(QMPackageFactory().Create(
85 package_options_.get("name").as<std::string>()));
86 qmpackage->setLog(&log_);
87 qmpackage->Initialize(package_options_);
88 qmpackage->setRunDir(".");
89
90 if (!mpsfile_.empty()) {
91 StaticRegion region(0, log_);
92 StaticSegment seg = StaticSegment("", 0);
94 region.push_back(seg);
95 qmpackage->AddRegion(region);
96 }
97
98 GWBSEEngine gwbse_engine;
99 gwbse_engine.setLog(&log_);
100 gwbse_engine.setQMPackage(qmpackage.get());
102
103 QMMolecule fullMol = orbitals.QMAtoms();
104 gwbse_engine.ExcitationEnergies(orbitals);
105 // If truncation was enabled then rewrite full basis/aux-basis, MOs in full
106 // basis and full QMAtoms
107 if (orbitals.getCalculationType() == "Truncated") {
108 orbitals.QMAtoms().clearAtoms();
109 orbitals.QMAtoms() = fullMol;
110 orbitals.MOs().eigenvectors() = orbitals.getTruncMOsFullBasis();
111 orbitals.SetupDftBasis(orbitals.getDftBasis().Name());
112 if (orbitals.hasAuxbasisName()) {
113 orbitals.SetupAuxBasis(orbitals.getAuxBasis().Name());
114 }
115 }
116
117 XTP_LOG(Log::error, log_) << "Saving data to " << archive_file_ << std::flush;
118 orbitals.WriteToCpt(archive_file_);
119
120 tools::Property summary = gwbse_engine.ReportSummary();
121 if (summary.exists("output")) { // only do gwbse summary output if we
122 // actually did gwbse
124 << "Writing output to " << xml_output_ << std::flush;
125 std::ofstream ofout(xml_output_, std::ofstream::out);
126 ofout << (summary.get("output"));
127 ofout.close();
128 }
129 return true;
130}
131
132} // namespace xtp
133} // namespace votca
const Eigen::MatrixXd & eigenvectors() const
Definition eigensystem.h:33
class to manage program options with xml serialization functionality
Definition property.h:55
Property & get(const std::string &key)
get existing property
Definition property.cc:79
bool exists(const std::string &key) const
check whether property exists
Definition property.cc:122
T as() const
return value as type
Definition property.h:283
const std::string & Name() const
Definition aobasis.h:81
void LoadFromFile(std::string filename)
void ParseOptions(const tools::Property &user_options)
Definition dftgwbse.cc:33
std::string guess_file_
Definition dftgwbse.h:47
tools::Property package_options_
Definition dftgwbse.h:54
std::string mpsfile_
Definition dftgwbse.h:48
std::string archive_file_
Definition dftgwbse.h:52
std::string xml_output_
Definition dftgwbse.h:51
tools::Property gwbseengine_options_
Definition dftgwbse.h:55
std::string xyzfile_
Definition dftgwbse.h:50
Electronic Excitations via Density-Functional Theory.
Definition gwbseengine.h:43
void ExcitationEnergies(Orbitals &orbitals)
const tools::Property & ReportSummary() const
Definition gwbseengine.h:58
void setLog(Logger *pLog)
Definition gwbseengine.h:50
void setQMPackage(QMPackage *qmpackage)
Definition gwbseengine.h:52
void Initialize(tools::Property &options, std::string archive_filename)
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
void push_back(const T &seg)
Definition mmregion.h:78
container for molecular orbitals
Definition orbitals.h:46
const Eigen::MatrixXd getTruncMOsFullBasis() const
Definition orbitals.h:62
bool hasAuxbasisName() const
Definition orbitals.h:234
const AOBasis & getAuxBasis() const
Definition orbitals.h:218
std::string getCalculationType() const
Definition orbitals.h:159
void SetupAuxBasis(std::string aux_basis_name)
Definition orbitals.cc:99
const tools::EigenSystem & MOs() const
Definition orbitals.h:122
const QMMolecule & QMAtoms() const
Definition orbitals.h:172
void ReadFromCpt(const std::string &filename)
Definition orbitals.cc:692
void WriteToCpt(const std::string &filename) const
Definition orbitals.cc:615
void SetupDftBasis(std::string basis_name)
Definition orbitals.cc:90
const AOBasis & getDftBasis() const
Definition orbitals.h:208
void LoadFromFile(std::string filename)
Definition qmmolecule.cc:45
std::string job_name_
Definition qmtool.h:50
#define XTP_LOG(level, log)
Definition logger.h:40
ClassicalSegment< StaticSite > StaticSegment
base class for all analysis tools
Definition basebead.h:33
static Level current_level
Definition globals.h:30