リビジョン | df42b133532c2c06c133905373a759669f8d8f0a (tree) |
---|---|
日時 | 2011-09-30 21:42:20 |
作者 | Mikiya Fujii <mikiya.fujii@gmai...> |
コミッター | Mikiya Fujii |
Molecule::CalcXyzCOM is modified to calculate COM for eveytime when this method is called.
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/MolDS/trunk@165 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -162,29 +162,27 @@ double* Molecule::GetXyzCOM(){ | ||
162 | 162 | } |
163 | 163 | |
164 | 164 | void Molecule::CalcXyzCOM(){ |
165 | - if(!this->wasCalculatedXyzCOM){ | |
166 | - double totalAtomicMass; | |
167 | - Atom* atom; | |
168 | - double* atomicXyz; | |
169 | - double atomicMass; | |
165 | + double totalAtomicMass; | |
166 | + Atom* atom; | |
167 | + double* atomicXyz; | |
168 | + double atomicMass; | |
170 | 169 | |
171 | - for(int j=0; j<3; j++){ | |
172 | - this->xyzCOM[j] = 0.0; | |
173 | - } | |
170 | + for(int j=0; j<3; j++){ | |
171 | + this->xyzCOM[j] = 0.0; | |
172 | + } | |
174 | 173 | |
175 | - for(int i=0; i<this->atomVect->size(); i++){ | |
176 | - atom = (*this->atomVect)[i]; | |
177 | - atomicXyz = atom->GetXyz(); | |
178 | - atomicMass = atom->GetAtomicMass(); | |
179 | - totalAtomicMass += atomicMass; | |
180 | - for(int j=0; j<3; j++){ | |
181 | - this->xyzCOM[j] += atomicXyz[j] * atomicMass; | |
182 | - } | |
183 | - } | |
184 | - for(int i=0; i<3; i++){ | |
185 | - this->xyzCOM[i]/=totalAtomicMass; | |
174 | + for(int i=0; i<this->atomVect->size(); i++){ | |
175 | + atom = (*this->atomVect)[i]; | |
176 | + atomicXyz = atom->GetXyz(); | |
177 | + atomicMass = atom->GetAtomicMass(); | |
178 | + totalAtomicMass += atomicMass; | |
179 | + for(int j=0; j<3; j++){ | |
180 | + this->xyzCOM[j] += atomicXyz[j] * atomicMass; | |
186 | 181 | } |
187 | 182 | } |
183 | + for(int i=0; i<3; i++){ | |
184 | + this->xyzCOM[i]/=totalAtomicMass; | |
185 | + } | |
188 | 186 | this->wasCalculatedXyzCOM = true; |
189 | 187 | } |
190 | 188 |