votca 2026-dev
Loading...
Searching...
No Matches
topology.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_TOPOLOGY_H
22#define VOTCA_XTP_TOPOLOGY_H
23
24// VOTCA includes
26#include <votca/csg/openbox.h>
29
30// Local VOTCA includes
31#include "qmnblist.h"
32
33namespace votca {
34namespace xtp {
35
36class Segment;
41class Topology {
42 public:
43 Topology() = default;
44
45 Topology(const Topology &top);
46
47 Topology &operator=(const Topology &top);
48
49 // I do not have to manually make a move constructor or move assignment
50 // operator or destructor because I only have to reassign pointers in qmnblist
51 // object
52
53 Segment &AddSegment(std::string segment_name);
54
55 Segment &getSegment(Index id) { return segments_[id]; }
56 const Segment &getSegment(Index id) const { return segments_[id]; }
57
58 std::vector<Segment> &Segments() { return segments_; }
59 const std::vector<Segment> &Segments() const { return segments_; }
60
61 // Periodic boundary: Can be 'open', 'orthorhombic', 'triclinic'
62 Eigen::Vector3d PbShortestConnect(const Eigen::Vector3d &r1,
63 const Eigen::Vector3d &r2) const;
64 const Eigen::Matrix3d &getBox() const { return bc_->getBox(); }
65 double BoxVolume() const { return bc_->BoxVolume(); }
66 void setBox(const Eigen::Matrix3d &box,
69
70 QMNBList &NBList() { return nblist_; }
71 const QMNBList &NBList() const { return nblist_; }
72
73 // Trajectory meta data: step number, time, frame (= Db ID)
74
75 Index getStep() const { return step_; }
76 void setStep(Index step) { step_ = step; }
77 double getTime() const { return time_; }
78 void setTime(double time) { time_ = time; }
79
80 void WriteToCpt(CheckpointWriter &w) const;
81
82 void WriteToPdb(std::string filename) const;
83
85
86 double GetShortestDist(const Segment &seg1, const Segment &seg2) const;
87
88 std::vector<const Segment *> FindAllSegmentsOnMolecule(
89 const Segment &seg1, const Segment &seg2) const;
90
91 // Finds the segments genuinely "in between" seg1 and seg2 along the
92 // real, actual covalent bond path connecting them -- i.e. every
93 // segment on the shortest such path, EXCLUDING seg1/seg2 themselves.
94 // Deliberately different from FindAllSegmentsOnMolecule above (an
95 // existing, IQM-specific mechanism, confirmed directly, earlier
96 // this session, to return EVERY segment on the same MD-level
97 // molecule as either seg1 or seg2, filtered only by segment TYPE --
98 // for a long polymer chain with many repeat-unit segments sharing
99 // one type, that mechanism pulls in every other unit on the whole
100 // molecule, not just the ones genuinely between the requested
101 // pair): this uses the real, actual bond-connectivity graph between
102 // segments (Atom::getExternalBondPartnerSegmentId(), built and
103 // tested earlier this session) directly, via a breadth-first search
104 // -- genuinely more precise, since only segments actually on the
105 // real, shortest bonded path are ever returned, regardless of how
106 // many other, unrelated segments happen to share a molecule with
107 // seg1/seg2.
108 //
109 // Returns an empty vector if seg1 and seg2 are not connected by any
110 // real, actual covalent bond path at all (including if they are
111 // simply not neighbors in the graph-theoretic sense -- e.g.
112 // genuinely different, unconnected molecules), matching
113 // FindAllSegmentsOnMolecule's own, established "empty means none"
114 // convention. Returns an empty vector too if seg1 and seg2 are
115 // DIRECTLY bonded (no genuine linker in between at all).
116 std::vector<const Segment *> FindLinkingSegments(const Segment &seg1,
117 const Segment &seg2) const;
118
119 private:
120 std::vector<Segment> segments_;
121
122 std::unique_ptr<csg::BoundaryCondition> bc_ = nullptr;
124
125 double time_;
127
129 const Eigen::Matrix3d &box);
130
131 static constexpr int topology_version() { return 1; }
132};
133
134} // namespace xtp
135} // namespace votca
136
137#endif // VOTCA_XTP_TOPOLOGY_H
double getTime() const
Definition topology.h:77
const Segment & getSegment(Index id) const
Definition topology.h:56
void WriteToCpt(CheckpointWriter &w) const
Definition topology.cc:274
Index getStep() const
Definition topology.h:75
std::unique_ptr< csg::BoundaryCondition > bc_
Definition topology.h:122
Segment & AddSegment(std::string segment_name)
Definition topology.cc:70
std::vector< Segment > segments_
Definition topology.h:120
Eigen::Vector3d PbShortestConnect(const Eigen::Vector3d &r1, const Eigen::Vector3d &r2) const
Definition topology.cc:134
void setTime(double time)
Definition topology.h:78
void setBox(const Eigen::Matrix3d &box, csg::BoundaryCondition::eBoxtype boxtype=csg::BoundaryCondition::typeAuto)
Definition topology.cc:79
std::vector< Segment > & Segments()
Definition topology.h:58
std::vector< const Segment * > FindAllSegmentsOnMolecule(const Segment &seg1, const Segment &seg2) const
Definition topology.cc:154
csg::BoundaryCondition::eBoxtype AutoDetectBoxType(const Eigen::Matrix3d &box)
Definition topology.cc:108
const Eigen::Matrix3d & getBox() const
Definition topology.h:64
std::vector< const Segment * > FindLinkingSegments(const Segment &seg1, const Segment &seg2) const
Definition topology.cc:176
void ReadFromCpt(CheckpointReader &r)
Definition topology.cc:289
void WriteToPdb(std::string filename) const
Definition topology.cc:262
QMNBList & NBList()
Definition topology.h:70
const QMNBList & NBList() const
Definition topology.h:71
Topology & operator=(const Topology &top)
Definition topology.cc:54
const std::vector< Segment > & Segments() const
Definition topology.h:59
double BoxVolume() const
Definition topology.h:65
double GetShortestDist(const Segment &seg1, const Segment &seg2) const
Definition topology.cc:139
void setStep(Index step)
Definition topology.h:76
Segment & getSegment(Index id)
Definition topology.h:55
static constexpr int topology_version()
Definition topology.h:131
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26