修订版 | d611b34fad6f905f0d5b3e182e2157e4d0c8ac17 (tree) |
---|---|
时间 | 2013-01-23 07:12:45 |
作者 | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Output on/off of DIIS and diisError of Cndo2::DoDIIS for each SCF step. #30554
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1245 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -198,9 +198,11 @@ void Cndo2::SetMessages(){ | ||
198 | 198 | this->messageStartSCF = "********** START: CNDO/2-SCF **********\n"; |
199 | 199 | this->messageDoneSCF = "********** DONE: CNDO/2-SCF **********\n\n\n"; |
200 | 200 | this->messageOmpElapsedTimeSCF = "\tElapsed time(omp) for the SCF = "; |
201 | - this->messageIterSCF = "SCF iter="; | |
202 | - this->messageDensityRMS = ": RMS density="; | |
203 | - this->messageEnergyMO = "\tEnergy of MO:"; | |
201 | + this->messageIterSCF = "\tSCF iter "; | |
202 | + this->messageDensityRMS = ":\tRMS density = "; | |
203 | + this->messageDiisError = "\tDIIS error = "; | |
204 | + this->messageDiisApplied = " (DIIS was applied)"; | |
205 | + this->messageEnergyMO = "\tEnergy of MO:"; | |
204 | 206 | this->messageEnergyMOTitle = "\t\t\t| i-th | occ/unocc | e[a.u.] | e[eV] | \n"; |
205 | 207 | this->messageOcc = "occ"; |
206 | 208 | this->messageUnOcc = "unocc"; |
@@ -528,9 +530,11 @@ void Cndo2::DoSCF(bool requiresGuess){ | ||
528 | 530 | this->CalcTwoElecTwoCore(this->twoElecTwoCore, *this->molecule); |
529 | 531 | |
530 | 532 | // SCF |
531 | - double rmsDensity; | |
533 | + double rmsDensity=0.0; | |
532 | 534 | int maxIterationsSCF = Parameters::GetInstance()->GetMaxIterationsSCF(); |
533 | 535 | bool isGuess=true; |
536 | + bool hasAppliedDIIS=false; | |
537 | + double diisError=0.0; | |
534 | 538 | for(int iterationStep=0; iterationStep<maxIterationsSCF; iterationStep++){ |
535 | 539 | this->CalcAtomicElectronPopulation(this->atomicElectronPopulation, |
536 | 540 | this->orbitalElectronPopulation, |
@@ -564,7 +568,9 @@ void Cndo2::DoSCF(bool requiresGuess){ | ||
564 | 568 | this->orbitalElectronPopulation, |
565 | 569 | this->molecule->GetTotalNumberAOs(), |
566 | 570 | &rmsDensity, |
567 | - iterationStep); | |
571 | + iterationStep, | |
572 | + diisError, | |
573 | + hasAppliedDIIS); | |
568 | 574 | if(hasConverged){ |
569 | 575 | this->OutputLog(this->messageSCFMetConvergence); |
570 | 576 | this->CalcSCFProperties(); |
@@ -583,6 +589,8 @@ void Cndo2::DoSCF(bool requiresGuess){ | ||
583 | 589 | diisStoredErrorVect, |
584 | 590 | diisErrorProducts, |
585 | 591 | diisErrorCoefficients, |
592 | + diisError, | |
593 | + hasAppliedDIIS, | |
586 | 594 | Parameters::GetInstance()->GetDiisNumErrorVectSCF(), |
587 | 595 | *this->molecule, |
588 | 596 | iterationStep); |
@@ -794,11 +802,13 @@ void Cndo2::DoDIIS(double** orbitalElectronPopulation, | ||
794 | 802 | double const* const* oldOrbitalElectronPopulation, |
795 | 803 | double*** diisStoredDensityMatrix, |
796 | 804 | double*** diisStoredErrorVect, |
797 | - double** diisErrorProducts, | |
798 | - double* diisErrorCoefficients, | |
799 | - int diisNumErrorVect, | |
800 | - const Molecule& molecule, | |
801 | - int step) const{ | |
805 | + double** diisErrorProducts, | |
806 | + double* diisErrorCoefficients, | |
807 | + double& diisError, | |
808 | + bool& hasAppliedDIIS, | |
809 | + int diisNumErrorVect, | |
810 | + const Molecule& molecule, | |
811 | + int step) const{ | |
802 | 812 | int totalNumberAOs = molecule.GetTotalNumberAOs(); |
803 | 813 | double diisStartError = Parameters::GetInstance()->GetDiisStartErrorSCF(); |
804 | 814 | double diisEndError = Parameters::GetInstance()->GetDiisEndErrorSCF(); |
@@ -881,14 +891,16 @@ void Cndo2::DoDIIS(double** orbitalElectronPopulation, | ||
881 | 891 | diisErrorProducts[diisNumErrorVect][diisNumErrorVect] = 0.0; |
882 | 892 | diisErrorCoefficients[diisNumErrorVect] = -1.0; |
883 | 893 | |
884 | - double eMax = 0; | |
894 | + diisError = 0.0; | |
885 | 895 | for(int j=0; j<totalNumberAOs; j++){ |
886 | 896 | for(int k=0; k<totalNumberAOs; k++){ |
887 | - eMax = max(eMax, fabs(diisStoredErrorVect[diisNumErrorVect-1][j][k])); | |
897 | + diisError = max(diisError, fabs(diisStoredErrorVect[diisNumErrorVect-1][j][k])); | |
888 | 898 | } |
889 | 899 | } |
890 | 900 | |
891 | - if(diisNumErrorVect <= step && diisEndError<eMax && eMax<diisStartError){ | |
901 | + hasAppliedDIIS = false; | |
902 | + if(diisNumErrorVect <= step && diisEndError<diisError && diisError<diisStartError){ | |
903 | + hasAppliedDIIS = true; | |
892 | 904 | MolDS_wrappers::Lapack::GetInstance()->Dsysv(diisErrorProducts, |
893 | 905 | diisErrorCoefficients, |
894 | 906 | diisNumErrorVect+1); |
@@ -1299,9 +1311,11 @@ void Cndo2::UpdateOldOrbitalElectronPopulation(double** oldOrbitalElectronPopula | ||
1299 | 1311 | |
1300 | 1312 | bool Cndo2::SatisfyConvergenceCriterion(double const* const * oldOrbitalElectronPopulation, |
1301 | 1313 | double const* const * orbitalElectronPopulation, |
1302 | - int numberAOs, | |
1314 | + int numberAOs, | |
1303 | 1315 | double* rmsDensity, |
1304 | - int times) const{ | |
1316 | + int times, | |
1317 | + double diisError, | |
1318 | + bool hasAppliedDIIS) const{ | |
1305 | 1319 | bool satisfy = false; |
1306 | 1320 | double change = 0.0; |
1307 | 1321 | stringstream ompErrors; |
@@ -1322,11 +1336,15 @@ bool Cndo2::SatisfyConvergenceCriterion(double const* const * oldOrbitalElectron | ||
1322 | 1336 | throw MolDSException(ompErrors.str()); |
1323 | 1337 | } |
1324 | 1338 | *rmsDensity = sqrt(change); |
1325 | - | |
1326 | - this->OutputLog(boost::format("%s%d%s%.15lf\n") % this->messageIterSCF.c_str() | |
1327 | - % times | |
1328 | - % this->messageDensityRMS.c_str() | |
1329 | - % *rmsDensity); | |
1339 | + | |
1340 | + string diisOnOff = hasAppliedDIIS ? this->messageDiisApplied : ""; | |
1341 | + this->OutputLog(boost::format("%s%d%s%.15lf%s%e%s\n") % this->messageIterSCF.c_str() | |
1342 | + % times | |
1343 | + % this->messageDensityRMS.c_str() | |
1344 | + % *rmsDensity | |
1345 | + % this->messageDiisError.c_str() | |
1346 | + % diisError | |
1347 | + % diisOnOff); | |
1330 | 1348 | |
1331 | 1349 | if(*rmsDensity < Parameters::GetInstance()->GetThresholdSCF()){ |
1332 | 1350 | satisfy = true; |
@@ -256,6 +256,8 @@ private: | ||
256 | 256 | std::string errorMessageRhs; |
257 | 257 | std::string messageIterSCF; |
258 | 258 | std::string messageDensityRMS; |
259 | + std::string messageDiisError; | |
260 | + std::string messageDiisApplied; | |
259 | 261 | std::string messageEnergyMO; |
260 | 262 | std::string messageEnergyMOTitle; |
261 | 263 | std::string messageElecEnergy; |
@@ -322,9 +324,11 @@ private: | ||
322 | 324 | double const* const* overlapAOs) const; |
323 | 325 | bool SatisfyConvergenceCriterion(double const* const* oldOrbitalElectronPopulation, |
324 | 326 | double const* const* orbitalElectronPopulation, |
325 | - int numberAOs, | |
327 | + int numberAOs, | |
326 | 328 | double* rmsDensity, |
327 | - int times) const; | |
329 | + int times, | |
330 | + double diisErro, | |
331 | + bool hasAppliedDIIS) const; | |
328 | 332 | void UpdateOldOrbitalElectronPopulation(double** oldOrbitalElectronPopulation, |
329 | 333 | double const* const* orbitalElectronPopulation, |
330 | 334 | int numberAOs) const; |
@@ -420,6 +424,8 @@ private: | ||
420 | 424 | double*** diisStoredErrorVect, |
421 | 425 | double** diisErrorProducts, |
422 | 426 | double* diisErrorCoefficients, |
427 | + double& diisError, | |
428 | + bool& hasAppliedDIIS, | |
423 | 429 | int diisNumErrorVect, |
424 | 430 | const MolDS_base::Molecule& molecule, |
425 | 431 | int step) const; |