• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

修订版16ef8baf4df572c8548c11251a8b26a8fd9cbe99 (tree)
时间2011-11-24 04:07:51
作者Mikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

CIS analytic force for NDDO series are is implemented. Parallerization is not carried out yet. #26396 #26626 #26630

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

更改概述

差异

--- a/src/cndo/Cndo2.cpp
+++ b/src/cndo/Cndo2.cpp
@@ -423,7 +423,8 @@ void Cndo2::DoesCIS(){
423423
424424 // elecState=0 means ground state
425425 double Cndo2::GetElectronicEnergy(int elecState){
426- if(elecState==0){
426+ int groundState = 0;
427+ if(elecState==groundState){
427428 return this->elecEnergy;
428429 }
429430 else{
@@ -440,7 +441,7 @@ double Cndo2::GetElectronicEnergy(int elecState){
440441 ss << errorMessageGetElectronicEnergyNumberCISStates << numberExcitedStates << endl;
441442 throw MolDSException(ss.str());
442443 }
443- return this->elecEnergy + this->excitedEnergies[elecState+1];
444+ return this->elecEnergy + this->excitedEnergies[elecState-1];
444445 }
445446 }
446447
--- a/src/mndo/Mndo.cpp
+++ b/src/mndo/Mndo.cpp
@@ -443,7 +443,6 @@ double Mndo::GetElectronCoreAttractionFirstDerivative(int atomAIndex,
443443 return value;
444444 }
445445
446-
447446 void Mndo::CalcDiatomicOverlapInDiatomicFrame(double** diatomicOverlap,
448447 Atom* atomA,
449448 Atom* atomB){
@@ -778,30 +777,29 @@ void Mndo::CalcActiveSetVariablesQ(vector<MoIndexPair>* nonRedundantQIndeces,
778777 vector<MoIndexPair>* redundantQIndeces){
779778 int numberAOs = this->molecule->GetTotalNumberAOs();
780779 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
781- int numberVir = numberAOs - numberOcc;
782780 int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS();
783781 int numberActiveVir = Parameters::GetInstance()->GetActiveVirCIS();
784- for(int i=0; i<numberOcc; i++){
785- bool isMoICIMO = numberOcc-numberActiveOcc<=i ? true : false;
786- for(int j=numberOcc; j<numberAOs; j++){
787- bool isMoJCIMO = j<numberOcc+numberActiveVir ? true : false;
788- MoIndexPair moIndexPair = {i, j, isMoICIMO, isMoJCIMO};
782+ for(int moI=0; moI<numberOcc; moI++){
783+ bool isMoICIMO = numberOcc-numberActiveOcc<=moI ? true : false;
784+ for(int moJ=numberOcc; moJ<numberAOs; moJ++){
785+ bool isMoJCIMO = moJ<numberOcc+numberActiveVir ? true : false;
786+ MoIndexPair moIndexPair = {moI, moJ, isMoICIMO, isMoJCIMO};
789787 nonRedundantQIndeces->push_back(moIndexPair);
790788 }
791789 }
792- for(int i=numberOcc-numberActiveOcc; i<numberOcc; i++){
790+ for(int moI=numberOcc-numberActiveOcc; moI<numberOcc; moI++){
793791 bool isMoICIMO = true;
794- for(int j=i; j<numberOcc; j++){
792+ for(int moJ=moI; moJ<numberOcc; moJ++){
795793 bool isMoJCIMO = true;
796- MoIndexPair moIndexPair = {i, j, isMoICIMO, isMoJCIMO};
794+ MoIndexPair moIndexPair = {moI, moJ, isMoICIMO, isMoJCIMO};
797795 redundantQIndeces->push_back(moIndexPair);
798796 }
799797 }
800- for(int i=numberOcc; i<numberOcc+numberActiveVir; i++){
798+ for(int moI=numberOcc; moI<numberOcc+numberActiveVir; moI++){
801799 bool isMoICIMO = true;
802- for(int j=i; j<numberOcc+numberActiveVir; j++){
800+ for(int moJ=moI; moJ<numberOcc+numberActiveVir; moJ++){
803801 bool isMoJCIMO = true;
804- MoIndexPair moIndexPair = {i, j, isMoICIMO, isMoJCIMO};
802+ MoIndexPair moIndexPair = {moI, moJ, isMoICIMO, isMoJCIMO};
805803 redundantQIndeces->push_back(moIndexPair);
806804 }
807805 }
@@ -943,9 +941,9 @@ double Mndo::GetGammaNRElement(int moI, int moJ, int moK, int moL){
943941 double value=0.0;
944942 if(moI==moK && moJ==moL){
945943 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
946- int nI = moI<numberOcc ? 2 : 1;
947- int nJ = moJ<numberOcc ? 2 : 1;
948- value = (energiesMO[moJ]-energiesMO[moI])/((double)(nJ-nI));
944+ double nI = moI<numberOcc ? 2.0 : 0.0;
945+ double nJ = moJ<numberOcc ? 2.0 : 0.0;
946+ value = (this->energiesMO[moJ]-this->energiesMO[moI])/(nJ-nI);
949947 }
950948 return value;
951949 }
@@ -954,7 +952,7 @@ double Mndo::GetGammaNRElement(int moI, int moJ, int moK, int moL){
954952 double Mndo::GetGammaRElement(int moI, int moJ, int moK, int moL){
955953 double value=0.0;
956954 if(moI==moK && moJ==moL){
957- value = moI==moJ ? 1 : energiesMO[moJ]-energiesMO[moI];
955+ value = moI==moJ ? 1.0 : this->energiesMO[moJ]-this->energiesMO[moI];
958956 }
959957 return value;
960958 }
@@ -964,9 +962,9 @@ double Mndo::GetNNRElement(int moI, int moJ, int moK, int moL){
964962 double value=0.0;
965963 if(moI==moK && moJ==moL){
966964 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
967- int nI = moI<numberOcc ? 2 : 1;
968- int nJ = moJ<numberOcc ? 2 : 1;
969- value = ((double)(nJ-nI));
965+ double nI = moI<numberOcc ? 2.0 : 0.0;
966+ double nJ = moJ<numberOcc ? 2.0 : 0.0;
967+ value = (nJ-nI);
970968 }
971969 return value;
972970 }
@@ -984,19 +982,22 @@ double Mndo::GetNRElement(int moI, int moJ, int moK, int moL){
984982 double Mndo::GetKNRElement(int moI, int moJ, int moK, int moL){
985983 double value=0.0;
986984 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
987- int nI = moI<numberOcc ? 2 : 1;
988- int nJ = moJ<numberOcc ? 2 : 1;
989- int nK = moK<numberOcc ? 2 : 1;
990- int nL = moL<numberOcc ? 2 : 1;
985+ int nI = moI<numberOcc ? 2 : 0;
986+ int nJ = moJ<numberOcc ? 2 : 0;
987+ int nK = moK<numberOcc ? 2 : 0;
988+ int nL = moL<numberOcc ? 2 : 0;
991989 if(nI!=nJ && nK!=nL){
992990 value = 4.0*this->GetMolecularIntegralElement(moI, moJ, moK, moL,
993- this->molecule, this->fockMatrix, NULL)
991+ this->molecule,
992+ this->fockMatrix, NULL)
994993 -1.0*this->GetMolecularIntegralElement(moI, moK, moJ, moL,
995- this->molecule, this->fockMatrix, NULL)
994+ this->molecule,
995+ this->fockMatrix, NULL)
996996 -1.0*this->GetMolecularIntegralElement(moI, moL, moJ, moK,
997- this->molecule, this->fockMatrix, NULL);
997+ this->molecule,
998+ this->fockMatrix, NULL);
998999 }
999- return value;
1000+ return 0.5*value;
10001001 }
10011002
10021003 // Dager of (45) in [PT_1996]. Note taht the (45) is real number.
@@ -1008,23 +1009,26 @@ double Mndo::GetKRDagerElement(int moI, int moJ, int moK, int moL){
10081009 double Mndo::GetKRElement(int moI, int moJ, int moK, int moL){
10091010 double value=0.0;
10101011 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
1011- int nI = moI<numberOcc ? 2 : 1;
1012- int nJ = moJ<numberOcc ? 2 : 1;
1013- int nK = moK<numberOcc ? 2 : 1;
1014- int nL = moL<numberOcc ? 2 : 1;
1012+ int nI = moI<numberOcc ? 2 : 0;
1013+ int nJ = moJ<numberOcc ? 2 : 0;
1014+ int nK = moK<numberOcc ? 2 : 0;
1015+ int nL = moL<numberOcc ? 2 : 0;
10151016 if(nI==nJ && nK!=nL){
10161017 value = 4.0*this->GetMolecularIntegralElement(moI, moJ, moK, moL,
1017- this->molecule, this->fockMatrix, NULL)
1018+ this->molecule,
1019+ this->fockMatrix, NULL)
10181020 -1.0*this->GetMolecularIntegralElement(moI, moK, moJ, moL,
1019- this->molecule, this->fockMatrix, NULL)
1021+ this->molecule,
1022+ this->fockMatrix, NULL)
10201023 -1.0*this->GetMolecularIntegralElement(moI, moL, moJ, moK,
1021- this->molecule, this->fockMatrix, NULL);
1024+ this->molecule,
1025+ this->fockMatrix, NULL);
10221026 }
1023- return value;
1027+ return 0.5*value;
10241028 }
10251029
10261030 // see (9) in [PT_1997]
1027-void Mndo::CalcDeltaVector(double* delta, int elecState){
1031+void Mndo::CalcDeltaVector(double* delta, int exciteState){
10281032 int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS();
10291033 int numberActiveVir = Parameters::GetInstance()->GetActiveVirCIS();
10301034 int numberActiveMO = numberActiveOcc + numberActiveVir;
@@ -1033,24 +1037,18 @@ void Mndo::CalcDeltaVector(double* delta, int elecState){
10331037 double value = 0.0;
10341038 if(r<numberActiveOcc){
10351039 // r is active occupied MO
1040+ int rr=numberActiveOcc-(r+1);
10361041 for(int a=0; a<numberActiveVir; a++){
1037- int slaterDeterminantIndex = this->GetSlaterDeterminantIndex(r,a);
1038- value -= pow(this->matrixCIS[elecState][slaterDeterminantIndex],2.0);
1039- //c.f. The index of each MO (r and a)is below:
1040- //int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
1041- //int moR = numberOcc - (slaterDeterminantIndex/numberActiveVir) -1;
1042- //int moA = numberOcc + (slaterDeterminantIndex%numberActiveVir);
1042+ int slaterDeterminantIndex = this->GetSlaterDeterminantIndex(rr,a);
1043+ value -= pow(this->matrixCIS[exciteState][slaterDeterminantIndex],2.0);
10431044 }
10441045 }
10451046 else{
10461047 // r is active virtual MO
1048+ int rr=r-numberActiveOcc;
10471049 for(int i=0; i<numberActiveOcc; i++){
1048- int slaterDeterminantIndex = this->GetSlaterDeterminantIndex(i,(r-numberActiveOcc));
1049- value += pow(this->matrixCIS[elecState][slaterDeterminantIndex],2.0);
1050- //c.f. The index of each MO (i and r)is below:
1051- //int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
1052- //int moI = numberOcc - (slaterDeterminantIndex/numberActiveVir) -1;
1053- //int moR = numberOcc + (slaterDeterminantIndex%numberActiveVir);
1050+ int slaterDeterminantIndex = this->GetSlaterDeterminantIndex(i,rr);
1051+ value += pow(this->matrixCIS[exciteState][slaterDeterminantIndex],2.0);
10541052 }
10551053 }
10561054 delta[r] = value;
@@ -1154,13 +1152,14 @@ double Mndo::GetSmallQElement(int moI,
11541152 int p = moP - numberOcc;
11551153 temp = 4.0*xiVir[p][mu]*eta[lambda][sigma]
11561154 -1.0*xiVir[p][lambda]*eta[sigma][mu]
1157- -1.0*xiVir[p][sigma]*eta[lambda][mu];
1155+ -1.0*xiVir[p][sigma]*eta[lambda][mu];
11581156 value += twoElecInt*this->fockMatrix[moI][nu]*temp;
11591157 temp = 4.0*xiVir[p][sigma]*eta[nu][mu]
11601158 -1.0*xiVir[p][nu]*eta[mu][sigma]
11611159 -1.0*xiVir[p][mu]*eta[nu][sigma];
11621160 value += twoElecInt*this->fockMatrix[moI][lambda]*temp;
11631161 }
1162+ }
11641163
11651164 if(mu!=nu && lambda!=sigma){
11661165 if(isMoPOcc){
@@ -1187,7 +1186,6 @@ double Mndo::GetSmallQElement(int moI,
11871186 }
11881187 }
11891188
1190- }
11911189 }
11921190 }
11931191 }
@@ -1247,7 +1245,6 @@ void Mndo::CalcQVector(double* q,
12471245 double** xiOcc,
12481246 double** xiVir,
12491247 double** eta,
1250- int elecState,
12511248 vector<MoIndexPair> nonRedundantQIndeces,
12521249 vector<MoIndexPair> redundantQIndeces){
12531250 MallocerFreer::GetInstance()->InitializeDoubleMatrix1d(
@@ -1256,15 +1253,11 @@ void Mndo::CalcQVector(double* q,
12561253
12571254 int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
12581255 int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS();
1259- int moI = 0;
1260- int moJ = 0;
1261- bool isMoICIMO = false;
1262- bool isMoJCIMO = false;
12631256 for(int i=0; i<nonRedundantQIndeces.size(); i++){
1264- moI = nonRedundantQIndeces[i].moI;
1265- moJ = nonRedundantQIndeces[i].moJ;
1266- isMoICIMO = nonRedundantQIndeces[i].isMoICIMO;
1267- isMoJCIMO = nonRedundantQIndeces[i].isMoJCIMO;
1257+ int moI = nonRedundantQIndeces[i].moI;
1258+ int moJ = nonRedundantQIndeces[i].moJ;
1259+ bool isMoICIMO = nonRedundantQIndeces[i].isMoICIMO;
1260+ bool isMoJCIMO = nonRedundantQIndeces[i].isMoJCIMO;
12681261 if(!isMoICIMO && isMoJCIMO){
12691262 q[i] = this->GetSmallQElement(moI, moJ, xiOcc, xiVir, eta);
12701263 }
@@ -1281,8 +1274,8 @@ void Mndo::CalcQVector(double* q,
12811274 }
12821275 for(int i=0; i<redundantQIndeces.size(); i++){
12831276 int r = nonRedundantQIndeces.size() + i;
1284- moI = redundantQIndeces[i].moI;
1285- moJ = redundantQIndeces[i].moJ;
1277+ int moI = redundantQIndeces[i].moI;
1278+ int moJ = redundantQIndeces[i].moJ;
12861279 if(moI == moJ){
12871280 int rr = moI - (numberOcc-numberActiveOcc);
12881281 q[r] = delta[rr];
@@ -1290,10 +1283,9 @@ void Mndo::CalcQVector(double* q,
12901283 else{
12911284 q[r] = this->GetSmallQElement(moI, moJ, xiOcc, xiVir, eta)
12921285 -this->GetSmallQElement(moJ, moI, xiOcc, xiVir, eta);
1293-
12941286 }
12951287 }
1296-
1288+ /*
12971289 for(int i=0; i<nonRedundantQIndeces.size(); i++){
12981290 printf("q[%d] = %e\n",i,q[i]);
12991291 }
@@ -1301,18 +1293,17 @@ void Mndo::CalcQVector(double* q,
13011293 int r = nonRedundantQIndeces.size() + i;
13021294 printf("q[%d] = %e\n",r,q[r]);
13031295 }
1304-
1296+ */
13051297 }
13061298
13071299 // see (43) and (45) in [PT_1996].
13081300 // This method calculates "\Gamma_{NR} - K_{NR}".
13091301 // Note taht K_{NR} is not calculated.
1310-// Note taht right upper part is only calulated because this matrix is symmetric.
13111302 void Mndo::CalcKNRMatrix(double** kNR, vector<MoIndexPair> nonRedundantQIndeces){
13121303 for(int i=0; i<nonRedundantQIndeces.size(); i++){
13131304 int moI = nonRedundantQIndeces[i].moI;
13141305 int moJ = nonRedundantQIndeces[i].moJ;
1315- for(int j=0; j<nonRedundantQIndeces.size(); j++){
1306+ for(int j=i; j<nonRedundantQIndeces.size(); j++){
13161307 int moK = nonRedundantQIndeces[j].moI;
13171308 int moL = nonRedundantQIndeces[j].moJ;
13181309 kNR[i][j] = this->GetGammaNRElement(moI, moJ, moK, moL)
@@ -1340,7 +1331,7 @@ void Mndo::CalcKRDagerMatrix(double** kRDager,
13401331 }
13411332
13421333 // right hand side of (54) in [PT_1996]
1343-void Mndo::CaclAuxiliaryVector(double* y,
1334+void Mndo::CalcAuxiliaryVector(double* y,
13441335 double* q,
13451336 double** kRDager,
13461337 vector<MoIndexPair> nonRedundantQIndeces,
@@ -1351,11 +1342,9 @@ void Mndo::CaclAuxiliaryVector(double* y,
13511342 for(int i=0; i<nonRedundantQIndeces.size(); i++){
13521343 int moI = nonRedundantQIndeces[i].moI;
13531344 int moJ = nonRedundantQIndeces[i].moJ;
1354- y[i] += q[i]/this->GetNRElement(moI, moJ, moI, moJ);
1345+ y[i] += q[i]/this->GetNNRElement(moI, moJ, moI, moJ);
13551346 for(int j=0; j<redundantQIndeces.size(); j++){
13561347 int k = nonRedundantQIndeces.size() + j;
1357- int moK = redundantQIndeces[j].moI;
1358- int moL = redundantQIndeces[j].moJ;
13591348 y[i] += kRDager[i][j]*q[k];
13601349 }
13611350 }
@@ -1390,8 +1379,7 @@ double Mndo::GetZMatrixForceElement(double* y,
13901379 int j = nonRedundantQIndeces.size() + i;
13911380 int moI = redundantQIndeces[i].moI;
13921381 int moJ = redundantQIndeces[i].moJ;
1393- value +=(q[j]
1394- /this->GetGammaRElement(moI, moJ, moI, moJ))
1382+ value += (q[j]/this->GetGammaRElement(moI, moJ, moI, moJ))
13951383 *transposedFockMatrix[mu][moI]
13961384 *transposedFockMatrix[nu][moJ];
13971385 }
@@ -1400,9 +1388,10 @@ double Mndo::GetZMatrixForceElement(double* y,
14001388
14011389 void Mndo::CalcXiMatrices(double** xiOcc,
14021390 double** xiVir,
1403- int elecState,
1391+ int exciteState,
14041392 double** transposedFockMatrix){
14051393 int numberAOs = this->molecule->GetTotalNumberAOs();
1394+ int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
14061395 int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS();
14071396 int numberActiveVir = Parameters::GetInstance()->GetActiveVirCIS();
14081397 MallocerFreer::GetInstance()->InitializeDoubleMatrix2d(
@@ -1412,22 +1401,22 @@ void Mndo::CalcXiMatrices(double** xiOcc,
14121401 // xiOcc
14131402 for(int p=0; p<numberActiveOcc; p++){
14141403 for(int mu=0; mu<numberAOs; mu++){
1415- int slaterDeterminantIndex = 0;
14161404 for(int a=0; a<numberActiveVir; a++){
1417- slaterDeterminantIndex = this->GetSlaterDeterminantIndex(p,a);
1418- xiOcc[p][mu] += this->matrixCIS[elecState][slaterDeterminantIndex]
1419- *transposedFockMatrix[mu][a];
1405+ int moA = numberOcc + a;
1406+ int slaterDeterminantIndex = this->GetSlaterDeterminantIndex(p,a);
1407+ xiOcc[p][mu] += this->matrixCIS[exciteState][slaterDeterminantIndex]
1408+ *transposedFockMatrix[mu][moA];
14201409 }
14211410 }
14221411 }
14231412 // xiVir
14241413 for(int p=0; p<numberActiveVir; p++){
14251414 for(int mu=0; mu<numberAOs; mu++){
1426- int slaterDeterminantIndex = 0;
14271415 for(int i=0; i<numberActiveOcc; i++){
1428- slaterDeterminantIndex = this->GetSlaterDeterminantIndex(i,p);
1429- xiVir[p][mu] += this->matrixCIS[elecState][slaterDeterminantIndex]
1430- *transposedFockMatrix[mu][i];
1416+ int moI = numberOcc - (i+1);
1417+ int slaterDeterminantIndex = this->GetSlaterDeterminantIndex(i,p);
1418+ xiVir[p][mu] += this->matrixCIS[exciteState][slaterDeterminantIndex]
1419+ *transposedFockMatrix[mu][moI];
14311420 }
14321421 }
14331422 }
@@ -1441,11 +1430,6 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){
14411430 throw MolDSException(ss.str());
14421431 }
14431432 this->CheckZMatrixForce(elecStates);
1444- int numberAOs = this->molecule->GetTotalNumberAOs();
1445- int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
1446- int numberVir = numberAOs - numberOcc;
1447- int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS();
1448- int numberActiveVir = Parameters::GetInstance()->GetActiveVirCIS();
14491433
14501434 // creat MO-index-pair for Q variables.
14511435 vector<MoIndexPair> nonRedundantQIndeces;
@@ -1458,7 +1442,7 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){
14581442 double** kNR = NULL; // K_{NR} matrix, see (45) in [PT_1996]
14591443 double** kRDager = NULL; // Dagar of K_{R} matrix, see (46) in [PT_1996]
14601444 double* y = NULL; // y-vector in (54) in [PT_1996]
1461- double** transposedFockMatrix = NULL; // transposed CIS matrix
1445+ double** transposedFockMatrix = NULL; // transposed Fock matrix
14621446 double** xiOcc = NULL;
14631447 double** xiVir = NULL;
14641448 this->MallocTempMatrixForZMatrix(&delta,
@@ -1475,28 +1459,27 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){
14751459 this->TransposeFockMatrixMatrix(transposedFockMatrix);
14761460 this->CalcKNRMatrix(kNR, nonRedundantQIndeces);
14771461 this->CalcKRDagerMatrix(kRDager, nonRedundantQIndeces,redundantQIndeces);
1462+ int groundState=0;
14781463 for(int n=0; n<elecStates.size(); n++){
1479- if(0 < elecStates[n]){
1480- int elecState = elecStates[n]-1;
1481- this->CalcDeltaVector(delta, elecState);
1482- this->CalcXiMatrices(xiOcc, xiVir, elecState, transposedFockMatrix);
1464+ if(groundState < elecStates[n]){
1465+ int exciteState = elecStates[n]-1;
1466+ this->CalcDeltaVector(delta, exciteState);
1467+ this->CalcXiMatrices(xiOcc, xiVir, exciteState, transposedFockMatrix);
14831468 this->CalcQVector(q,
14841469 delta,
14851470 xiOcc,
14861471 xiVir,
14871472 this->etaMatrixForce[n],
1488- elecState,
14891473 nonRedundantQIndeces,
14901474 redundantQIndeces);
1491- this->CaclAuxiliaryVector(y, q, kRDager, nonRedundantQIndeces, redundantQIndeces);
1475+ this->CalcAuxiliaryVector(y, q, kRDager, nonRedundantQIndeces, redundantQIndeces);
14921476 // solve (54) in [PT_1996]
14931477 MolDS_mkl_wrapper::LapackWrapper::GetInstance()->Dsysv(kNR,
14941478 y,
14951479 nonRedundantQIndeces.size());
1496-
14971480 // calculate each element of Z matrix.
1498- for(int mu=0; mu<numberAOs; mu++){
1499- for(int nu=0; nu<numberAOs; nu++){
1481+ for(int mu=0; mu<this->molecule->GetTotalNumberAOs(); mu++){
1482+ for(int nu=0; nu<this->molecule->GetTotalNumberAOs(); nu++){
15001483 this->zMatrixForce[n][mu][nu] = this->GetZMatrixForceElement(
15011484 y,
15021485 q,
@@ -1507,6 +1490,7 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){
15071490 nu);
15081491 }
15091492 }
1493+
15101494 }
15111495 }
15121496 }
@@ -1538,29 +1522,32 @@ void Mndo::CalcZMatrixForce(vector<int> elecStates){
15381522 void Mndo::CalcEtaMatrixForce(vector<int> elecStates){
15391523 this->CheckEtaMatrixForce(elecStates);
15401524 int numberAOs = this->molecule->GetTotalNumberAOs();
1525+ int numberOcc = this->molecule->GetTotalNumberValenceElectrons()/2;
15411526 int numberActiveOcc = Parameters::GetInstance()->GetActiveOccCIS();
15421527 int numberActiveVir = Parameters::GetInstance()->GetActiveVirCIS();
1543- double** transposedFockMatrix = NULL; // transposed CIS matrix
1528+ int groundState = 0;
1529+ double** transposedFockMatrix = NULL; // transposed Fock matrix
15441530 transposedFockMatrix = MallocerFreer::GetInstance()->MallocDoubleMatrix2d(
15451531 numberAOs,
15461532 numberAOs);
15471533 try{
15481534 this->TransposeFockMatrixMatrix(transposedFockMatrix);
15491535 for(int n=0; n<elecStates.size(); n++){
1550- if(0 < elecStates[n]){
1551- int elecState = elecStates[n]-1;
1536+ if(groundState < elecStates[n]){
1537+ int exciteState = elecStates[n]-1;
15521538
15531539 // calc each element
15541540 for(int mu=0; mu<numberAOs; mu++){
15551541 for(int nu=0; nu<numberAOs; nu++){
1556- int slaterDeterminantIndex = 0;
15571542 for(int i=0; i<numberActiveOcc; i++){
1543+ int moI = numberOcc-(i+1);
15581544 for(int a=0; a<numberActiveVir; a++){
1559- slaterDeterminantIndex = this->GetSlaterDeterminantIndex(i,a);
1545+ int moA = numberOcc+a;
1546+ int slaterDeterminantIndex = this->GetSlaterDeterminantIndex(i,a);
15601547 this->etaMatrixForce[n][mu][nu]
1561- += this->matrixCIS[elecState][slaterDeterminantIndex]
1562- *transposedFockMatrix[mu][i]
1563- *transposedFockMatrix[nu][a];
1548+ += this->matrixCIS[exciteState][slaterDeterminantIndex]
1549+ *transposedFockMatrix[mu][moI]
1550+ *transposedFockMatrix[nu][moA];
15641551 }
15651552 }
15661553 }
@@ -1595,11 +1582,8 @@ void Mndo::CalcForceHFElecCoreAttractionPart(double* force,
15951582 int atomBIndex,
15961583 double***** twoElecTwoCoreFirstDeriv){
15971584 Atom* atomA = (*this->molecule->GetAtomVect())[atomAIndex];
1598- Atom* atomB = (*this->molecule->GetAtomVect())[atomBIndex];
15991585 int firstAOIndexA = atomA->GetFirstAOIndex();
1600- int firstAOIndexB = atomB->GetFirstAOIndex();
16011586 int numberAOsA = atomA->GetValence().size();
1602- int numberAOsB = atomB->GetValence().size();
16031587 for(int mu=firstAOIndexA; mu<firstAOIndexA+numberAOsA; mu++){
16041588 for(int nu=firstAOIndexA; nu<firstAOIndexA+numberAOsA; nu++){
16051589 for(int i=0; i<CartesianType_end; i++){
@@ -1681,6 +1665,130 @@ void Mndo::CalcForceHFTwoElecPart(double* force,
16811665 }
16821666 }
16831667
1668+void Mndo::CalcForceExcitedStaticPart(double* force,
1669+ int elecStateIndex,
1670+ int atomAIndex,
1671+ int atomBIndex,
1672+ double***** twoElecTwoCoreFirstDeriv){
1673+ Atom* atomA = (*this->molecule->GetAtomVect())[atomAIndex];
1674+ Atom* atomB = (*this->molecule->GetAtomVect())[atomBIndex];
1675+ int firstAOIndexA = atomA->GetFirstAOIndex();
1676+ int firstAOIndexB = atomB->GetFirstAOIndex();
1677+ int numberAOsA = atomA->GetValence().size();
1678+ int numberAOsB = atomB->GetValence().size();
1679+ for(int mu=firstAOIndexA; mu<firstAOIndexA+numberAOsA; mu++){
1680+ for(int nu=firstAOIndexA; nu<firstAOIndexA+numberAOsA; nu++){
1681+ for(int lambda=firstAOIndexB; lambda<firstAOIndexB+numberAOsB; lambda++){
1682+ for(int sigma=firstAOIndexB; sigma<firstAOIndexB+numberAOsB; sigma++){
1683+ for(int i=0; i<CartesianType_end; i++){
1684+ double temp= 2.0*this->etaMatrixForce[elecStateIndex][mu][nu]
1685+ *this->etaMatrixForce[elecStateIndex][lambda][sigma]
1686+ -1.0*this->etaMatrixForce[elecStateIndex][mu][lambda]
1687+ *this->etaMatrixForce[elecStateIndex][nu][sigma];
1688+ force[i] += temp
1689+ *twoElecTwoCoreFirstDeriv[mu-firstAOIndexA]
1690+ [nu-firstAOIndexA]
1691+ [lambda-firstAOIndexB]
1692+ [sigma-firstAOIndexB]
1693+ [i];
1694+ }
1695+ }
1696+ }
1697+ }
1698+ }
1699+}
1700+
1701+void Mndo::CalcForceExcitedElecCoreAttractionPart(double* force,
1702+ int elecStateIndex,
1703+ int atomAIndex,
1704+ int atomBIndex,
1705+ double***** twoElecTwoCoreFirstDeriv){
1706+ Atom* atomA = (*this->molecule->GetAtomVect())[atomAIndex];
1707+ int firstAOIndexA = atomA->GetFirstAOIndex();
1708+ int numberAOsA = atomA->GetValence().size();
1709+ for(int mu=firstAOIndexA; mu<firstAOIndexA+numberAOsA; mu++){
1710+ for(int nu=firstAOIndexA; nu<firstAOIndexA+numberAOsA; nu++){
1711+ for(int i=0; i<CartesianType_end; i++){
1712+ force[i] += this->zMatrixForce[elecStateIndex][mu][nu]
1713+ *this->GetElectronCoreAttractionFirstDerivative(
1714+ atomAIndex,
1715+ atomBIndex,
1716+ mu-firstAOIndexA,
1717+ nu-firstAOIndexA,
1718+ twoElecTwoCoreFirstDeriv,
1719+ (CartesianType)i);
1720+ }
1721+ }
1722+ }
1723+}
1724+
1725+void Mndo::CalcForceExcitedOverlapPart(double* force,
1726+ int elecStateIndex,
1727+ int atomAIndex,
1728+ int atomBIndex,
1729+ double*** overlapDer){
1730+ Atom* atomA = (*this->molecule->GetAtomVect())[atomAIndex];
1731+ Atom* atomB = (*this->molecule->GetAtomVect())[atomBIndex];
1732+ int firstAOIndexA = atomA->GetFirstAOIndex();
1733+ int firstAOIndexB = atomB->GetFirstAOIndex();
1734+ int numberAOsA = atomA->GetValence().size();
1735+ int numberAOsB = atomB->GetValence().size();
1736+ for(int mu=firstAOIndexA; mu<firstAOIndexA+numberAOsA; mu++){
1737+ for(int nu=firstAOIndexB; nu<firstAOIndexB+numberAOsB; nu++){
1738+ double bondParameter = atomA->GetBondingParameter(
1739+ this->theory,
1740+ atomA->GetValence()[mu-firstAOIndexA])
1741+ +atomB->GetBondingParameter(
1742+ this->theory,
1743+ atomB->GetValence()[nu-firstAOIndexB]);
1744+ bondParameter *= 0.5;
1745+ for(int i=0; i<CartesianType_end; i++){
1746+ force[i] += this->zMatrixForce[elecStateIndex][mu][nu]
1747+ *bondParameter
1748+ *overlapDer[mu-firstAOIndexA][nu-firstAOIndexB][i];
1749+ }
1750+ }
1751+ }
1752+}
1753+
1754+void Mndo::CalcForceExcitedTwoElecPart(double* force,
1755+ int elecStateIndex,
1756+ int atomAIndex,
1757+ int atomBIndex,
1758+ double***** twoElecTwoCoreFirstDeriv){
1759+ Atom* atomA = (*this->molecule->GetAtomVect())[atomAIndex];
1760+ Atom* atomB = (*this->molecule->GetAtomVect())[atomBIndex];
1761+ int firstAOIndexA = atomA->GetFirstAOIndex();
1762+ int firstAOIndexB = atomB->GetFirstAOIndex();
1763+ int numberAOsA = atomA->GetValence().size();
1764+ int numberAOsB = atomB->GetValence().size();
1765+ for(int mu=firstAOIndexA; mu<firstAOIndexA+numberAOsA; mu++){
1766+ for(int nu=firstAOIndexA; nu<firstAOIndexA+numberAOsA; nu++){
1767+ for(int lambda=firstAOIndexB; lambda<firstAOIndexB+numberAOsB; lambda++){
1768+ for(int sigma=firstAOIndexB; sigma<firstAOIndexB+numberAOsB; sigma++){
1769+ for(int i=0; i<CartesianType_end; i++){
1770+ force[i] += this->zMatrixForce[elecStateIndex][mu][nu]
1771+ *this->orbitalElectronPopulation[lambda][sigma]
1772+ *twoElecTwoCoreFirstDeriv[mu-firstAOIndexA]
1773+ [nu-firstAOIndexA]
1774+ [lambda-firstAOIndexB]
1775+ [sigma-firstAOIndexB]
1776+ [i];
1777+ force[i] -= 0.50
1778+ *this->zMatrixForce[elecStateIndex][mu][lambda]
1779+ *this->orbitalElectronPopulation[nu][sigma]
1780+ *twoElecTwoCoreFirstDeriv[mu-firstAOIndexA]
1781+ [nu-firstAOIndexA]
1782+ [lambda-firstAOIndexB]
1783+ [sigma-firstAOIndexB]
1784+ [(CartesianType)i];
1785+ }
1786+ }
1787+ }
1788+ }
1789+ }
1790+}
1791+
16841792 // electronicStateIndex is index of the electroinc eigen state.
16851793 // "electronicStateIndex = 0" means electronic ground state.
16861794 void Mndo::CalcForce(vector<int> elecStates){
@@ -1702,7 +1810,7 @@ void Mndo::CalcForce(vector<int> elecStates){
17021810 OrbitalType_end,
17031811 CartesianType_end);
17041812 try{
1705- #pragma omp for schedule(auto)
1813+ #pragma omp for schedule(auto)
17061814 for(int a=0; a<this->molecule->GetAtomVect()->size(); a++){
17071815 Atom* atomA = (*molecule->GetAtomVect())[a];
17081816 int firstAOIndexA = atomA->GetFirstAOIndex();
@@ -1726,28 +1834,24 @@ void Mndo::CalcForce(vector<int> elecStates){
17261834 coreRepulsion[i] += this->GetDiatomCoreRepulsionFirstDerivative(
17271835 a, b, (CartesianType)i);
17281836 }
1729-
17301837 // electron core attraction part (ground state)
17311838 double forceElecCoreAttPart[CartesianType_end] = {0.0,0.0,0.0};
17321839 this->CalcForceHFElecCoreAttractionPart(forceElecCoreAttPart,
17331840 a,
17341841 b,
17351842 twoElecTwoCoreFirstDeriv);
1736-
17371843 // overlap part (ground state)
17381844 double forceOverlapPart[CartesianType_end] = {0.0,0.0,0.0};
17391845 this->CalcForceHFOverlapPart(forceOverlapPart,
17401846 a,
17411847 b,
17421848 overlapDer);
1743-
17441849 // two electron part (ground state)
17451850 double forceTwoElecPart[CartesianType_end] = {0.0,0.0,0.0};
17461851 this->CalcForceHFTwoElecPart(forceTwoElecPart,
17471852 a,
17481853 b,
17491854 twoElecTwoCoreFirstDeriv);
1750-
17511855 // sum up contributions from each part (ground state)
17521856 for(int n=0; n<elecStates.size(); n++){
17531857 for(int i=0; i<CartesianType_end; i++){
@@ -1759,7 +1863,58 @@ void Mndo::CalcForce(vector<int> elecStates){
17591863 +forceTwoElecPart[i];
17601864 }
17611865 }
1866+
1867+ // excited state potential
1868+ for(int n=0; n<elecStates.size(); n++){
1869+ if(0<elecStates[n]){
1870+ // static part
1871+ double forceExcitedStaticPart[CartesianType_end] = {0.0,0.0,0.0};
1872+ this->CalcForceExcitedStaticPart(forceExcitedStaticPart,
1873+ n,
1874+ a,
1875+ b,
1876+ twoElecTwoCoreFirstDeriv);
1877+ // sum up contributions from static part (excited state)
1878+ for(int i=0; i<CartesianType_end; i++){
1879+ this->matrixForce[n][b][i] += forceExcitedStaticPart[i];
1880+ this->matrixForce[n][a][i] -= forceExcitedStaticPart[i];
1881+ }
1882+
1883+ // response part
1884+ // electron core attraction part (excited state)
1885+ double forceExcitedElecCoreAttPart[CartesianType_end]={0.0,0.0,0.0};
1886+ this->CalcForceExcitedElecCoreAttractionPart(
1887+ forceExcitedElecCoreAttPart,
1888+ n,
1889+ a,
1890+ b,
1891+ twoElecTwoCoreFirstDeriv);
1892+ // overlap part (excited state)
1893+ double forceExcitedOverlapPart[CartesianType_end] = {0.0,0.0,0.0};
1894+ this->CalcForceExcitedOverlapPart(forceExcitedOverlapPart,
1895+ n,
1896+ a,
1897+ b,
1898+ overlapDer);
1899+ // two electron part (ground state)
1900+ double forceExcitedTwoElecPart[CartesianType_end] = {0.0,0.0,0.0};
1901+ this->CalcForceExcitedTwoElecPart(forceExcitedTwoElecPart,
1902+ n,
1903+ a,
1904+ b,
1905+ twoElecTwoCoreFirstDeriv);
1906+ // sum up contributions from response part (excited state)
1907+ for(int i=0; i<CartesianType_end; i++){
1908+ this->matrixForce[n][b][i] += forceExcitedElecCoreAttPart[i];
1909+ this->matrixForce[n][b][i] += forceExcitedOverlapPart[i];
1910+ this->matrixForce[n][b][i] += forceExcitedTwoElecPart[i];
1911+ this->matrixForce[n][a][i] -= forceExcitedElecCoreAttPart[i];
1912+ this->matrixForce[n][a][i] -= forceExcitedOverlapPart[i];
1913+ this->matrixForce[n][a][i] -= forceExcitedTwoElecPart[i];
1914+ }
17621915
1916+ }
1917+ }
17631918 }
17641919 }
17651920 }
--- a/src/mndo/Mndo.h
+++ b/src/mndo/Mndo.h
@@ -118,7 +118,7 @@ private:
118118 double*** xiVir,
119119 int sizeQNR,
120120 int sizeQR);
121- void CalcDeltaVector(double* delta, int elecState);
121+ void CalcDeltaVector(double* delta, int exciteState);
122122 double GetSmallQElement(int moI,
123123 int moP,
124124 double**xiOcc,
@@ -129,7 +129,6 @@ private:
129129 double** xiOcc,
130130 double** xiVir,
131131 double** eta,
132- int elecState,
133132 std::vector<MoIndexPair> nonRedundantQIndeces,
134133 std::vector<MoIndexPair> redundantQIndeces);
135134 void TransposeFockMatrixMatrix(double** transposedFockMatrix);
@@ -138,14 +137,14 @@ private:
138137 void CalcKRDagerMatrix(double** kRDager,
139138 std::vector<MoIndexPair> nonRedundantQIndeces,
140139 std::vector<MoIndexPair> redundantQIndeces);
141- void CaclAuxiliaryVector(double* y,
140+ void CalcAuxiliaryVector(double* y,
142141 double* q,
143142 double** kRDager,
144143 std::vector<MoIndexPair> nonRedundantQIndeces,
145144 std::vector<MoIndexPair> redundantQIndeces);
146145 void CalcXiMatrices(double** xiOcc,
147146 double** xiVir,
148- int elecState,
147+ int exciteState,
149148 double** transposedFockMatrix);
150149 double GetZMatrixForceElement(double* y,
151150 double* q,
@@ -219,6 +218,26 @@ private:
219218 int atomAIndex,
220219 int atomBIndex,
221220 double***** twoElecTwoCoreFirstDeriv);
221+ void CalcForceExcitedStaticPart(double* force,
222+ int elecStateIndex,
223+ int atomAIndex,
224+ int atomBIndex,
225+ double***** twoElecTwoCoreFirstDeriv);
226+ void CalcForceExcitedElecCoreAttractionPart(double* force,
227+ int elecStateIndex,
228+ int atomAIndex,
229+ int atomBIndex,
230+ double***** twoElecTwoCoreFirstDeriv);
231+ void CalcForceExcitedOverlapPart(double* force,
232+ int elecStateIndex,
233+ int atomAIndex,
234+ int atomBIndex,
235+ double*** overlapDer);
236+ void CalcForceExcitedTwoElecPart(double* force,
237+ int elecStateIndex,
238+ int atomAIndex,
239+ int atomBIndex,
240+ double***** twoElecTwoCoreFirstDeriv);
222241
223242 };
224243
--- a/src/zindo/ZindoS.cpp
+++ b/src/zindo/ZindoS.cpp
@@ -1436,6 +1436,7 @@ void ZindoS::CheckMatrixForce(vector<int> elecStates){
14361436 }
14371437
14381438 // Note taht activeOccIndex and activeVirIndex are not MO's number.
1439+// activeOccIndex=0 means HOMO and activeVirIndex=0 means LUMO.
14391440 int ZindoS::GetSlaterDeterminantIndex(int activeOccIndex,
14401441 int activeVirIndex){
14411442 return Parameters::GetInstance()->GetActiveVirCIS()
@@ -1443,7 +1444,7 @@ int ZindoS::GetSlaterDeterminantIndex(int activeOccIndex,
14431444 +activeVirIndex;
14441445 }
14451446
1446-// electronicStates is indeces of the electroinc eigen states.
1447+// elecStates is indeces of the electroinc eigen states.
14471448 // The index = 0 means electronic ground state.
14481449 void ZindoS::CalcForce(vector<int> elecStates){
14491450 int elecState = elecStates[0];