Changes in src/atom.cpp [dddbfe:d74077]
- File:
-
- 1 edited
-
src/atom.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
rdddbfe rd74077 13 13 #include "lists.hpp" 14 14 #include "parser.hpp" 15 #include " LinearAlgebra/Vector.hpp"15 #include "vector.hpp" 16 16 #include "World.hpp" 17 17 #include "molecule.hpp" … … 19 19 20 20 #include <iomanip> 21 #include <iostream>22 21 23 22 /************************************* Functions for class atom *************************************/ … … 28 27 atom::atom() : 29 28 father(this), sort(&nr), mol(0) 30 { 31 node = &x; // TesselPoint::x can only be referenced from here 32 }; 29 {}; 33 30 34 31 /** Constructor of class atom. … … 37 34 ParticleInfo(pointer),father(pointer), sort(&nr) 38 35 { 39 type = pointer->type; // copy element of atom40 x = pointer->x; // copy coordination41 v = pointer->v; // copy velocity36 setType(pointer->getType()); // copy element of atom 37 setPosition(pointer->getPosition()); // copy coordination 38 AtomicVelocity = pointer->AtomicVelocity; // copy velocity 42 39 FixedIon = pointer->FixedIon; 43 node = &x;44 40 mol = 0; 45 41 }; … … 49 45 res->father = this; 50 46 res->sort = &res->nr; 51 res-> type = type;52 res-> x = this->x;53 res-> v = this->v;47 res->setType(getType()); 48 res->setPosition(this->getPosition()); 49 res->AtomicVelocity = this->AtomicVelocity; 54 50 res->FixedIon = FixedIon; 55 res->node = &x;56 51 res->mol = 0; 57 52 World::getInstance().registerAtom(res); … … 110 105 }; 111 106 112 bool atom::isFather(const atom *ptr){113 return ptr==father;114 }115 116 107 /** Checks whether atom is within the given box. 117 108 * \param offset offset to box origin … … 121 112 bool atom::IsInShape(const Shape& shape) const 122 113 { 123 return shape.isInside( *node);114 return shape.isInside(getPosition()); 124 115 }; 125 116 … … 146 137 if (out != NULL) { 147 138 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint; 148 *out << x[0] << "\t" << x[1] << "\t" << x[2];139 *out << at(0) << "\t" << at(1) << "\t" << at(2); 149 140 *out << "\t" << FixedIon; 150 if ( v.Norm() > MYEPSILON)151 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";141 if (AtomicVelocity.Norm() > MYEPSILON) 142 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 152 143 if (comment != NULL) 153 144 *out << " # " << comment << endl; … … 166 157 * \return true - \a *out present, false - \a *out is NULL 167 158 */ 168 bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const 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]; 159 bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const 160 { 161 AtomNo[getType()->Z]++; // increment number 162 if (out != NULL) { 163 *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t" << fixed << setprecision(9) << showpoint; 164 *out << at(0) << "\t" << at(1) << "\t" << at(2); 176 165 *out << "\t" << FixedIon; 177 if ( v.Norm() > MYEPSILON)178 *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";166 if (AtomicVelocity.Norm() > MYEPSILON) 167 *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t"; 179 168 if (comment != NULL) 180 169 *out << " # " << comment << endl; … … 193 182 { 194 183 if (out != NULL) { 195 *out << type->symbol << "\t" << x[0] << "\t" << x[1] << "\t" << x[2]<< "\t" << endl;184 *out << getType()->symbol << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl; 196 185 return true; 197 186 } else … … 208 197 bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const 209 198 { 210 AtomNo[ type->Z]++;211 if (out != NULL) { 212 *out << "Ion_Type" << ElementNo[ type->Z] << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint;199 AtomNo[getType()->Z]++; 200 if (out != NULL) { 201 *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t" << fixed << setprecision(9) << showpoint; 213 202 *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2]; 214 203 *out << "\t" << FixedIon; … … 231 220 { 232 221 if (out != NULL) { 233 *out << type->symbol << "\t";222 *out << getType()->symbol << "\t"; 234 223 *out << Trajectory.R.at(step)[0] << "\t"; 235 224 *out << Trajectory.R.at(step)[1] << "\t"; … … 247 236 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const 248 237 { 249 *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; 238 Vector recentered(getPosition()); 239 recentered -= *center; 240 *out << "\t\t" << getType()->symbol << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl; 250 241 if (AtomNo != NULL) 251 242 *AtomNo++; … … 270 261 double atom::DistanceSquaredToVector(const Vector &origin) const 271 262 { 272 return origin.DistanceSquared(x);263 return DistanceSquared(origin); 273 264 }; 274 265 … … 279 270 double atom::DistanceToVector(const Vector &origin) const 280 271 { 281 return origin.distance(x);272 return distance(origin); 282 273 }; 283 274 … … 294 285 }; 295 286 287 std::ostream & atom::operator << (std::ostream &ost) const 288 { 289 ParticleInfo::operator<<(ost); 290 ost << "," << getPosition(); 291 return ost; 292 } 293 294 std::ostream & operator << (std::ostream &ost, const atom &a) 295 { 296 a.ParticleInfo::operator<<(ost); 297 ost << "," << a.getPosition(); 298 return ost; 299 } 296 300 297 301 bool operator < (atom &a, atom &b) … … 333 337 mol = _mol; 334 338 if(!mol->containsAtom(this)){ 335 mol-> insert(this);339 mol->AddAtom(this); 336 340 } 337 341 }
Note:
See TracChangeset
for help on using the changeset viewer.
