votca 2026-dev
Loading...
Searching...
No Matches
qmatom.h
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#pragma once
21#ifndef VOTCA_XTP_QMATOM_H
22#define VOTCA_XTP_QMATOM_H
23
24// VOTCA includes
25#include "eigen.h"
27#include <votca/tools/types.h>
28
29namespace votca {
30namespace xtp {
31class CptTable;
37class QMAtom {
38 friend class ECPAOBasis;
39
40 public:
41 // Same as Atom::kMaxBondedPartners.
42 static constexpr Index kMaxBondedPartners = 4;
43
59
60 QMAtom(Index index, std::string element, Eigen::Vector3d pos);
61
62 QMAtom(const data& d);
63
64 const Eigen::Vector3d& getPos() const { return pos_; }
65
66 void Translate(const Eigen::Vector3d& shift) { pos_ += shift; }
67
68 void Rotate(const Eigen::Matrix3d& R, const Eigen::Vector3d& refPos);
69
70 void setPos(const Eigen::Vector3d& position) { pos_ = position; }
71
72 const std::string& getElement() const { return element_; }
73
74 Index getId() const { return index_; }
75
76 void setID(const Index index) { index_ = index; }
77
79
80 Index getElementNumber() const { return nuccharge_; }
81
82 // Same meaning as Atom::hasExternalBond()/getExternalBondDirection()
83 // (QMAtom does not derive from Atom). Set by SegmentMapper from the MD
84 // atom's direction, rotated with the fragment's MD->template transform.
85 bool hasExternalBond() const { return has_external_bond_; }
86 const Eigen::Vector3d& getExternalBondDirection() const {
88 }
89 void setExternalBondDirection(const Eigen::Vector3d& dir) {
90 has_external_bond_ = true;
91 external_bond_direction_ = dir.normalized();
92 }
93
94 // Marks the external bond as satisfied, e.g. because the partner segment
95 // is part of the same assembled supermolecule, so hasExternalBond()
96 // returns false and no H is added. Only affects this copy: each
97 // SegmentMapper::map() call rebuilds the atoms from the persisted Segment
98 // data.
100 has_external_bond_ = false;
101 external_bond_direction_ = Eigen::Vector3d::Zero();
103 }
104
105 // Same meaning as Atom::getExternalBondPartnerSegmentId(); copied
106 // unchanged by SegmentMapper. -1 if unset. The transient partner atom ID
107 // of Atom is not needed here.
114
115 // Same meaning as Atom::getBondedPartnerIds(), but as QM-level IDs
116 // (QMAtom::getId() within this QMMolecule). Translated from the MD-level
117 // IDs by SegmentMapper::map() (TransferBondedPartners). Unused slots hold
118 // -1.
120 void AddBondedPartner(Index partner_id) {
121 for (Index& slot : bonded_partner_ids_) {
122 if (slot == -1) {
123 slot = partner_id;
124 return;
125 }
126 }
127 // All slots full: partner is dropped (see Atom::kMaxBondedPartners).
128 }
129 // Overwrites all partner IDs, e.g. to offset them in
130 // QMMolecule::AddContainer() (AddBondedPartner() only fills free slots).
132 for (Index i = 0; i < kMaxBondedPartners; i++) {
133 bonded_partner_ids_[i] = ids[i];
134 }
135 }
136
137 std::string identify() const { return "qmatom"; }
138
139 friend std::ostream& operator<<(std::ostream& out, const QMAtom& atom) {
140 out << atom.getId() << " " << atom.getElement();
141 out << " " << atom.getPos().x() << "," << atom.getPos().y() << ","
142 << atom.getPos().z() << " " << atom.getNuccharge() << "\n";
143 return out;
144 }
145
146 private:
148 std::string element_;
149 Eigen::Vector3d pos_; // Bohr
151 Index ecpcharge_ = 0; // ecp charge is set in ecpaobasis.fill
152 bool has_external_bond_ = false;
153 Eigen::Vector3d external_bond_direction_ = Eigen::Vector3d::Zero();
156
157 public:
158 static void SetupCptTable(CptTable& table);
159
160 void WriteData(data& d) const;
161
162 void ReadData(const data& d);
163};
164} // namespace xtp
165} // namespace votca
166
167#endif // VOTCA_XTP_QMATOM_H
void AddBondedPartner(Index partner_id)
Definition qmatom.h:120
friend std::ostream & operator<<(std::ostream &out, const QMAtom &atom)
Definition qmatom.h:139
std::string element_
Definition qmatom.h:148
const Eigen::Vector3d & getPos() const
Definition qmatom.h:64
Index external_bond_partner_segment_id_
Definition qmatom.h:154
void Translate(const Eigen::Vector3d &shift)
Definition qmatom.h:66
const Index * getBondedPartnerIds() const
Definition qmatom.h:119
void clearExternalBond()
Definition qmatom.h:99
Eigen::Vector3d external_bond_direction_
Definition qmatom.h:153
Eigen::Vector3d pos_
Definition qmatom.h:149
Index getElementNumber() const
Definition qmatom.h:80
void setPos(const Eigen::Vector3d &position)
Definition qmatom.h:70
void WriteData(data &d) const
Definition qmatom.cc:68
friend class ECPAOBasis
Definition qmatom.h:38
Index getId() const
Definition qmatom.h:74
const std::string & getElement() const
Definition qmatom.h:72
const Eigen::Vector3d & getExternalBondDirection() const
Definition qmatom.h:86
void Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &refPos)
Definition qmatom.cc:34
static void SetupCptTable(CptTable &table)
Definition qmatom.cc:40
std::string identify() const
Definition qmatom.h:137
bool hasExternalBond() const
Definition qmatom.h:85
void setExternalBondDirection(const Eigen::Vector3d &dir)
Definition qmatom.h:89
Index bonded_partner_ids_[kMaxBondedPartners]
Definition qmatom.h:155
void setBondedPartnerIds(const Index(&ids)[kMaxBondedPartners])
Definition qmatom.h:131
Index getNuccharge() const
Definition qmatom.h:78
void setExternalBondPartnerSegmentId(Index segment_id)
Definition qmatom.h:111
Index getExternalBondPartnerSegmentId() const
Definition qmatom.h:108
void ReadData(const data &d)
Definition qmatom.cc:86
QMAtom(Index index, std::string element, Eigen::Vector3d pos)
Definition qmatom.cc:26
void setID(const Index index)
Definition qmatom.h:76
static constexpr Index kMaxBondedPartners
Definition qmatom.h:42
bool has_external_bond_
Definition qmatom.h:152
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
Index ext_bond_partner_segment_id
Definition qmatom.h:56
Index bonded_partner_ids[kMaxBondedPartners]
Definition qmatom.h:57