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 |
} |
74 |
|
75 |
virtual ~Restraint() {} |
76 |
|
77 |
// these are place-holders. The subclasses will have different arguments |
78 |
// to the two functions. |
79 |
void calcForce() {} |
80 |
void setReferenceStructure() {} |
81 |
|
82 |
RealType getUnscaledPotential() { return pot_; } |
83 |
RealType getPotential() { return scaleFactor_ * pot_; } |
84 |
|
85 |
void setRestraintName(std::string name) { restName_ = name; } |
86 |
std::string getRestraintName() { return restName_; } |
87 |
|
88 |
/** Returns the restraint type */ |
89 |
int getRestraintType(){ return restType_; } |
90 |
/** Sets the restraint type */ |
91 |
void setRestraintType(int restType) { restType_ = restType; } |
92 |
|
93 |
void setScaleFactor(RealType sf) { scaleFactor_ = sf;} |
94 |
|
95 |
void setDisplacementForceConstant(RealType kDisp) { |
96 |
kDisp_ = kDisp; |
97 |
restType_ |= rtDisplacement; |
98 |
restInfo_[rtDisplacement] = std::make_pair(0.0, 0.0); |
99 |
} |
100 |
|
101 |
void setTwistForceConstant(RealType kTwist) { |
102 |
kTwist_ = kTwist/4; |
103 |
restType_ |= rtTwist; |
104 |
restInfo_[rtTwist] = std::make_pair(0.0, 0.0); |
105 |
} |
106 |
|
107 |
void setSwingXForceConstant(RealType kSwingX) { |
108 |
kSwingX_ = kSwingX; |
109 |
restType_ |= rtSwingX; |
110 |
restInfo_[rtSwingX] = std::make_pair(0.0, 0.0); |
111 |
} |
112 |
|
113 |
void setSwingYForceConstant(RealType kSwingY) { |
114 |
kSwingY_ = kSwingY; |
115 |
restType_ |= rtSwingY; |
116 |
restInfo_[rtSwingY] = std::make_pair(0.0, 0.0); |
117 |
} |
118 |
|
119 |
/* restraint angles are measured relative to the ideal structure, |
120 |
and are measured in radians. If you want to restrain to the |
121 |
same structure as the ideal structure, these do not need to be set. |
122 |
*/ |
123 |
void setRestrainedTwistAngle(RealType twist0) { |
124 |
twist0_ = twist0; |
125 |
restType_ |= rtTwist; |
126 |
restInfo_[rtTwist] = std::make_pair(0.0, 0.0); |
127 |
} |
128 |
|
129 |
void setRestrainedSwingXAngle(RealType swingX0) { |
130 |
swingX0_ = swingX0; |
131 |
restType_ |= rtSwingX; |
132 |
restInfo_[rtSwingX] = std::make_pair(0.0, 0.0); |
133 |
} |
134 |
|
135 |
void setRestrainedSwingYAngle(RealType swingY0) { |
136 |
swingY0_ = swingY0; |
137 |
restType_ |= rtSwingY; |
138 |
restInfo_[rtSwingY] = std::make_pair(0.0, 0.0); |
139 |
} |
140 |
|
141 |
void setPrintRestraint(bool printRest) { |
142 |
printRest_ = printRest; |
143 |
} |
144 |
|
145 |
RealType getDisplacementForceConstant() { return kDisp_; } |
146 |
RealType getTwistForceConstant() { return kTwist_; } |
147 |
RealType getSwingXForceConstant() { return kSwingX_; } |
148 |
RealType getSwingYForceConstant() { return kSwingY_; } |
149 |
RealType getRestrainedTwistAngle() { return twist0_; } |
150 |
RealType getRestrainedSwingXAngle() { return swingX0_; } |
151 |
RealType getRestrainedSwingYAngle() { return swingY0_; } |
152 |
std::map<int, RealPair> getRestraintInfo() { return restInfo_; } |
153 |
bool getPrintRestraint() { return printRest_; } |
154 |
|
155 |
protected: |
156 |
|
157 |
RealType scaleFactor_; |
158 |
RealType kDisp_; |
159 |
RealType kTwist_; |
160 |
RealType kSwingX_; |
161 |
RealType kSwingY_; |
162 |
RealType pot_; |
163 |
RealType twist0_; |
164 |
RealType swingX0_; |
165 |
RealType swingY0_; |
166 |
bool printRest_; |
167 |
|
168 |
int restType_; |
169 |
std::string restName_; |
170 |
std::map<int, RealPair> restInfo_; |
171 |
}; |
172 |
|
173 |
typedef SimpleTypeData<Restraint*> RestraintData; |
174 |
|
175 |
|
176 |
} |
177 |
#endif |