修訂 | bfd0f98715a0777243b2fb7568a89755025eccb5 (tree) |
---|---|
時間 | 2012-11-26 20:41:54 |
作者 | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Read initial trust radius and maximum step size from input file. #28764
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1131 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -178,6 +178,8 @@ void InputParser::SetMessages(){ | ||
178 | 178 | this->messageOptimizationMaxGradient = "\t\tMax gradient: "; |
179 | 179 | this->messageOptimizationRmsGradient = "\t\tRms gradient: "; |
180 | 180 | this->messageOptimizationTimeWidth = "\t\tFictious time width: "; |
181 | + this->messageOptimizationInitialTrustRadius = "\t\tInitial trust radius: "; | |
182 | + this->messageOptimizationMaxNormStep = "\t\tMax size of the optimization step: "; | |
181 | 183 | |
182 | 184 | // Frequencies (Normal modes) |
183 | 185 | this->messageFrequenciesConditions = "\tFrequencies (Normal modes) analysis conditions:\n"; |
@@ -360,6 +362,8 @@ void InputParser::SetMessages(){ | ||
360 | 362 | this->stringOptimizationMaxGradient = "max_gradient"; |
361 | 363 | this->stringOptimizationRmsGradient = "rms_gradient"; |
362 | 364 | this->stringOptimizationTimeWidth = "dt"; |
365 | + this->stringOptimizationInitialTrustRadius = "initialtrustradius"; | |
366 | + this->stringOptimizationMaxNormStep = "maxnormstep"; | |
363 | 367 | |
364 | 368 | // Frequencies (Normal modes) |
365 | 369 | this->stringFrequencies = "frequencies"; |
@@ -1017,6 +1021,18 @@ int InputParser::ParseConditionsOptimization(vector<string>* inputTerms, int par | ||
1017 | 1021 | Parameters::GetInstance()->SetRmsGradientOptimization(rmsGradient); |
1018 | 1022 | parseIndex++; |
1019 | 1023 | } |
1024 | + // Initial trust radius. | |
1025 | + if((*inputTerms)[parseIndex].compare(this->stringOptimizationInitialTrustRadius) == 0){ | |
1026 | + double initialTrustRadius = atof((*inputTerms)[parseIndex+1].c_str()); | |
1027 | + Parameters::GetInstance()->SetInitialTrustRadiusOptimization(initialTrustRadius); | |
1028 | + parseIndex++; | |
1029 | + } | |
1030 | + // Max size of optimization step. | |
1031 | + if((*inputTerms)[parseIndex].compare(this->stringOptimizationMaxNormStep) == 0){ | |
1032 | + double maxNormStep = atof((*inputTerms)[parseIndex+1].c_str()); | |
1033 | + Parameters::GetInstance()->SetMaxNormStepOptimization(maxNormStep); | |
1034 | + parseIndex++; | |
1035 | + } | |
1020 | 1036 | parseIndex++; |
1021 | 1037 | } |
1022 | 1038 | return parseIndex; |
@@ -1667,6 +1683,11 @@ void InputParser::OutputOptimizationConditions() const{ | ||
1667 | 1683 | % (Parameters::GetInstance()->GetTimeWidthOptimization()/Parameters::GetInstance()->GetFs2AU()) |
1668 | 1684 | % this->messageFs.c_str()); |
1669 | 1685 | break; |
1686 | + case BFGSMethod: | |
1687 | + this->OutputLog(boost::format("%s%lf\n") % this->messageOptimizationInitialTrustRadius.c_str() | |
1688 | + % Parameters::GetInstance()->GetInitialTrustRadiusOptimization()); | |
1689 | + this->OutputLog(boost::format("%s%lf\n") % this->messageOptimizationMaxNormStep.c_str() | |
1690 | + % Parameters::GetInstance()->GetMaxNormStepOptimization()); | |
1670 | 1691 | default: |
1671 | 1692 | break; |
1672 | 1693 | } |
@@ -118,6 +118,8 @@ private: | ||
118 | 118 | std::string messageOptimizationTimeWidth; |
119 | 119 | std::string messageOptimizationRmsGradient; |
120 | 120 | std::string messageOptimizationMaxGradient; |
121 | + std::string messageOptimizationInitialTrustRadius; | |
122 | + std::string messageOptimizationMaxNormStep; | |
121 | 123 | // Frequencies (Normal modes) |
122 | 124 | std::string messageFrequenciesConditions; |
123 | 125 | std::string messageFrequenciesElecState; |
@@ -279,6 +281,8 @@ private: | ||
279 | 281 | std::string stringOptimizationMaxGradient; |
280 | 282 | std::string stringOptimizationRmsGradient; |
281 | 283 | std::string stringOptimizationTimeWidth; |
284 | + std::string stringOptimizationInitialTrustRadius; | |
285 | + std::string stringOptimizationMaxNormStep; | |
282 | 286 | // Frequencies (Normal modes) |
283 | 287 | std::string stringFrequencies; |
284 | 288 | std::string stringFrequenciesEnd; |
@@ -197,6 +197,8 @@ void Parameters::SetDefaultValues(){ | ||
197 | 197 | this->maxGradientOptimization = 0.00045; |
198 | 198 | this->rmsGradientOptimization = 0.00030; |
199 | 199 | this->timeWidthOptimization = 50.0*this->fs2AU; |
200 | + this->initialTrustRadiusOptimization = 0.3; | |
201 | + this->maxNormStepOptimization = 0.3; | |
200 | 202 | // Frequencies |
201 | 203 | this->requiresFrequencies = false; |
202 | 204 | this->electronicStateIndexFrequencies = 0; |
@@ -887,6 +889,22 @@ void Parameters::SetRmsGradientOptimization(double rmsGradient){ | ||
887 | 889 | this->rmsGradientOptimization = rmsGradient; |
888 | 890 | } |
889 | 891 | |
892 | +double Parameters::GetInitialTrustRadiusOptimization() const{ | |
893 | + return this->initialTrustRadiusOptimization; | |
894 | +} | |
895 | + | |
896 | +void Parameters::SetInitialTrustRadiusOptimization(double initialTrustRadius){ | |
897 | + this->initialTrustRadiusOptimization = initialTrustRadius; | |
898 | +} | |
899 | + | |
900 | +double Parameters::GetMaxNormStepOptimization() const{ | |
901 | + return this->maxNormStepOptimization; | |
902 | +} | |
903 | + | |
904 | +void Parameters::SetMaxNormStepOptimization(double maxNormStep){ | |
905 | + this->maxNormStepOptimization = maxNormStep; | |
906 | +} | |
907 | + | |
890 | 908 | double Parameters::GetTimeWidthOptimization() const{ |
891 | 909 | return this->timeWidthOptimization; |
892 | 910 | } |
@@ -197,6 +197,10 @@ public: | ||
197 | 197 | void SetRmsGradientOptimization(double rmsGradient); |
198 | 198 | double GetTimeWidthOptimization() const; |
199 | 199 | void SetTimeWidthOptimization(double timeWidth); |
200 | + double GetInitialTrustRadiusOptimization() const; | |
201 | + void SetInitialTrustRadiusOptimization(double initialTrustRadius); | |
202 | + double GetMaxNormStepOptimization() const; | |
203 | + void SetMaxNormStepOptimization(double maxNormStep); | |
200 | 204 | // Frequencies |
201 | 205 | bool RequiresFrequencies() const; |
202 | 206 | void SetRequiresFrequencies(bool requiresFrequencies); |
@@ -308,6 +312,8 @@ private: | ||
308 | 312 | double maxGradientOptimization; |
309 | 313 | double rmsGradientOptimization; |
310 | 314 | double timeWidthOptimization; |
315 | + double initialTrustRadiusOptimization; | |
316 | + double maxNormStepOptimization; | |
311 | 317 | // Frequencies |
312 | 318 | bool requiresFrequencies; |
313 | 319 | int electronicStateIndexFrequencies; |
@@ -88,8 +88,8 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct | ||
88 | 88 | double** matrixOldCoordinates = NULL; |
89 | 89 | double* vectorOldCoordinates = NULL; |
90 | 90 | double** matrixDisplacement = NULL; |
91 | - double trustRadius = 0.3; | |
92 | - const double maxNormStep = 0.3; | |
91 | + double trustRadius = Parameters::GetInstance()->GetInitialTrustRadiusOptimization(); | |
92 | + const double maxNormStep = Parameters::GetInstance()->GetMaxNormStepOptimization(); | |
93 | 93 | |
94 | 94 | try{ |
95 | 95 | // initialize Hessian with unit matrix |