OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
ShortRangeInteraction.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#ifndef PRIMITIVES_SHORTRANGEINTERACTION_HPP
46#define PRIMITIVES_SHORTRANGEINTERACTION_HPP
47
48#include <memory>
49#include <vector>
50
51#include "brains/Snapshot.hpp"
53#include "utils/PropertyMap.hpp"
54#include "visitors/BaseVisitor.hpp"
55
56namespace OpenMD {
57
58 /**
59 * @class ShortRangeInteraction
60 * @brief
61 *
62 * A ShortRangeInteraction holds some bookeeping data for bonded
63 * interactions (e.g. Bonds, Bends, Torsions, Inversions).
64 *
65 */
67 public:
68 virtual ~ShortRangeInteraction();
69
70 /**
71 * Returns the global index of this ShortRangeInteraction.
72 * @return the global index of this ShortRangeInteraction
73 */
74 int getGlobalIndex() { return globalIndex_; }
75
76 /**
77 * Sets the global index of this ShortRangeInteraction.
78 * @param index new global index to be set
79 */
80 void setGlobalIndex(int index) { globalIndex_ = index; }
81
82 /**
83 * Returns the local index of this ShortRangeInteraction
84 * @return the local index of this ShortRangeInteraction
85 */
86 int getLocalIndex() { return localIndex_; }
87
88 /**
89 * Sets the local index of this ShortRangeInteraction
90 * @param index new index to be set
91 */
92 void setLocalIndex(int index) { localIndex_ = index; }
93
94 /**
95 * Sets the Snapshot Manager of this ShortRangeInteraction
96 */
97 void setSnapshotManager(SnapshotManager* sman) { snapshotMan_ = sman; }
98
99 /** Returns the name of this ShortRangeInteraction */
100 virtual std::string getName() = 0;
101
102 /** Sets the name of this ShortRangeInteraction*/
103 virtual void setName(const std::string&) {}
104
105 /**
106 * <p>
107 * The purpose of the Visitor Pattern is to encapsulate an
108 * operation that you want to perform on the elements of a data
109 * structure. In this way, you can change the operation being
110 * performed on a structure without the need of changing the
111 * classes of the elements that you are operating on. Using a
112 * Visitor pattern allows you to decouple the classes for the data
113 * structure and the algorithms used upon them
114 * </p>
115 * @param v visitor
116 */
117 virtual void accept(BaseVisitor* v) = 0;
118
119 /**
120 * Returns the previous value of this ShortRangeInteraction
121 * @return the value of this ShortRangeInteraction
122 */
123 virtual RealType getPrevValue();
124
125 /**
126 * Returns the current value of this ShortRangeInteraction
127 * @return the current value of this ShortRangeInteraction
128 */
129 virtual RealType getValue();
130
131 /**
132 * Returns the value of this ShortRangeInteraction in specified snapshot
133 * @return the value of this ShortRangeInteraction
134 * @param snapshotNo
135 */
136 virtual RealType getValue(int snapshotNo) = 0;
137
138 virtual std::vector<Atom*> getAtoms() { return atoms_; }
139
140 /**
141 * Adds property into property map
142 * @param genData GenericData to be added into PropertyMap
143 */
144 void addProperty(std::shared_ptr<GenericData> genData);
145
146 /**
147 * Removes property from PropertyMap by name
148 * @param propName the name of property to be removed
149 */
150 void removeProperty(const std::string& propName);
151
152 /**
153 * Returns all names of properties
154 * @return all names of properties
155 */
156 std::vector<std::string> getPropertyNames();
157
158 /**
159 * Returns all of the properties in PropertyMap
160 * @return all of the properties in PropertyMap
161 */
162 std::vector<std::shared_ptr<GenericData>> getProperties();
163
164 /**
165 * Returns property
166 * @param propName name of property
167 * @return a pointer point to property with propName. If no property named
168 * propName exists, return NULL
169 */
170 std::shared_ptr<GenericData> getPropertyByName(const std::string& propName);
171
172 protected:
175 ShortRangeInteraction& operator=(const ShortRangeInteraction& sri);
176
177 SnapshotManager* snapshotMan_;
178 std::vector<Atom*> atoms_;
179
180 int globalIndex_;
181 int localIndex_;
182
183 private:
184 PropertyMap properties_;
185 };
186} // namespace OpenMD
187
188#endif // PRIMITIVES_STUNTDOUBLE_HPP
PropertyMap class maintains a list of GenericData.
A ShortRangeInteraction holds some bookeeping data for bonded interactions (e.g.
int getLocalIndex()
Returns the local index of this ShortRangeInteraction.
virtual RealType getValue()
Returns the current value of this ShortRangeInteraction.
void setLocalIndex(int index)
Sets the local index of this ShortRangeInteraction.
virtual RealType getPrevValue()
Returns the previous value of this ShortRangeInteraction.
virtual RealType getValue(int snapshotNo)=0
Returns the value of this ShortRangeInteraction in specified snapshot.
std::vector< std::shared_ptr< GenericData > > getProperties()
Returns all of the properties in PropertyMap.
virtual std::string getName()=0
Returns the name of this ShortRangeInteraction.
void setGlobalIndex(int index)
Sets the global index of this ShortRangeInteraction.
std::shared_ptr< GenericData > getPropertyByName(const std::string &propName)
Returns property.
virtual void accept(BaseVisitor *v)=0
void addProperty(std::shared_ptr< GenericData > genData)
Adds property into property map.
std::vector< std::string > getPropertyNames()
Returns all names of properties.
void setSnapshotManager(SnapshotManager *sman)
Sets the Snapshot Manager of this ShortRangeInteraction.
virtual void setName(const std::string &)
Sets the name of this ShortRangeInteraction.
void removeProperty(const std::string &propName)
Removes property from PropertyMap by name.
int getGlobalIndex()
Returns the global index of this ShortRangeInteraction.
SnapshotManager class is an abstract class which maintains a series of snapshots.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.