Révision | 8253f95746f2a27a5a8fa034eba6e8a291c1aa5b (tree) |
---|---|
l'heure | 2013-08-08 19:43:41 |
Auteur | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Factor out BFGS::CalcDisplacement. #31856
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1468 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -205,14 +205,8 @@ void BFGS::SearchMinimum(boost::shared_ptr<ElectronicStructure> electronicStruct | ||
205 | 205 | } |
206 | 206 | |
207 | 207 | //Calculate displacement (K_k at Eq. (15) in [SJTO_1983]) |
208 | - MallocerFreer::GetInstance()->Malloc(&matrixDisplacement, molecule.GetNumberAtoms(), CartesianType_end); | |
209 | - for(int i=0;i<molecule.GetNumberAtoms();i++){ | |
210 | - const Atom* atom = molecule.GetAtom(i); | |
211 | - const double* xyz = atom->GetXyz(); | |
212 | - for(int j=0;j<CartesianType_end;j++){ | |
213 | - matrixDisplacement[i][j] = xyz[j] - matrixOldCoordinates[i][j]; | |
214 | - } | |
215 | - } | |
208 | + this->CalcDisplacement(matrixDisplacement, matrixOldCoordinates, molecule); | |
209 | + | |
216 | 210 | matrixForce = electronicStructure->GetForce(elecState); |
217 | 211 | vectorForce = &matrixForce[0][0]; |
218 | 212 |
@@ -568,4 +562,18 @@ void BFGS::RollbackMolecularGeometry(MolDS_base::Molecule& molecule, | ||
568 | 562 | } |
569 | 563 | molecule.SetCanOutputLogs(tempCanOutputLogs); |
570 | 564 | } |
565 | + | |
566 | +void BFGS::CalcDisplacement(double * *& matrixDisplacement, | |
567 | + double const* const* matrixOldCoordinates, | |
568 | + const MolDS_base::Molecule& molecule)const{ | |
569 | + //Calculate displacement (K_k at Eq. (15) in [SJTO_1983]) | |
570 | + MallocerFreer::GetInstance()->Malloc(&matrixDisplacement, molecule.GetNumberAtoms(), CartesianType_end); | |
571 | + for(int i=0;i<molecule.GetNumberAtoms();i++){ | |
572 | + const Atom* atom = molecule.GetAtom(i); | |
573 | + const double* xyz = atom->GetXyz(); | |
574 | + for(int j=0;j<CartesianType_end;j++){ | |
575 | + matrixDisplacement[i][j] = xyz[j] - matrixOldCoordinates[i][j]; | |
576 | + } | |
577 | + } | |
578 | +} | |
571 | 579 | } |
@@ -56,6 +56,9 @@ protected: | ||
56 | 56 | double const* vectorForce, |
57 | 57 | const double maxNormStep, |
58 | 58 | const int dimension) const; |
59 | + void CalcDisplacement(double * *& matrixDisplacement, | |
60 | + double const* const* matrixOldCoordinates, | |
61 | + const MolDS_base::Molecule& molecule)const; | |
59 | 62 | void UpdateHessian(double** matrixHessian, |
60 | 63 | const int dimension, |
61 | 64 | double const* vectorForce, |