• 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évision486d6bbdd08885c502fe67bdbfa2f6a071a5f3e5 (tree)
l'heure2012-12-05 10:57:29
AuteurKatsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Message de Log

Push back the oldest error vector after recalculating GDIIS step without it. #28915

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/branches/gdiis@1174 1136aad2-a195-0410-b898-f5ea1d11b9d8

Change Summary

Modification

--- a/src/optimization/GDIIS.cpp
+++ b/src/optimization/GDIIS.cpp
@@ -50,6 +50,7 @@ GDIIS::GDIIS(int sizeErrorVector):
5050 messageTakingGDIISStep("Taking GDIIS step.\n"),
5151 messageSingularGDIISMatrix("Error while solving GDIIS equation. Discarding current data.\n"),
5252 messageOnlyOneErrorVector("There is only one error vector.\n"),
53+ messageRecalcGDIISStep("Recalculate GDIIS step without the oldest error vector.\n"),
5354 formatTooSmallLagrangeMultiplier("GDIIS: Lagrange Multiplier is too small. (%e)\n"),
5455 formatTooLargeGDIISStep("GDIIS: GDIIS step is too large. (gdiis:%e, reference:%e)\n"),
5556 formatWrongDirection("GDIIS: GDIIS step direction is too far from reference step. (cosine: %+f)\n")
@@ -131,6 +132,7 @@ void GDIIS::CalcGDIIS(double* vectorError,
131132
132133 // If only one error vector is given, following routine is meaningless.
133134 if(numErrors <= 1){
135+ this->OutputLog(messageOnlyOneErrorVector);
134136 throw GDIISException(this->messageOnlyOneErrorVector);
135137 }
136138
@@ -158,8 +160,7 @@ void GDIIS::CalcGDIIS(double* vectorError,
158160 this->OutputLog((this->formatTooSmallLagrangeMultiplier % -vectorCoefs[numErrors]).str());
159161 MallocerFreer::GetInstance()->Free(&vectorCoefs, numErrors+1);
160162 // Recalculate GDIIS step without the oldest data.
161- this->DiscardOldest();
162- return CalcGDIIS(vectorError,vectorPosition,vectorRefStep);
163+ return this->RecalcGDIIS(vectorError,vectorPosition,vectorRefStep);
163164 }
164165
165166 // Interpolate error vectors and positions
@@ -193,8 +194,7 @@ void GDIIS::CalcGDIIS(double* vectorError,
193194 this->OutputLog((this->formatTooLargeGDIISStep % sqrt(normSquaregdiis) % sqrt(normSquareref)).str());
194195 MallocerFreer::GetInstance()->Free(&vectorCoefs, numErrors+1);
195196 // and recalculate GDIIS step without the oldest data
196- this->DiscardOldest();
197- return CalcGDIIS(vectorError,vectorPosition,vectorRefStep);
197+ return this->RecalcGDIIS(vectorError,vectorPosition,vectorRefStep);
198198 }
199199
200200 // If the calculated cos(theta) on Eq. 8 of [FS_2002] is below the minimum tolerant value
@@ -207,8 +207,7 @@ void GDIIS::CalcGDIIS(double* vectorError,
207207 this->OutputLog((formatWrongDirection % cosine).str());
208208 MallocerFreer::GetInstance()->Free(&vectorCoefs, numErrors+1);
209209 // and recalculate GDIIS step without the oldest data
210- this->DiscardOldest();
211- return CalcGDIIS(vectorError,vectorPosition,vectorRefStep);
210+ return this->RecalcGDIIS(vectorError,vectorPosition,vectorRefStep);
212211 }
213212 }
214213 catch(GDIISException ex){
@@ -223,6 +222,30 @@ void GDIIS::CalcGDIIS(double* vectorError,
223222 this->OutputLog(messageTakingGDIISStep);
224223 }
225224
225+void GDIIS::RecalcGDIIS(double* vectorError,
226+ double* vectorPosition,
227+ double const* vectorRefStep) throw(GDIISException, MolDS_base::MolDSException){
228+ double *vectorErrorOldest = NULL;
229+ double *vectorPositionOldest = NULL;
230+
231+ this->PopOldest(&vectorErrorOldest, &vectorPositionOldest);
232+
233+ this->OutputLog(messageRecalcGDIISStep);
234+
235+ try{
236+ this->CalcGDIIS(vectorError, vectorPosition, vectorRefStep);
237+ }
238+ catch(GDIISException ex){
239+ this->PushOldest(vectorErrorOldest, vectorPositionOldest);
240+ throw ex;
241+ }
242+ catch(MolDSException ex){
243+ MallocerFreer::GetInstance()->Free(&vectorErrorOldest, this->sizeErrorVector);
244+ MallocerFreer::GetInstance()->Free(&vectorPositionOldest, this->sizeErrorVector);
245+ throw ex;
246+ }
247+}
248+
226249 void GDIIS::DoGDIIS(double *vectorError, Molecule& molecule, double const* vectorRefStep) throw(GDIISException, MolDS_base::MolDSException){
227250 double** matrixPosition = NULL;
228251 try{
--- a/src/optimization/GDIIS.h
+++ b/src/optimization/GDIIS.h
@@ -53,6 +53,9 @@ private:
5353 void CalcGDIIS(double* vectorError,
5454 double* vectorPosition,
5555 double const* vectorRefStep) throw(GDIISException, MolDS_base::MolDSException);
56+ void RecalcGDIIS(double* vectorError,
57+ double* vectorPosition,
58+ double const* vectorRefStep) throw(GDIISException, MolDS_base::MolDSException);
5659 void PopOldest(double** vectorError, double** vectorPosition);
5760 void PushOldest(double* vectorError, double* vectorPosition);
5861 const int sizeErrorVector;
@@ -64,6 +67,7 @@ private:
6467 std::string messageTakingGDIISStep;
6568 std::string messageSingularGDIISMatrix;
6669 std::string messageOnlyOneErrorVector;
70+ std::string messageRecalcGDIISStep;
6771 boost::format formatTooSmallLagrangeMultiplier;
6872 boost::format formatTooLargeGDIISStep;
6973 boost::format formatWrongDirection;