-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtspring.cpp
22 lines (18 loc) · 886 Bytes
/
tspring.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "tspring.h"
//---------------------------------------------------------------------------------------------------
double TSpring::dCalcEnergy() const
{
double dEfficientDistance = dLength() - bpBondInfo.dREq;
return bpBondInfo.dKr*dEfficientDistance*dEfficientDistance;
}
//---------------------------------------------------------------------------------------------------
void TSpring::CalcGradients() const
{
TVector vecDirect12;
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;
}
//---------------------------------------------------------------------------------------------------