00001
00007
00008
00009 #if !defined(RESTRAINT_HPP)
00010 #define RESTRAINT_HPP
00011
00012 class GlobalMasterFreeEnergy;
00013
00014
00015
00016
00017 class ARestraint {
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 protected:
00037 double m_Kf;
00038 int m_NumGroups;
00039 AGroup* m_pGroups;
00040 AVector* m_pCOMs;
00041
00042
00043 static double m_LambdaKf;
00044 static double m_LambdaRef;
00045
00046 public:
00047 ARestraint();
00048 virtual ~ARestraint();
00049 int GetNumGroups() {return(m_NumGroups);}
00050 void SetKf(double Kf) {m_Kf=Kf;}
00051 double GetKf() {return(m_Kf);}
00052 void SetLambdaKf(double LambdaKf) {m_LambdaKf=LambdaKf;}
00053 void SetLambdaRef(double LambdaRef) {m_LambdaRef=LambdaRef;}
00054 double GetLambdaKf() {return(m_LambdaKf);}
00055 double GetLambdaRef() {return(m_LambdaRef);}
00056 void SetGroup(AGroup& Group, int GroupIndex);
00057 void SetGroups(AGroup& Group1);
00058 void SetGroups(AGroup& Group1, AGroup& Group2);
00059 void SetGroups(AGroup& Group1, AGroup& Group2, AGroup& Group3);
00060 void SetGroups(AGroup& Group1, AGroup& Group2, AGroup& Group3, AGroup& Group4);
00061 void UpdateCOMs(GlobalMasterFreeEnergy& CFE);
00062 void DistributeForce(int WhichGroup, AVector Force, GlobalMasterFreeEnergy& CFE);
00063
00064
00065 #if defined(_DEBUG) //
00066 void SetCOM(int Index, AVector& Pos);
00067 #endif //
00068
00069
00070
00071 virtual AVector GetGradient(int WhichGroup) = 0;
00072 virtual double GetEnergy() = 0;
00073 virtual void GetStr(char* Str) = 0;
00074 virtual void PrintInfo() = 0;
00075
00076 virtual Bool_t IsForcing() {return(kFalse);}
00077 virtual double Get_dU_dLambda() {return(0.0);}
00078
00079 virtual void SetRefPos(AVector) {ASSERT(kFalse);}
00080 virtual void SetRefDist(double) {ASSERT(kFalse);}
00081 virtual void SetRefAngle(double) {ASSERT(kFalse);}
00082 virtual void SetBound(Bound_t) {ASSERT(kFalse);}
00083 virtual void SetLowerAngle(double) {ASSERT(kFalse);}
00084 virtual void SetUpperAngle(double) {ASSERT(kFalse);}
00085 virtual void SetIntervalAngle(double) {ASSERT(kFalse);}
00086 virtual void SetStartPos(AVector) {ASSERT(kFalse);}
00087 virtual void SetStopPos(AVector) {ASSERT(kFalse);}
00088 virtual void SetStartDist(double) {ASSERT(kFalse);}
00089 virtual void SetStopDist(double) {ASSERT(kFalse);}
00090 virtual void SetStartAngle(double) {ASSERT(kFalse);}
00091 virtual void SetStopAngle(double) {ASSERT(kFalse);}
00092 protected:
00093 double GetAngle(AVector& A, AVector& B, AVector& C);
00094 double GetDihe(AVector& A, AVector& B, AVector& C, AVector& D);
00095 void EarlyExit(char* Str, int AtomID);
00096 };
00097
00098
00099
00100
00101
00102 class APosRestraint : public ARestraint {
00103
00104
00105
00106 public:
00107 APosRestraint();
00108 void PrintInfo();
00109 protected:
00110 double GetE(AVector RefPos, double LambdaKf=1.0);
00111 AVector GetGrad(int WhichGroup, AVector RefPos, double LambdaKf=1.0);
00112 public:
00113
00114 virtual AVector GetPosTarget() = 0;
00115 virtual double GetDistance() = 0;
00116 };
00117
00118 class ADistRestraint : public ARestraint {
00119
00120
00121
00122 public:
00123 ADistRestraint();
00124 void PrintInfo();
00125 protected:
00126 double GetE(double RefDist, double LambdaKf=1.0);
00127 AVector GetGrad(int WhichGroup, double RefDist, double LambdaKf=1.0);
00128 public:
00129 virtual double GetDistTarget() = 0;
00130 };
00131
00132 class AnAngleRestraint : public ARestraint {
00133
00134
00135
00136 public:
00137 AnAngleRestraint();
00138 void PrintInfo();
00139 protected:
00140 double GetE(double RefAngle, double LambdaKf=1.0);
00141 AVector GetGrad(int WhichGroup, double RefAngle, double LambdaKf=1.0);
00142 public:
00143 virtual double GetAngleTarget() = 0;
00144 };
00145
00146 class ADiheRestraint : public ARestraint {
00147
00148
00149
00150 public:
00151 ADiheRestraint();
00152 void PrintInfo();
00153 protected:
00154 double GetE(double RefDihe, double Const);
00155 AVector GetGrad(int WhichGroup, double RefDihe, double Const);
00156 AVector gradU(AVector& P1P2P3, AVector& P4P5P6,
00157 AVector& dP1, AVector& dP2, AVector& dP3,
00158 AVector& dP4, AVector& dP5, AVector& dP6);
00159 public:
00160 virtual Bool_t TwoTargets() = 0;
00161 virtual double GetDiheTarget1() = 0;
00162 virtual double GetDiheTarget2() = 0;
00163 };
00164
00165
00166
00167
00168
00169 class AFixedPosRestraint : public APosRestraint {
00170
00171
00172
00173 private:
00174 AVector m_RefPos;
00175 public:
00176 void SetRefPos(AVector Pos) {m_RefPos=Pos;}
00177 AVector GetRefPos() {return(m_RefPos);}
00178 double GetEnergy();
00179 AVector GetGradient(int WhichGroup);
00180 void GetStr(char* Str) {
00181 strcpy(Str, "Fixed Position Restraint");
00182 }
00183 AVector GetPosTarget() {return(m_RefPos);}
00184 double GetDistance() {return(m_RefPos.Dist(m_pCOMs[0]));}
00185 };
00186
00187 class ABoundPosRestraint : public APosRestraint {
00188
00189
00190
00191 private:
00192 AVector m_RefPos;
00193 double m_RefDist;
00194 Bound_t m_Bound;
00195 public:
00196 void SetRefPos(AVector Pos) {m_RefPos=Pos;}
00197 void SetRefDist(double Dist) {m_RefDist=Dist;}
00198 void SetBound(Bound_t Bound) {m_Bound=Bound;}
00199 AVector GetRefPos() {return(m_RefPos);}
00200 double GetRefDist() {return(m_RefDist);}
00201 Bound_t GetBound() {return(m_Bound);}
00202 double GetEnergy();
00203 AVector GetGradient(int WhichGroup);
00204 void GetStr(char* Str) {
00205 strcpy(Str, "Bound Position Restraint");
00206 }
00207 AVector GetPosTarget() {return(m_RefPos);}
00208 double GetDistance() {return(m_RefPos.Dist(m_pCOMs[0]));}
00209 };
00210
00211 class AForcingPosRestraint : public APosRestraint {
00212
00213
00214
00215 private:
00216 AVector m_StartPos;
00217 AVector m_StopPos;
00218 public:
00219 void SetStartPos(AVector Pos) {m_StartPos=Pos;}
00220 void SetStopPos(AVector Pos) {m_StopPos=Pos;}
00221 AVector GetStartPos() {return(m_StartPos);}
00222 AVector GetStopPos() {return(m_StopPos);}
00223 double GetEnergy();
00224 AVector GetGradient(int WhichGroup);
00225 double Get_dU_dLambda();
00226 Bool_t IsForcing() {return(kTrue);}
00227 void GetStr(char* Str) {
00228 strcpy(Str, "Forcing Position Restraint");
00229 }
00230 AVector GetPosTarget() {
00231 return(m_StopPos*m_LambdaRef + m_StartPos*(1.0-m_LambdaRef));
00232 }
00233 double GetDistance() {
00234 AVector RefPos = m_StopPos*m_LambdaRef + m_StartPos*(1.0-m_LambdaRef);
00235 return(RefPos.Dist(m_pCOMs[0]));
00236 }
00237 };
00238
00239
00240
00241
00242
00243 class AFixedDistRestraint : public ADistRestraint {
00244
00245
00246
00247 private:
00248 double m_RefDist;
00249 public:
00250 void SetRefDist(double Dist) {m_RefDist=Dist;}
00251 double GetRefDist() {return(m_RefDist);}
00252 double GetEnergy();
00253 AVector GetGradient(int WhichGroup);
00254 void GetStr(char* Str) {
00255 strcpy(Str, "Fixed Distance Restraint");
00256 }
00257 double GetDistTarget() {return(m_RefDist);}
00258 };
00259
00260 class ABoundDistRestraint : public ADistRestraint {
00261
00262
00263
00264 private:
00265 double m_RefDist;
00266 Bound_t m_Bound;
00267 public:
00268 void SetRefDist(double Dist) {m_RefDist=Dist;}
00269 void SetBound(Bound_t Bound) {m_Bound=Bound;}
00270 double GetRefDist() {return(m_RefDist);}
00271 Bound_t GetBound() {return(m_Bound);}
00272 double GetEnergy();
00273 AVector GetGradient(int WhichGroup);
00274 void GetStr(char* Str) {
00275 strcpy(Str, "Bound Distance Restraint");
00276 }
00277 double GetDistTarget() {return(m_RefDist);}
00278 };
00279
00280 class AForcingDistRestraint : public ADistRestraint {
00281
00282
00283
00284 private:
00285 double m_StartDist;
00286 double m_StopDist;
00287 public:
00288 void SetStartDist(double Dist) {m_StartDist=Dist;}
00289 void SetStopDist(double Dist) {m_StopDist=Dist;}
00290 double GetStartDist() {return(m_StartDist);}
00291 double GetStopDist() {return(m_StopDist);}
00292 double GetEnergy();
00293 AVector GetGradient(int WhichGroup);
00294 double Get_dU_dLambda();
00295 Bool_t IsForcing() {return(kTrue);}
00296 void GetStr(char* Str) {
00297 strcpy(Str, "Forcing Distance Restraint");
00298 }
00299 double GetDistTarget() {
00300 return(m_StopDist*m_LambdaRef + m_StartDist*(1.0-m_LambdaRef));
00301 }
00302 };
00303
00304
00305
00306
00307
00308 class AFixedAngleRestraint : public AnAngleRestraint {
00309
00310
00311
00312 private:
00313 double m_RefAngle;
00314 public:
00315 void SetRefAngle(double Angle) {m_RefAngle=Angle;}
00316 double GetRefAngle() {return(m_RefAngle);}
00317 double GetEnergy();
00318 AVector GetGradient(int WhichGroup);
00319 void GetStr(char* Str) {
00320 strcpy(Str, "Fixed Angle Restraint");
00321 }
00322 double GetAngleTarget() {return(m_RefAngle);}
00323 };
00324
00325 class ABoundAngleRestraint : public AnAngleRestraint {
00326
00327
00328
00329 private:
00330 double m_RefAngle;
00331 Bound_t m_Bound;
00332 public:
00333 void SetRefAngle(double Angle) {m_RefAngle=Angle;}
00334 void SetBound(Bound_t Bound) {m_Bound=Bound;}
00335 double GetRefAngle() {return(m_RefAngle);}
00336 Bound_t GetBound() {return(m_Bound);}
00337 double GetEnergy();
00338 AVector GetGradient(int WhichGroup);
00339 void GetStr(char* Str) {
00340 strcpy(Str, "Bound Angle Restraint");
00341 }
00342 double GetAngleTarget() {return(m_RefAngle);}
00343 };
00344
00345 class AForcingAngleRestraint : public AnAngleRestraint {
00346
00347
00348
00349 private:
00350 double m_StartAngle;
00351 double m_StopAngle;
00352 public:
00353 void SetStartAngle(double Angle) {m_StartAngle=Angle;}
00354 void SetStopAngle(double Angle) {m_StopAngle=Angle;}
00355 double GetStartAngle() {return(m_StartAngle);}
00356 double GetStopAngle() {return(m_StopAngle);}
00357 double GetEnergy();
00358 AVector GetGradient(int WhichGroup);
00359 double Get_dU_dLambda();
00360 Bool_t IsForcing() {return(kTrue);}
00361 void GetStr(char* Str) {
00362 strcpy(Str, "Forcing Angle Restraint");
00363 }
00364 double GetAngleTarget() {
00365 return(m_StopAngle*m_LambdaRef + m_StartAngle*(1.0-m_LambdaRef));
00366 }
00367 };
00368
00369
00370
00371
00372
00373 class AFixedDiheRestraint : public ADiheRestraint {
00374
00375
00376
00377 private:
00378 double m_RefAngle;
00379 public:
00380 void SetRefAngle(double Angle) {m_RefAngle=Angle;}
00381 double GetRefAngle() {return(m_RefAngle);}
00382 double GetEnergy();
00383 AVector GetGradient(int WhichGroup);
00384 void GetStr(char* Str) {
00385 strcpy(Str, "Fixed Dihedral Restraint");
00386 }
00387 Bool_t TwoTargets() {return(kFalse);}
00388 double GetDiheTarget1() {return(m_RefAngle);}
00389 double GetDiheTarget2() {return(0);}
00390 };
00391
00392 class ABoundDiheRestraint : public ADiheRestraint {
00393
00394
00395
00396 private:
00397 double m_LowerAngle;
00398 double m_UpperAngle;
00399 double m_IntervalAngle;
00400 public:
00401 void SetLowerAngle(double Angle) {m_LowerAngle=Angle;}
00402 void SetUpperAngle(double Angle) {m_UpperAngle=Angle;}
00403 void SetIntervalAngle(double Angle) {m_IntervalAngle=Angle;}
00404 double GetLowerAngle() {return(m_LowerAngle);}
00405 double GetUpperAngle() {return(m_UpperAngle);}
00406 double GetIntervalAngle() {return(m_IntervalAngle);}
00407 double GetEnergy();
00408 AVector GetGradient(int WhichGroup);
00409 void GetStr(char* Str) {
00410 strcpy(Str, "Bound Dihedral Restraint");
00411 }
00412 Bool_t TwoTargets() {return(kTrue);}
00413 double GetDiheTarget1() {return(m_LowerAngle);}
00414 double GetDiheTarget2() {return(m_UpperAngle);}
00415 };
00416
00417 class AForcingDiheRestraint : public ADiheRestraint {
00418
00419
00420
00421 private:
00422 double m_StartAngle;
00423 double m_StopAngle;
00424 public:
00425 void SetStartAngle(double Angle) {m_StartAngle=Angle;}
00426 void SetStopAngle(double Angle) {m_StopAngle=Angle;}
00427 double GetStartAngle() {return(m_StartAngle);}
00428 double GetStopAngle() {return(m_StopAngle);}
00429 double GetEnergy();
00430 AVector GetGradient(int WhichGroup);
00431 double Get_dU_dLambda();
00432 Bool_t IsForcing() {return(kTrue);}
00433 void GetStr(char* Str) {
00434 strcpy(Str, "Forcing Dihedral Restraint");
00435 }
00436 Bool_t TwoTargets() {return(kFalse);}
00437 double GetDiheTarget1() {
00438 return(m_StopAngle*m_LambdaRef + m_StartAngle*(1.0-m_LambdaRef));
00439 }
00440 double GetDiheTarget2() {return(0);}
00441 };
00442
00443 #endif
00444