Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r822f01 rbf3817  
    55 */
    66
     7// include config.h
    78#ifdef HAVE_CONFIG_H
    89#include <config.h>
     
    2425#include "element.hpp"
    2526#include "graph.hpp"
    26 #include "helpers.hpp"
     27#include "Helpers/helpers.hpp"
    2728#include "leastsquaremin.hpp"
    2829#include "linkedcell.hpp"
    2930#include "lists.hpp"
    30 #include "log.hpp"
     31#include "Helpers/Log.hpp"
    3132#include "molecule.hpp"
    3233
     
    3435#include "stackclass.hpp"
    3536#include "tesselation.hpp"
    36 #include "vector.hpp"
    37 #include "Matrix.hpp"
     37#include "LinearAlgebra/Vector.hpp"
     38#include "LinearAlgebra/Matrix.hpp"
    3839#include "World.hpp"
    3940#include "Box.hpp"
    40 #include "Plane.hpp"
     41#include "LinearAlgebra/Plane.hpp"
    4142#include "Exceptions/LinearDependenceException.hpp"
    4243
     
    157158  atomIds.erase( atom->getId() );
    158159  atoms.remove( atom );
    159   formula-=atom->type;
     160  formula-=atom->getType();
    160161  atom->removeFromMolecule();
    161162  return iter;
     
    169170    atomIds.erase( key->getId() );
    170171    atoms.remove( key );
    171     formula-=key->type;
     172    formula-=key->getType();
    172173    key->removeFromMolecule();
    173174  }
     
    191192  if (res.second) { // push atom if went well
    192193    atoms.push_back(key);
    193     formula+=key->type;
     194    formula+=key->getType();
    194195    return pair<iterator,bool>(molecule::iterator(--end()),res.second);
    195196  } else {
     
    212213  if (pointer != NULL) {
    213214    pointer->sort = &pointer->nr;
    214     if (pointer->type != NULL) {
    215       formula += pointer->type;
    216       if (pointer->type->Z != 1)
     215    if (pointer->getType() != NULL) {
     216      formula += pointer->getType();
     217      if (pointer->getType()->Z != 1)
    217218        NoNonHydrogen++;
    218219      if(pointer->getName() == "Unknown"){
    219220        stringstream sstr;
    220         sstr << pointer->type->getSymbol() << pointer->nr+1;
     221        sstr << pointer->getType()->getSymbol() << pointer->nr+1;
    221222        pointer->setName(sstr.str());
    222223      }
     
    239240  if (pointer != NULL) {
    240241    atom *walker = pointer->clone();
    241     formula += walker->type;
     242    formula += walker->getType();
    242243    walker->setName(pointer->getName());
    243244    walker->nr = last_atom++;  // increase number within molecule
    244245    insert(walker);
    245     if ((pointer->type != NULL) && (pointer->type->Z != 1))
     246    if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1))
    246247      NoNonHydrogen++;
    247248    retval=walker;
     
    301302//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
    302303  // create vector in direction of bond
    303   InBondvector = TopReplacement->x - TopOrigin->x;
     304  InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition();
    304305  bondlength = InBondvector.Norm();
    305306
     
    313314    Orthovector1.Zero();
    314315    for (int i=NDIM;i--;) {
    315       l = TopReplacement->x[i] - TopOrigin->x[i];
     316      l = TopReplacement->at(i) - TopOrigin->at(i);
    316317      if (fabs(l) > BondDistance) { // is component greater than bond distance
    317318        Orthovector1[i] = (l < 0) ? -1. : +1.;
     
    328329  InBondvector.Normalize();
    329330  // get typical bond length and store as scale factor for later
    330   ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
    331   BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
     331  ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
     332  BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1];
    332333  if (BondRescale == -1) {
    333334    DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     
    343344    case 1:
    344345      FirstOtherAtom = World::getInstance().createAtom();    // new atom
    345       FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
    346       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     346      FirstOtherAtom->setType(1);  // element is Hydrogen
     347      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    347348      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    348       if (TopReplacement->type->Z == 1) { // neither rescale nor replace if it's already hydrogen
     349      if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen
    349350        FirstOtherAtom->father = TopReplacement;
    350351        BondRescale = bondlength;
     
    353354      }
    354355      InBondvector *= BondRescale;   // rescale the distance vector to Hydrogen bond length
    355       FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ...
    356       FirstOtherAtom->x += InBondvector;  // ... and add distance vector to replacement atom
     356      FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom
    357357      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    358358//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     
    387387        // determine the plane of these two with the *origin
    388388        try {
    389           Orthovector1 =Plane(TopOrigin->x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();
     389          Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal();
    390390        }
    391391        catch(LinearDependenceException &excp){
     
    408408      FirstOtherAtom = World::getInstance().createAtom();
    409409      SecondOtherAtom = World::getInstance().createAtom();
    410       FirstOtherAtom->type = elemente->FindElement(1);
    411       SecondOtherAtom->type = elemente->FindElement(1);
    412       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     410      FirstOtherAtom->setType(1);
     411      SecondOtherAtom->setType(1);
     412      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    413413      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    414       SecondOtherAtom->v = TopReplacement->v; // copy velocity
     414      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    415415      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    416416      FirstOtherAtom->father = NULL;  // we are just an added hydrogen with no father
    417417      SecondOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
    418       bondangle = TopOrigin->type->HBondAngle[1];
     418      bondangle = TopOrigin->getType()->HBondAngle[1];
    419419      if (bondangle == -1) {
    420420        DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     
    430430//      Log() << Verbose(0) << endl;
    431431//      Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
    432       FirstOtherAtom->x.Zero();
    433       SecondOtherAtom->x.Zero();
     432      FirstOtherAtom->Zero();
     433      SecondOtherAtom->Zero();
    434434      for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction)
    435         FirstOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));
    436         SecondOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));
    437       }
    438       FirstOtherAtom->x *= BondRescale;  // rescale by correct BondDistance
    439       SecondOtherAtom->x *= BondRescale;
     435        FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle)));
     436        SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle)));
     437      }
     438      FirstOtherAtom->Scale(BondRescale);  // rescale by correct BondDistance
     439      SecondOtherAtom->Scale(BondRescale);
    440440      //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
    441       for(int i=NDIM;i--;) { // and make relative to origin atom
    442         FirstOtherAtom->x[i] += TopOrigin->x[i];
    443         SecondOtherAtom->x[i] += TopOrigin->x[i];
    444       }
     441      *FirstOtherAtom += TopOrigin->getPosition();
     442      *SecondOtherAtom += TopOrigin->getPosition();
    445443      // ... and add to molecule
    446444      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
     
    464462      SecondOtherAtom = World::getInstance().createAtom();
    465463      ThirdOtherAtom = World::getInstance().createAtom();
    466       FirstOtherAtom->type = elemente->FindElement(1);
    467       SecondOtherAtom->type = elemente->FindElement(1);
    468       ThirdOtherAtom->type = elemente->FindElement(1);
    469       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     464      FirstOtherAtom->setType(1);
     465      SecondOtherAtom->setType(1);
     466      ThirdOtherAtom->setType(1);
     467      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    470468      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    471       SecondOtherAtom->v = TopReplacement->v; // copy velocity
     469      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    472470      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    473       ThirdOtherAtom->v = TopReplacement->v; // copy velocity
     471      ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    474472      ThirdOtherAtom->FixedIon = TopReplacement->FixedIon;
    475473      FirstOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
     
    494492
    495493      // create correct coordination for the three atoms
    496       alpha = (TopOrigin->type->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
     494      alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
    497495      l = BondRescale;        // desired bond length
    498496      b = 2.*l*sin(alpha);    // base length of isosceles triangle
     
    505503      factors[1] = f;
    506504      factors[2] = 0.;
    507       FirstOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     505      FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    508506      factors[1] = -0.5*f;
    509507      factors[2] = g;
    510       SecondOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     508      SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    511509      factors[2] = -g;
    512       ThirdOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     510      ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    513511
    514512      // rescale each to correct BondDistance
     
    518516
    519517      // and relative to *origin atom
    520       FirstOtherAtom->x += TopOrigin->x;
    521       SecondOtherAtom->x += TopOrigin->x;
    522       ThirdOtherAtom->x += TopOrigin->x;
     518      *FirstOtherAtom += TopOrigin->getPosition();
     519      *SecondOtherAtom += TopOrigin->getPosition();
     520      *ThirdOtherAtom += TopOrigin->getPosition();
    523521
    524522      // ... and add to molecule
     
    596594    *item >> x[1];
    597595    *item >> x[2];
    598     Walker->type = elemente->FindElement(shorthand);
    599     if (Walker->type == NULL) {
     596    Walker->setType(elemente->FindElement(shorthand));
     597    if (Walker->getType() == NULL) {
    600598      DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
    601       Walker->type = elemente->FindElement(1);
     599      Walker->setType(1);
    602600    }
    603601    if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) {
     
    606604      Walker->Trajectory.F.resize(MDSteps+10);
    607605    }
     606    Walker->setPosition(Vector(x));
    608607    for(j=NDIM;j--;) {
    609       Walker->x[j] = x[j];
    610608      Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
    611609      Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
     
    702700  atom1->RegisterBond(Binder);
    703701  atom2->RegisterBond(Binder);
    704   if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
     702  if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1))
    705703    NoNonBonds++;
    706704
     
    776774  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
    777775  OBSERVE;
    778   formula-=pointer->type;
     776  formula-=pointer->getType();
    779777  RemoveBonds(pointer);
    780778  erase(pointer);
     
    790788  if (pointer == NULL)
    791789    return false;
    792   formula-=pointer->type;
     790  formula-=pointer->getType();
    793791  erase(pointer);
    794792  return true;
     
    972970  for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
    973971    (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    974     if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
     972    if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it
    975973      NoNonHydrogen++;
    976974    stringstream sstr;
    977     sstr << (*iter)->type->getSymbol() << (*iter)->nr+1;
     975    sstr << (*iter)->getType()->getSymbol() << (*iter)->nr+1;
    978976    (*iter)->setName(sstr.str());
    979977    DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
Note: See TracChangeset for help on using the changeset viewer.