1 |
tim |
1011 |
#include "Integrator.hpp"
|
2 |
|
|
|
3 |
|
|
OOPSEMinimizerBase::OOPSEMinimizerBase(SimInfo* theInfo, ForceFields* the_ff)
|
4 |
|
|
: RealIntegrator( theInfo, the_ff ){
|
5 |
|
|
tStats = new Thermo(info);
|
6 |
|
|
}
|
7 |
|
|
|
8 |
|
|
OOPSEMinimizerBase::~OOPSEMinimizerBase(){
|
9 |
|
|
delete tStats;
|
10 |
|
|
}
|
11 |
|
|
|
12 |
|
|
/**
|
13 |
|
|
*
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
double OOPSEMinimizerBase::calcGradient(vector<double>& x, vector<double>& grad){
|
18 |
|
|
Atom** atoms;
|
19 |
|
|
DirectionalAtom* dAtom;
|
20 |
|
|
int index;
|
21 |
|
|
double force[3];
|
22 |
|
|
double dAtomGrad[6];
|
23 |
|
|
|
24 |
|
|
setOptCoor(x);
|
25 |
|
|
|
26 |
|
|
atoms = this->atoms;
|
27 |
|
|
index = 0;
|
28 |
|
|
|
29 |
|
|
for(int i = 0; i < nAtoms; i++){
|
30 |
|
|
|
31 |
|
|
if(atoms[i]->isDirectional()){
|
32 |
|
|
dAtom = (DirectionalAtom*) atoms[i];
|
33 |
|
|
dAtom->getGrad(dAtomGrad);
|
34 |
|
|
|
35 |
|
|
grad[index++] = dAtomGrad[0];
|
36 |
|
|
grad[index++] = dAtomGrad[1];
|
37 |
|
|
grad[index++] = dAtomGrad[2];
|
38 |
|
|
grad[index++] = dAtomGrad[3];
|
39 |
|
|
grad[index++] = dAtomGrad[4];
|
40 |
|
|
grad[index++] = dAtomGrad[5];
|
41 |
|
|
|
42 |
|
|
}
|
43 |
|
|
else{
|
44 |
|
|
atoms[i]->getFrc(force);
|
45 |
|
|
|
46 |
|
|
grad[index++] = force[0];
|
47 |
|
|
grad[index++] = force[1];
|
48 |
|
|
grad[index++] = force[2];
|
49 |
|
|
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
return tStats->getPotential();
|
55 |
|
|
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
/**
|
59 |
|
|
*
|
60 |
|
|
*/
|
61 |
|
|
|
62 |
|
|
void OOPSEMinimizerBase::setOptCoor(vector<double>& x){
|
63 |
|
|
Atom** atoms;
|
64 |
|
|
DirectionalAtom* dAtom;
|
65 |
|
|
int index;
|
66 |
|
|
double position[3];
|
67 |
|
|
double eulerAngle[3];
|
68 |
|
|
|
69 |
|
|
atoms = this->atoms;
|
70 |
|
|
index = 0;
|
71 |
|
|
|
72 |
|
|
for(int i = 0; i < nAtoms; i++){
|
73 |
|
|
|
74 |
|
|
position[0] = x[index++];
|
75 |
|
|
position[1] = x[index++];
|
76 |
|
|
position[2] = x[index++];
|
77 |
|
|
|
78 |
|
|
atoms[i]->setPos(position);
|
79 |
|
|
|
80 |
|
|
if (atoms[i]->isDirectional()){
|
81 |
|
|
dAtom = (DirectionalAtom*) atoms[i];
|
82 |
|
|
|
83 |
|
|
eulerAngle[0] = x[index++];
|
84 |
|
|
eulerAngle[1] = x[index++];
|
85 |
|
|
eulerAngle[2] = x[index++];
|
86 |
|
|
|
87 |
|
|
dAtom->setEuler(eulerAngle[0], eulerAngle[1], eulerAngle[2]);
|
88 |
|
|
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
/**
|
96 |
|
|
*
|
97 |
|
|
*/
|
98 |
|
|
void OOPSEMinimizerBase::getOptCoor(vector<double>& x){
|
99 |
|
|
Atom** atoms;
|
100 |
|
|
DirectionalAtom* dAtom;
|
101 |
|
|
int index;
|
102 |
|
|
double position[3];
|
103 |
|
|
double eulerAngle[3];
|
104 |
|
|
|
105 |
|
|
atoms = this->atoms;
|
106 |
|
|
index = 0;
|
107 |
|
|
|
108 |
|
|
for(int i = 0; i < nAtoms; i++){
|
109 |
|
|
atoms[i]->getPos(position);
|
110 |
|
|
|
111 |
|
|
x[index++] = position[0];
|
112 |
|
|
x[index++] = position[1];
|
113 |
|
|
x[index++] = position[2];
|
114 |
|
|
|
115 |
|
|
if (atoms[i]->isDirectional()){
|
116 |
|
|
dAtom = (DirectionalAtom*) atoms[i];
|
117 |
|
|
dAtom->getEulerAngles(eulerAngle);
|
118 |
|
|
|
119 |
|
|
x[index++] = eulerAngle[0];
|
120 |
|
|
x[index++] = eulerAngle[1];
|
121 |
|
|
x[index++] = eulerAngle[2];
|
122 |
|
|
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
|