4 |
|
: RealIntegrator( theInfo, the_ff ){ |
5 |
|
tStats = new Thermo(info); |
6 |
|
dumpOut = new DumpWriter(info); |
7 |
+ |
statOut = new StatWriter(info); |
8 |
|
calcDim(); |
9 |
|
} |
10 |
|
|
11 |
|
OOPSEMinimizerBase::~OOPSEMinimizerBase(){ |
12 |
|
delete tStats; |
13 |
|
delete dumpOut; |
14 |
+ |
delete statOut; |
15 |
|
} |
16 |
|
|
17 |
|
/** |
26 |
|
double force[3]; |
27 |
|
double dAtomGrad[6]; |
28 |
|
|
29 |
< |
setOptCoor(x); |
30 |
< |
|
31 |
< |
atoms = this->atoms; |
29 |
> |
setCoor(x); |
30 |
> |
calcForce(1, 1); |
31 |
> |
|
32 |
> |
atoms = info->atoms; |
33 |
|
index = 0; |
34 |
|
|
35 |
|
for(int i = 0; i < nAtoms; i++){ |
38 |
|
dAtom = (DirectionalAtom*) atoms[i]; |
39 |
|
dAtom->getGrad(dAtomGrad); |
40 |
|
|
41 |
< |
grad[index++] = dAtomGrad[0]; |
42 |
< |
grad[index++] = dAtomGrad[1]; |
43 |
< |
grad[index++] = dAtomGrad[2]; |
44 |
< |
grad[index++] = dAtomGrad[3]; |
45 |
< |
grad[index++] = dAtomGrad[4]; |
46 |
< |
grad[index++] = dAtomGrad[5]; |
41 |
> |
//gradient = du/dx = -f |
42 |
> |
grad[index++] = -dAtomGrad[0]; |
43 |
> |
grad[index++] = -dAtomGrad[1]; |
44 |
> |
grad[index++] = -dAtomGrad[2]; |
45 |
> |
grad[index++] = -dAtomGrad[3]; |
46 |
> |
grad[index++] = -dAtomGrad[4]; |
47 |
> |
grad[index++] = -dAtomGrad[5]; |
48 |
|
|
49 |
|
} |
50 |
|
else{ |
51 |
|
atoms[i]->getFrc(force); |
52 |
|
|
53 |
< |
grad[index++] = force[0]; |
54 |
< |
grad[index++] = force[1]; |
55 |
< |
grad[index++] = force[2]; |
53 |
> |
grad[index++] = -force[0]; |
54 |
> |
grad[index++] = -force[1]; |
55 |
> |
grad[index++] = -force[2]; |
56 |
|
|
57 |
|
} |
58 |
|
|
66 |
|
* |
67 |
|
*/ |
68 |
|
|
69 |
< |
void OOPSEMinimizerBase::setOptCoor(vector<double>& x){ |
69 |
> |
void OOPSEMinimizerBase::setCoor(vector<double>& x){ |
70 |
|
Atom** atoms; |
71 |
|
DirectionalAtom* dAtom; |
72 |
|
int index; |
73 |
|
double position[3]; |
74 |
|
double eulerAngle[3]; |
75 |
|
|
76 |
< |
atoms = this->atoms; |
76 |
> |
atoms = info->atoms; |
77 |
|
index = 0; |
78 |
|
|
79 |
|
for(int i = 0; i < nAtoms; i++){ |
102 |
|
/** |
103 |
|
* |
104 |
|
*/ |
105 |
< |
vector<double> OOPSEMinimizerBase::getOptCoor(){ |
105 |
> |
vector<double> OOPSEMinimizerBase::getCoor(){ |
106 |
|
Atom** atoms; |
107 |
|
DirectionalAtom* dAtom; |
108 |
|
int index; |
111 |
|
vector<double> x; |
112 |
|
|
113 |
|
x.resize(getDim()); |
114 |
< |
atoms = this->atoms; |
114 |
> |
atoms = info->atoms; |
115 |
|
index = 0; |
116 |
|
|
117 |
|
for(int i = 0; i < nAtoms; i++){ |
128 |
|
x[index++] = eulerAngle[0]; |
129 |
|
x[index++] = eulerAngle[1]; |
130 |
|
x[index++] = eulerAngle[2]; |
131 |
< |
|
131 |
> |
|
132 |
|
} |
133 |
|
|
134 |
|
} |
140 |
|
void OOPSEMinimizerBase::calcDim(){ |
141 |
|
Atom** atoms; |
142 |
|
DirectionalAtom* dAtom; |
139 |
– |
int dim; |
143 |
|
|
144 |
|
dim = 0; |
145 |
|
|
146 |
< |
atoms = this->atoms; |
146 |
> |
atoms = info->atoms; |
147 |
|
|
148 |
|
for(int i = 0; i < nAtoms; i++){ |
149 |
|
dim += 3; |
154 |
|
} |
155 |
|
|
156 |
|
void OOPSEMinimizerBase::output(vector<double>& x, int iteration){ |
157 |
< |
setOptCoor(x); |
157 |
> |
setCoor(x); |
158 |
> |
calcForce(1, 1); |
159 |
|
dumpOut->writeDump(iteration); |
160 |
< |
} |
160 |
> |
statOut->writeStat(iteration); |
161 |
> |
} |