• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision57956c5db62c87f7ce2a19342e66cae88289ba1d (tree)
l'heure2012-11-28 13:40:12
AuteurKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Message de Log

tmp

Change Summary

Modification

--- a/src/optimization/GDIIS.cpp
+++ b/src/optimization/GDIIS.cpp
@@ -66,7 +66,7 @@ GDIIS::~GDIIS(){
6666 }
6767 }
6868
69-bool GDIIS::DoGDIIS(double* vectorError,
69+bool GDIIS::TryGDIIS(double* vectorError,
7070 double* vectorPosition,
7171 double const* vectorRefStep){
7272 this->Update(vectorError, vectorPosition);
@@ -128,13 +128,19 @@ bool GDIIS::CalcGDIIS(double* vectorError,
128128 }
129129 matrixGDIIS[numErrors][numErrors] = 0;
130130
131+ // If only one error vector is given, following routine is meaningless.
132+ if(numErrors <= 1){
133+ return false;
134+ }
135+
131136 double* vectorCoefs = NULL;
132137 try{
133138 // Solve DIIS equation
134139 MallocerFreer::GetInstance()->Malloc(&vectorCoefs, numErrors+1);
135- for(int i=0;i<numErrors;i++){
136- vectorCoefs[i]=0.0;
137- }
140+ // Initialized in Malloc
141+ // for(int i=0;i<numErrors;i++){
142+ // vectorCoefs[i]=0.0;
143+ // }
138144 vectorCoefs[numErrors]=1.0;
139145 try{
140146 MolDS_wrappers::Lapack::GetInstance()->Dsysv(matrixGDIIS,
@@ -150,12 +156,6 @@ bool GDIIS::CalcGDIIS(double* vectorError,
150156 return false;
151157 }
152158
153- // If only one error vector is given, following routine is meaningless.
154- if(numErrors <= 1){
155- MallocerFreer::GetInstance()->Free(&vectorCoefs, numErrors+1);
156- return false;
157- }
158-
159159 // If Lagrange multiplier is too small;
160160 if(-vectorCoefs[numErrors] < 1e-8){
161161 this->OutputLog((formatTooSmallLagrangeMultiplier % -vectorCoefs[numErrors]).str());
@@ -177,23 +177,23 @@ bool GDIIS::CalcGDIIS(double* vectorError,
177177
178178 // Calculate cosine of the angle between GDIIS step and vectorRefStep
179179 // and lengths of the vectors.
180- double innerprod = 0, norm2gdiis = 0, norm2ref = 0;
180+ double innerprod = 0, normSquaregdiis = 0, normSquareref = 0;
181181 for(int i=0;i<this->sizeErrorVector;i++){
182182 double diff = vectorPosition[i] - listPositions.back()[i];
183183 innerprod += diff * vectorRefStep[i];
184- norm2gdiis += diff * diff;
185- norm2ref += vectorRefStep[i] * vectorRefStep[i];
184+ normSquaregdiis += diff * diff;
185+ normSquareref += vectorRefStep[i] * vectorRefStep[i];
186186 }
187- double cosine = innerprod/sqrt(norm2gdiis*norm2ref);
187+ double cosine = innerprod/sqrt(normSquaregdiis*normSquareref);
188188
189189 // If length of the GDIIS step is larger than reference step * 10
190- if(norm2gdiis >= norm2ref * 100){
190+ if(normSquaregdiis >= normSquareref * 100){
191191 // Rollback vectorPosition and vectorError to original value
192192 for(int i=0; i<this->sizeErrorVector; i++){
193193 vectorError[i] = listErrors.back()[i];
194194 vectorPosition[i] = listPositions.back()[i];
195195 }
196- this->OutputLog((formatTooLargeGDIISStep % sqrt(norm2gdiis) % sqrt(norm2ref)).str());
196+ this->OutputLog((formatTooLargeGDIISStep % sqrt(normSquaregdiis) % sqrt(normSquareref)).str());
197197 MallocerFreer::GetInstance()->Free(&vectorCoefs, numErrors+1);
198198 // and recalculate GDIIS step without the oldest data
199199 this->DiscardOldest();
@@ -223,7 +223,7 @@ bool GDIIS::CalcGDIIS(double* vectorError,
223223 return true;
224224 }
225225
226-bool GDIIS::DoGDIIS(double *vectorError, Molecule& molecule, double const* vectorRefStep){
226+bool GDIIS::TryGDIIS(double *vectorError, Molecule& molecule, double const* vectorRefStep){
227227 double** matrixPosition = NULL;
228228 try{
229229 MallocerFreer::GetInstance()->Malloc(&matrixPosition, molecule.GetNumberAtoms(), CartesianType_end);
@@ -233,7 +233,7 @@ bool GDIIS::DoGDIIS(double *vectorError, Molecule& molecule, double const* vecto
233233 matrixPosition[i][j] = atom->GetXyz()[j];
234234 }
235235 }
236- if(this->DoGDIIS(vectorError,&matrixPosition[0][0],vectorRefStep)){
236+ if(this->TryGDIIS(vectorError,&matrixPosition[0][0],vectorRefStep)==SUCCEED){
237237 for(int i=0;i<molecule.GetNumberAtoms();i++){
238238 Atom* atom = molecule.GetAtom(i);
239239 for(int j=0;j<CartesianType_end;j++){
@@ -255,6 +255,7 @@ bool GDIIS::DoGDIIS(double *vectorError, Molecule& molecule, double const* vecto
255255 }
256256
257257 double GDIIS::MinCosine(){
258+ //reference
258259 static const double inf = std::numeric_limits<double>::infinity();
259260 static const double mincos[] = {inf, inf, 0.97, 0.84, 0.71, 0.67, 0.62, 0.56, 0.49, 0.41};
260261 static const int nummincos = sizeof(mincos)/sizeof(mincos[0]);