Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r952f38 rd74077  
    2424#include "element.hpp"
    2525#include "graph.hpp"
    26 #include "Helpers/helpers.hpp"
     26#include "helpers.hpp"
    2727#include "leastsquaremin.hpp"
    2828#include "linkedcell.hpp"
    2929#include "lists.hpp"
    30 #include "Helpers/Log.hpp"
     30#include "log.hpp"
    3131#include "molecule.hpp"
    3232
     
    3434#include "stackclass.hpp"
    3535#include "tesselation.hpp"
    36 #include "LinearAlgebra/Vector.hpp"
    37 #include "LinearAlgebra/Matrix.hpp"
     36#include "vector.hpp"
     37#include "Matrix.hpp"
    3838#include "World.hpp"
    3939#include "Box.hpp"
    40 #include "LinearAlgebra/Plane.hpp"
     40#include "Plane.hpp"
    4141#include "Exceptions/LinearDependenceException.hpp"
    4242
     
    206206  if (pointer != NULL) {
    207207    pointer->sort = &pointer->nr;
    208     if (pointer->type != NULL) {
    209       formula += pointer->type;
    210       if (pointer->type->Z != 1)
     208    if (pointer->getType() != NULL) {
     209      formula += pointer->getType();
     210      if (pointer->getType()->Z != 1)
    211211        NoNonHydrogen++;
    212212      if(pointer->getName() == "Unknown"){
    213213        stringstream sstr;
    214         sstr << pointer->type->symbol << pointer->nr+1;
     214        sstr << pointer->getType()->symbol << pointer->nr+1;
    215215        pointer->setName(sstr.str());
    216216      }
     
    236236    walker->nr = last_atom++;  // increase number within molecule
    237237    insert(walker);
    238     if ((pointer->type != NULL) && (pointer->type->Z != 1))
     238    if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1))
    239239      NoNonHydrogen++;
    240240    retval=walker;
     
    294294//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
    295295  // create vector in direction of bond
    296   InBondvector = TopReplacement->x - TopOrigin->x;
     296  InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition();
    297297  bondlength = InBondvector.Norm();
    298298
     
    306306    Orthovector1.Zero();
    307307    for (int i=NDIM;i--;) {
    308       l = TopReplacement->x[i] - TopOrigin->x[i];
     308      l = TopReplacement->at(i) - TopOrigin->at(i);
    309309      if (fabs(l) > BondDistance) { // is component greater than bond distance
    310310        Orthovector1[i] = (l < 0) ? -1. : +1.;
     
    321321  InBondvector.Normalize();
    322322  // get typical bond length and store as scale factor for later
    323   ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
    324   BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
     323  ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
     324  BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1];
    325325  if (BondRescale == -1) {
    326326    DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     
    336336    case 1:
    337337      FirstOtherAtom = World::getInstance().createAtom();    // new atom
    338       FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
    339       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     338      FirstOtherAtom->setType(1);  // element is Hydrogen
     339      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    340340      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    341       if (TopReplacement->type->Z == 1) { // neither rescale nor replace if it's already hydrogen
     341      if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen
    342342        FirstOtherAtom->father = TopReplacement;
    343343        BondRescale = bondlength;
     
    346346      }
    347347      InBondvector *= BondRescale;   // rescale the distance vector to Hydrogen bond length
    348       FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ...
    349       FirstOtherAtom->x += InBondvector;  // ... and add distance vector to replacement atom
     348      FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom
    350349      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    351350//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     
    380379        // determine the plane of these two with the *origin
    381380        try {
    382           Orthovector1 =Plane(TopOrigin->x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();
     381          Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal();
    383382        }
    384383        catch(LinearDependenceException &excp){
     
    401400      FirstOtherAtom = World::getInstance().createAtom();
    402401      SecondOtherAtom = World::getInstance().createAtom();
    403       FirstOtherAtom->type = elemente->FindElement(1);
    404       SecondOtherAtom->type = elemente->FindElement(1);
    405       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     402      FirstOtherAtom->setType(1);
     403      SecondOtherAtom->setType(1);
     404      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    406405      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    407       SecondOtherAtom->v = TopReplacement->v; // copy velocity
     406      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    408407      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    409408      FirstOtherAtom->father = NULL;  // we are just an added hydrogen with no father
    410409      SecondOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
    411       bondangle = TopOrigin->type->HBondAngle[1];
     410      bondangle = TopOrigin->getType()->HBondAngle[1];
    412411      if (bondangle == -1) {
    413412        DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     
    423422//      Log() << Verbose(0) << endl;
    424423//      Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
    425       FirstOtherAtom->x.Zero();
    426       SecondOtherAtom->x.Zero();
     424      FirstOtherAtom->Zero();
     425      SecondOtherAtom->Zero();
    427426      for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction)
    428         FirstOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));
    429         SecondOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));
    430       }
    431       FirstOtherAtom->x *= BondRescale;  // rescale by correct BondDistance
    432       SecondOtherAtom->x *= BondRescale;
     427        FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle)));
     428        SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle)));
     429      }
     430      FirstOtherAtom->Scale(BondRescale);  // rescale by correct BondDistance
     431      SecondOtherAtom->Scale(BondRescale);
    433432      //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
    434       for(int i=NDIM;i--;) { // and make relative to origin atom
    435         FirstOtherAtom->x[i] += TopOrigin->x[i];
    436         SecondOtherAtom->x[i] += TopOrigin->x[i];
    437       }
     433      *FirstOtherAtom += TopOrigin->getPosition();
     434      *SecondOtherAtom += TopOrigin->getPosition();
    438435      // ... and add to molecule
    439436      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
     
    457454      SecondOtherAtom = World::getInstance().createAtom();
    458455      ThirdOtherAtom = World::getInstance().createAtom();
    459       FirstOtherAtom->type = elemente->FindElement(1);
    460       SecondOtherAtom->type = elemente->FindElement(1);
    461       ThirdOtherAtom->type = elemente->FindElement(1);
    462       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     456      FirstOtherAtom->setType(1);
     457      SecondOtherAtom->setType(1);
     458      ThirdOtherAtom->setType(1);
     459      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    463460      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    464       SecondOtherAtom->v = TopReplacement->v; // copy velocity
     461      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    465462      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    466       ThirdOtherAtom->v = TopReplacement->v; // copy velocity
     463      ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    467464      ThirdOtherAtom->FixedIon = TopReplacement->FixedIon;
    468465      FirstOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
     
    487484
    488485      // create correct coordination for the three atoms
    489       alpha = (TopOrigin->type->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
     486      alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
    490487      l = BondRescale;        // desired bond length
    491488      b = 2.*l*sin(alpha);    // base length of isosceles triangle
     
    498495      factors[1] = f;
    499496      factors[2] = 0.;
    500       FirstOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     497      FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    501498      factors[1] = -0.5*f;
    502499      factors[2] = g;
    503       SecondOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     500      SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    504501      factors[2] = -g;
    505       ThirdOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     502      ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    506503
    507504      // rescale each to correct BondDistance
     
    511508
    512509      // and relative to *origin atom
    513       FirstOtherAtom->x += TopOrigin->x;
    514       SecondOtherAtom->x += TopOrigin->x;
    515       ThirdOtherAtom->x += TopOrigin->x;
     510      *FirstOtherAtom += TopOrigin->getPosition();
     511      *SecondOtherAtom += TopOrigin->getPosition();
     512      *ThirdOtherAtom += TopOrigin->getPosition();
    516513
    517514      // ... and add to molecule
     
    589586    *item >> x[1];
    590587    *item >> x[2];
    591     Walker->type = elemente->FindElement(shorthand);
    592     if (Walker->type == NULL) {
     588    Walker->setType(elemente->FindElement(shorthand));
     589    if (Walker->getType() == NULL) {
    593590      DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
    594       Walker->type = elemente->FindElement(1);
     591      Walker->setType(1);
    595592    }
    596593    if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) {
     
    599596      Walker->Trajectory.F.resize(MDSteps+10);
    600597    }
     598    Walker->setPosition(Vector(x));
    601599    for(j=NDIM;j--;) {
    602       Walker->x[j] = x[j];
    603600      Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
    604601      Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
     
    694691  atom1->RegisterBond(Binder);
    695692  atom2->RegisterBond(Binder);
    696   if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
     693  if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1))
    697694    NoNonBonds++;
    698695
     
    768765  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
    769766  OBSERVE;
    770   formula-=pointer->type;
     767  formula-=pointer->getType();
    771768  RemoveBonds(pointer);
    772769  erase(pointer);
     
    782779  if (pointer == NULL)
    783780    return false;
    784   formula-=pointer->type;
     781  formula-=pointer->getType();
    785782  erase(pointer);
    786783  return true;
     
    969966  for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
    970967    (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    971     if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
     968    if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it
    972969      NoNonHydrogen++;
    973970    stringstream sstr;
    974     sstr << (*iter)->type->symbol << (*iter)->nr+1;
     971    sstr << (*iter)->getType()->symbol << (*iter)->nr+1;
    975972    (*iter)->setName(sstr.str());
    976973    DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
Note: See TracChangeset for help on using the changeset viewer.