Revision | 04f014ed581f43537aaa550c9c566dbd890815cf (tree) |
---|---|
Time | 2012-11-09 15:45:10 |
Author | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Refactoring of methods to calculate overlaps. #28791
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1114 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -3583,6 +3583,7 @@ void Cndo2::CalcOverlapMOsWithAnotherElectronicStructure(double** overlapMOs, | ||
3583 | 3583 | int totalAONumber = this->molecule->GetTotalNumberAOs(); |
3584 | 3584 | int usedMONumber = this->molecule->GetTotalNumberValenceElectrons()/2 |
3585 | 3585 | +Parameters::GetInstance()->GetActiveVirCIS(); |
3586 | + MallocerFreer::GetInstance()->Initialize<double>(overlapMOs, totalAONumber, totalAONumber); | |
3586 | 3587 | double** tmpMatrix=NULL; |
3587 | 3588 | try{ |
3588 | 3589 | MallocerFreer::GetInstance()->Malloc<double>(&tmpMatrix,totalAONumber,totalAONumber); |
@@ -707,14 +707,17 @@ void ZindoS::CalcDiatomicOverlapAOs2ndDerivativeInDiatomicFrame(double** diatomi | ||
707 | 707 | void ZindoS::CalcOverlapSingletSDsWithAnotherElectronicStructure(double** overlapSingletSDs, |
708 | 708 | double const* const* overlapMOs) const{ |
709 | 709 | int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2; |
710 | + MallocerFreer::GetInstance()->Initialize<double>(overlapSingletSDs, | |
711 | + this->matrixCISdimension, | |
712 | + this->matrixCISdimension); | |
710 | 713 | double** tmpMatrix1=NULL; |
711 | 714 | double** tmpMatrix2=NULL; |
712 | 715 | 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); | |
716 | 716 | double sqrtGroundStateOverlap; |
717 | 717 | 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); | |
718 | 721 | // between ground state |
719 | 722 | for(int i=0; i<numberOcc; i++){ |
720 | 723 | for(int j=0; j<numberOcc; j++){ |
@@ -779,38 +782,47 @@ void ZindoS::CalcOverlapESsWithAnotherElectronicStructure(double** overlapESs, | ||
779 | 782 | int dimOverlapSingletSDs = this->matrixCISdimension + 1; |
780 | 783 | int dimOverlapESs = Parameters::GetInstance()->GetNumberElectronicStatesNASCO(); |
781 | 784 | int groundstate = 0; |
785 | + MallocerFreer::GetInstance()->Initialize<double>(overlapESs, dimOverlapESs, dimOverlapESs); | |
782 | 786 | // extended CIS matrix includes groundstate althoug matrixCIS does not include groundstate. |
783 | 787 | double** lhsExtendedMatrixCIS=NULL; |
784 | 788 | double** rhsExtendedMatrixCIS=NULL; |
785 | 789 | 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 | + } | |
795 | 801 | } |
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; | |
796 | 825 | } |
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); | |
814 | 826 | MallocerFreer::GetInstance()->Free<double>(&lhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs); |
815 | 827 | MallocerFreer::GetInstance()->Free<double>(&rhsExtendedMatrixCIS, dimOverlapSingletSDs, dimOverlapSingletSDs); |
816 | 828 | MallocerFreer::GetInstance()->Free<double>(&tmpMatrix, dimOverlapSingletSDs, dimOverlapESs); |