Revisão | 687c9166f823b296ad27b6e74bb7e35e80eaf2bc (tree) |
---|---|
Hora | 2011-01-07 11:07:31 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Translate molecule is refactored.
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/MolDS/trunk@46 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -258,7 +258,7 @@ void InputParser::Parse(Molecule* molecule){ | ||
258 | 258 | double x = atof(inputTerms[j+1].c_str()) * Parameters::GetInstance()->GetAngstrom2AU(); |
259 | 259 | double y = atof(inputTerms[j+2].c_str()) * Parameters::GetInstance()->GetAngstrom2AU(); |
260 | 260 | double z = atof(inputTerms[j+3].c_str()) * Parameters::GetInstance()->GetAngstrom2AU(); |
261 | - molecule->SetTranslatingDifference(x, y, z); | |
261 | + Parameters::GetInstance()->SetTranslatingDifference(x, y, z); | |
262 | 262 | j+=3; |
263 | 263 | } |
264 | 264 | j++; |
@@ -36,7 +36,6 @@ public: | ||
36 | 36 | void SetRotatingAngle(double angle); |
37 | 37 | void SetRotatingEularAngles(double alpha, double beta, double gamma); |
38 | 38 | void SetRotatingType(RotatingType rotatingType); |
39 | - void SetTranslatingDifference(double x, double y, double z); | |
40 | 39 | void Translate(); |
41 | 40 | private: |
42 | 41 | vector<Atom*>* atomVect; |
@@ -45,7 +44,6 @@ private: | ||
45 | 44 | double* rotatingOrigin; |
46 | 45 | double* rotatingAxis; |
47 | 46 | double rotatingAngle; |
48 | - double* translatingDifference; | |
49 | 47 | EularAngle* rotatingEularAngles; |
50 | 48 | RotatingType rotatingType; |
51 | 49 | bool wasCalculatedCOMXyz; |
@@ -56,7 +54,7 @@ private: | ||
56 | 54 | void OutputPrincipalAxes(double** inertiaTensor, double* inertiaMoments); |
57 | 55 | void OutputInertiaTensorOrigin(); |
58 | 56 | void OutputRotatingConditions(); |
59 | - void OutputTranslatingConditions(); | |
57 | + void OutputTranslatingConditions(double* translatingDifference); | |
60 | 58 | string messageTotalNumberAOs; |
61 | 59 | string messageTotalNumberAtoms; |
62 | 60 | string messageTotalNumberValenceElectrons; |
@@ -174,11 +172,6 @@ Molecule::~Molecule(){ | ||
174 | 172 | this->rotatingEularAngles = NULL; |
175 | 173 | //cout << "rotatingEularAngles deleted\n"; |
176 | 174 | } |
177 | - if(this->translatingDifference != NULL){ | |
178 | - MallocerFreer::GetInstance()->FreeDoubleMatrix1d(this->translatingDifference); | |
179 | - this->translatingDifference = NULL; | |
180 | - //cout << "translatingDifference deleted\n"; | |
181 | - } | |
182 | 175 | } |
183 | 176 | |
184 | 177 | vector<Atom*>* Molecule::GetAtomVect(){ |
@@ -558,37 +551,23 @@ void Molecule::OutputRotatingConditions(){ | ||
558 | 551 | |
559 | 552 | } |
560 | 553 | |
561 | -void Molecule::SetTranslatingDifference(double x, double y, double z){ | |
562 | - if(this->translatingDifference == NULL){ | |
563 | - this->translatingDifference = MallocerFreer::GetInstance()->MallocDoubleMatrix1d(3); | |
564 | - } | |
565 | - | |
566 | - this->translatingDifference[0] = x; | |
567 | - this->translatingDifference[1] = y; | |
568 | - this->translatingDifference[2] = z; | |
569 | - | |
570 | -} | |
571 | 554 | |
572 | -/**** | |
573 | - * Call this->SetTranslatingDifference before calling this-function. | |
574 | - ***/ | |
575 | 555 | void Molecule::Translate(){ |
576 | 556 | |
577 | 557 | cout << this->messageStartTranslate; |
578 | 558 | |
579 | - if(this->translatingDifference == NULL){ | |
580 | - this->SetTranslatingDifference(0.0, 0.0, 0.0); | |
581 | - } | |
559 | + double x = Parameters::GetInstance()->GetTranslatingDifference()[0]; | |
560 | + double y = Parameters::GetInstance()->GetTranslatingDifference()[1]; | |
561 | + double z = Parameters::GetInstance()->GetTranslatingDifference()[2]; | |
582 | 562 | |
583 | - | |
584 | - this->OutputTranslatingConditions(); | |
563 | + this->OutputTranslatingConditions(Parameters::GetInstance()->GetTranslatingDifference()); | |
585 | 564 | |
586 | 565 | Atom* atom; |
587 | 566 | for(int i=0; i<this->atomVect->size(); i++){ |
588 | 567 | atom = (*this->atomVect)[i]; |
589 | - atom->GetXyz()[0] += this->translatingDifference[0]; | |
590 | - atom->GetXyz()[1] += this->translatingDifference[1]; | |
591 | - atom->GetXyz()[2] += this->translatingDifference[2]; | |
568 | + atom->GetXyz()[0] += x; | |
569 | + atom->GetXyz()[1] += y; | |
570 | + atom->GetXyz()[2] += z; | |
592 | 571 | } |
593 | 572 | |
594 | 573 | this->wasCalculatedCOMXyz = false; |
@@ -600,21 +579,20 @@ void Molecule::Translate(){ | ||
600 | 579 | cout << this->messageDoneTranslate; |
601 | 580 | } |
602 | 581 | |
603 | -void Molecule::OutputTranslatingConditions(){ | |
582 | +void Molecule::OutputTranslatingConditions(double* translatingDifference){ | |
604 | 583 | |
605 | 584 | double angst2AU = Parameters::GetInstance()->GetAngstrom2AU(); |
606 | 585 | |
607 | - // rotating origin | |
608 | 586 | cout << this->messageTranslatingDifference; |
609 | 587 | cout << this->messageTranslatingDifferenceTitleAng; |
610 | - printf("\t\t%e\t%e\t%e\n\n",this->translatingDifference[0]/angst2AU, | |
611 | - this->translatingDifference[1]/angst2AU, | |
612 | - this->translatingDifference[2]/angst2AU); | |
588 | + printf("\t\t%e\t%e\t%e\n\n",translatingDifference[0]/angst2AU, | |
589 | + translatingDifference[1]/angst2AU, | |
590 | + translatingDifference[2]/angst2AU); | |
613 | 591 | |
614 | 592 | cout << this->messageTranslatingDifferenceTitleAU; |
615 | - printf("\t\t%e\t%e\t%e\n\n",this->translatingDifference[0], | |
616 | - this->translatingDifference[1], | |
617 | - this->translatingDifference[2]); | |
593 | + printf("\t\t%e\t%e\t%e\n\n",translatingDifference[0], | |
594 | + translatingDifference[1], | |
595 | + translatingDifference[2]); | |
618 | 596 | |
619 | 597 | } |
620 | 598 |
@@ -27,6 +27,8 @@ public: | ||
27 | 27 | double GetBondingAdjustParameterK(); |
28 | 28 | TheoryType GetCurrentTheory(); |
29 | 29 | void SetCurrentTheory(TheoryType theory); |
30 | + void SetTranslatingDifference(double x, double y, double z); | |
31 | + double* GetTranslatingDifference(); | |
30 | 32 | |
31 | 33 | private: |
32 | 34 | static Parameters* parameters; |
@@ -45,6 +47,7 @@ private: | ||
45 | 47 | double degree2Radian; |
46 | 48 | double bondingAdjustParameterK; //see (3.79) in J. A. Pople book |
47 | 49 | TheoryType currentTheory; |
50 | + double translatingDifference[3]; | |
48 | 51 | |
49 | 52 | }; |
50 | 53 | Parameters* Parameters::parameters = NULL; |
@@ -79,6 +82,9 @@ void Parameters::SetDefaultValues(){ | ||
79 | 82 | this->currentTheory = CNDO2; |
80 | 83 | this->gMolin2AU = pow(10.0,5.0)/(6.0221415*9.1095); |
81 | 84 | this->degree2Radian = M_PI / 180.0; |
85 | + this->translatingDifference[0] = 0.0; | |
86 | + this->translatingDifference[1] = 0.0; | |
87 | + this->translatingDifference[2] = 0.0; | |
82 | 88 | } |
83 | 89 | |
84 | 90 | double Parameters::GetThresholdSCF(){ |
@@ -129,6 +135,17 @@ void Parameters::SetCurrentTheory(TheoryType theory){ | ||
129 | 135 | this->currentTheory = theory; |
130 | 136 | } |
131 | 137 | |
138 | +void Parameters::SetTranslatingDifference(double x, double y, double z){ | |
139 | + this->translatingDifference[0] = x; | |
140 | + this->translatingDifference[1] = y; | |
141 | + this->translatingDifference[2] = z; | |
142 | +} | |
143 | + | |
144 | +double* Parameters::GetTranslatingDifference(){ | |
145 | + return this->translatingDifference; | |
146 | +} | |
147 | + | |
148 | + | |
132 | 149 | } |
133 | 150 | #endif |
134 | 151 |