Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r2fe971 r97b825  
    1313#include "lists.hpp"
    1414#include "parser.hpp"
    15 #include "vector.hpp"
     15#include "LinearAlgebra/Vector.hpp"
    1616#include "World.hpp"
    1717#include "molecule.hpp"
     
    2727 */
    2828atom::atom() :
    29   father(this), sort(&nr), mol(0)
    30 {
    31   node = &x;  // TesselPoint::x can only be referenced from here
    32 };
     29  father(this),
     30  sort(&nr),
     31  mol(0)
     32{};
    3333
    3434/** Constructor of class atom.
    3535 */
    3636atom::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
    4244  FixedIon = pointer->FixedIon;
    43   node = &x;
    4445  mol = 0;
    4546};
     
    4950  res->father = this;
    5051  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;
    5455  res->FixedIon = FixedIon;
    55   res->node = &x;
    5656  res->mol = 0;
    5757  World::getInstance().registerAtom(res);
     
    121121bool atom::IsInShape(const Shape& shape) const
    122122{
    123   return shape.isInside(*node);
     123  return shape.isInside(getPosition());
    124124};
    125125
     
    146146  if (out != NULL) {
    147147    *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);
    149149    *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";
    152152    if (comment != NULL)
    153153      *out << " # " << comment << endl;
     
    168168bool atom::OutputArrayIndexed(ostream * const out,const enumeration<const element*> &elementLookup, int *AtomNo, const char *comment) const
    169169{
    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);
    176177    *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";
    179180    if (comment != NULL)
    180181      *out << " # " << comment << endl;
     
    193194{
    194195  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;
    196197    return true;
    197198  } else
     
    208209bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const
    209210{
    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;
    213214    *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
    214215    *out << "\t" << FixedIon;
     
    231232{
    232233  if (out != NULL) {
    233     *out << type->getSymbol() << "\t";
     234    *out << getType()->symbol << "\t";
    234235    *out << Trajectory.R.at(step)[0] << "\t";
    235236    *out << Trajectory.R.at(step)[1] << "\t";
     
    247248void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
    248249{
    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;
    250253  if (AtomNo != NULL)
    251254    *AtomNo++;
     
    270273double atom::DistanceSquaredToVector(const Vector &origin) const
    271274{
    272   return origin.DistanceSquared(x);
     275  return DistanceSquared(origin);
    273276};
    274277
     
    279282double atom::DistanceToVector(const Vector &origin) const
    280283{
    281   return origin.distance(x);
     284  return distance(origin);
    282285};
    283286
     
    294297};
    295298
     299std::ostream & atom::operator << (std::ostream &ost) const
     300{
     301  ParticleInfo::operator<<(ost);
     302  ost << "," << getPosition();
     303  return ost;
     304}
     305
     306std::ostream & operator << (std::ostream &ost, const atom &a)
     307{
     308  a.ParticleInfo::operator<<(ost);
     309  ost << "," << a.getPosition();
     310  return ost;
     311}
    296312
    297313bool operator < (atom &a, atom &b)
     
    333349  mol = _mol;
    334350  if(!mol->containsAtom(this)){
    335     mol->AddAtom(this);
     351    mol->insert(this);
    336352  }
    337353}
Note: See TracChangeset for help on using the changeset viewer.