• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revision04f014ed581f43537aaa550c9c566dbd890815cf (tree)
Time2012-11-09 15:45:10
AuthorMikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Refactoring of methods to calculate overlaps. #28791

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1114 1136aad2-a195-0410-b898-f5ea1d11b9d8

Change Summary

Incremental Difference

--- a/src/cndo/Cndo2.cpp
+++ b/src/cndo/Cndo2.cpp
@@ -3583,6 +3583,7 @@ void Cndo2::CalcOverlapMOsWithAnotherElectronicStructure(double** overlapMOs,
35833583 int totalAONumber = this->molecule->GetTotalNumberAOs();
35843584 int usedMONumber = this->molecule->GetTotalNumberValenceElectrons()/2
35853585 +Parameters::GetInstance()->GetActiveVirCIS();
3586+ MallocerFreer::GetInstance()->Initialize<double>(overlapMOs, totalAONumber, totalAONumber);
35863587 double** tmpMatrix=NULL;
35873588 try{
35883589 MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix,totalAONumber,totalAONumber);
--- a/src/zindo/ZindoS.cpp
+++ b/src/zindo/ZindoS.cpp
@@ -707,14 +707,17 @@ void ZindoS::CalcDiatomicOverlapAOs2ndDerivativeInDiatomicFrame(double** diatomi
707707 void ZindoS::CalcOverlapSingletSDsWithAnotherElectronicStructure(double** overlapSingletSDs,
708708 double const* const* overlapMOs) const{
709709 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
710+ MallocerFreer::GetInstance()->Initialize<double>(overlapSingletSDs,
711+ this->matrixCISdimension,
712+ this->matrixCISdimension);
710713 double** tmpMatrix1=NULL;
711714 double** tmpMatrix2=NULL;
712715 double** tmpMatrix3=NULL;
713- MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix1, numberOcc, numberOcc);
714- MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix2, numberOcc, numberOcc);
715- MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix3, numberOcc, numberOcc);
716716 double sqrtGroundStateOverlap;
717717 try{
718+ MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix1, numberOcc, numberOcc);
719+ MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix2, numberOcc, numberOcc);
720+ MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix3, numberOcc, numberOcc);
718721 // between ground state
719722 for(int i=0; i<numberOcc; i++){
720723 for(int j=0; j<numberOcc; j++){
@@ -779,38 +782,47 @@ void ZindoS::CalcOverlapESsWithAnotherElectronicStructure(double** overlapESs,
779782 int dimOverlapSingletSDs = this->matrixCISdimension + 1;
780783 int dimOverlapESs = Parameters::GetInstance()->GetNumberElectronicStatesNASCO();
781784 int groundstate = 0;
785+ MallocerFreer::GetInstance()->Initialize<double>(overlapESs, dimOverlapESs, dimOverlapESs);
782786 // extended CIS matrix includes groundstate althoug matrixCIS does not include groundstate.
783787 double** lhsExtendedMatrixCIS=NULL;
784788 double** rhsExtendedMatrixCIS=NULL;
785789 double** tmpMatrix=NULL;
786- MallocerFreer::GetInstance()->Malloc<double>(&lhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
787- MallocerFreer::GetInstance()->Malloc<double>(&rhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
788- MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix, dimOverlapSingletSDs, dimOverlapESs);
789- lhsExtendedMatrixCIS[groundstate][groundstate] = 1.0;
790- rhsExtendedMatrixCIS[groundstate][groundstate] = 1.0;
791- for(int i=1; i<dimOverlapESs; i++){
792- for(int j=1; j<dimOverlapSingletSDs; j++){
793- rhsExtendedMatrixCIS[i][j] = rhsMatrixCIS[i-1][j-1];
794- lhsExtendedMatrixCIS[i][j] = lhsMatrixCIS[i-1][j-1];
790+ try{
791+ MallocerFreer::GetInstance()->Malloc<double>(&lhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
792+ MallocerFreer::GetInstance()->Malloc<double>(&rhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
793+ MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix, dimOverlapSingletSDs, dimOverlapESs);
794+ lhsExtendedMatrixCIS[groundstate][groundstate] = 1.0;
795+ rhsExtendedMatrixCIS[groundstate][groundstate] = 1.0;
796+ for(int i=1; i<dimOverlapESs; i++){
797+ for(int j=1; j<dimOverlapSingletSDs; j++){
798+ rhsExtendedMatrixCIS[i][j] = rhsMatrixCIS[i-1][j-1];
799+ lhsExtendedMatrixCIS[i][j] = lhsMatrixCIS[i-1][j-1];
800+ }
795801 }
802+ // calc. overlap between eigenstates
803+ bool isColumnMajorOverlapSingletSDs = false;
804+ bool isColumnMajorRhsMatrixCIS = true;
805+ double alpha=1.0;
806+ double beta=0.0;
807+ MolDS_wrappers::Blas::GetInstance()->Dgemm(isColumnMajorOverlapSingletSDs,
808+ isColumnMajorRhsMatrixCIS,
809+ dimOverlapSingletSDs, dimOverlapESs, dimOverlapSingletSDs,
810+ alpha,
811+ overlapSingletSDs,
812+ rhsExtendedMatrixCIS,
813+ beta,
814+ tmpMatrix);
815+ MolDS_wrappers::Blas::GetInstance()->Dgemm(dimOverlapESs, dimOverlapESs, dimOverlapSingletSDs,
816+ lhsExtendedMatrixCIS,
817+ tmpMatrix,
818+ overlapESs);
819+ }
820+ catch(MolDSException ex){
821+ MallocerFreer::GetInstance()->Free<double>(&lhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
822+ MallocerFreer::GetInstance()->Free<double>(&rhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
823+ MallocerFreer::GetInstance()->Free<double>(&tmpMatrix, dimOverlapSingletSDs, dimOverlapESs);
824+ throw ex;
796825 }
797- // calc. overlap between eigenstates
798- bool isColumnMajorOverlapSingletSDs = false;
799- bool isColumnMajorRhsMatrixCIS = true;
800- double alpha=1.0;
801- double beta=0.0;
802- MolDS_wrappers::Blas::GetInstance()->Dgemm(isColumnMajorOverlapSingletSDs,
803- isColumnMajorRhsMatrixCIS,
804- dimOverlapSingletSDs, dimOverlapESs, dimOverlapSingletSDs,
805- alpha,
806- overlapSingletSDs,
807- rhsExtendedMatrixCIS,
808- beta,
809- tmpMatrix);
810- MolDS_wrappers::Blas::GetInstance()->Dgemm(dimOverlapESs, dimOverlapESs, dimOverlapSingletSDs,
811- lhsExtendedMatrixCIS,
812- tmpMatrix,
813- overlapESs);
814826 MallocerFreer::GetInstance()->Free<double>(&lhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
815827 MallocerFreer::GetInstance()->Free<double>(&rhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs);
816828 MallocerFreer::GetInstance()->Free<double>(&tmpMatrix, dimOverlapSingletSDs, dimOverlapESs);