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#include <memory>
26// VOTCA includes
28
29// Local VOTCA includes
30#include "aobasis.h"
31#include "classicalsegment.h"
32#include "logger.h"
33#include "staticsite.h"
35#include "vxc_grid.h"
37
38namespace votca {
39namespace xtp {
40
41class Orbitals;
42
43class QMPackage {
44 public:
45 virtual ~QMPackage() = default;
46
47 virtual std::string getPackageName() const = 0;
48
49 void Initialize(const tools::Property& options);
50
52 virtual bool WriteInputFile(const Orbitals& orbitals) = 0;
53
54 bool Run();
55 bool RunActiveRegion();
56 virtual bool ParseLogFile(Orbitals& orbitals) = 0;
57
58 virtual bool ParseMOsFile(Orbitals& orbitals) = 0;
59
60 virtual void CleanUp() = 0;
61
62 template <class MMRegion>
63 void AddRegion(const MMRegion& mmregion) {
64
65 using Segmenttype = typename MMRegion::SegmentType;
66 using Sitetype = typename Segmenttype::Atom_Type;
67 for (const Segmenttype& segment : mmregion) {
68 for (const Sitetype& site : segment) {
69 externalsites_.push_back(std::make_unique<Sitetype>(site));
70 }
71 }
73 }
74
75 void setRunDir(const std::string& run_dir) { run_dir_ = run_dir; }
76
77 void setInputFileName(const std::string& input_file_name) {
78 input_file_name_ = input_file_name;
79 }
80
81 void setLogFileName(const std::string& log_file_name) {
82 log_file_name_ = log_file_name;
83 }
84
85 void setMOsFileName(const std::string& mo_file) { mo_file_name_ = mo_file; }
86
87 void setLog(Logger* pLog) { pLog_ = pLog; }
88
89 void setCharge(Index charge) {
90 charge_ = charge;
91 spin_ = std::abs(charge) + 1;
92 }
93
94 bool GuessRequested() const {
95 return options_.get("initial_guess").as<std::string>() == "orbfile";
96 }
97
98 virtual StaticSegment GetCharges() const = 0;
99
100 virtual Eigen::Matrix3d GetPolarizability() const = 0;
101
102 std::string getLogFile() const { return log_file_name_; };
103
104 std::string getMOFile() const { return mo_file_name_; };
105
106 void setEwaldgrid(const Vxc_Grid& ewaldgrid) {
107 ewaldgrid_ = ewaldgrid;
108 has_ewaldgrid_ = true;
109 };
110
111 // sum_A Z_A phi(R_A): the nuclei's share of the periodic background's
112 // potential. The grid above carries only what the electron density
113 // feels, so without this the nuclei sit in vacuum while the electrons
114 // do not -- which for a charged region is a large, silent error.
115 void setEwaldNuclearEnergy(double energy) {
116 ewald_nuclear_energy_ = energy;
118 }
119
120 // =========== EWALD MOMENTS SETTER AND ACCESS ==========
121 // +++++++++++ BACKGROUND +++++++++++++++++++++++++++++++
126
131
133 assert(ewald_background_ != nullptr);
134 return *ewald_background_;
135 }
136
137 // +++++++++++ FOREGROUND CORRECTION ++++++++++++++++++++++
141
146
151
152 // +++++++++++ SHAPE CORRECTION +++++++++++++++++++++++++++
156
161
166
167 // +++++++++++ MM1 REGION +++++++++++++++++++++++++++
169
171 assert(ewald_mm1_ != nullptr);
172 return *ewald_mm1_;
173 }
174
176 assert(ewald_mm1_ != nullptr);
177 return *ewald_mm1_;
178 }
179
180 protected:
181 virtual void ParseSpecificOptions(const tools::Property& options) = 0;
183 MinimalMMCharge(const Eigen::Vector3d& pos, double q) : pos_(pos), q_(q) {};
184 Eigen::Vector3d pos_;
185 double q_;
186 };
187
188 virtual bool RunDFT() = 0;
189 virtual bool RunActiveDFT() = 0;
190 virtual void WriteChargeOption() = 0;
191 std::vector<MinimalMMCharge> SplitMultipoles(const StaticSite& site) const;
192 void ReorderOutput(Orbitals& orbitals) const;
193 Eigen::MatrixXd ReorderMOsBack(const Orbitals& orbitals) const;
194 bool isLinker(std::string name, std::vector<std::string> linker_names);
195
196 std::vector<std::string> GetLineAndSplit(std::ifstream& input_file,
197 const std::string separators) const;
198
199 // ShellReorder() and ShellMulitplier() specify the order for each
200 // QMPackage. Some codes also use different normalisation conditions which
201 // lead to other signs for some of the entries, which can be changed via the
202 // multipliers.
203 virtual const std::array<Index, 49>& ShellMulitplier() const = 0;
204 virtual const std::array<Index, 49>& ShellReorder() const = 0;
205
207 Index spin_; // 2S+1mem
208 std::string basisset_name_;
209 std::string cleanup_ = "";
210 std::string input_file_name_;
211 std::string log_file_name_;
212 std::string mo_file_name_;
213 std::string run_dir_;
214 std::string scratch_dir_;
215 std::string shell_file_name_;
217
219
220 std::vector<std::unique_ptr<StaticSite> > externalsites_;
221
223 bool has_ewaldgrid_ = false;
226
232};
233
234} // namespace xtp
235} // namespace votca
236
237#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
const ewaldcontainer::PotentialData & ewaldBackground() const
Definition qmpackage.h:132
virtual ~QMPackage()=default
virtual void WriteChargeOption()=0
void setEwaldgrid(const Vxc_Grid &ewaldgrid)
Definition qmpackage.h:106
void setCharge(Index charge)
Definition qmpackage.h:89
std::string log_file_name_
Definition qmpackage.h:211
ewaldcontainer::PotentialData * ewald_foreground_correction_
Definition qmpackage.h:229
void setEwaldShapeCorrection(ewaldcontainer::PotentialData &shape_corr)
Definition qmpackage.h:153
ewaldcontainer::PotentialData * ewald_mm1_
Definition qmpackage.h:231
void setEwaldBackground(ewaldcontainer::PotentialData &bg)
Definition qmpackage.h:122
ewaldcontainer::PotentialData & ewaldShapeCorrection()
Definition qmpackage.h:157
virtual Eigen::Matrix3d GetPolarizability() const =0
void setEwaldMM1(ewaldcontainer::PotentialData &mm1)
Definition qmpackage.h:168
virtual const std::array< Index, 49 > & ShellReorder() const =0
void setLog(Logger *pLog)
Definition qmpackage.h:87
virtual void CleanUp()=0
ewaldcontainer::PotentialData * ewald_background_
Definition qmpackage.h:227
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:213
bool GuessRequested() const
Definition qmpackage.h:94
std::vector< std::unique_ptr< StaticSite > > externalsites_
Definition qmpackage.h:220
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:81
ewaldcontainer::PotentialData & ewaldForegroundCorrection()
Definition qmpackage.h:142
std::string mo_file_name_
Definition qmpackage.h:212
const ewaldcontainer::PotentialData & ewaldShapeCorrection() const
Definition qmpackage.h:162
virtual void ParseSpecificOptions(const tools::Property &options)=0
std::string getMOFile() const
Definition qmpackage.h:104
const ewaldcontainer::PotentialData & ewaldMM1() const
Definition qmpackage.h:175
virtual bool RunDFT()=0
virtual bool RunActiveDFT()=0
const ewaldcontainer::PotentialData & ewaldForegroundCorrection() const
Definition qmpackage.h:147
virtual StaticSegment GetCharges() const =0
void setEwaldNuclearEnergy(double energy)
Definition qmpackage.h:115
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:75
void AddRegion(const MMRegion &mmregion)
Definition qmpackage.h:63
virtual bool ParseLogFile(Orbitals &orbitals)=0
std::string basisset_name_
Definition qmpackage.h:208
std::string cleanup_
Definition qmpackage.h:209
bool isLinker(std::string name, std::vector< std::string > linker_names)
void Initialize(const tools::Property &options)
Definition qmpackage.cc:35
ewaldcontainer::PotentialData & ewaldBackground()
Definition qmpackage.h:127
virtual const std::array< Index, 49 > & ShellMulitplier() const =0
tools::Property options_
Definition qmpackage.h:216
ewaldcontainer::PotentialData * ewald_shape_correction_
Definition qmpackage.h:230
void setEwaldForegroundCorrection(ewaldcontainer::PotentialData &fg_corr)
Definition qmpackage.h:138
virtual bool ParseMOsFile(Orbitals &orbitals)=0
ewaldcontainer::PotentialData & ewaldMM1()
Definition qmpackage.h:170
std::string shell_file_name_
Definition qmpackage.h:215
void setMOsFileName(const std::string &mo_file)
Definition qmpackage.h:85
std::string scratch_dir_
Definition qmpackage.h:214
std::string input_file_name_
Definition qmpackage.h:210
void setInputFileName(const std::string &input_file_name)
Definition qmpackage.h:77
std::string getLogFile() const
Definition qmpackage.h:102
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:183