votca 2026-dev
Loading...
Searching...
No Matches
ewaldcontainer.h
Go to the documentation of this file.
1
2/*
3 * Copyright 2009-2026 The VOTCA Development Team
4 * (http://www.votca.org)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License")
7 *
8 * You may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 */
20
21#pragma once
22
23#include <Eigen/Core>
24#include <complex>
25#include <stdexcept>
26#include <vector>
28
29namespace votca {
30namespace xtp {
31namespace ewaldcontainer {
32
34 double charge = 0.0;
35 Eigen::Vector3d position = Eigen::Vector3d::Zero();
36};
37
39 Eigen::Vector3d dipole = Eigen::Vector3d::Zero();
40 Eigen::Vector3d position = Eigen::Vector3d::Zero();
41};
42
44 Eigen::Vector3d G = Eigen::Vector3d::Zero();
45 std::complex<double> coefficient = {0.0, 0.0};
46};
47
49 public:
50 PotentialData() = default;
51
52 explicit PotentialData(double eta) : eta_(eta) {}
53
54 /* ---------- eta ---------- */
55
56 void setEta(double eta) {
57 if (eta <= 0.0) {
58 throw std::runtime_error("Ewald eta must be positive");
59 }
60 // eta in Ewald is in nm^-1; QM need bohr^-1
62 }
63
64 double eta() const { return eta_; }
65
66 /* ---------- charges ---------- */
67
68 void addCharge(double q, const Eigen::Vector3d& pos) {
69 charges_.push_back({q, pos * tools::conv::nm2bohr});
70 }
71
72 const std::vector<PointCharge>& charges() const { return charges_; }
73 std::vector<PointCharge>& charges() { return charges_; }
74
75 size_t numCharges() const { return charges_.size(); }
76
77 /* ---------- dipoles ---------- */
78
79 void addDipole(const Eigen::Vector3d& mu, const Eigen::Vector3d& pos) {
80 dipoles_.push_back({mu * tools::conv::nm2bohr, pos * tools::conv::nm2bohr});
81 }
82
83 const std::vector<PointDipole>& dipoles() const { return dipoles_; }
84 std::vector<PointDipole>& dipoles() { return dipoles_; }
85
86 size_t numDipoles() const { return dipoles_.size(); }
87
88 /* ---------- reciprocal terms ---------- */
89
90 void addReciprocalTerm(const Eigen::Vector3d& G,
91 const std::complex<double>& coeff) {
92 reciprocal_terms_.push_back(
94 }
95
96 const std::vector<ReciprocalTerm>& reciprocalTerms() const {
97 return reciprocal_terms_;
98 }
99
100 std::vector<ReciprocalTerm>& reciprocalTerms() { return reciprocal_terms_; }
101
102 size_t numReciprocalTerms() const { return reciprocal_terms_.size(); }
103
104 /* ---------- utilities ---------- */
105
106 bool empty() const {
107 return charges_.empty() && dipoles_.empty() && reciprocal_terms_.empty();
108 }
109
110 void clear() {
111 charges_.clear();
112 dipoles_.clear();
113 reciprocal_terms_.clear();
114 shape_factors_.setZero();
115 }
116
117 /* total charge useful for sanity checks */
118 double totalCharge() const {
119 double q = 0.0;
120 for (const auto& c : charges_) {
121 q += c.charge;
122 }
123 return q;
124 }
125
126 void setShapeFactors(Eigen::Vector4d vector) {
128 }
129
130 Eigen::Vector4d& shapeFactors() { return shape_factors_; }
131
132 const Eigen::Vector4d& shapeFactors() const { return shape_factors_; }
133
134 private:
135 double eta_ = 0.0;
137
138 std::vector<PointCharge> charges_;
139 std::vector<PointDipole> dipoles_;
140 std::vector<ReciprocalTerm> reciprocal_terms_;
141 Eigen::Vector4d shape_factors_ = Eigen::VectorXd::Zero(4);
142};
143
144} // namespace ewaldcontainer
145} // namespace xtp
146} // namespace votca
const std::vector< PointDipole > & dipoles() const
const Eigen::Vector4d & shapeFactors() const
const std::vector< ReciprocalTerm > & reciprocalTerms() const
std::vector< ReciprocalTerm > reciprocal_terms_
std::vector< PointCharge > & charges()
void addReciprocalTerm(const Eigen::Vector3d &G, const std::complex< double > &coeff)
std::vector< PointDipole > & dipoles()
std::vector< ReciprocalTerm > & reciprocalTerms()
void addDipole(const Eigen::Vector3d &mu, const Eigen::Vector3d &pos)
const std::vector< PointCharge > & charges() const
void addCharge(double q, const Eigen::Vector3d &pos)
void setShapeFactors(Eigen::Vector4d vector)
const double bohr2nm
Definition constants.h:46
const double nm2bohr
Definition constants.h:47
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33