Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r906822 rc550dd  
    99#include <cstring>
    1010#include <boost/bind.hpp>
     11#include <boost/foreach.hpp>
    1112
    1213#include "World.hpp"
     
    2728#include "tesselation.hpp"
    2829#include "vector.hpp"
     30#include "Matrix.hpp"
    2931#include "World.hpp"
     32#include "Box.hpp"
    3033#include "Plane.hpp"
    3134#include "Exceptions/LinearDependenceException.hpp"
     
    7982void molecule::setName(const std::string _name){
    8083  OBSERVE;
     84  cout << "Set name of molecule " << getId() << " to " << _name << endl;
    8185  strncpy(name,_name.c_str(),MAXSTRINGSIZE);
    8286}
     
    283287  Vector Orthovector1, Orthovector2;  // temporary vectors in coordination construction
    284288  Vector InBondvector;    // vector in direction of *Bond
    285   double *matrix = NULL;
     289  const Matrix &matrix =  World::getInstance().getDomain().getM();
    286290  bond *Binder = NULL;
    287   double * const cell_size = World::getInstance().getDomain();
    288291
    289292//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
     
    306309      } // (signs are correct, was tested!)
    307310    }
    308     matrix = ReturnFullMatrixforSymmetric(cell_size);
    309     Orthovector1.MatrixMultiplication(matrix);
     311    Orthovector1 *= matrix;
    310312    InBondvector -= Orthovector1; // subtract just the additional translation
    311     delete[](matrix);
    312313    bondlength = InBondvector.Norm();
    313314//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
     
    540541      break;
    541542  }
    542   delete[](matrix);
    543543
    544544//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     
    659659 * @param three vectors forming the matrix that defines the shape of the parallelpiped
    660660 */
    661 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {
     661molecule* molecule::CopyMoleculeFromSubRegion(const Shape &region) const {
    662662  molecule *copy = World::getInstance().createMolecule();
    663663
    664   ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped );
     664  BOOST_FOREACH(atom *iter,atoms){
     665    if(iter->IsInShape(region)){
     666      copy->AddCopyAtom(iter);
     667    }
     668  }
    665669
    666670  //TODO: copy->BuildInducedSubgraph(this);
     
    739743  else
    740744    length = strlen(molname) - strlen(endname);
     745  cout << "Set name of molecule " << getId() << " to " << molname << endl;
    741746  strncpy(name, molname, length);
    742747  name[length]='\0';
     
    748753void molecule::SetBoxDimension(Vector *dim)
    749754{
    750   double * const cell_size = World::getInstance().getDomain();
    751   cell_size[0] = dim->at(0);
    752   cell_size[1] = 0.;
    753   cell_size[2] = dim->at(1);
    754   cell_size[3] = 0.;
    755   cell_size[4] = 0.;
    756   cell_size[5] = dim->at(2);
     755  Matrix domain;
     756  for(int i =0; i<NDIM;++i)
     757    domain.at(i,i) = dim->at(i);
     758  World::getInstance().setDomain(domain);
    757759};
    758760
     
    847849bool molecule::CheckBounds(const Vector *x) const
    848850{
    849   double * const cell_size = World::getInstance().getDomain();
     851  const Matrix &domain = World::getInstance().getDomain().getM();
    850852  bool result = true;
    851   int j =-1;
    852853  for (int i=0;i<NDIM;i++) {
    853     j += i+1;
    854     result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j]));
     854    result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i)));
    855855  }
    856856  //return result;
     
    880880        ElementNo[i] = current++;
    881881    }
    882     ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
     882    ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );
    883883    return true;
    884884  }
     
    10031003  for(int i=MAX_ELEMENTS;i--;)
    10041004    ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
    1005 };
    1006 
    1007 
    1008 /** Counts necessary number of valence electrons and returns number and SpinType.
    1009  * \param configuration containing everything
    1010  */
    1011 void molecule::CalculateOrbitals(class config &configuration)
    1012 {
    1013   configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0;
    1014   for(int i=MAX_ELEMENTS;i--;) {
    1015     if (ElementsInMolecule[i] != 0) {
    1016       //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;
    1017       configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);
    1018     }
    1019   }
    1020   configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2);
    1021   configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2;
    1022   configuration.MaxPsiDouble /= 2;
    1023   configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;
    1024   if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) {
    1025     configuration.ProcPEGamma /= 2;
    1026     configuration.ProcPEPsi *= 2;
    1027   } else {
    1028     configuration.ProcPEGamma *= configuration.ProcPEPsi;
    1029     configuration.ProcPEPsi = 1;
    1030   }
    1031   cout << configuration.PsiMaxNoDown << ">" << configuration.PsiMaxNoUp << endl;
    1032   if (configuration.PsiMaxNoDown > configuration.PsiMaxNoUp) {
    1033     configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoDown;
    1034     cout << configuration.PsiMaxNoDown << " " << configuration.InitMaxMinStopStep << endl;
    1035   } else {
    1036     configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoUp;
    1037     cout << configuration.PsiMaxNoUp << " " << configuration.InitMaxMinStopStep << endl;
    1038   }
    10391005};
    10401006
Note: See TracChangeset for help on using the changeset viewer.