Changes in src/atom.cpp [2fe971:97b825]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
r2fe971 r97b825 13 13 #include "lists.hpp" 14 14 #include "parser.hpp" 15 #include " vector.hpp"15 #include "LinearAlgebra/Vector.hpp" 16 16 #include "World.hpp" 17 17 #include "molecule.hpp" … … 27 27 */ 28 28 atom::atom() : 29 father(this), sort(&nr), mol(0)30 { 31 node = &x; // TesselPoint::x can only be referenced from here32 };29 father(this), 30 sort(&nr), 31 mol(0) 32 {}; 33 33 34 34 /** Constructor of class atom. 35 35 */ 36 36 atom::atom(atom *pointer) : 37 ParticleInfo(pointer),father(pointer), sort(&nr) 38 { 39 type = pointer->type; // copy element of atom 40 x = pointer->x; // copy coordination 41 v = pointer->v; // copy velocity 37 ParticleInfo(pointer), 38 father(pointer), 39 sort(&nr) 40 { 41 setType(pointer->getType()); // copy element of atom 42 setPosition(pointer->getPosition()); // copy coordination 43 AtomicVelocity = pointer->AtomicVelocity; // copy velocity 42 44 FixedIon = pointer->FixedIon; 43 node = &x;44 45 mol = 0; 45 46 }; … … 49 50 res->father = this; 50 51 res->sort = &res->nr; 51 res-> type = type;52 res-> x = this->x;53 res-> v = this->v;52 res->setType(getType()); 53 res->setPosition(this->getPosition()); 54 res->AtomicVelocity = this->AtomicVelocity; 54 55 res->FixedIon = FixedIon; 55 res->node = &x;56 56 res->mol = 0; 57 57 World::getInstance().registerAtom(res); … … 121 121 bool atom::IsInShape(const Shape& shape) const 122 122 { 123 return shape.isInside( *node);123 return shape.isInside(getPosition()); 124 124 }; 125 125 … … 146 146 if (out != NULL) { 147 147 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint; 148 *out << x[0] << "\t" << x[1] << "\t" << x[2];148 *out << at(0) << "\t" << at(1) << "\t" << at(2); 149 149 *out << "\t" << FixedIon; 150 if ( v.Norm() > MYEPSILON)151 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";150 if (AtomicVelocity.Norm() > MYEPSILON) 151 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 152 152 if (comment != NULL) 153 153 *out << " # " << comment << endl; … … 168 168 bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const 169 169 { 170 AtomNo[type->Z]++; // increment number 171 if (out != NULL) { 172 cout << "Looking for atom with element " << *type << endl; 173 ASSERT(elementLookup.there.find(type)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 174 *out << "Ion_Type" << elementLookup.there.find(type)->second << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint; 175 *out << x[0] << "\t" << x[1] << "\t" << x[2]; 170 AtomNo[getType()->Z]++; // increment number 171 if (out != NULL) { 172 const element *elemental = getType(); 173 cout << "Looking for atom with element " << *elemental << endl; 174 ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 175 *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[elemental->Z] << "\t" << fixed << setprecision(9) << showpoint; 176 *out << at(0) << "\t" << at(1) << "\t" << at(2); 176 177 *out << "\t" << FixedIon; 177 if ( v.Norm() > MYEPSILON)178 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";178 if (AtomicVelocity.Norm() > MYEPSILON) 179 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 179 180 if (comment != NULL) 180 181 *out << " # " << comment << endl; … … 193 194 { 194 195 if (out != NULL) { 195 *out << type->getSymbol() << "\t" << x[0] << "\t" << x[1] << "\t" << x[2]<< "\t" << endl;196 *out << getType()->symbol << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl; 196 197 return true; 197 198 } else … … 208 209 bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const 209 210 { 210 AtomNo[ type->Z]++;211 if (out != NULL) { 212 *out << "Ion_Type" << ElementNo[ type->Z] << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint;211 AtomNo[getType()->Z]++; 212 if (out != NULL) { 213 *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t" << fixed << setprecision(9) << showpoint; 213 214 *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2]; 214 215 *out << "\t" << FixedIon; … … 231 232 { 232 233 if (out != NULL) { 233 *out << type->getSymbol()<< "\t";234 *out << getType()->symbol << "\t"; 234 235 *out << Trajectory.R.at(step)[0] << "\t"; 235 236 *out << Trajectory.R.at(step)[1] << "\t"; … … 247 248 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 248 249 { 249 *out << "\t\t" << type->getSymbol() << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; 250 Vector recentered(getPosition()); 251 recentered -= *center; 252 *out << "\t\t" << getType()->symbol << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl; 250 253 if (AtomNo != NULL) 251 254 *AtomNo++; … … 270 273 double atom::DistanceSquaredToVector(const Vector &origin) const 271 274 { 272 return origin.DistanceSquared(x);275 return DistanceSquared(origin); 273 276 }; 274 277 … … 279 282 double atom::DistanceToVector(const Vector &origin) const 280 283 { 281 return origin.distance(x);284 return distance(origin); 282 285 }; 283 286 … … 294 297 }; 295 298 299 std::ostream & atom::operator << (std::ostream &ost) const 300 { 301 ParticleInfo::operator<<(ost); 302 ost << "," << getPosition(); 303 return ost; 304 } 305 306 std::ostream & operator << (std::ostream &ost, const atom &a) 307 { 308 a.ParticleInfo::operator<<(ost); 309 ost << "," << a.getPosition(); 310 return ost; 311 } 296 312 297 313 bool operator < (atom &a, atom &b) … … 333 349 mol = _mol; 334 350 if(!mol->containsAtom(this)){ 335 mol-> AddAtom(this);351 mol->insert(this); 336 352 } 337 353 }
Note:
See TracChangeset
for help on using the changeset viewer.