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