Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    rdddbfe rd74077  
    1313#include "lists.hpp"
    1414#include "parser.hpp"
    15 #include "LinearAlgebra/Vector.hpp"
     15#include "vector.hpp"
    1616#include "World.hpp"
    1717#include "molecule.hpp"
     
    1919
    2020#include <iomanip>
    21 #include <iostream>
    2221
    2322/************************************* Functions for class atom *************************************/
     
    2827atom::atom() :
    2928  father(this), sort(&nr), mol(0)
    30 {
    31   node = &x;  // TesselPoint::x can only be referenced from here
    32 };
     29{};
    3330
    3431/** Constructor of class atom.
     
    3734    ParticleInfo(pointer),father(pointer), sort(&nr)
    3835{
    39   type = pointer->type;  // copy element of atom
    40   x = pointer->x; // copy coordination
    41   v = pointer->v; // copy velocity
     36  setType(pointer->getType());  // copy element of atom
     37  setPosition(pointer->getPosition()); // copy coordination
     38  AtomicVelocity = pointer->AtomicVelocity; // copy velocity
    4239  FixedIon = pointer->FixedIon;
    43   node = &x;
    4440  mol = 0;
    4541};
     
    4945  res->father = this;
    5046  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;
    5450  res->FixedIon = FixedIon;
    55   res->node = &x;
    5651  res->mol = 0;
    5752  World::getInstance().registerAtom(res);
     
    110105};
    111106
    112 bool atom::isFather(const atom *ptr){
    113   return ptr==father;
    114 }
    115 
    116107/** Checks whether atom is within the given box.
    117108 * \param offset offset to box origin
     
    121112bool atom::IsInShape(const Shape& shape) const
    122113{
    123   return shape.isInside(*node);
     114  return shape.isInside(getPosition());
    124115};
    125116
     
    146137  if (out != NULL) {
    147138    *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);
    149140    *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";
    152143    if (comment != NULL)
    153144      *out << " # " << comment << endl;
     
    166157  * \return true - \a *out present, false - \a *out is NULL
    167158 */
    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];
     159bool 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);
    176165    *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";
    179168    if (comment != NULL)
    180169      *out << " # " << comment << endl;
     
    193182{
    194183  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;
    196185    return true;
    197186  } else
     
    208197bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const
    209198{
    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;
    213202    *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
    214203    *out << "\t" << FixedIon;
     
    231220{
    232221  if (out != NULL) {
    233     *out << type->symbol << "\t";
     222    *out << getType()->symbol << "\t";
    234223    *out << Trajectory.R.at(step)[0] << "\t";
    235224    *out << Trajectory.R.at(step)[1] << "\t";
     
    247236void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
    248237{
    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;
    250241  if (AtomNo != NULL)
    251242    *AtomNo++;
     
    270261double atom::DistanceSquaredToVector(const Vector &origin) const
    271262{
    272   return origin.DistanceSquared(x);
     263  return DistanceSquared(origin);
    273264};
    274265
     
    279270double atom::DistanceToVector(const Vector &origin) const
    280271{
    281   return origin.distance(x);
     272  return distance(origin);
    282273};
    283274
     
    294285};
    295286
     287std::ostream & atom::operator << (std::ostream &ost) const
     288{
     289  ParticleInfo::operator<<(ost);
     290  ost << "," << getPosition();
     291  return ost;
     292}
     293
     294std::ostream & operator << (std::ostream &ost, const atom &a)
     295{
     296  a.ParticleInfo::operator<<(ost);
     297  ost << "," << a.getPosition();
     298  return ost;
     299}
    296300
    297301bool operator < (atom &a, atom &b)
     
    333337  mol = _mol;
    334338  if(!mol->containsAtom(this)){
    335     mol->insert(this);
     339    mol->AddAtom(this);
    336340  }
    337341}
Note: See TracChangeset for help on using the changeset viewer.