• 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

修订版4eb87953851d1a2fece5a9c083838e00add7c458 (tree)
时间2011-01-28 18:23:57
作者Mikiya Fujii <mikiya.fujii@gmai...>
CommiterMikiya Fujii

Log Message

Cndo2::GetTotalEnergy is modified.

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

更改概述

差异

--- a/src/cndo/Cndo2.h
+++ b/src/cndo/Cndo2.h
@@ -107,6 +107,10 @@ private:
107107 void CheckNumberValenceElectrons(Molecule* molecule);
108108 void FreeDiatomicOverlapAndRotatingMatrix(double** diatomicOverlap, double** rotatingMatrix);
109109 double GetTotalEnergy(Molecule* molecule, double* energiesMO, double** fockMatrix, double** gammaAB);
110+ void FreeTotalEnergyMatrices(double** fMatrix,
111+ double** hMatrix,
112+ double** dammyOrbitalElectronPopulation,
113+ double* dammyAtomicElectronPopulation );
110114
111115 };
112116
@@ -400,22 +404,112 @@ void Cndo2::OutputResults(double** fockMatrix, double* energiesMO, double* atomi
400404 }
401405
402406 double Cndo2::GetTotalEnergy(Molecule* molecule, double* energiesMO, double** fockMatrix, double** gammaAB){
403- double totalEnergy = molecule->GetTotalCoreRepulsionEnergy();
407+ double electronicEnergy = 0.0;
408+
409+ // use density matrix for electronic energy
410+ int totalNumberAOs = this->molecule->GetTotalNumberAOs();
411+ double** fMatrix = MallocerFreer::GetInstance()->MallocDoubleMatrix2d
412+ (totalNumberAOs, totalNumberAOs);
413+ double** hMatrix = MallocerFreer::GetInstance()->MallocDoubleMatrix2d
414+ (totalNumberAOs, totalNumberAOs);
415+ double** dammyOrbitalElectronPopulation = MallocerFreer::GetInstance()->MallocDoubleMatrix2d
416+ (totalNumberAOs, totalNumberAOs);
417+ double* dammyAtomicElectronPopulation = MallocerFreer::GetInstance()->MallocDoubleMatrix1d
418+ (molecule->GetAtomVect()->size());
419+
420+ try{
421+ bool isGuess = false;
422+ this->CalcFockMatrix(fMatrix,
423+ this->molecule,
424+ this->overlap,
425+ this->gammaAB,
426+ this->orbitalElectronPopulation,
427+ this->atomicElectronPopulation,
428+ isGuess);
429+ this->CalcFockMatrix(hMatrix,
430+ this->molecule,
431+ this->overlap,
432+ this->gammaAB,
433+ dammyOrbitalElectronPopulation,
434+ dammyAtomicElectronPopulation,
435+ isGuess);
436+
437+ for(int i=0; i<totalNumberAOs; i++){
438+ for(int j=i+1; j<totalNumberAOs; j++){
439+ fMatrix[j][i] = fMatrix[i][j];
440+ hMatrix[j][i] = hMatrix[i][j];
441+ }
442+ }
443+
444+ for(int i=0; i<totalNumberAOs; i++){
445+ for(int j=0; j<totalNumberAOs; j++){
446+ electronicEnergy += this->orbitalElectronPopulation[j][i]*
447+ (fMatrix[i][j] + hMatrix[i][j]);
448+ }
449+ }
450+ electronicEnergy *= 0.5;
451+ }
452+ catch(MolDSException ex){
453+ this->FreeTotalEnergyMatrices(fMatrix,
454+ hMatrix,
455+ dammyOrbitalElectronPopulation,
456+ dammyAtomicElectronPopulation );
457+ throw ex;
458+ }
459+ this->FreeTotalEnergyMatrices(fMatrix,
460+ hMatrix,
461+ dammyOrbitalElectronPopulation,
462+ dammyAtomicElectronPopulation );
463+
464+
465+ // use two electrons integrals for electronic energy
466+ /*
404467 for(int mo=0; mo<molecule->GetTotalNumberValenceElectrons()/2; mo++){
405- totalEnergy += 2.0*energiesMO[mo];
468+ electronicEnergy += 2.0*energiesMO[mo];
406469 }
407470
408471 for(int moA=0; moA<molecule->GetTotalNumberValenceElectrons()/2; moA++){
409472 for(int moB=0; moB<molecule->GetTotalNumberValenceElectrons()/2; moB++){
410473
411- totalEnergy -= 2.0*this->GetMolecularIntegralElement(moA, moA, moB, moB,
474+ electronicEnergy -= 2.0*this->GetMolecularIntegralElement(moA, moA, moB, moB,
412475 molecule, fockMatrix, gammaAB);
413- totalEnergy += 1.0*this->GetMolecularIntegralElement(moA, moB, moB, moA,
476+ electronicEnergy += 1.0*this->GetMolecularIntegralElement(moA, moB, moB, moA,
414477 molecule, fockMatrix, gammaAB);
415478 }
416479 }
480+ */
481+
482+ return electronicEnergy + molecule->GetTotalCoreRepulsionEnergy();
483+}
484+
485+void Cndo2::FreeTotalEnergyMatrices(double** fMatrix,
486+ double** hMatrix,
487+ double** dammyOrbitalElectronPopulation,
488+ double* dammyAtomicElectronPopulation ){
489+
490+ int totalNumberAOs = this->molecule->GetTotalNumberAOs();
491+ if(fMatrix != NULL){
492+ MallocerFreer::GetInstance()->FreeDoubleMatrix2d(fMatrix, totalNumberAOs);
493+ fMatrix = NULL;
494+ //cout << "fMatrix deleted\n";
495+ }
496+ if(hMatrix != NULL){
497+ MallocerFreer::GetInstance()->FreeDoubleMatrix2d(hMatrix, totalNumberAOs);
498+ hMatrix = NULL;
499+ //cout << "hMatrix deleted\n";
500+ }
501+ if(dammyOrbitalElectronPopulation != NULL){
502+ MallocerFreer::GetInstance()->FreeDoubleMatrix2d(dammyOrbitalElectronPopulation,
503+ totalNumberAOs);
504+ dammyOrbitalElectronPopulation = NULL;
505+ //cout << "dammyOrbitalElectronPopulation deleted\n";
506+ }
507+ if(dammyAtomicElectronPopulation != NULL){
508+ MallocerFreer::GetInstance()->FreeDoubleMatrix1d(dammyAtomicElectronPopulation);
509+ dammyAtomicElectronPopulation = NULL;
510+ //cout << "dammyAtomicElectronPopulation deleted\n";
511+ }
417512
418- return totalEnergy;
419513 }
420514
421515 // The order of mol, moJ, moK, moL is consistent with Eq. (9) in [RZ_1973]
--- a/src/indo/Indo.h
+++ b/src/indo/Indo.h
@@ -184,6 +184,11 @@ double Indo::GetMolecularIntegralElement(int moI, int moJ, int moK, int moL,
184184 *fockMatrix[moJ][nu]
185185 *fockMatrix[moK][nu]
186186 *fockMatrix[moL][mu];
187+ value += exchange
188+ *fockMatrix[moI][mu]
189+ *fockMatrix[moJ][nu]
190+ *fockMatrix[moK][mu]
191+ *fockMatrix[moL][nu];
187192 }
188193
189194 coulomb = this->GetCoulombInt(orbitalMu, orbitalNu, gammaAB[A][A], atomA);
--- a/src/input.in
+++ b/src/input.in
@@ -1,7 +1,7 @@
11 THEORY
22 //cndo/2
3- //indo
4- zindo/s
3+ indo
4+ //zindo/s
55 //none
66 //principal_axes
77 //translate