-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtbond.cpp
33 lines (27 loc) · 1.18 KB
/
tbond.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "tbond.h"
//---------------------------------------------------------------------------------------------------
double TBond::dLength_SQR() const
{
return dDistance_SQR(patAtom1, patAtom2);
}
//---------------------------------------------------------------------------------------------------
double TBond::dLength() const
{
return sqrt(dLength_SQR());
}
//---------------------------------------------------------------------------------------------------
double TBond::dCalcEnergy() const
{
double dEfficientDistance = dLength() - bpBondInfo.dREq;
return bpBondInfo.dKr*dEfficientDistance*dEfficientDistance;
}
//---------------------------------------------------------------------------------------------------
void TBond::CalcGradients()
{
TVector vecDirect12 = vecMakeVector(patAtom1, patAtom2);
double dBondLength = vecDirect12.dLength();
vecDirect12.Normalize();
patAtom1->vecEnergyGradient -= (2.*(bpBondInfo.dKr)*(dBondLength - bpBondInfo.dREq)) * vecDirect12;
patAtom2->vecEnergyGradient += (2.*(bpBondInfo.dKr)*(dBondLength - bpBondInfo.dREq)) * vecDirect12;
}
//---------------------------------------------------------------------------------------------------