ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/OOPSEMinimizerBase.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/OOPSEMinimizerBase.cpp (file contents):
Revision 1011 by tim, Tue Feb 3 20:47:10 2004 UTC vs.
Revision 1035 by tim, Fri Feb 6 21:37:59 2004 UTC

# Line 3 | Line 3 | OOPSEMinimizerBase::OOPSEMinimizerBase(SimInfo* theInf
3   OOPSEMinimizerBase::OOPSEMinimizerBase(SimInfo* theInfo, ForceFields* the_ff)
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   /**
# Line 21 | Line 26 | double OOPSEMinimizerBase::calcGradient(vector<double>
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++){
# Line 32 | Line 38 | double OOPSEMinimizerBase::calcGradient(vector<double>
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];
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];
# Line 43 | Line 50 | double OOPSEMinimizerBase::calcGradient(vector<double>
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      
# Line 59 | Line 66 | void OOPSEMinimizerBase::setOptCoor(vector<double>& x)
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++){
# Line 95 | Line 102 | void OOPSEMinimizerBase::getOptCoor(vector<double>& x)
102   /**
103   *
104   */
105 < void OOPSEMinimizerBase::getOptCoor(vector<double>& x){
105 > vector<double> OOPSEMinimizerBase::getCoor(){
106    Atom** atoms;  
107    DirectionalAtom* dAtom;
108    int index;
109    double position[3];
110    double eulerAngle[3];
111 +  vector<double> x;
112  
113 <  atoms = this->atoms;
113 >  x.resize(getDim());
114 >  atoms = info->atoms;
115    index = 0;
116    
117    for(int i = 0; i < nAtoms; i++){
# Line 124 | Line 133 | void OOPSEMinimizerBase::getOptCoor(vector<double>& x)
133      
134    }
135  
136 +  return x;
137 +
138   }
139          
140 + void OOPSEMinimizerBase::calcDim(){
141 +  Atom** atoms;  
142 +  DirectionalAtom* dAtom;
143  
144 +  dim = 0;
145 +
146 +  atoms = info->atoms;
147 +  
148 +  for(int i = 0; i < nAtoms; i++){
149 +    dim += 3;
150 +    if (atoms[i]->isDirectional())
151 +      dim += 3;      
152 +  }
153 +
154 + }
155 +
156 + void OOPSEMinimizerBase::output(vector<double>& x, int iteration){
157 +  setCoor(x);
158 +  calcForce(1, 1);
159 +  dumpOut->writeDump(iteration);
160 +  statOut->writeStat(iteration);
161 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines