Révision | 392f4d8ce533c35aad5ae95de5f027b0b9f2389f (tree) |
---|---|
l'heure | 2011-07-02 15:53:40 |
Auteur | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
CIS-direct (= without Davidson) is improved.
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/MolDS/trunk@99 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -29,8 +29,6 @@ private: | ||
29 | 29 | InputParser(InputParser&); |
30 | 30 | void operator = (InputParser&); |
31 | 31 | ~InputParser(); |
32 | - string messageYES; | |
33 | - string messageNO; | |
34 | 32 | string messageStartParseInput; |
35 | 33 | string messageDoneParseInput; |
36 | 34 | string messageTotalNumberAOs; |
@@ -50,6 +48,8 @@ private: | ||
50 | 48 | string messageCisNumberActiveVir; |
51 | 49 | string messageCisNumberExcitedStates; |
52 | 50 | string messageCisDavidson; |
51 | + string stringYES; | |
52 | + string stringNO; | |
53 | 53 | string stringSpace; |
54 | 54 | string stringCommentOut; |
55 | 55 | string stringTheory; |
@@ -105,8 +105,6 @@ private: | ||
105 | 105 | InputParser* InputParser::inputParser = NULL; |
106 | 106 | |
107 | 107 | InputParser::InputParser(){ |
108 | - this->messageYES = "YES"; | |
109 | - this->messageNO = "NO"; | |
110 | 108 | this->messageStartParseInput = "********** START: Parse input **********\n"; |
111 | 109 | this->messageDoneParseInput = "********** DONE: Parse input ***********\n\n\n"; |
112 | 110 | this->messageTotalNumberAOs = "\tTotal number of valence AOs: "; |
@@ -126,6 +124,8 @@ InputParser::InputParser(){ | ||
126 | 124 | this->messageCisNumberActiveVir = "\t\tNumber of active Vir.: "; |
127 | 125 | this->messageCisNumberExcitedStates = "\t\tNumber of excited states: "; |
128 | 126 | this->messageCisDavidson = "\t\tCIS-Davidson: "; |
127 | + this->stringYES = "yes"; | |
128 | + this->stringNO = "no"; | |
129 | 129 | this->stringSpace = " "; |
130 | 130 | this->stringCommentOut = "//"; |
131 | 131 | this->stringTheoryCNDO2 = "cndo/2"; |
@@ -418,7 +418,7 @@ void InputParser::Parse(Molecule* molecule){ | ||
418 | 418 | } |
419 | 419 | // Davidson is used or not |
420 | 420 | if(inputTerms[j].compare(this->stringCISDavidson) == 0){ |
421 | - if(inputTerms[j+1].compare(this->messageYES) == 0){ | |
421 | + if(inputTerms[j+1].compare(this->stringYES) == 0){ | |
422 | 422 | Parameters::GetInstance()->SetIsDavidsonCIS(true); |
423 | 423 | } |
424 | 424 | else{ |
@@ -509,25 +509,35 @@ void InputParser::CalcMolecularBasics(Molecule* molecule){ | ||
509 | 509 | |
510 | 510 | void InputParser::CalcCisCondition(Molecule* molecule){ |
511 | 511 | |
512 | - int numberOcc = molecule->GetTotalNumberValenceElectrons()/2; | |
513 | - int numberVir = molecule->GetTotalNumberAOs() - numberOcc; | |
514 | - | |
515 | - // check the number of active occupied orbitals. | |
516 | - if(numberOcc < Parameters::GetInstance()->GetActiveOccCIS()){ | |
517 | - Parameters::GetInstance()->SetActiveOccCIS(numberOcc); | |
518 | - } | |
519 | - | |
520 | - // check the number of active virtual orbitals. | |
521 | - if(numberVir < Parameters::GetInstance()->GetActiveVirCIS()){ | |
522 | - Parameters::GetInstance()->SetActiveVirCIS(numberVir); | |
523 | - } | |
524 | - | |
525 | - // check the number of calculated excited states. | |
526 | - int numberExcitedStates = Parameters::GetInstance()->GetActiveOccCIS() | |
527 | - *Parameters::GetInstance()->GetActiveVirCIS(); | |
528 | - if(numberExcitedStates < Parameters::GetInstance()->GetNumberExcitedStatesCIS()){ | |
529 | - Parameters::GetInstance()->SetNumberExcitedStatesCIS(numberExcitedStates); | |
530 | - } | |
512 | + if(Parameters::GetInstance()->GetIsDavidsonCIS()){ | |
513 | + // Davidson CIS | |
514 | + // ToDo: calc condition for CIS-Davidson | |
515 | + stringstream ss; | |
516 | + ss << "Condition check for CIS-Davidson in InputParser::CalcCisCondition is not implemented yet.\n\n"; | |
517 | + throw MolDSException(ss.str()); | |
518 | + } | |
519 | + else{ | |
520 | + // direct CIS | |
521 | + int numberOcc = molecule->GetTotalNumberValenceElectrons()/2; | |
522 | + int numberVir = molecule->GetTotalNumberAOs() - numberOcc; | |
523 | + | |
524 | + // check the number of active occupied orbitals. | |
525 | + if(numberOcc < Parameters::GetInstance()->GetActiveOccCIS()){ | |
526 | + Parameters::GetInstance()->SetActiveOccCIS(numberOcc); | |
527 | + } | |
528 | + | |
529 | + // check the number of active virtual orbitals. | |
530 | + if(numberVir < Parameters::GetInstance()->GetActiveVirCIS()){ | |
531 | + Parameters::GetInstance()->SetActiveVirCIS(numberVir); | |
532 | + } | |
533 | + | |
534 | + // check the number of calculated excited states. | |
535 | + int numberExcitedStates = Parameters::GetInstance()->GetActiveOccCIS() | |
536 | + *Parameters::GetInstance()->GetActiveVirCIS(); | |
537 | + if(numberExcitedStates < Parameters::GetInstance()->GetNumberExcitedStatesCIS()){ | |
538 | + Parameters::GetInstance()->SetNumberExcitedStatesCIS(numberExcitedStates); | |
539 | + } | |
540 | + } | |
531 | 541 | |
532 | 542 | } |
533 | 543 |
@@ -561,10 +571,10 @@ void InputParser::OutputCisConditions(){ | ||
561 | 571 | printf("%s%d\n",this->messageCisNumberExcitedStates.c_str(),Parameters::GetInstance()->GetNumberExcitedStatesCIS()); |
562 | 572 | printf("%s",this->messageCisDavidson.c_str()); |
563 | 573 | if(Parameters::GetInstance()->GetIsDavidsonCIS()){ |
564 | - printf("%s\n",this->messageYES.c_str()); | |
574 | + printf("%s\n",this->stringYES.c_str()); | |
565 | 575 | } |
566 | 576 | else{ |
567 | - printf("%s\n",this->messageNO.c_str()); | |
577 | + printf("%s\n",this->stringNO.c_str()); | |
568 | 578 | } |
569 | 579 | |
570 | 580 | cout << "\n"; |
@@ -19,7 +19,7 @@ SCF | ||
19 | 19 | SCF_END |
20 | 20 | |
21 | 21 | CIS |
22 | - davidson no | |
22 | + davidson yes | |
23 | 23 | activeOcc 2 |
24 | 24 | activeVir 2 |
25 | 25 | nstates 1000 |
@@ -37,6 +37,9 @@ protected: | ||
37 | 37 | virtual double GetMolecularIntegralElement(int moI, int moJ, int moK, int moL, |
38 | 38 | Molecule* molecule, double** fockMatrix, double** gammaAB); |
39 | 39 | private: |
40 | + double** matrixCIS; | |
41 | + double* excitedEnergies; | |
42 | + int matrixCISdimension; | |
40 | 43 | double GetCoulombInt(OrbitalType orbital1, |
41 | 44 | OrbitalType orbital2, |
42 | 45 | Atom* atom); // Apendix in [BZ_1979] |
@@ -45,6 +48,8 @@ private: | ||
45 | 48 | Atom* atom); // Apendix in [BZ_1979] |
46 | 49 | double GetNishimotoMatagaTwoEleInt(Atom* atomA, OrbitalType orbitalA, |
47 | 50 | Atom* atomB, OrbitalType orbitalB); // ref. [MN_1957] and (5a) in [AEZ_1986] |
51 | + void DoesCISDirect(); | |
52 | + void DoesCISDavidson(); | |
48 | 53 | string errorMessageNishimotoMataga; |
49 | 54 | string messageStartCIS; |
50 | 55 | string messageDoneCIS; |
@@ -54,10 +59,21 @@ ZindoS::ZindoS() : MolDS_cndo::Cndo2(){ | ||
54 | 59 | this->theory = ZINDOS; |
55 | 60 | this->SetMessages(); |
56 | 61 | this->SetEnableAtomTypes(); |
62 | + this->matrixCIS = NULL; | |
63 | + this->excitedEnergies = NULL; | |
64 | + this->matrixCISdimension = 0; | |
57 | 65 | //cout << "ZindoS created\n"; |
58 | 66 | } |
59 | 67 | |
60 | 68 | ZindoS::~ZindoS(){ |
69 | + if(this->matrixCIS != NULL){ | |
70 | + MallocerFreer::GetInstance()->FreeDoubleMatrix2d(&this->matrixCIS, this->matrixCISdimension); | |
71 | + //cout << "matrixCIS deleted\n"; | |
72 | + } | |
73 | + if(this->excitedEnergies != NULL){ | |
74 | + MallocerFreer::GetInstance()->FreeDoubleMatrix1d(&this->excitedEnergies); | |
75 | + //cout << "exceitedEnergies deleted\n"; | |
76 | + } | |
61 | 77 | //cout << "ZindoS deleted\n"; |
62 | 78 | } |
63 | 79 |
@@ -601,16 +617,56 @@ double ZindoS::GetMolecularIntegralElement(int moI, int moJ, int moK, int moL, | ||
601 | 617 | return value; |
602 | 618 | } |
603 | 619 | |
604 | - | |
605 | 620 | void ZindoS::DoesCIS(){ |
606 | 621 | cout << this->messageStartCIS; |
607 | 622 | |
623 | + if(Parameters::GetInstance()->GetIsDavidsonCIS()){ | |
624 | + this->DoesCISDavidson(); | |
625 | + } | |
626 | + else{ | |
627 | + this->DoesCISDirect(); | |
628 | + } | |
629 | + | |
630 | + // output eigen energies | |
631 | + for(int k=0; k<Parameters::GetInstance()->GetNumberExcitedStatesCIS(); k++){ | |
632 | + printf("%d-th excited energy: %e\n",k+1, this->excitedEnergies[k]); | |
633 | + } | |
634 | + cout << endl; | |
635 | + cout << this->messageDoneCIS; | |
636 | +} | |
637 | + | |
638 | +void ZindoS::DoesCISDavidson(){ | |
639 | + // ToDo: CIS-Davidson | |
640 | + stringstream ss; | |
641 | + ss << "CIS-Davidson (ZindoS::DoesCISDavidson()) is not implemented yet.\n\n"; | |
642 | + throw MolDSException(ss.str()); | |
643 | +} | |
644 | + | |
645 | +void ZindoS::DoesCISDirect(){ | |
646 | + | |
608 | 647 | int numberOcc = Parameters::GetInstance()->GetActiveOccCIS(); |
609 | 648 | int numberVir = Parameters::GetInstance()->GetActiveVirCIS(); |
610 | 649 | int numberExcitedStates = Parameters::GetInstance()->GetNumberExcitedStatesCIS(); |
611 | 650 | |
612 | - double** matrixCIS = MallocerFreer::GetInstance()->MallocDoubleMatrix2d(numberExcitedStates, numberExcitedStates); | |
613 | - double* excitedEnergies = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(numberExcitedStates); | |
651 | + // malloc CIS matrix | |
652 | + if(this->matrixCIS == NULL){ | |
653 | + this->matrixCISdimension = numberExcitedStates; | |
654 | + this->matrixCIS = MallocerFreer::GetInstance()->MallocDoubleMatrix2d(this->matrixCISdimension, | |
655 | + this->matrixCISdimension); | |
656 | + } | |
657 | + else{ | |
658 | + MallocerFreer::GetInstance()->InitializeDoubleMatrix2d(this->matrixCIS, | |
659 | + this->matrixCISdimension, | |
660 | + this->matrixCISdimension); | |
661 | + } | |
662 | + | |
663 | + // malloc CIS eigen vector | |
664 | + if(this->excitedEnergies == NULL){ | |
665 | + this->excitedEnergies = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(this->matrixCISdimension); | |
666 | + } | |
667 | + else{ | |
668 | + MallocerFreer::GetInstance()->InitializeDoubleMatrix1d(this->excitedEnergies, this->matrixCISdimension); | |
669 | + } | |
614 | 670 | |
615 | 671 | double value=0.0; |
616 | 672 | int moI; |
@@ -647,7 +703,7 @@ void ZindoS::DoesCIS(){ | ||
647 | 703 | this->molecule, this->fockMatrix, NULL); |
648 | 704 | } |
649 | 705 | |
650 | - matrixCIS[k][l] = value; | |
706 | + this->matrixCIS[k][l] = value; | |
651 | 707 | l++; |
652 | 708 | } |
653 | 709 | } |
@@ -656,27 +712,11 @@ void ZindoS::DoesCIS(){ | ||
656 | 712 | } |
657 | 713 | |
658 | 714 | bool calcEigenVectors = true; |
659 | - MolDS_mkl_wrapper::LapackWrapper::GetInstance()->Dsyevd(matrixCIS, | |
660 | - excitedEnergies, | |
661 | - numberExcitedStates, | |
715 | + MolDS_mkl_wrapper::LapackWrapper::GetInstance()->Dsyevd(this->matrixCIS, | |
716 | + this->excitedEnergies, | |
717 | + this->matrixCISdimension, | |
662 | 718 | calcEigenVectors); |
663 | 719 | |
664 | - // output eigen energies | |
665 | - for(int k=0; k<numberExcitedStates; k++){ | |
666 | - printf("%d-th excited energy: %e\n",k+1, excitedEnergies[k]); | |
667 | - } | |
668 | - cout << endl; | |
669 | - | |
670 | - if(matrixCIS != NULL){ | |
671 | - MallocerFreer::GetInstance()->FreeDoubleMatrix2d(&matrixCIS, numberExcitedStates); | |
672 | - //cout << "matrixCIS deleted\n"; | |
673 | - } | |
674 | - if(excitedEnergies != NULL){ | |
675 | - MallocerFreer::GetInstance()->FreeDoubleMatrix1d(&excitedEnergies); | |
676 | - //cout << "exceitedEnergies deleted\n"; | |
677 | - } | |
678 | - | |
679 | - cout << this->messageDoneCIS; | |
680 | 720 | } |
681 | 721 | |
682 | 722 |