Changes in src/atom.cpp [49f802c:d3dfe18]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/atom.cpp
-
Property mode
changed from
100755
to100644
r49f802c rd3dfe18 6 6 7 7 #include "atom.hpp" 8 #include "bond.hpp"9 #include "element.hpp"10 8 #include "memoryallocator.hpp" 11 #include "vector.hpp"12 9 13 10 /************************************* Functions for class atom *************************************/ … … 65 62 atom::~atom() 66 63 { 67 Free<int>(&ComponentNr, "atom::~atom: *ComponentNr"); 68 Free<char>(&Name, "atom::~atom: *Name"); 69 Trajectory.R.clear(); 70 Trajectory.U.clear(); 71 Trajectory.F.clear(); 64 Free(&ComponentNr); 72 65 }; 73 66 … … 87 80 }; 88 81 89 /** Sets father to itself or its father in case of copying a molecule.90 */91 void atom::CorrectFather()92 {93 if (father->father == father) // same atom in copy's father points to itself94 father = this; // set father to itself (copy of a whole molecule)95 else96 father = father->father; // set father to original's father97 98 };99 100 /** Check whether father is equal to given atom.101 * \param *ptr atom to compare father to102 * \param **res return value (only set if atom::father is equal to \a *ptr)103 */104 void atom::EqualsFather ( atom *ptr, atom **res )105 {106 if ( ptr == father )107 *res = this;108 };109 110 /** Checks whether atom is within the given box.111 * \param offset offset to box origin112 * \param *parallelepiped box matrix113 * \return true - is inside, false - is not114 */115 bool atom::IsInParallelepiped(Vector offset, double *parallelepiped)116 {117 return (node->IsInParallelepiped(offset, parallelepiped));118 };119 120 82 /** Output of a single atom. 121 83 * \param ElementNo cardinal number of the element … … 123 85 * \param *out stream to output to 124 86 * \param *comment commentary after '#' sign 125 * \return true - \a *out present, false - \a *out is NULL126 87 */ 127 bool atom::Output( ofstream *out, int ElementNo, int AtomNo, const char *comment) const88 bool atom::Output(int ElementNo, int AtomNo, ofstream *out, const char *comment) const 128 89 { 129 90 if (out != NULL) { … … 141 102 return false; 142 103 }; 143 bool atom::Output(ofstream *out, int *ElementNo, int *AtomNo, const char *comment)144 {145 AtomNo[type->Z]++; // increment number146 if (out != NULL) {147 *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint;148 *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];149 *out << "\t" << FixedIon;150 if (v.Norm() > MYEPSILON)151 *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t";152 if (comment != NULL)153 *out << " # " << comment << endl;154 else155 *out << " # molecule nr " << nr << endl;156 return true;157 } else158 return false;159 };160 104 161 105 /** Output of a single atom as one lin in xyz file. 162 106 * \param *out stream to output to 163 * \return true - \a *out present, false - \a *out is NULL164 107 */ 165 108 bool atom::OutputXYZLine(ofstream *out) const … … 167 110 if (out != NULL) { 168 111 *out << type->symbol << "\t" << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2] << "\t" << endl; 169 return true;170 } else171 return false;172 };173 174 /** Output of a single atom as one lin in xyz file.175 * \param *out stream to output to176 * \param *ElementNo array with ion type number in the config file this atom's element shall have177 * \param *AtomNo array with atom number in the config file this atom shall have, is increase by one automatically178 * \param step Trajectory time step to output179 * \return true - \a *out present, false - \a *out is NULL180 */181 bool atom::OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const182 {183 AtomNo[type->Z]++;184 if (out != NULL) {185 *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t" << fixed << setprecision(9) << showpoint;186 *out << Trajectory.R.at(step).x[0] << "\t" << Trajectory.R.at(step).x[1] << "\t" << Trajectory.R.at(step).x[2];187 *out << "\t" << FixedIon;188 if (Trajectory.U.at(step).Norm() > MYEPSILON)189 *out << "\t" << scientific << setprecision(6) << Trajectory.U.at(step).x[0] << "\t" << Trajectory.U.at(step).x[1] << "\t" << Trajectory.U.at(step).x[2] << "\t";190 if (Trajectory.F.at(step).Norm() > MYEPSILON)191 *out << "\t" << scientific << setprecision(6) << Trajectory.F.at(step).x[0] << "\t" << Trajectory.F.at(step).x[1] << "\t" << Trajectory.F.at(step).x[2] << "\t";192 *out << "\t# Number in molecule " << nr << endl;193 return true;194 } else195 return false;196 };197 198 /** Output of a single atom as one lin in xyz file.199 * \param *out stream to output to200 * \param step Trajectory time step to output201 * \return true - \a *out present, false - \a *out is NULL202 */203 bool atom::OutputTrajectoryXYZ(ofstream *out, int step) const204 {205 if (out != NULL) {206 *out << type->symbol << "\t";207 *out << Trajectory.R.at(step).x[0] << "\t";208 *out << Trajectory.R.at(step).x[1] << "\t";209 *out << Trajectory.R.at(step).x[2] << endl;210 return true;211 } else212 return false;213 };214 215 /** Prints all bonds of this atom from given global lists.216 * \param *out stream to output to217 * \param *NumberOfBondsPerAtom array with number of bonds per atomic index218 * \param ***ListOfBondsPerAtom array per atomic index of array with pointer to bond219 * \return true - \a *out present, false - \a *out is NULL220 */221 bool atom::OutputBondOfAtom(ofstream *out, int *NumberOfBondsPerAtom, bond ***ListOfBondsPerAtom) const222 {223 if (out != NULL) {224 #ifdef ADDHYDROGEN225 if (type->Z != 1) { // regard only non-hydrogen226 #endif227 *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << NumberOfBondsPerAtom[nr] << " bonds: ";228 int TotalDegree = 0;229 for (int j=0;j<NumberOfBondsPerAtom[nr];j++) {230 *out << *ListOfBondsPerAtom[nr][j] << "\t";231 TotalDegree += ListOfBondsPerAtom[nr][j]->BondDegree;232 }233 *out << " -- TotalDegree: " << TotalDegree << endl;234 #ifdef ADDHYDROGEN235 }236 #endif237 112 return true; 238 113 } else … … 264 139 }; 265 140 266 /** Returns squared distance to a given vector.267 * \param origin vector to calculate distance to268 * \return distance squared269 */270 double atom::DistanceSquaredToVector(Vector &origin)271 {272 return origin.DistanceSquared(&x);273 };274 275 /** Adds kinetic energy of this atom to given temperature value.276 * \param *temperature add on this value277 * \param step given step of trajectory to add278 */279 void atom::AddKineticToTemperature(double *temperature, int step) const280 {281 for (int i=NDIM;i--;)282 *temperature += type->mass * Trajectory.U.at(step).x[i]* Trajectory.U.at(step).x[i];283 };284 285 /** Returns distance to a given vector.286 * \param origin vector to calculate distance to287 * \return distance288 */289 double atom::DistanceToVector(Vector &origin)290 {291 return origin.Distance(&x);292 };293 294 141 bool operator < (atom &a, atom &b) 295 142 { -
Property mode
changed from
Note:
See TracChangeset
for help on using the changeset viewer.