ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/restraints/Restraint.hpp
Revision: 2020
Committed: Mon Sep 22 19:18:35 2014 UTC (10 years, 7 months ago) by gezelter
File size: 6052 byte(s)
Log Message:
Fixes for restraints, renaming of UniformField

File Contents

# Content
1 /*
2 * Copyright (c) 2009 The University of Notre Dame. All Rights Reserved.
3 *
4 * The University of Notre Dame grants you ("Licensee") a
5 * non-exclusive, royalty free, license to use, modify and
6 * redistribute this software in source and binary code form, provided
7 * that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * This software is provided "AS IS," without a warranty of any
18 * kind. All express or implied conditions, representations and
19 * warranties, including any implied warranty of merchantability,
20 * fitness for a particular purpose or non-infringement, are hereby
21 * excluded. The University of Notre Dame and its licensors shall not
22 * be liable for any damages suffered by licensee as a result of
23 * using, modifying or distributing the software or its
24 * derivatives. In no event will the University of Notre Dame or its
25 * licensors be liable for any lost revenue, profit or data, or for
26 * direct, indirect, special, consequential, incidental or punitive
27 * damages, however caused and regardless of the theory of liability,
28 * arising out of the use of or inability to use software, even if the
29 * University of Notre Dame has been advised of the possibility of
30 * such damages.
31 *
32 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33 * research, please cite the appropriate papers when you publish your
34 * work. Good starting points are:
35 *
36 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 */
42
43 /**
44 * @file Restraint.hpp
45 * @author cli2
46 * @date 06/17/2009
47 * @version 1.0
48 */
49
50 #ifndef RESTRAINTS_RESTRAINT_HPP
51 #define RESTRAINTS_RESTRAINT_HPP
52
53 #include "config.h"
54 #include "utils/GenericData.hpp"
55 #include "math/Vector3.hpp"
56 #include <map>
57
58 namespace OpenMD {
59
60 class Restraint {
61 public:
62
63 enum {
64 rtDisplacement = 1,
65 rtTwist = 2,
66 rtSwingX = 4,
67 rtSwingY = 8
68 };
69
70 typedef std::pair<RealType, RealType> RealPair;
71
72 Restraint() : twist0_(0.0), swingX0_(0.0), swingY0_(0.0), restType_(0),
73 printRest_(false) {
74 }
75
76 virtual ~Restraint() {}
77
78 // these are place-holders. The subclasses will have different arguments
79 // to the two functions.
80 void calcForce() {}
81 void setReferenceStructure() {}
82
83 RealType getUnscaledPotential() { return pot_; }
84 RealType getPotential() { return scaleFactor_ * pot_; }
85
86 void setRestraintName(std::string name) { restName_ = name; }
87 std::string getRestraintName() { return restName_; }
88
89 /** Returns the restraint type */
90 int getRestraintType(){ return restType_; }
91 /** Sets the restraint type */
92 void setRestraintType(int restType) { restType_ = restType; }
93
94 void setScaleFactor(RealType sf) { scaleFactor_ = sf;}
95
96 void setDisplacementForceConstant(RealType kDisp) {
97 kDisp_ = kDisp;
98 restType_ |= rtDisplacement;
99 if (printRest_) restInfo_[rtDisplacement] = std::make_pair(0.0, 0.0);
100 }
101
102 void setTwistForceConstant(RealType kTwist) {
103 kTwist_ = kTwist/4;
104 restType_ |= rtTwist;
105 if (printRest_) restInfo_[rtTwist] = std::make_pair(0.0, 0.0);
106 }
107
108 void setSwingXForceConstant(RealType kSwingX) {
109 kSwingX_ = kSwingX;
110 restType_ |= rtSwingX;
111 if (printRest_) restInfo_[rtSwingX] = std::make_pair(0.0, 0.0);
112 }
113
114 void setSwingYForceConstant(RealType kSwingY) {
115 kSwingY_ = kSwingY;
116 restType_ |= rtSwingY;
117 if (printRest_) restInfo_[rtSwingY] = std::make_pair(0.0, 0.0);
118 }
119
120 /* restraint angles are measured relative to the ideal structure,
121 and are measured in radians. If you want to restrain to the
122 same structure as the ideal structure, these do not need to be set.
123 */
124 void setRestrainedTwistAngle(RealType twist0) {
125 twist0_ = twist0;
126 restType_ |= rtTwist;
127 if (printRest_) restInfo_[rtTwist] = std::make_pair(0.0, 0.0);
128 }
129
130 void setRestrainedSwingXAngle(RealType swingX0) {
131 swingX0_ = swingX0;
132 restType_ |= rtSwingX;
133 if (printRest_) restInfo_[rtSwingX] = std::make_pair(0.0, 0.0);
134 }
135
136 void setRestrainedSwingYAngle(RealType swingY0) {
137 swingY0_ = swingY0;
138 restType_ |= rtSwingY;
139 if (printRest_) restInfo_[rtSwingY] = std::make_pair(0.0, 0.0);
140 }
141
142 void setPrintRestraint(bool printRest) {
143 printRest_ = printRest;
144 }
145
146 RealType getDisplacementForceConstant() { return kDisp_; }
147 RealType getTwistForceConstant() { return kTwist_; }
148 RealType getSwingXForceConstant() { return kSwingX_; }
149 RealType getSwingYForceConstant() { return kSwingY_; }
150 RealType getRestrainedTwistAngle() { return twist0_; }
151 RealType getRestrainedSwingXAngle() { return swingX0_; }
152 RealType getRestrainedSwingYAngle() { return swingY0_; }
153 std::map<int, RealPair> getRestraintInfo() { return restInfo_; }
154 bool getPrintRestraint() { return printRest_; }
155
156 protected:
157
158 RealType scaleFactor_;
159 RealType kDisp_;
160 RealType kTwist_;
161 RealType kSwingX_;
162 RealType kSwingY_;
163 RealType pot_;
164 RealType twist0_;
165 RealType swingX0_;
166 RealType swingY0_;
167 bool printRest_;
168
169 int restType_;
170 std::string restName_;
171 std::map<int, RealPair> restInfo_;
172 };
173
174 typedef SimpleTypeData<Restraint*> RestraintData;
175
176
177 }
178 #endif

Properties

Name Value
svn:executable *
svn:keywords Author Id Revision Date