Revisión | 125beb363f517ce51b4f0204ff6c151ac86f963f (tree) |
---|---|
Tiempo | 2013-05-23 17:49:02 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Refactoring of Molecule class.
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1352 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -70,8 +70,6 @@ void Molecule::CopyInitialize(const Molecule& rhs){ | ||
70 | 70 | this->xyzCOM[i] = rhs.xyzCOM[i]; |
71 | 71 | this->xyzCOC[i] = rhs.xyzCOC[i]; |
72 | 72 | } |
73 | - this->wasCalculatedXyzCOM = rhs.wasCalculatedXyzCOM; | |
74 | - this->wasCalculatedXyzCOC = rhs.wasCalculatedXyzCOC; | |
75 | 73 | this->totalNumberAOs = rhs.totalNumberAOs; |
76 | 74 | this->totalNumberValenceElectrons = rhs.totalNumberValenceElectrons; |
77 | 75 | this->totalCoreMass = rhs.totalCoreMass; |
@@ -90,8 +88,6 @@ void Molecule::CopyInitialize(const Molecule& rhs){ | ||
90 | 88 | |
91 | 89 | void Molecule::Initialize(){ |
92 | 90 | this->SetMessages(); |
93 | - this->wasCalculatedXyzCOM = false; | |
94 | - this->wasCalculatedXyzCOC = false; | |
95 | 91 | this->xyzCOM = NULL; |
96 | 92 | this->xyzCOC = NULL; |
97 | 93 | this->atomVect = NULL; |
@@ -170,39 +166,24 @@ void Molecule::AddAtom(Atom* atom){ | ||
170 | 166 | |
171 | 167 | } |
172 | 168 | |
173 | -double* Molecule::GetXyzCOM() const{ | |
169 | +double const* Molecule::GetXyzCOM() const{ | |
174 | 170 | #ifdef MOLDS_DBG |
175 | 171 | if(this->xyzCOM==NULL) throw MolDSException(this->errorMessageGetXyzCOMNull); |
176 | 172 | #endif |
177 | 173 | return this->xyzCOM; |
178 | 174 | } |
179 | 175 | |
180 | -double* Molecule::GetXyzCOM(){ | |
181 | - if(!this->wasCalculatedXyzCOM){ | |
182 | - this->CalcXyzCOM(); | |
183 | - } | |
184 | - return this->xyzCOM; | |
185 | -} | |
186 | - | |
187 | -double* Molecule::GetXyzCOC() const{ | |
176 | +double const* Molecule::GetXyzCOC() const{ | |
188 | 177 | #ifdef MOLDS_DBG |
189 | 178 | if(this->xyzCOC==NULL) throw MolDSException(this->errorMessageGetXyzCOCNull); |
190 | 179 | #endif |
191 | 180 | return this->xyzCOC; |
192 | 181 | } |
193 | 182 | |
194 | -double* Molecule::GetXyzCOC(){ | |
195 | - if(!this->wasCalculatedXyzCOC){ | |
196 | - this->CalcXyzCOC(); | |
197 | - } | |
198 | - return this->xyzCOC; | |
199 | -} | |
200 | - | |
201 | 183 | void Molecule::CalcXyzCOM(){ |
202 | - MallocerFreer::GetInstance()->Malloc<double>(&this->xyzCOM, CartesianType_end); | |
203 | - double totalAtomicMass = 0.0; | |
184 | + double totalAtomicMass = 0.0; | |
204 | 185 | double* atomicXyz; |
205 | - double atomicMass = 0.0; | |
186 | + double atomicMass = 0.0; | |
206 | 187 | |
207 | 188 | for(int j=0; j<3; j++){ |
208 | 189 | this->xyzCOM[j] = 0.0; |
@@ -220,14 +201,12 @@ void Molecule::CalcXyzCOM(){ | ||
220 | 201 | for(int i=0; i<3; i++){ |
221 | 202 | this->xyzCOM[i]/=totalAtomicMass; |
222 | 203 | } |
223 | - this->wasCalculatedXyzCOM = true; | |
224 | 204 | } |
225 | 205 | |
226 | 206 | void Molecule::CalcXyzCOC(){ |
227 | - MallocerFreer::GetInstance()->Malloc<double>(&this->xyzCOC, CartesianType_end); | |
228 | - double totalCoreMass = 0.0; | |
207 | + double totalCoreMass = 0.0; | |
229 | 208 | double* atomicXyz; |
230 | - double coreMass = 0.0; | |
209 | + double coreMass = 0.0; | |
231 | 210 | |
232 | 211 | for(int j=0; j<3; j++){ |
233 | 212 | this->xyzCOC[j] = 0.0; |
@@ -245,7 +224,6 @@ void Molecule::CalcXyzCOC(){ | ||
245 | 224 | for(int i=0; i<3; i++){ |
246 | 225 | this->xyzCOC[i]/=totalCoreMass; |
247 | 226 | } |
248 | - this->wasCalculatedXyzCOC = true; | |
249 | 227 | } |
250 | 228 | |
251 | 229 | int Molecule::GetTotalNumberAOs() const{ |
@@ -408,9 +386,7 @@ void Molecule::OutputInertiaTensorOrigin(double* inertiaTensorOrigin) const{ | ||
408 | 386 | |
409 | 387 | void Molecule::CalcPrincipalAxes(){ |
410 | 388 | this->OutputLog(this->messageStartPrincipalAxes); |
411 | - if(!this->wasCalculatedXyzCOM){ | |
412 | - this->CalcXyzCOM(); | |
413 | - } | |
389 | + this->CalcXyzCOM(); | |
414 | 390 | double inertiaTensorOrigin[3] = {this->xyzCOM[0], this->xyzCOM[1], this->xyzCOM[2]}; |
415 | 391 | if(Parameters::GetInstance()->GetInertiaTensorOrigin() != NULL){ |
416 | 392 | inertiaTensorOrigin[0] = Parameters::GetInstance()->GetInertiaTensorOrigin()[0]; |
@@ -479,9 +455,7 @@ void Molecule::Rotate(){ | ||
479 | 455 | this->OutputLog(this->messageStartRotate); |
480 | 456 | |
481 | 457 | // Default values are set if some conditions are not specified. |
482 | - if(!this->wasCalculatedXyzCOM){ | |
483 | - this->CalcXyzCOM(); | |
484 | - } | |
458 | + this->CalcXyzCOM(); | |
485 | 459 | double rotatingOrigin[3] = {this->xyzCOM[0], this->xyzCOM[1], this->xyzCOM[2]}; |
486 | 460 | if(Parameters::GetInstance()->GetRotatingOrigin() != NULL){ |
487 | 461 | rotatingOrigin[0] = Parameters::GetInstance()->GetRotatingOrigin()[0]; |
@@ -642,12 +616,8 @@ void Molecule::Translate(){ | ||
642 | 616 | atom.GetXyz()[1] += y; |
643 | 617 | atom.GetXyz()[2] += z; |
644 | 618 | } |
645 | - | |
646 | - this->wasCalculatedXyzCOM = false; | |
647 | 619 | this->CalcXyzCOM(); |
648 | - this->wasCalculatedXyzCOC = false; | |
649 | 620 | this->CalcXyzCOC(); |
650 | - | |
651 | 621 | this->OutputConfiguration(); |
652 | 622 | this->OutputXyzCOM(); |
653 | 623 | this->OutputXyzCOC(); |
@@ -674,13 +644,11 @@ double Molecule::GetDistanceAtoms(int indexAtomA, int indexAtomB) const{ | ||
674 | 644 | } |
675 | 645 | |
676 | 646 | double Molecule::GetDistanceAtoms(const Atom& atomA, const Atom& atomB) const{ |
677 | - | |
678 | 647 | double distance=0.0; |
679 | 648 | distance = sqrt( pow(atomA.GetXyz()[0] - atomB.GetXyz()[0], 2.0) |
680 | 649 | +pow(atomA.GetXyz()[1] - atomB.GetXyz()[1], 2.0) |
681 | 650 | +pow(atomA.GetXyz()[2] - atomB.GetXyz()[2], 2.0) ); |
682 | 651 | return distance; |
683 | - | |
684 | 652 | } |
685 | 653 | |
686 | 654 | void Molecule::SynchronizeConfigurationTo(const Molecule& ref){ |
@@ -39,10 +39,8 @@ public: | ||
39 | 39 | return (*this->atomVect)[atomIndex]; |
40 | 40 | } |
41 | 41 | void AddAtom(MolDS_base_atoms::Atom* atom); |
42 | - double* GetXyzCOM() const; | |
43 | - double* GetXyzCOM(); | |
44 | - double* GetXyzCOC() const; | |
45 | - double* GetXyzCOC(); | |
42 | + double const* GetXyzCOM() const; | |
43 | + double const* GetXyzCOC() const; | |
46 | 44 | void CalcXyzCOM(); |
47 | 45 | void CalcXyzCOC(); |
48 | 46 | void CalcBasics(); |
@@ -67,8 +65,6 @@ private: | ||
67 | 65 | std::vector<MolDS_base_atoms::Atom*>* atomVect; |
68 | 66 | double* xyzCOM; // x, y, z coordinates of Center of Mass; |
69 | 67 | double* xyzCOC; // x, y, z coordinates of Center of Core; |
70 | - bool wasCalculatedXyzCOM; | |
71 | - bool wasCalculatedXyzCOC; | |
72 | 68 | int totalNumberAOs; |
73 | 69 | int totalNumberValenceElectrons; |
74 | 70 | double totalCoreMass; |