votca 2026-dev
Loading...
Searching...
No Matches
qmpackage.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2022 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
22#ifndef VOTCA_XTP_QMPACKAGE_H
23#define VOTCA_XTP_QMPACKAGE_H
24
25// Standard includes
26#include <memory>
27
28// VOTCA includes
30
31// Local VOTCA includes
32#include "aobasis.h"
33#include "classicalsegment.h"
34#include "logger.h"
35#include "staticsite.h"
37#include "vxc_grid.h"
38
39namespace votca {
40namespace xtp {
41
42class Orbitals;
43
44struct DFTSetupCache;
45
46class QMPackage {
47 public:
48 virtual ~QMPackage() = default;
49
50 virtual std::string getPackageName() const = 0;
51
52 void Initialize(const tools::Property& options);
53
55 virtual bool WriteInputFile(const Orbitals& orbitals) = 0;
56
57 bool Run();
58 bool RunActiveRegion();
59 virtual bool ParseLogFile(Orbitals& orbitals) = 0;
60
61 virtual bool ParseMOsFile(Orbitals& orbitals) = 0;
62
63 virtual void CleanUp() = 0;
64
65 template <class MMRegion>
66 void AddRegion(const MMRegion& mmregion) {
67
68 using Segmenttype = typename MMRegion::SegmentType;
69 using Sitetype = typename Segmenttype::Atom_Type;
70 for (const Segmenttype& segment : mmregion) {
71 for (const Sitetype& site : segment) {
72 externalsites_.push_back(std::make_unique<Sitetype>(site));
73 }
74 }
76 }
77
78 void setRunDir(const std::string& run_dir) { run_dir_ = run_dir; }
79
80 void setInputFileName(const std::string& input_file_name) {
81 input_file_name_ = input_file_name;
82 }
83
84 void setLogFileName(const std::string& log_file_name) {
85 log_file_name_ = log_file_name;
86 }
87
88 void setMOsFileName(const std::string& mo_file) { mo_file_name_ = mo_file; }
89
90 void setLog(Logger* pLog) { pLog_ = pLog; }
91
92 void setCharge(Index charge) {
93 charge_ = charge;
94 spin_ = std::abs(charge) + 1;
95 }
96
97 bool GuessRequested() const {
98 return options_.get("initial_guess").as<std::string>() == "orbfile";
99 }
100
101 virtual StaticSegment GetCharges() const = 0;
102
103 virtual Eigen::Matrix3d GetPolarizability() const = 0;
104
105 std::string getLogFile() const { return log_file_name_; };
106
107 std::string getMOFile() const { return mo_file_name_; };
108
109 void setEwaldgrid(const Vxc_Grid& ewaldgrid) {
110 ewaldgrid_ = ewaldgrid;
111 has_ewaldgrid_ = true;
112 };
113
114 // sum_A Z_A phi(R_A): the nuclei's share of the periodic background's
115 // potential. The grid above carries only what the electron density
116 // feels, so without this the nuclei sit in vacuum while the electrons
117 // do not -- which for a charged region is a large, silent error.
118 void setEwaldNuclearEnergy(double energy) {
119 ewald_nuclear_energy_ = energy;
121 }
122
123 // Start the SCF from the orbitals handed to WriteInputFile instead of the
124 // configured guess (QM/MM iterations after the first). Packages that cannot
125 // do this ignore it.
126 void setWarmStart(bool warm_start) { warm_start_ = warm_start; }
127
131 virtual void setSetupCache(std::shared_ptr<DFTSetupCache>) {}
132
137 virtual void setSCFToleranceFloor(double, double) {}
138
139 protected:
140 virtual void ParseSpecificOptions(const tools::Property& options) = 0;
142 MinimalMMCharge(const Eigen::Vector3d& pos, double q) : pos_(pos), q_(q) {};
143 Eigen::Vector3d pos_;
144 double q_;
145 };
146
147 virtual bool RunDFT() = 0;
148 virtual bool RunActiveDFT() = 0;
149 virtual void WriteChargeOption() = 0;
150 std::vector<MinimalMMCharge> SplitMultipoles(const StaticSite& site) const;
151 void ReorderOutput(Orbitals& orbitals) const;
152 Eigen::MatrixXd ReorderMOsBack(const Orbitals& orbitals) const;
153 bool isLinker(std::string name, std::vector<std::string> linker_names);
154
155 std::vector<std::string> GetLineAndSplit(std::ifstream& input_file,
156 const std::string separators) const;
157
158 // ShellReorder() and ShellMulitplier() specify the order for each
159 // QMPackage. Some codes also use different normalisation conditions which
160 // lead to other signs for some of the entries, which can be changed via the
161 // multipliers.
162 virtual const std::array<Index, 49>& ShellMulitplier() const = 0;
163 virtual const std::array<Index, 49>& ShellReorder() const = 0;
164
166 Index spin_; // 2S+1mem
167 std::string basisset_name_;
168 std::string cleanup_ = "";
169 std::string input_file_name_;
170 std::string log_file_name_;
171 std::string mo_file_name_;
172 std::string run_dir_;
173 std::string scratch_dir_;
174 std::string shell_file_name_;
176
178
179 std::vector<std::unique_ptr<StaticSite> > externalsites_;
180
182 bool has_ewaldgrid_ = false;
185 bool warm_start_ = false;
186};
187
188} // namespace xtp
189} // namespace votca
190
191#endif // VOTCA_XTP_QMPACKAGE_H
class to manage program options with xml serialization functionality
Definition property.h:55
Logger is used for thread-safe output of messages.
Definition logger.h:164
Container for molecular orbitals and derived one-particle data.
Definition orbitals.h:47
virtual void setSetupCache(std::shared_ptr< DFTSetupCache >)
Definition qmpackage.h:131
virtual ~QMPackage()=default
virtual void WriteChargeOption()=0
void setEwaldgrid(const Vxc_Grid &ewaldgrid)
Definition qmpackage.h:109
void setCharge(Index charge)
Definition qmpackage.h:92
std::string log_file_name_
Definition qmpackage.h:170
virtual Eigen::Matrix3d GetPolarizability() const =0
virtual const std::array< Index, 49 > & ShellReorder() const =0
void setLog(Logger *pLog)
Definition qmpackage.h:90
virtual void CleanUp()=0
std::vector< std::string > GetLineAndSplit(std::ifstream &input_file, const std::string separators) const
Definition qmpackage.cc:144
std::string run_dir_
Definition qmpackage.h:172
virtual void setSCFToleranceFloor(double, double)
Definition qmpackage.h:137
bool GuessRequested() const
Definition qmpackage.h:97
std::vector< std::unique_ptr< StaticSite > > externalsites_
Definition qmpackage.h:179
virtual std::string getPackageName() const =0
Eigen::MatrixXd ReorderMOsBack(const Orbitals &orbitals) const
Definition qmpackage.cc:97
std::vector< MinimalMMCharge > SplitMultipoles(const StaticSite &site) const
Definition qmpackage.cc:109
void setLogFileName(const std::string &log_file_name)
Definition qmpackage.h:84
std::string mo_file_name_
Definition qmpackage.h:171
virtual void ParseSpecificOptions(const tools::Property &options)=0
std::string getMOFile() const
Definition qmpackage.h:107
virtual bool RunDFT()=0
virtual bool RunActiveDFT()=0
virtual StaticSegment GetCharges() const =0
void setEwaldNuclearEnergy(double energy)
Definition qmpackage.h:118
virtual bool WriteInputFile(const Orbitals &orbitals)=0
writes a coordinate file WITHOUT taking into account PBCs
void setRunDir(const std::string &run_dir)
Definition qmpackage.h:78
void AddRegion(const MMRegion &mmregion)
Definition qmpackage.h:66
virtual bool ParseLogFile(Orbitals &orbitals)=0
std::string basisset_name_
Definition qmpackage.h:167
std::string cleanup_
Definition qmpackage.h:168
bool isLinker(std::string name, std::vector< std::string > linker_names)
void Initialize(const tools::Property &options)
Definition qmpackage.cc:35
virtual const std::array< Index, 49 > & ShellMulitplier() const =0
tools::Property options_
Definition qmpackage.h:175
virtual bool ParseMOsFile(Orbitals &orbitals)=0
std::string shell_file_name_
Definition qmpackage.h:174
void setMOsFileName(const std::string &mo_file)
Definition qmpackage.h:88
std::string scratch_dir_
Definition qmpackage.h:173
std::string input_file_name_
Definition qmpackage.h:169
void setInputFileName(const std::string &input_file_name)
Definition qmpackage.h:80
void setWarmStart(bool warm_start)
Definition qmpackage.h:126
std::string getLogFile() const
Definition qmpackage.h:105
void ReorderOutput(Orbitals &orbitals) const
Definition qmpackage.cc:74
Class to represent Atom/Site in electrostatic.
Definition staticsite.h:37
ClassicalSegment< StaticSite > StaticSegment
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
MinimalMMCharge(const Eigen::Vector3d &pos, double q)
Definition qmpackage.h:142