Revision | 49ce430526dbc569844bbb6c6f1c0d8a405d7a4d (tree) |
---|---|
Zeit | 2011-09-29 23:19:16 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Input-parse-module for MD is added.
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/MolDS/trunk@159 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -51,6 +51,11 @@ private: | ||
51 | 51 | string messageCisNormTolerance; |
52 | 52 | string messageCisMaxIterations; |
53 | 53 | string messageCisMaxDimensions; |
54 | + string messageMdConditions; | |
55 | + string messageMdTotalSteps; | |
56 | + string messageMdElecState; | |
57 | + string messageMdTimeWidth; | |
58 | + string messageFs; | |
54 | 59 | string stringYES; |
55 | 60 | string stringNO; |
56 | 61 | string stringSpace; |
@@ -99,11 +104,18 @@ private: | ||
99 | 104 | string stringCISMaxIter; |
100 | 105 | string stringCISMaxDimensions; |
101 | 106 | string stringCISNormTolerance; |
107 | + string stringMD; | |
108 | + string stringMDEnd; | |
109 | + string stringMDTotalSteps; | |
110 | + string stringMDElecState; | |
111 | + string stringMDTimeWidth; | |
102 | 112 | void CalcMolecularBasics(Molecule* molecule); |
103 | 113 | void CalcCisCondition(Molecule* molecule); |
114 | + void CheckMdConditions(); | |
104 | 115 | void OutputMolecularBasics(Molecule* molecule); |
105 | 116 | void OutputScfConditions(); |
106 | 117 | void OutputCisConditions(); |
118 | + void OutputMdConditions(); | |
107 | 119 | void OutputInputTerms(vector<string> inputTerms); |
108 | 120 | bool IsCommentOut(string str); |
109 | 121 | vector<string> GetInputTerms(); |
@@ -133,6 +145,11 @@ InputParser::InputParser(){ | ||
133 | 145 | this->messageCisNormTolerance = "\t\tNorm tolerance for the residual of the Davidson: "; |
134 | 146 | this->messageCisMaxIterations = "\t\tMax iterations for the Davidson: "; |
135 | 147 | this->messageCisMaxDimensions = "\t\tMax dimensions for the Davidson: "; |
148 | + this->messageMdConditions = "\tMD conditions:\n"; | |
149 | + this->messageMdTotalSteps = "\t\tTotal steps: "; | |
150 | + this->messageMdElecState = "\t\tElectronic eigen state: "; | |
151 | + this->messageMdTimeWidth = "\t\tTime width(dt): "; | |
152 | + this->messageFs = "[fs]"; | |
136 | 153 | this->stringYES = "yes"; |
137 | 154 | this->stringNO = "no"; |
138 | 155 | this->stringSpace = " "; |
@@ -181,6 +198,11 @@ InputParser::InputParser(){ | ||
181 | 198 | this->stringCISMaxIter = "max_iter"; |
182 | 199 | this->stringCISMaxDimensions = "max_dim"; |
183 | 200 | this->stringCISNormTolerance = "norm_tol"; |
201 | + this->stringMD = "md"; | |
202 | + this->stringMDEnd = "md_end"; | |
203 | + this->stringMDTotalSteps = "total_steps"; | |
204 | + this->stringMDElecState = "electronic_state"; | |
205 | + this->stringMDTimeWidth = "dt"; | |
184 | 206 | } |
185 | 207 | |
186 | 208 | InputParser::~InputParser(){ |
@@ -462,6 +484,34 @@ void InputParser::Parse(Molecule* molecule){ | ||
462 | 484 | i = j; |
463 | 485 | } |
464 | 486 | |
487 | + // MD condition | |
488 | + if(inputTerms[i].compare(this->stringMD) == 0){ | |
489 | + Parameters::GetInstance()->SetRequiresMD(true); | |
490 | + int j=i+1; | |
491 | + while(inputTerms[j].compare(this->stringMDEnd) != 0){ | |
492 | + // number of total steps | |
493 | + if(inputTerms[j].compare(this->stringMDTotalSteps) == 0){ | |
494 | + int totalSteps = atoi(inputTerms[j+1].c_str()); | |
495 | + Parameters::GetInstance()->SetTotalStepsMD(totalSteps); | |
496 | + j++; | |
497 | + } | |
498 | + // index of electronic eigen state on whichi MD runs. | |
499 | + if(inputTerms[j].compare(this->stringMDElecState) == 0){ | |
500 | + int elecStateIndex = atoi(inputTerms[j+1].c_str()); | |
501 | + Parameters::GetInstance()->SetElectronicStateIndexMD(elecStateIndex); | |
502 | + j++; | |
503 | + } | |
504 | + // time width for MD. | |
505 | + if(inputTerms[j].compare(this->stringMDTimeWidth) == 0){ | |
506 | + double dt = atof(inputTerms[j+1].c_str()) * Parameters::GetInstance()->GetFs2AU(); | |
507 | + Parameters::GetInstance()->SetTimeWidthMD(dt); | |
508 | + j++; | |
509 | + } | |
510 | + j++; | |
511 | + } | |
512 | + i = j; | |
513 | + } | |
514 | + | |
465 | 515 | // theory |
466 | 516 | if(inputTerms[i].compare(this->stringTheory) == 0){ |
467 | 517 | int j=i+1; |
@@ -514,6 +564,7 @@ void InputParser::Parse(Molecule* molecule){ | ||
514 | 564 | if(Parameters::GetInstance()->GetCurrentTheory() == ZINDOS){ |
515 | 565 | this->CalcCisCondition(molecule); |
516 | 566 | } |
567 | + this->CheckMdConditions(); | |
517 | 568 | |
518 | 569 | // output conditions |
519 | 570 | this->OutputMolecularBasics(molecule); |
@@ -521,6 +572,9 @@ void InputParser::Parse(Molecule* molecule){ | ||
521 | 572 | if(Parameters::GetInstance()->GetCurrentTheory() == ZINDOS){ |
522 | 573 | this->OutputCisConditions(); |
523 | 574 | } |
575 | + if(Parameters::GetInstance()->RequiresMD()){ | |
576 | + this->OutputMdConditions(); | |
577 | + } | |
524 | 578 | |
525 | 579 | // output inputs |
526 | 580 | this->OutputInputTerms(inputTerms); |
@@ -570,6 +624,13 @@ void InputParser::CalcCisCondition(Molecule* molecule){ | ||
570 | 624 | |
571 | 625 | } |
572 | 626 | |
627 | +void InputParser::CheckMdConditions(){ | |
628 | + if(Parameters::GetInstance()->GetCurrentTheory() == ZINDOS){ | |
629 | + int groundStateIndex = 0; | |
630 | + Parameters::GetInstance()->SetElectronicStateIndexMD(groundStateIndex); | |
631 | + } | |
632 | +} | |
633 | + | |
573 | 634 | void InputParser::OutputMolecularBasics(Molecule* molecule){ |
574 | 635 | |
575 | 636 | molecule->OutputTotalNumberAtomsAOsValenceelectrons(); |
@@ -612,6 +673,16 @@ void InputParser::OutputCisConditions(){ | ||
612 | 673 | cout << "\n"; |
613 | 674 | } |
614 | 675 | |
676 | +void InputParser::OutputMdConditions(){ | |
677 | + cout << this->messageMdConditions; | |
678 | + | |
679 | + printf("%s%d\n",this->messageMdElecState.c_str(),Parameters::GetInstance()->GetElectronicStateIndexMD()); | |
680 | + printf("%s%d\n",this->messageMdTotalSteps.c_str(),Parameters::GetInstance()->GetTotalStepsMD()); | |
681 | + printf("%s%lf%s\n",this->messageMdTimeWidth.c_str(),Parameters::GetInstance()->GetTimeWidthMD()/Parameters::GetInstance()->GetFs2AU(),this->messageFs.c_str()); | |
682 | + | |
683 | + cout << "\n"; | |
684 | +} | |
685 | + | |
615 | 686 | void InputParser::OutputInputTerms(vector<string> inputTerms){ |
616 | 687 | |
617 | 688 | // output input terms |
@@ -34,6 +34,7 @@ public: | ||
34 | 34 | double GetKayser2AU(); |
35 | 35 | double GetGMolin2AU(); |
36 | 36 | double GetDegree2Radian(); |
37 | + double GetFs2AU(); | |
37 | 38 | double GetBondingAdjustParameterK(); |
38 | 39 | TheoryType GetCurrentTheory(); |
39 | 40 | void SetCurrentTheory(TheoryType theory); |
@@ -67,6 +68,14 @@ public: | ||
67 | 68 | void SetMaxDimensionsCIS(int maxDimensionsCIS); |
68 | 69 | double GetNormToleranceCIS(); |
69 | 70 | void SetNormToleranceCIS(double normToleranceCIS); |
71 | + bool RequiresMD(); | |
72 | + void SetRequiresMD(bool requiresMD); | |
73 | + int GetElectronicStateIndexMD(); | |
74 | + void SetElectronicStateIndexMD(int electronicStateIndex); | |
75 | + int GetTotalStepsMD(); | |
76 | + void SetTotalStepsMD(int totalSteps); | |
77 | + double GetTimeWidthMD(); | |
78 | + void SetTimeWidthMD(double timeWidth); | |
70 | 79 | private: |
71 | 80 | static Parameters* parameters; |
72 | 81 | Parameters(); |
@@ -87,6 +96,7 @@ private: | ||
87 | 96 | double kayser2AU; |
88 | 97 | double gMolin2AU; |
89 | 98 | double degree2Radian; |
99 | + double fs2AU; | |
90 | 100 | double bondingAdjustParameterK; //see (3.79) in J. A. Pople book |
91 | 101 | TheoryType currentTheory; |
92 | 102 | double translatingDifference[3]; |
@@ -104,6 +114,10 @@ private: | ||
104 | 114 | double normToleranceCIS; |
105 | 115 | bool requiresCIS; |
106 | 116 | bool isDavidsonCIS; |
117 | + bool requiresMD; | |
118 | + int electronicStateIndexMD; | |
119 | + int totalStepsMD; | |
120 | + double timeWidthMD; | |
107 | 121 | }; |
108 | 122 | Parameters* Parameters::parameters = NULL; |
109 | 123 |
@@ -141,6 +155,7 @@ void Parameters::SetDefaultValues(){ | ||
141 | 155 | this->eV2AU = 0.03674903; |
142 | 156 | this->angstrom2AU = 1.0/0.5291772; |
143 | 157 | this->kayser2AU = 4.556336*pow(10.0,-6.0); |
158 | + this->fs2AU = 1.0/(2.418884326505*pow(10.0,-2.0)); | |
144 | 159 | this->thresholdSCF = pow(10.0, -8.0); |
145 | 160 | this->maxIterationsSCF = 100; |
146 | 161 | this->dampingThreshSCF = 1.0; |
@@ -171,6 +186,9 @@ void Parameters::SetDefaultValues(){ | ||
171 | 186 | this->maxIterationsCIS = 100; |
172 | 187 | this->maxDimensionsCIS = 100; |
173 | 188 | this->normToleranceCIS = pow(10.0, -6.0); |
189 | + this->electronicStateIndexMD = 0; | |
190 | + this->totalStepsMD = 10; | |
191 | + this->timeWidthMD = 0.1*this->fs2AU; | |
174 | 192 | } |
175 | 193 | |
176 | 194 | double Parameters::GetThresholdSCF(){ |
@@ -249,6 +267,10 @@ double Parameters::GetDegree2Radian(){ | ||
249 | 267 | return this->degree2Radian; |
250 | 268 | } |
251 | 269 | |
270 | +double Parameters::GetFs2AU(){ | |
271 | + return this->fs2AU; | |
272 | +} | |
273 | + | |
252 | 274 | double Parameters::GetBondingAdjustParameterK(){ |
253 | 275 | return this->bondingAdjustParameterK; |
254 | 276 | } |
@@ -402,6 +424,38 @@ void Parameters::SetNormToleranceCIS(double normToleranceCIS){ | ||
402 | 424 | this->normToleranceCIS = normToleranceCIS; |
403 | 425 | } |
404 | 426 | |
427 | +bool Parameters::RequiresMD(){ | |
428 | + return this->requiresMD; | |
429 | +} | |
430 | + | |
431 | +void Parameters::SetRequiresMD(bool requiresMD){ | |
432 | + this->requiresMD = requiresMD; | |
433 | +} | |
434 | + | |
435 | +int Parameters::GetElectronicStateIndexMD(){ | |
436 | + return this->electronicStateIndexMD; | |
437 | +} | |
438 | + | |
439 | +void Parameters::SetElectronicStateIndexMD(int electronicStateIndex){ | |
440 | + this->electronicStateIndexMD = electronicStateIndex; | |
441 | +} | |
442 | + | |
443 | +int Parameters::GetTotalStepsMD(){ | |
444 | + return this->totalStepsMD; | |
445 | +} | |
446 | + | |
447 | +void Parameters::SetTotalStepsMD(int totalSteps){ | |
448 | + this->totalStepsMD = totalSteps; | |
449 | +} | |
450 | + | |
451 | +double Parameters::GetTimeWidthMD(){ | |
452 | + return this->timeWidthMD; | |
453 | +} | |
454 | + | |
455 | +void Parameters::SetTimeWidthMD(double timeWidth){ | |
456 | + this->timeWidthMD = timeWidth; | |
457 | +} | |
458 | + | |
405 | 459 | } |
406 | 460 | #endif |
407 | 461 |
@@ -1,8 +1,8 @@ | ||
1 | 1 | // example of the input file |
2 | 2 | THEORY |
3 | 3 | //cndo/2 |
4 | - //indo | |
5 | - zindo/s | |
4 | + indo | |
5 | + //zindo/s | |
6 | 6 | //none |
7 | 7 | //principal_axes |
8 | 8 | //translate |
@@ -19,18 +19,21 @@ SCF | ||
19 | 19 | diis_end_error 0.00000002 |
20 | 20 | SCF_END |
21 | 21 | |
22 | -CIS | |
23 | - davidson yes | |
24 | - active_occ 100 | |
25 | - active_vir 100 | |
26 | - nstates 11 | |
27 | - max_iter 200 | |
28 | - max_dim 100 | |
29 | - norm_tol 0.000001 | |
30 | -CIS_END | |
31 | - | |
32 | - | |
33 | - | |
22 | +//CIS | |
23 | +// davidson yes | |
24 | +// active_occ 100 | |
25 | +// active_vir 100 | |
26 | +// nstates 11 | |
27 | +// max_iter 200 | |
28 | +// max_dim 100 | |
29 | +// norm_tol 0.000001 | |
30 | +//CIS_END | |
31 | + | |
32 | +MD | |
33 | +// total_steps 20 | |
34 | +// electronic_state 2 | |
35 | +// dt 0.2 | |
36 | +MD_END | |
34 | 37 | |
35 | 38 | //INERTIA |
36 | 39 | // origin 1.0 2.0 30.0 |
@@ -50,7 +53,6 @@ CIS_END | ||
50 | 53 | //difference 100.0 200.0 300.0 |
51 | 54 | //TRANSLATE_END |
52 | 55 | |
53 | - | |
54 | 56 | // NH3 |
55 | 57 | //GEOMETRY |
56 | 58 | // N 0.950135 0.471698 0.000000 |
@@ -92,7 +94,6 @@ CIS_END | ||
92 | 94 | // H -0.422611 0.820144 0.000000 |
93 | 95 | //GEOMETRY_END |
94 | 96 | |
95 | - | |
96 | 97 | // c2 |
97 | 98 | //GEOMETRY |
98 | 99 | // C 0.168464 0.0 0.000000 |
@@ -188,8 +189,6 @@ GEOMETRY_END | ||
188 | 189 | // Li 1.994960 0.485175 0.000000 |
189 | 190 | //GEOMETRY_END |
190 | 191 | |
191 | - | |
192 | - | |
193 | 192 | // Li2 |
194 | 193 | //GEOMETRY |
195 | 194 | // Li 0.0 0.0 1.230000 |
@@ -201,7 +200,6 @@ GEOMETRY_END | ||
201 | 200 | // Li -1.570081 0.094340 0.0 |
202 | 201 | // Li -4.030081 0.094340 0.0 |
203 | 202 | //GEOMETRY_END |
204 | -// | |
205 | 203 | |
206 | 204 | //GEOMETRY |
207 | 205 | // C -3.402965 0.646900 0.000000 |
@@ -22,7 +22,7 @@ public: | ||
22 | 22 | ZindoS(); |
23 | 23 | ~ZindoS(); |
24 | 24 | void DoesCIS(); |
25 | - virtual void CalcForce(int electronicEigenIndex); | |
25 | + virtual void CalcForce(int electronicStateIndex); | |
26 | 26 | protected: |
27 | 27 | virtual void CalcGammaAB(double** gammaAB, Molecule* molecule); |
28 | 28 | virtual void SetMessages(); |
@@ -1424,9 +1424,9 @@ void ZindoS::CalcCISMatrix(double** matrixCIS, int numberOcc, int numberVir){ | ||
1424 | 1424 | cout << this->messageDoneCalcCISMatrix; |
1425 | 1425 | } |
1426 | 1426 | |
1427 | -// eigenIndex is index of the electroinc eigen state. | |
1428 | -// "eigenIndex = 0" means electronic ground state. | |
1429 | -void ZindoS::CalcForce(int electronicEigenIndex){ | |
1427 | +// electronicStateIndex is index of the electroinc eigen state. | |
1428 | +// "electronicStateIndex = 0" means electronic ground state. | |
1429 | +void ZindoS::CalcForce(int electronicStateIndex){ | |
1430 | 1430 | |
1431 | 1431 | // malloc or initialize Force matrix |
1432 | 1432 | if(this->matrixForce == NULL){ |