修订版 | 77ae820d2e0ed5c791276d8946b7d1670009a93e (tree) |
---|---|
时间 | 2011-11-16 07:11:21 |
作者 | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
delta in Mndo::CalcZMatrixForce is modified. #26396
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/MolDS/trunk@299 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -773,19 +773,17 @@ void Mndo::CalcActiveSetVariablesQ(vector<MoIndexPair>* nonRedundantQIndeces, | ||
773 | 773 | } |
774 | 774 | } |
775 | 775 | |
776 | -void Mndo::MallocTempMatrixForZMatrix(double*** delta, | |
777 | - double** q, | |
778 | - double*** kNR, | |
779 | - double*** kRDag, | |
780 | - double** y, | |
781 | - double** b, | |
782 | - int numElecStates, | |
783 | - int sizeQNR, | |
784 | - int sizeQR){ | |
776 | +void Mndo::MallocTempMatrixForZMatrix(double** delta, | |
777 | + double** q, | |
778 | + double*** kNR, | |
779 | + double*** kRDag, | |
780 | + double** y, | |
781 | + double** b, | |
782 | + int sizeQNR, | |
783 | + int sizeQR){ | |
785 | 784 | int numberActiveMO = Parameters::GetInstance()->GetActiveOccCIS() |
786 | 785 | +Parameters::GetInstance()->GetActiveVirCIS(); |
787 | - *delta = MallocerFreer::GetInstance()->MallocDoubleMatrix2d( | |
788 | - numElecStates, | |
786 | + *delta = MallocerFreer::GetInstance()->MallocDoubleMatrix1d( | |
789 | 787 | numberActiveMO); |
790 | 788 | *q = MallocerFreer::GetInstance()->MallocDoubleMatrix1d( |
791 | 789 | sizeQNR+sizeQR); |
@@ -801,17 +799,16 @@ void Mndo::MallocTempMatrixForZMatrix(double*** delta, | ||
801 | 799 | sizeQNR); |
802 | 800 | } |
803 | 801 | |
804 | -void Mndo::FreeTempMatrixForZMatrix(double*** delta, | |
802 | +void Mndo::FreeTempMatrixForZMatrix(double** delta, | |
805 | 803 | double** q, |
806 | 804 | double*** kNR, |
807 | 805 | double*** kRDag, |
808 | 806 | double** y, |
809 | 807 | double** b, |
810 | - int numElecStates, | |
811 | 808 | int sizeQNR, |
812 | 809 | int sizeQR){ |
813 | 810 | if(*delta != NULL){ |
814 | - MallocerFreer::GetInstance()->FreeDoubleMatrix2d(delta, numElecStates); | |
811 | + MallocerFreer::GetInstance()->FreeDoubleMatrix1d(delta); | |
815 | 812 | //cout << "delta deleted" << endl; |
816 | 813 | } |
817 | 814 | if(*q != NULL){ |
@@ -880,38 +877,36 @@ double Mndo::GetCISCoefficientTwoElecIntegral(int k, | ||
880 | 877 | return value; |
881 | 878 | } |
882 | 879 | |
883 | -void Mndo::CalcDeltaVector(double** delta, vector<int> elecStates){ | |
880 | +void Mndo::CalcDeltaVector(double* delta, int elecState){ | |
884 | 881 | int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS(); |
885 | 882 | int numberActiveVir = Parameters::GetInstance()->GetActiveVirCIS(); |
886 | 883 | int numberActiveMO = numberActiveOcc + numberActiveVir; |
887 | - for(int n=0; n<elecStates.size(); n++){ | |
888 | - for(int r=0; r<numberActiveMO; r++){ | |
889 | - double value = 0.0; | |
890 | - if(r<numberActiveOcc){ | |
891 | - // r is active occupied MO | |
892 | - for(int a=0; a<numberActiveVir; a++){ | |
893 | - int slaterDeterminantIndex = numberActiveVir*r + a; | |
894 | - value -= pow(this->matrixCIS[elecStates[n]][slaterDeterminantIndex],2.0); | |
895 | - //c.f. The index of each MO (r and a)is below: | |
896 | - //int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2; | |
897 | - //int moR = numberOcc - (slaterDeterminantIndex/numberActiveVir) -1; | |
898 | - //int moA = numberOcc + (slaterDeterminantIndex%numberActiveVir); | |
899 | - } | |
900 | - | |
884 | + MallocerFreer::GetInstance()->InitializeDoubleMatrix1d(delta, numberActiveMO); | |
885 | + for(int r=0; r<numberActiveMO; r++){ | |
886 | + double value = 0.0; | |
887 | + if(r<numberActiveOcc){ | |
888 | + // r is active occupied MO | |
889 | + for(int a=0; a<numberActiveVir; a++){ | |
890 | + int slaterDeterminantIndex = numberActiveVir*r + a; | |
891 | + value -= pow(this->matrixCIS[elecState][slaterDeterminantIndex],2.0); | |
892 | + //c.f. The index of each MO (r and a)is below: | |
893 | + //int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2; | |
894 | + //int moR = numberOcc - (slaterDeterminantIndex/numberActiveVir) -1; | |
895 | + //int moA = numberOcc + (slaterDeterminantIndex%numberActiveVir); | |
901 | 896 | } |
902 | - else{ | |
903 | - // r is active virtual MO | |
904 | - for(int i=0; i<numberActiveOcc; i++){ | |
905 | - int slaterDeterminantIndex = numberActiveVir*i + (r-numberActiveOcc); | |
906 | - value += pow(this->matrixCIS[elecStates[n]][slaterDeterminantIndex],2.0); | |
907 | - //c.f. The index of each MO (i and r)is below: | |
908 | - //int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2; | |
909 | - //int moI = numberOcc - (slaterDeterminantIndex/numberActiveVir) -1; | |
910 | - //int moR = numberOcc + (slaterDeterminantIndex%numberActiveVir); | |
911 | - } | |
897 | + } | |
898 | + else{ | |
899 | + // r is active virtual MO | |
900 | + for(int i=0; i<numberActiveOcc; i++){ | |
901 | + int slaterDeterminantIndex = numberActiveVir*i + (r-numberActiveOcc); | |
902 | + value += pow(this->matrixCIS[elecState][slaterDeterminantIndex],2.0); | |
903 | + //c.f. The index of each MO (i and r)is below: | |
904 | + //int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2; | |
905 | + //int moI = numberOcc - (slaterDeterminantIndex/numberActiveVir) -1; | |
906 | + //int moR = numberOcc + (slaterDeterminantIndex%numberActiveVir); | |
912 | 907 | } |
913 | - delta[n][r] = value; | |
914 | 908 | } |
909 | + delta[r] = value; | |
915 | 910 | } |
916 | 911 | } |
917 | 912 |
@@ -930,7 +925,7 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){ | ||
930 | 925 | this->CalcActiveSetVariablesQ(&nonRedundantQIndeces, &redundantQIndeces); |
931 | 926 | |
932 | 927 | // malloc temporary arraies |
933 | - double** delta = NULL; // Delta matrix, see (9) in [PT_1997] | |
928 | + double* delta = NULL; // Delta matrix, see (9) in [PT_1997] | |
934 | 929 | double* q = NULL; //// Q-vector in (19) in [PT_1997] |
935 | 930 | double** kNR = NULL; // K_{NR} matrix, see (45) in [PT_1996] |
936 | 931 | double** kRDag = NULL; // Daggar of K_{R} matrix, see (46) in [PT_1996] |
@@ -942,14 +937,14 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){ | ||
942 | 937 | &kRDag, |
943 | 938 | &y, |
944 | 939 | &b, |
945 | - elecStates.size(), | |
946 | 940 | nonRedundantQIndeces.size(), |
947 | 941 | redundantQIndeces.size()); |
948 | 942 | try{ |
949 | - // delta | |
950 | - this->CalcDeltaVector(delta, elecStates); | |
951 | - | |
952 | - | |
943 | + for(int n=0; n<elecStates.size(); n++){ | |
944 | + int elecState = elecStates[n]; | |
945 | + // delta | |
946 | + this->CalcDeltaVector(delta, elecState); | |
947 | + } | |
953 | 948 | } |
954 | 949 | catch(MolDSException ex){ |
955 | 950 | this->FreeTempMatrixForZMatrix(&delta, |
@@ -958,7 +953,6 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){ | ||
958 | 953 | &kRDag, |
959 | 954 | &y, |
960 | 955 | &b, |
961 | - elecStates.size(), | |
962 | 956 | nonRedundantQIndeces.size(), |
963 | 957 | redundantQIndeces.size()); |
964 | 958 | throw ex; |
@@ -969,7 +963,6 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){ | ||
969 | 963 | &kRDag, |
970 | 964 | &y, |
971 | 965 | &b, |
972 | - elecStates.size(), | |
973 | 966 | nonRedundantQIndeces.size(), |
974 | 967 | redundantQIndeces.size()); |
975 | 968 | } |
@@ -88,25 +88,23 @@ private: | ||
88 | 88 | double*** zMatrixForce; |
89 | 89 | int zMatrixForceElecStatesNum; |
90 | 90 | double heatsFormation; |
91 | - void MallocTempMatrixForZMatrix(double*** delta, | |
91 | + void MallocTempMatrixForZMatrix(double** delta, | |
92 | 92 | double** q, |
93 | 93 | double*** kNR, |
94 | 94 | double*** kRDag, |
95 | 95 | double** y, |
96 | 96 | double** b, |
97 | - int numElecStates, | |
98 | 97 | int sizeQNR, |
99 | 98 | int sizeQR); |
100 | - void FreeTempMatrixForZMatrix(double*** delta, | |
99 | + void FreeTempMatrixForZMatrix(double** delta, | |
101 | 100 | double** q, |
102 | 101 | double*** kNR, |
103 | 102 | double*** kRDag, |
104 | 103 | double** y, |
105 | 104 | double** b, |
106 | - int numElecStates, | |
107 | 105 | int sizeQNR, |
108 | 106 | int sizeQR); |
109 | - void CalcDeltaVector(double** delta, std::vector<int> elecStates); | |
107 | + void CalcDeltaVector(double* delta, int elecStates); | |
110 | 108 | void CalcZMatrixForce(std::vector<int> elecStates); |
111 | 109 | double GetCISCoefficientMOEnergy(int k, |
112 | 110 | int l, |