votca 2026-dev
Loading...
Searching...
No Matches
polarsite.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 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_POLARSITE_H
22#define VOTCA_XTP_POLARSITE_H
23
24// Local VOTCA includes
25#include "eigen.h"
26#include "staticsite.h"
27
28namespace votca {
29namespace xtp {
30
36class PolarSite final : public StaticSite {
37
38 public:
39 // delete these two functions because we do not want to be able to read
40 // StaticSite::data but PolarSite::data
41 void WriteData(StaticSite::data& d) const = delete;
42 void ReadData(StaticSite::data& d) = delete;
43
44 PolarSite(Index id, std::string element, Eigen::Vector3d pos);
45 PolarSite(Index id, std::string element)
46 : PolarSite(id, element, Eigen::Vector3d::Zero()) {};
47
48 ~PolarSite() final = default;
49
50 void setpolarization(const Eigen::Matrix3d& pol) final;
51
52 Eigen::Matrix3d getpolarization() const { return pinv_.inverse(); }
53
54 const Eigen::Matrix3d& getPInv() const { return pinv_; }
55
56 // MULTIPOLES DEFINITION
57 Eigen::Vector3d getDipole() const final;
58 Eigen::Vector3d getStaticDipole() const final;
59 Eigen::Vector3d getInducedDipole() const final;
60
61 double getSqrtInvEigenDamp() const { return eigendamp_invsqrt_; }
62
63 void Rotate(const Eigen::Matrix3d& R, const Eigen::Vector3d& ref_pos) final {
64 StaticSite::Rotate(R, ref_pos);
65 pinv_ = R.transpose() * pinv_ * R;
66 }
67
68 const Eigen::Vector3d& V() const { return V_; }
69
70 Eigen::Vector3d& V() { return V_; }
71
72 const Eigen::Vector3d& V_noE() const { return V_noE_; }
73
74 Eigen::Vector3d& V_noE() { return V_noE_; }
75
76 void Reset() {
77 V_.setZero();
78 V_noE_.setZero();
79 }
80
81 void Depolarize() {
82 this->Reset();
83 this->setInduced_Dipole(Eigen::Vector3d::Zero());
84 }
85
86 double deltaQ_V_ext() const { return induced_dipole_.dot(V_); }
87
88 double InternalEnergy() const {
89 return 0.5 * induced_dipole_.transpose() * pinv_ * induced_dipole_;
90 }
91
92 const Eigen::Vector3d& Induced_Dipole() const { return induced_dipole_; }
93 void setInduced_Dipole(const Eigen::Vector3d& induced_dipole) {
94 induced_dipole_ = induced_dipole;
95 }
96
97 struct data {
99 char* element;
100 double posX;
101 double posY;
102 double posZ;
103
105
106 double Q00;
107 double Q11c;
108 double Q11s;
109 double Q10;
110 double Q20;
111 double Q21c;
112 double Q21s;
113 double Q22c;
114 double Q22s;
115
116 double Vx;
117 double Vy;
118 double Vz;
119
120 double Vx_noE;
121 double Vy_noE;
122 double Vz_noE;
123
124 double pxx;
125 double pxy;
126 double pxz;
127 double pyy;
128 double pyz;
129 double pzz;
130
131 double d_x_ind;
132 double d_y_ind;
133 double d_z_ind;
134 };
135 // do not move up has to be below data definition
136 PolarSite(const data& d);
137
138 double DipoleChange() const;
139
140 static void SetupCptTable(CptTable& table);
141 void WriteData(data& d) const;
142 void ReadData(const data& d);
143
144 std::string identify() const final { return "polarsite"; }
145
146 friend std::ostream& operator<<(std::ostream& out, const PolarSite& site) {
147 out << site.getId() << " " << site.getElement() << " " << site.getRank();
148 out << " " << site.getPos().transpose() << " "
149 << site.Induced_Dipole().transpose() << "\n";
150 return out;
151 }
152
153 private:
154 std::string writepolarization() const final;
155
156 // PolarSite has two external fields,
157 // the first is used for interaction with regions, which are further out, i.e.
158 // the interaction energy with it is included in the polar region energy
159 Eigen::Vector3d V_ = Eigen::Vector3d::Zero();
160 // the second is used for interaction with regions, which are further inside,
161 // i.e. the interaction energy with it is included in the other region's
162 // energy
163 Eigen::Vector3d V_noE_ = Eigen::Vector3d::Zero();
164
165 Eigen::Vector3d induced_dipole_ = Eigen::Vector3d::Zero();
166 Eigen::Matrix3d pinv_ = Eigen::Matrix3d::Zero();
167 double eigendamp_invsqrt_ = 0.0;
168};
169
170} // namespace xtp
171} // namespace votca
172
173#endif // VOTCA_XTP_POLARSITE_H
Eigen::Vector3d & V_noE()
Definition polarsite.h:74
double DipoleChange() const
double deltaQ_V_ext() const
Definition polarsite.h:86
double getSqrtInvEigenDamp() const
Definition polarsite.h:61
double InternalEnergy() const
Definition polarsite.h:88
void setInduced_Dipole(const Eigen::Vector3d &induced_dipole)
Definition polarsite.h:93
const Eigen::Matrix3d & getPInv() const
Definition polarsite.h:54
PolarSite(Index id, std::string element, Eigen::Vector3d pos)
Definition polarsite.cc:39
const Eigen::Vector3d & Induced_Dipole() const
Definition polarsite.h:92
static void SetupCptTable(CptTable &table)
Definition polarsite.cc:79
friend std::ostream & operator<<(std::ostream &out, const PolarSite &site)
Definition polarsite.h:146
PolarSite(Index id, std::string element)
Definition polarsite.h:45
const Eigen::Vector3d & V_noE() const
Definition polarsite.h:72
void WriteData(StaticSite::data &d) const =delete
void Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &ref_pos) final
Definition polarsite.h:63
Eigen::Vector3d V_noE_
Definition polarsite.h:163
Eigen::Vector3d induced_dipole_
Definition polarsite.h:165
void setpolarization(const Eigen::Matrix3d &pol) final
Definition polarsite.cc:62
Eigen::Matrix3d getpolarization() const
Definition polarsite.h:52
std::string identify() const final
Definition polarsite.h:144
Eigen::Matrix3d pinv_
Definition polarsite.h:166
Eigen::Vector3d getStaticDipole() const final
Definition polarsite.cc:58
const Eigen::Vector3d & V() const
Definition polarsite.h:68
Eigen::Vector3d getInducedDipole() const final
Definition polarsite.cc:60
std::string writepolarization() const final
Definition polarsite.cc:70
Eigen::Vector3d getDipole() const final
Definition polarsite.cc:54
Eigen::Vector3d & V()
Definition polarsite.h:70
void ReadData(StaticSite::data &d)=delete
~PolarSite() final=default
Eigen::Vector3d V_
Definition polarsite.h:159
const std::string & getElement() const
Definition staticsite.h:79
Index getId() const
Definition staticsite.h:77
const Eigen::Vector3d & getPos() const
Definition staticsite.h:80
StaticSite(Index id, std::string element, Eigen::Vector3d pos)
Definition staticsite.h:59
Index getRank() const
Definition staticsite.h:78
virtual void Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &refPos)
Definition staticsite.cc:66
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26