votca 2024.1-dev
Loading...
Searching...
No Matches
xtpdft.cc
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// Standard includes
21#include <cstdio>
22#include <iomanip>
23
24// Third party includes
25#include <boost/algorithm/string.hpp>
26#include <boost/filesystem.hpp>
27#include <boost/format.hpp>
28
29// VOTCA includes
31
32// Local private VOTCA includes
33#include "xtpdft.h"
34
35namespace votca {
36namespace xtp {
37using namespace std;
38
40 const std::string job_name = options.get("temporary_file").as<std::string>();
41 log_file_name_ = job_name + ".orb";
43}
44
45bool XTPDFT::WriteInputFile(const Orbitals& orbitals) {
46 orbitals_ = orbitals;
48 return true;
49}
50
55 DFTEngine xtpdft;
56 xtpdft.Initialize(options_);
57 xtpdft.setLogger(pLog_);
58
59 if (!externalsites_.empty()) {
61 }
62 bool success = xtpdft.Evaluate(orbitals_);
63 std::string file_name = run_dir_ + "/" + log_file_name_;
65 << "Writing result to " << log_file_name_ << flush;
66 orbitals_.WriteToCpt(file_name);
67 return success;
68}
69
71 DFTEngine xtpdft;
72 xtpdft.Initialize(options_);
73 xtpdft.setLogger(pLog_);
74
75 if (!externalsites_.empty()) {
77 }
78
79 bool success = xtpdft.EvaluateActiveRegion(orbitals_) &&
81 std::string file_name = run_dir_ + "/" + log_file_name_;
83 << "Writing embedding result to " << log_file_name_ << flush;
84 orbitals_.WriteToCpt(file_name);
85 return success;
86}
87
89 if (cleanup_.size() != 0) {
90 XTP_LOG(Log::info, *pLog_) << "Removing " << cleanup_ << " files" << flush;
91 std::vector<std::string> cleanup_info =
93 for (const std::string& substring : cleanup_info) {
94 if (substring == "log") {
95 std::string file_name = run_dir_ + "/" + log_file_name_;
96 remove(file_name.c_str());
97 }
98 }
99 }
100
101 return;
102}
103
107bool XTPDFT::ParseMOsFile(Orbitals&) { return true; }
108
110 try {
111 std::string file_name = run_dir_ + "/" + log_file_name_;
112 orbitals.ReadFromCpt(file_name);
113 XTP_LOG(Log::info, *pLog_) << (boost::format("QM energy[Hrt]: %4.8f ") %
114 orbitals.getDFTTotalEnergy())
115 .str()
116 << flush;
117 } catch (std::runtime_error& error) {
119 << "Reading" << log_file_name_ << " failed" << flush;
120 return false;
121 }
122 return true;
123}
124
125} // namespace xtp
126} // namespace votca
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
T as() const
return value as type
Definition property.h:283
break string into words
Definition tokenizer.h:72
std::vector< T > ToVector()
store all words in a vector of type T, does type conversion.
Definition tokenizer.h:109
Electronic ground-state via Density-Functional Theory.
Definition dftengine.h:48
void setExternalcharges(std::vector< std::unique_ptr< StaticSite > > *externalsites)
Definition dftengine.h:54
bool EvaluateTruncatedActiveRegion(Orbitals &trunc_orb)
void setLogger(Logger *pLog)
Definition dftengine.h:52
bool EvaluateActiveRegion(Orbitals &orb)
void Initialize(tools::Property &options)
Definition dftengine.cc:46
bool Evaluate(Orbitals &orb)
Definition dftengine.cc:209
container for molecular orbitals
Definition orbitals.h:46
double getDFTTotalEnergy() const
Definition orbitals.h:193
void setQMpackage(const std::string &qmpackage)
Definition orbitals.h:114
void ReadFromCpt(const std::string &filename)
Definition orbitals.cc:692
void WriteToCpt(const std::string &filename) const
Definition orbitals.cc:615
std::string log_file_name_
Definition qmpackage.h:135
std::string run_dir_
Definition qmpackage.h:137
std::vector< std::unique_ptr< StaticSite > > externalsites_
Definition qmpackage.h:144
std::string mo_file_name_
Definition qmpackage.h:136
std::string cleanup_
Definition qmpackage.h:133
tools::Property options_
Definition qmpackage.h:140
bool ParseLogFile(Orbitals &orbitals) final
Definition xtpdft.cc:109
Orbitals orbitals_
Definition xtpdft.h:105
bool RunDFT() final
Definition xtpdft.cc:54
void ParseSpecificOptions(const tools::Property &options) final
Definition xtpdft.cc:39
void CleanUp() final
Definition xtpdft.cc:88
std::string getPackageName() const final
Definition xtpdft.h:45
bool WriteInputFile(const Orbitals &orbitals) final
writes a coordinate file WITHOUT taking into account PBCs
Definition xtpdft.cc:45
bool ParseMOsFile(Orbitals &orbitals) final
Definition xtpdft.cc:107
bool RunActiveDFT() final
Definition xtpdft.cc:70
#define XTP_LOG(level, log)
Definition logger.h:40
STL namespace.
base class for all analysis tools
Definition basebead.h:33