OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
Restraint.hpp
Go to the documentation of this file.
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/**
46 * @file Restraint.hpp
47 * @author cli2
48 * @date 06/17/2009
49 * @version 1.0
50 */
51
52#ifndef RESTRAINTS_RESTRAINT_HPP
53#define RESTRAINTS_RESTRAINT_HPP
54
55#include <config.h>
56
57#include <map>
58
59#include "math/Vector3.hpp"
60#include "utils/GenericData.hpp"
61
62namespace OpenMD {
63
64 class Restraint {
65 public:
66 enum {
67 rtDisplacement = 1,
68 rtAbsoluteZ = 2,
69 rtTwist = 4,
70 rtSwingX = 8,
71 rtSwingY = 16
72 };
73
74 using RealPair = std::pair<RealType, RealType>;
75
76 Restraint() :
77 twist0_(0.0), swingX0_(0.0), swingY0_(0.0), posZ0_(0.0),
78 printRest_(false), restType_(0) {}
79
80 virtual ~Restraint() {}
81
82 // these are place-holders. The subclasses will have different arguments
83 // to the two functions.
84 void calcForce() {}
85 void setReferenceStructure() {}
86
87 RealType getUnscaledPotential() { return pot_; }
88 RealType getPotential() { return scaleFactor_ * pot_; }
89
90 void setRestraintName(std::string name) { restName_ = name; }
91 std::string getRestraintName() { return restName_; }
92
93 /** Returns the restraint type */
94 int getRestraintType() { return restType_; }
95 /** Sets the restraint type */
96 void setRestraintType(int restType) { restType_ = restType; }
97
98 void setScaleFactor(RealType sf) { scaleFactor_ = sf; }
99
100 void setDisplacementForceConstant(RealType kDisp) {
101 kDisp_ = kDisp;
102 restType_ |= rtDisplacement;
103 if (printRest_) restInfo_[rtDisplacement] = std::make_pair(0.0, 0.0);
104 }
105
106 void setAbsoluteForceConstant(RealType kAbs) {
107 kAbs_ = kAbs;
108 restType_ |= rtAbsoluteZ;
109 if (printRest_) restInfo_[rtAbsoluteZ] = std::make_pair(0.0, 0.0);
110 }
111
112 void setTwistForceConstant(RealType kTwist) {
113 kTwist_ = kTwist / 4;
114 restType_ |= rtTwist;
115 if (printRest_) restInfo_[rtTwist] = std::make_pair(0.0, 0.0);
116 }
117
118 void setSwingXForceConstant(RealType kSwingX) {
119 kSwingX_ = kSwingX;
120 restType_ |= rtSwingX;
121 if (printRest_) restInfo_[rtSwingX] = std::make_pair(0.0, 0.0);
122 }
123
124 void setSwingYForceConstant(RealType kSwingY) {
125 kSwingY_ = kSwingY;
126 restType_ |= rtSwingY;
127 if (printRest_) restInfo_[rtSwingY] = std::make_pair(0.0, 0.0);
128 }
129
130 void setAbsolutePositionZ(RealType z0) {
131 posZ0_ = z0;
132 restType_ |= rtAbsoluteZ;
133 if (printRest_) restInfo_[rtAbsoluteZ] = std::make_pair(0.0, 0.0);
134 }
135
136 /* restraint angles are measured relative to the ideal structure,
137 and are measured in radians. If you want to restrain to the
138 same structure as the ideal structure, these do not need to be set.
139 */
140 void setRestrainedTwistAngle(RealType twist0) {
141 twist0_ = twist0;
142 restType_ |= rtTwist;
143 if (printRest_) restInfo_[rtTwist] = std::make_pair(0.0, 0.0);
144 }
145
146 void setRestrainedSwingXAngle(RealType swingX0) {
147 swingX0_ = swingX0;
148 restType_ |= rtSwingX;
149 if (printRest_) restInfo_[rtSwingX] = std::make_pair(0.0, 0.0);
150 }
151
152 void setRestrainedSwingYAngle(RealType swingY0) {
153 swingY0_ = swingY0;
154 restType_ |= rtSwingY;
155 if (printRest_) restInfo_[rtSwingY] = std::make_pair(0.0, 0.0);
156 }
157
158 void setPrintRestraint(bool printRest) { printRest_ = printRest; }
159
160 RealType getDisplacementForceConstant() { return kDisp_; }
161 RealType getAbsoluteForceConstant() { return kAbs_; }
162 RealType getAbsolutePositionZ() { return posZ0_; }
163 RealType getTwistForceConstant() { return kTwist_; }
164 RealType getSwingXForceConstant() { return kSwingX_; }
165 RealType getSwingYForceConstant() { return kSwingY_; }
166 RealType getRestrainedTwistAngle() { return twist0_; }
167 RealType getRestrainedSwingXAngle() { return swingX0_; }
168 RealType getRestrainedSwingYAngle() { return swingY0_; }
169 std::map<int, RealPair> getRestraintInfo() { return restInfo_; }
170 bool getPrintRestraint() { return printRest_; }
171
172 protected:
173 RealType scaleFactor_;
174 RealType kDisp_;
175 RealType kAbs_;
176 RealType kTwist_;
177 RealType kSwingX_;
178 RealType kSwingY_;
179 RealType pot_;
180 RealType twist0_;
181 RealType swingX0_;
182 RealType swingY0_;
183 RealType posZ0_;
184 bool printRest_;
185
186 int restType_;
187 std::string restName_;
188 std::map<int, RealPair> restInfo_;
189 };
190
191 using RestraintData = SimpleTypeData<Restraint*>;
192} // namespace OpenMD
193
194#endif
void setRestraintType(int restType)
Sets the restraint type
Definition Restraint.hpp:96
int getRestraintType()
Returns the restraint type
Definition Restraint.hpp:94
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.