votca 2026-dev
Loading...
Searching...
No Matches
qmmolecule.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_QMMOLECULE_H
22#define VOTCA_XTP_QMMOLECULE_H
23
24// Local VOTCA includes
25#include "atomcontainer.h"
26#include "qmatom.h"
27
28namespace votca {
29namespace xtp {
30
31class QMMolecule : public AtomContainer<QMAtom> {
32 public:
33 QMMolecule(std::string name, Index id) : AtomContainer<QMAtom>(name, id) {};
34
36 void LoadFromFile(std::string filename);
37
38 void WriteXYZ(std::string filename, std::string header) const;
39
40 void AddContainer(const AtomContainer<QMAtom>& container) {
41 Index offset = atomlist_.size();
42 type_ += "_" + container.getType();
43 for (const auto& at : container) {
44 // Copy the whole atom so that external-bond data and bonded partners
45 // are kept (constructing a new QMAtom from index, element and
46 // position dropped them). The atom ID and the bonded-partner IDs
47 // are local to the added container and are shifted by offset; the
48 // external-bond partner is a segment ID and needs no offset.
49 QMAtom atom = at;
50 atom.setID(at.getId() + offset);
51 const Index* partners = at.getBondedPartnerIds();
52 Index offset_partners[QMAtom::kMaxBondedPartners];
53 for (Index i = 0; i < QMAtom::kMaxBondedPartners; i++) {
54 offset_partners[i] = (partners[i] == -1) ? -1 : partners[i] + offset;
55 }
56 atom.setBondedPartnerIds(offset_partners);
57 atomlist_.push_back(atom);
58 }
59 calcPos();
60 }
61
63 Index id = 0;
64 for (auto& at : atomlist_) {
65 at.setID(id);
66 id++;
67 }
68 }
69
70 friend std::ostream& operator<<(std::ostream& out,
71 const QMMolecule& container) {
72 out << container.getId() << " " << container.getType() << "\n";
73 for (const QMAtom& atom : container) {
74 out << atom;
75 }
76 out << std::endl;
77 return out;
78 }
79};
80
81} // namespace xtp
82} // namespace votca
83
84#endif // VOTCA_XTP_QMMOLECULE_H
const std::string & getType() const
const QMAtom & at(Index index) const
AtomContainer(std::string type, Index id)
container for QM atoms
Definition qmatom.h:37
void setBondedPartnerIds(const Index(&ids)[kMaxBondedPartners])
Definition qmatom.h:131
void setID(const Index index)
Definition qmatom.h:76
static constexpr Index kMaxBondedPartners
Definition qmatom.h:42
QMMolecule(std::string name, Index id)
Definition qmmolecule.h:33
void LoadFromFile(std::string filename)
Definition qmmolecule.cc:45
friend std::ostream & operator<<(std::ostream &out, const QMMolecule &container)
Definition qmmolecule.h:70
void WriteXYZ(std::string filename, std::string header) const
Definition qmmolecule.cc:37
void AddContainer(const AtomContainer< QMAtom > &container)
Definition qmmolecule.h:40
QMMolecule(CheckpointReader &r)
Definition qmmolecule.h:35
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26