Changeset 6625c3 for src


Ignore:
Timestamp:
Feb 24, 2011, 5:46:46 PM (14 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
056e70
Parents:
54b42e
git-author:
Frederik Heber <heber@…> (02/24/11 11:18:59)
git-committer:
Frederik Heber <heber@…> (02/24/11 17:46:46)
Message:

Removed atom_trajectoryparticle*, replaced by AtomInfo class now having std::vector<> for trajectories.

AtomInfo:

Other changes:

  • gsl_rng_gaussian() exchanged by boost::random specific type.
Location:
src
Files:
4 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • src/AtomSet.hpp

    r54b42e r6625c3  
    8282  template<class T>
    8383  struct valueSum {
    84     valueSum(T (atom::*_f)() const,T startValue) :
     84    valueSum(T (AtomInfo::*_f)() const,T startValue) :
    8585      f(_f),
    8686      value(startValue)
    8787    {}
    88     T operator+(atom *atom){
     88    T operator+(AtomInfo *atom){
    8989      return value + (atom->*f)();
    9090    }
     
    9393      return value;
    9494    }
    95     T (atom::*f)() const;
     95    T (AtomInfo::*f)() const;
    9696    T value;
    9797  };
     
    9999  template<class T>
    100100  struct stepValueSum {
    101     stepValueSum(unsigned int _step, T (atom::*_f)(unsigned int) const,T startValue) :
     101    stepValueSum(unsigned int _step, T (AtomInfo::*_f)(unsigned int) const,T startValue) :
    102102      step(_step),
    103103      f(_f),
    104104      value(startValue)
    105105    {}
    106     T operator+(atom *atom){
     106    T operator+(AtomInfo *atom){
    107107      return value + (atom->*f)(step);
    108108    }
     
    112112    }
    113113    unsigned int step;
    114     T (atom::*f)(unsigned int) const;
     114    T (AtomInfo::*f)(unsigned int) const;
    115115    T value;
    116116  };
     
    119119template<class Set>
    120120inline void AtomSetMixin<Set>::translate(const Vector &translater){
    121   BOOST_FOREACH(atom *atom,*this){
     121  BOOST_FOREACH(AtomInfo *atom,*this){
    122122    *(atom) += translater;
    123123  }
     
    126126template<class Set>
    127127inline void AtomSetMixin<Set>::addVelocityAtStep(const Vector velocity, unsigned int step){
    128   BOOST_FOREACH(atom *atom,*this){
    129     atom->Trajectory.U.at(step) += velocity;
     128  BOOST_FOREACH(AtomInfo *atom,*this){
     129    atom->getAtomicVelocity(step) += velocity;
    130130  }
    131131}
     
    141141template<class Set>
    142142inline double AtomSetMixin<Set>::totalMass() const{
    143   return accumulate(this->begin(),this->end(),valueSum<double>(&atom::getMass,0)).value;
     143  return accumulate(this->begin(),this->end(),valueSum<double>(&AtomInfo::getMass,0)).value;
    144144}
    145145
    146146template<class Set>
    147147inline double AtomSetMixin<Set>::totalTemperatureAtStep(unsigned int step) const{
    148   return accumulate(this->begin(),this->end(),stepValueSum<double>(step,&atom::getKineticEnergy,0)).value;
     148  return accumulate(this->begin(),this->end(),stepValueSum<double>(step,&AtomInfo::getKineticEnergy,0)).value;
    149149}
    150150
    151151template<class Set>
    152152inline Vector AtomSetMixin<Set>::totalMomentumAtStep(unsigned int step) const{
    153   return accumulate(this->begin(),this->end(),stepValueSum<Vector>(step,&atom::getMomentum,Vector())).value;
     153  return accumulate(this->begin(),this->end(),stepValueSum<Vector>(step,&AtomInfo::getMomentum,Vector())).value;
    154154}
    155155
  • src/Makefile.am

    r54b42e r6625c3  
    2121  atom_graphnode.cpp \
    2222  atom_graphnodeinfo.cpp \
    23   atom_particleinfo.cpp \
    24   atom_trajectoryparticle.cpp \
    25   atom_trajectoryparticleinfo.cpp
     23  atom_particleinfo.cpp
    2624ATOMHEADER = \
    2725  atom.hpp \
     
    3230  atom_graphnode.hpp \
    3331  atom_graphnodeinfo.hpp \
    34   atom_particleinfo.hpp \
    35   atom_trajectoryparticle.hpp \
    36   atom_trajectoryparticleinfo.hpp
     32  atom_particleinfo.hpp
    3733
    3834ANALYSISSOURCE = \
  • src/Parser/PcpParser.cpp

    r54b42e r6625c3  
    557557    *file << "Ion_Type" << ZtoIndexMap[Z] << "_" << ZtoCountMap[Z] << "\t"  << fixed << setprecision(9) << showpoint;
    558558    *file << (*AtomRunner)->at(0) << "\t" << (*AtomRunner)->at(1) << "\t" << (*AtomRunner)->at(2);
    559     *file << "\t" << (*AtomRunner)->FixedIon;
     559    *file << "\t" << (int)((*AtomRunner)->getFixedIon());
    560560    if ((*AtomRunner)->getAtomicVelocity().Norm() > MYEPSILON)
    561561      *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->getAtomicVelocity()[0] << "\t" << (*AtomRunner)->getAtomicVelocity()[1] << "\t" << (*AtomRunner)->getAtomicVelocity()[2] << "\t";
  • src/Thermostats/Berendsen.cpp

    r54b42e r6625c3  
    6363  double ScaleTempFactor = getContainer().TargetTemp/ActualTemp;
    6464  for(ForwardIterator iter=begin;iter!=end;++iter){
    65     Vector &U = (*iter)->Trajectory.U.at(step);
    66     if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
     65    Vector &U = (*iter)->getAtomicVelocity(step);
     66    if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces
    6767      U *= sqrt(1+(World::getInstance().getConfig()->Deltat/TempFrequency)*(ScaleTempFactor-1));
    6868      ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared();
  • src/Thermostats/GaussianThermostat.cpp

    r54b42e r6625c3  
    7070  double ekin =0;
    7171  for(ForwardIterator iter=begin;iter!=end;++iter){
    72     Vector &U = (*iter)->Trajectory.U.at(step);
    73     if ((*iter)->FixedIon == 0) {// even FixedIon moves, only not by other's forces
     72    Vector &U = (*iter)->getAtomicVelocity(step);
     73    if ((*iter)->getFixedIon() == 0) {// even FixedIon moves, only not by other's forces
    7474      U += World::getInstance().getConfig()->Deltat * G_over_E * U;
    7575      ekin += (*iter)->getType()->getMass() * U.NormSquared();
     
    8484  G=0;
    8585  for(ForwardIterator iter=begin;iter!=end;++iter){
    86     Vector &U = (*iter)->Trajectory.U.at(step);
    87     Vector &F = (*iter)->Trajectory.F.at(step);
    88     if ((*iter)->FixedIon == 0){ // even FixedIon moves, only not by other's forces
     86    const Vector &U = (*iter)->getAtomicVelocity(step);
     87    const Vector &F = (*iter)->getAtomicForce(step);
     88    if ((*iter)->getFixedIon() == 0){ // even FixedIon moves, only not by other's forces
    8989      G += U.ScalarProduct(F);
    9090      E += U.NormSquared()*(*iter)->getType()->getMass();
  • src/Thermostats/Langevin.cpp

    r54b42e r6625c3  
    2020#include "ThermoStatContainer.hpp"
    2121
     22#include <boost/random/mersenne_twister.hpp>
     23#include <boost/random/normal_distribution.hpp>
     24#include <boost/random/variate_generator.hpp>
     25
    2226#include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
    2327#include "RandomNumbers/RandomNumberGenerator.hpp"
     
    2529Langevin::Langevin(double _TempFrequency,double _alpha) :
    2630  TempFrequency(_TempFrequency),
    27   alpha(_alpha)
    28 {
    29   gsl_rng_env_setup();
    30   T = gsl_rng_default;
    31   r = gsl_rng_alloc (T);
    32 }
     31  alpha(_alpha),
     32  rng_engine(new boost::mt19937),
     33  rng_distribution(NULL)
     34{}
    3335
    3436Langevin::Langevin() :
    3537  TempFrequency(2.5),
    36   alpha(0.)
     38  alpha(0.),
     39  rng_engine(new boost::mt19937),
     40  rng_distribution(NULL)
    3741{}
    3842
    3943Langevin::~Langevin()
    4044{
    41   gsl_rng_free (r);
     45  delete rng_engine;
     46  delete rng_distribution;
    4247}
    4348
     
    7681double Langevin::doScaleAtoms(unsigned int step,double ActualTemp,ForwardIterator begin, ForwardIterator end){
    7782  DoLog(2) && (Log() << Verbose(2) <<  "Applying Langevin thermostat..." << endl);
    78   RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();
     83  RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator("mt19937", "normal_distribution");
    7984  const double rng_min = random.min();
    8085  const double rng_max = random.max();
     
    8287  for(ForwardIterator iter=begin;iter!=end;++iter){
    8388    double sigma  = sqrt(getContainer().TargetTemp/(*iter)->getType()->getMass()); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
    84     Vector &U = (*iter)->Trajectory.U.at(step);
    85     if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
     89    rng_distribution = new boost::normal_distribution<>(0,sigma);
     90    boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > rng(*rng_engine, *rng_distribution);
     91    Vector &U = (*iter)->getAtomicVelocity(step);
     92    if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces
    8693      // throw a dice to determine whether it gets hit by a heat bath particle
    8794      if (((((random()/(rng_max-rng_min)))*TempFrequency) < 1.)) {
     
    8996        // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
    9097        for (int d=0; d<NDIM; d++) {
    91           U[d] = gsl_ran_gaussian (r, sigma);
     98          U[d] = rng();
    9299        }
    93100        DoLog(2) && (Log() << Verbose(2) << U.Norm() << endl);
     
    95102      ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared();
    96103    }
     104    delete rng_distribution;
     105    rng_distribution = NULL;
    97106  }
    98107  return ekin;
  • src/Thermostats/Langevin.hpp

    r54b42e r6625c3  
    1414#endif
    1515
     16#include "Thermostats/Thermostat.hpp"
    1617
    17 #include "Thermostats/Thermostat.hpp"
     18#include <boost/random/mersenne_twister.hpp>
     19#include <boost/random/normal_distribution.hpp>
    1820
    1921class Langevin : public Thermostat
     
    3840  double TempFrequency;
    3941  double alpha;
    40   gsl_rng * r;
    41   const gsl_rng_type * T;
     42
     43  boost::mt19937 *rng_engine;
     44  boost::normal_distribution<> *rng_distribution;
    4245};
    4346
  • src/Thermostats/NoseHoover.cpp

    r54b42e r6625c3  
    6868  double ekin =0;
    6969  for(ForwardIterator iter=begin;iter!=end;++iter){
    70     Vector &U = (*iter)->Trajectory.U.at(step);
    71     if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
     70    Vector &U = (*iter)->getAtomicVelocity(step);
     71    if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces
    7272      U += World::getInstance().getConfig()->Deltat/(*iter)->getType()->getMass() * (alpha * (U * (*iter)->getType()->getMass()));
    7373      ekin += (0.5*(*iter)->getType()->getMass()) * U.NormSquared();
     
    8282  count=0;
    8383  for(ForwardIterator iter = begin;iter!=end;++iter){
    84     Vector &U = (*iter)->Trajectory.U.at(step);
    85     if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
     84    const Vector &U = (*iter)->getAtomicVelocity(step);
     85    if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces
    8686      delta_alpha += U.NormSquared()*(*iter)->getType()->getMass();
    8787    }
  • src/Thermostats/Woodcock.cpp

    r54b42e r6625c3  
    6767    double ekin;
    6868    for (ForwardIterator iter = begin; iter!=end;++iter){
    69       Vector &U = (*iter)->Trajectory.U.at(step);
    70       if ((*iter)->FixedIon == 0){ // even FixedIon moves, only not by other's forces
     69      Vector &U = (*iter)->getAtomicVelocity(step);
     70      if ((*iter)->getFixedIon() == 0){ // even FixedIon moves, only not by other's forces
    7171        U *= ScaleTempFactor;
    7272        ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared();
  • src/atom.cpp

    r54b42e r6625c3  
    5555  setPosition(pointer->getPosition()); // copy coordination
    5656  setAtomicVelocity(pointer->getAtomicVelocity()); // copy velocity
    57   FixedIon = pointer->FixedIon;
     57  setFixedIon(pointer->getFixedIon());
    5858};
    5959
     
    152152    *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
    153153    *out << at(0) << "\t" << at(1) << "\t" << at(2);
    154     *out << "\t" << FixedIon;
     154    *out << "\t" << (int)(getFixedIon());
    155155    if (getAtomicVelocity().Norm() > MYEPSILON)
    156156      *out << "\t" << scientific << setprecision(6) << getAtomicVelocity()[0] << "\t" << getAtomicVelocity()[1] << "\t" << getAtomicVelocity()[2] << "\t";
     
    179179    *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[elemental->getAtomicNumber()] << "\t"  << fixed << setprecision(9) << showpoint;
    180180    *out << at(0) << "\t" << at(1) << "\t" << at(2);
    181     *out << "\t" << FixedIon;
     181    *out << "\t" << getFixedIon();
    182182    if (getAtomicVelocity().Norm() > MYEPSILON)
    183183      *out << "\t" << scientific << setprecision(6) << getAtomicVelocity()[0] << "\t" << getAtomicVelocity()[1] << "\t" << getAtomicVelocity()[2] << "\t";
     
    191191};
    192192
    193 /** Output of a single atom as one lin in xyz file.
     193/** Output of a single atom as one line in xyz file.
    194194 * \param *out stream to output to
    195195  * \return true - \a *out present, false - \a *out is NULL
     
    204204};
    205205
    206 /** Output of a single atom as one lin in xyz file.
     206/** Output of a single atom as one line in xyz file.
    207207 * \param *out stream to output to
    208208 * \param *ElementNo array with ion type number in the config file this atom's element shall have
     
    218218    ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration");
    219219    *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[getType()->getAtomicNumber()] << "\t"  << fixed << setprecision(9) << showpoint;
    220     *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
    221     *out << "\t" << FixedIon;
    222     if (Trajectory.U.at(step).Norm() > MYEPSILON)
    223       *out << "\t" << scientific << setprecision(6) << Trajectory.U.at(step)[0] << "\t" << Trajectory.U.at(step)[1] << "\t" << Trajectory.U.at(step)[2] << "\t";
    224     if (Trajectory.F.at(step).Norm() > MYEPSILON)
    225       *out << "\t" << scientific << setprecision(6) << Trajectory.F.at(step)[0] << "\t" << Trajectory.F.at(step)[1] << "\t" << Trajectory.F.at(step)[2] << "\t";
     220    *out << getPosition(step)[0] << "\t" << getPosition(step)[1] << "\t" << getPosition(step)[2];
     221    *out << "\t" << (int)(getFixedIon());
     222    if (getAtomicVelocity(step).Norm() > MYEPSILON)
     223      *out << "\t" << scientific << setprecision(6) << getAtomicVelocity(step)[0] << "\t" << getAtomicVelocity(step)[1] << "\t" << getAtomicVelocity(step)[2] << "\t";
     224    if (getAtomicForce(step).Norm() > MYEPSILON)
     225      *out << "\t" << scientific << setprecision(6) << getAtomicForce(step)[0] << "\t" << getAtomicForce(step)[1] << "\t" << getAtomicForce(step)[2] << "\t";
    226226    *out << "\t# Number in molecule " << nr << endl;
    227227    return true;
     
    239239  if (out != NULL) {
    240240    *out << getType()->getSymbol() << "\t";
    241     *out << Trajectory.R.at(step)[0] << "\t";
    242     *out << Trajectory.R.at(step)[1] << "\t";
    243     *out << Trajectory.R.at(step)[2] << endl;
     241    *out << getPosition(step)[0] << "\t";
     242    *out << getPosition(step)[1] << "\t";
     243    *out << getPosition(step)[2] << endl;
    244244    return true;
    245245  } else
     
    383383}
    384384
    385 double atom::getMass() const{
    386   return getType()->getMass();
    387 }
    388 
    389385int atom::getNr() const{
    390386  return nr;
  • src/atom.hpp

    r54b42e r6625c3  
    2727#include "atom_graphnode.hpp"
    2828#include "atom_particleinfo.hpp"
    29 #include "atom_trajectoryparticle.hpp"
    3029#include "TesselPoint.hpp"
    3130#include "types.hpp"
     
    4544 * Class incorporates position, type
    4645 */
    47 class atom : public TrajectoryParticle, public GraphNode, public BondedParticle, public TesselPoint {
     46class atom : public GraphNode, public BondedParticle, public TesselPoint {
    4847  friend atom* NewAtom(atomId_t);
    4948  friend void  DeleteAtom(atom*);
     
    9897   void removeFromMolecule();
    9998
    100    double getMass() const;
    10199   int getNr() const;
    102100
  • src/atom_atominfo.cpp

    r54b42e r6625c3  
    2020#include "CodePatterns/MemDebug.hpp"
    2121
     22#include "CodePatterns/Log.hpp"
     23#include "CodePatterns/Verbose.hpp"
     24#include "config.hpp"
     25#include "element.hpp"
     26#include "parser.hpp"
    2227#include "periodentafel.hpp"
    2328#include "World.hpp"
    24 #include "element.hpp"
    2529#include "atom_atominfo.hpp"
    2630
     
    2832 */
    2933AtomInfo::AtomInfo() :
    30   AtomicElement(NULL)
     34  AtomicElement(NULL),
     35  FixedIon(false)
    3136{
    3237  AtomicPosition.reserve(1);
     
    4247AtomInfo::AtomInfo(const AtomInfo &_atom) :
    4348    AtomicPosition(_atom.AtomicPosition),
    44     AtomicElement(_atom.AtomicElement)
    45 {};
     49    AtomicElement(_atom.AtomicElement),
     50    FixedIon(false)
     51{
     52  AtomicVelocity.reserve(1);
     53  AtomicVelocity.push_back(zeroVec);
     54  AtomicForce.reserve(1);
     55  AtomicForce.push_back(zeroVec);
     56};
    4657
    4758AtomInfo::AtomInfo(const VectorInterface &_v) :
    48     AtomicElement(NULL)
     59    AtomicElement(NULL),
     60    FixedIon(false)
    4961{
    5062  AtomicPosition[0] = _v.getPosition();
     63  AtomicVelocity.reserve(1);
     64  AtomicVelocity.push_back(zeroVec);
     65  AtomicForce.reserve(1);
     66  AtomicForce.push_back(zeroVec);
    5167};
    5268
     
    8096{
    8197  return AtomicPosition[0];
     98}
     99
     100const Vector& AtomInfo::getPosition(const int _step) const
     101{
     102  ASSERT(_step < AtomicPosition.size(),
     103      "AtomInfo::getPosition() - Access out of range.");
     104  return AtomicPosition[_step];
    82105}
    83106
     
    96119}
    97120
     121Vector& AtomInfo::getAtomicVelocity(const int _step)
     122{
     123  ASSERT(_step < AtomicVelocity.size(),
     124      "AtomInfo::getAtomicVelocity() - Access out of range.");
     125  return AtomicVelocity[_step];
     126}
     127
    98128const Vector& AtomInfo::getAtomicVelocity() const
    99129{
     
    101131}
    102132
     133const Vector& AtomInfo::getAtomicVelocity(const int _step) const
     134{
     135  ASSERT(_step < AtomicVelocity.size(),
     136      "AtomInfo::getAtomicVelocity() - Access out of range.");
     137  return AtomicVelocity[_step];
     138}
     139
    103140void AtomInfo::setAtomicVelocity(const Vector &_newvelocity)
    104141{
     
    106143}
    107144
     145void AtomInfo::setAtomicVelocity(const int _step, const Vector &_newvelocity)
     146{
     147  ASSERT(_step <= AtomicVelocity.size(),
     148      "AtomInfo::setAtomicVelocity() - Access out of range.");
     149  if(_step < (int)AtomicVelocity.size()) {
     150    AtomicVelocity[_step] = _newvelocity;
     151  } else if (_step == (int)AtomicVelocity.size()) {
     152    AtomicVelocity.push_back(_newvelocity);
     153  }
     154}
     155
    108156const Vector& AtomInfo::getAtomicForce() const
    109157{
     
    111159}
    112160
     161const Vector& AtomInfo::getAtomicForce(const int _step) const
     162{
     163  ASSERT(_step < AtomicForce.size(),
     164      "AtomInfo::getAtomicForce() - Access out of range.");
     165  return AtomicForce[_step];
     166}
     167
    113168void AtomInfo::setAtomicForce(const Vector &_newforce)
    114169{
     
    116171}
    117172
     173void AtomInfo::setAtomicForce(const int _step, const Vector &_newforce)
     174{
     175  ASSERT(_step <= AtomicForce.size(),
     176      "AtomInfo::setAtomicForce() - Access out of range.");
     177  if(_step < (int)AtomicForce.size()) {
     178    AtomicForce[_step] = _newforce;
     179  } else if (_step == (int)AtomicForce.size()) {
     180    AtomicForce.push_back(_newforce);
     181  }
     182}
     183
     184bool AtomInfo::getFixedIon() const
     185{
     186  return FixedIon;
     187}
     188
     189void AtomInfo::setFixedIon(const bool _fixedion)
     190{
     191  FixedIon = _fixedion;
     192}
     193
    118194void AtomInfo::setPosition(const Vector& _vector)
    119195{
    120196  AtomicPosition[0] = _vector;
     197  //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
     198}
     199
     200void AtomInfo::setPosition(int _step, const Vector& _vector)
     201{
     202  ASSERT(_step <= AtomicPosition.size(),
     203      "AtomInfo::setPosition() - Access out of range.");
     204  if(_step < (int)AtomicPosition.size()) {
     205    AtomicPosition[_step] = _vector;
     206  } else if (_step == (int)AtomicPosition.size()) {
     207    AtomicPosition.push_back(_vector);
     208  }
    121209  //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl;
    122210}
     
    204292}
    205293
     294/**
     295 *  returns the kinetic energy of this atom at a given time step
     296 */
     297double AtomInfo::getKineticEnergy(unsigned int step) const{
     298  return getMass() * AtomicVelocity[step].NormSquared();
     299}
     300
     301Vector AtomInfo::getMomentum(unsigned int step) const{
     302  return getMass()*AtomicVelocity[step];
     303}
     304
     305/** Extends the trajectory STL vector to the new size.
     306 * Does nothing if \a MaxSteps is smaller than current size.
     307 * \param MaxSteps
     308 */
     309void AtomInfo::ResizeTrajectory(size_t MaxSteps)
     310{
     311  if (AtomicPosition.size() <= (unsigned int)(MaxSteps)) {
     312    DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array from " << AtomicPosition.size() << " to " << (MaxSteps+1) << "." << endl);
     313    AtomicPosition.resize(MaxSteps+1, zeroVec);
     314    AtomicVelocity.resize(MaxSteps+1, zeroVec);
     315    AtomicForce.resize(MaxSteps+1, zeroVec);
     316  }
     317};
     318
     319size_t AtomInfo::getTrajectorySize() const
     320{
     321  return AtomicPosition.size();
     322}
     323
     324double AtomInfo::getMass() const{
     325  return AtomicElement->getMass();
     326}
     327
     328/** Copies a given trajectory step \a src onto another \a dest
     329 * \param dest index of destination step
     330 * \param src index of source step
     331 */
     332void AtomInfo::CopyStepOnStep(int dest, int src)
     333{
     334  if (dest == src)  // self assignment check
     335    return;
     336
     337  ASSERT(dest < AtomicPosition.size(),
     338      "AtomInfo::CopyStepOnStep() - destination outside of current trajectory array.");
     339  ASSERT(src < AtomicPosition.size(),
     340      "AtomInfo::CopyStepOnStep() - source outside of current trajectory array.");
     341  for (int n=NDIM;n--;) {
     342    AtomicPosition.at(dest)[n] = AtomicPosition.at(src)[n];
     343    AtomicVelocity.at(dest)[n] = AtomicVelocity.at(src)[n];
     344    AtomicForce.at(dest)[n] = AtomicForce.at(src)[n];
     345  }
     346};
     347
     348/** Performs a velocity verlet update of the trajectory.
     349 * Parameters are according to those in configuration class.
     350 * \param NextStep index of sequential step to set
     351 * \param *configuration pointer to configuration with parameters
     352 * \param *Force matrix with forces
     353 */
     354void AtomInfo::VelocityVerletUpdate(int nr, int NextStep, config *configuration, ForceMatrix *Force, const size_t offset)
     355{
     356  //a = configuration.Deltat*0.5/walker->type->mass;        // (F+F_old)/2m = a and thus: v = (F+F_old)/2m * t = (F + F_old) * a
     357  if ((int)AtomicPosition.size() <= NextStep)
     358    ResizeTrajectory(NextStep+10);
     359  for (int d=0; d<NDIM; d++) {
     360    AtomicForce.at(NextStep)[d] = -Force->Matrix[0][nr][d+offset]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);
     361    AtomicPosition.at(NextStep)[d] = AtomicPosition.at(NextStep-1)[d];
     362    AtomicPosition.at(NextStep)[d] += configuration->Deltat*(AtomicVelocity.at(NextStep-1)[d]);     // s(t) = s(0) + v * deltat + 1/2 a * deltat^2
     363    AtomicPosition.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(AtomicForce.at(NextStep)[d]/getMass());     // F = m * a and s =
     364  }
     365  // Update U
     366  for (int d=0; d<NDIM; d++) {
     367    AtomicVelocity.at(NextStep)[d] = AtomicVelocity.at(NextStep-1)[d];
     368    AtomicVelocity.at(NextStep)[d] += configuration->Deltat * (AtomicForce.at(NextStep)[d]+AtomicForce.at(NextStep-1)[d]/getMass()); // v = F/m * t
     369  }
     370  // Update R (and F)
     371//      out << "Integrated position&velocity of step " << (NextStep) << ": (";
     372//      for (int d=0;d<NDIM;d++)
     373//        out << AtomicPosition.at(NextStep).x[d] << " ";          // next step
     374//      out << ")\t(";
     375//      for (int d=0;d<NDIM;d++)
     376//        Log() << Verbose(0) << AtomicVelocity.at(NextStep).x[d] << " ";          // next step
     377//      out << ")" << endl;
     378};
     379
    206380const AtomInfo& operator*=(AtomInfo& a, const double m)
    207381{
  • src/atom_atominfo.hpp

    r54b42e r6625c3  
    2727
    2828class AtomInfo;
     29class config;
    2930class element;
     31class ForceMatrix;
    3032class RealSpaceMatrix;
    3133
     
    5860  /** Getter for AtomicVelocity.
    5961   *
     62   * Current time step is used.
     63   *
    6064   * @return constant reference to AtomicVelocity
    6165   */
     
    6367  /** Getter for AtomicVelocity.
    6468   *
     69   * @param _step time step to return
     70   * @return constant reference to AtomicVelocity
     71   */
     72  Vector& getAtomicVelocity(const int _step);
     73  /** Getter for AtomicVelocity.
     74   *
     75   * Current time step is used.
     76   *
    6577   * @return constant reference to AtomicVelocity
    6678   */
    6779  const Vector& getAtomicVelocity() const;
     80  /** Getter for AtomicVelocity.
     81   *
     82   * @param _step time step to return
     83   * @return constant reference to AtomicVelocity
     84   */
     85  const Vector& getAtomicVelocity(const int _step) const;
    6886  /** Setter for AtomicVelocity.
    6987   *
     88   * Current time step is used.
     89   *
    7090   * @param _newvelocity new velocity to set
    7191   */
    7292  void setAtomicVelocity(const Vector &_newvelocity);
     93  /** Setter for AtomicVelocity.
     94   *
     95   * @param _step time step to set
     96   * @param _newvelocity new velocity to set
     97   */
     98  void setAtomicVelocity(const int _step, const Vector &_newvelocity);
    7399
    74100  /** Getter for AtomicForce.
    75101   *
     102   * Current time step is used.
     103   *
    76104   * @return constant reference to AtomicForce
    77105   */
    78106  const Vector& getAtomicForce() const;
     107  /** Getter for AtomicForce.
     108   *
     109   * @param _step time step to return
     110   * @return constant reference to AtomicForce
     111   */
     112  const Vector& getAtomicForce(const int _step) const;
    79113  /** Setter for AtomicForce.
    80114   *
     115   * Current time step is used.
     116   *
    81117   * @param _newvelocity new force vector to set
    82118   */
    83119  void setAtomicForce(const Vector &_newforce);
     120  /** Setter for AtomicForce.
     121   *
     122   * @param _step time step to set
     123   * @param _newvelocity new force vector to set
     124   */
     125  void setAtomicForce(const int _step, const Vector &_newforce);
     126
     127  /** Getter for FixedIon.
     128   *
     129   * @return constant reference to FixedIon
     130   */
     131  bool getFixedIon() const;
     132  /** Setter for FixedIon.
     133   *
     134   * @param _fixedion new state of FixedIon
     135   */
     136  void setFixedIon(const bool _fixedion);
    84137
    85138  ///// manipulation of the atomic position
    86139
    87140  // Accessors ussually come in pairs... and sometimes even more than that
     141  /** Getter for AtomicPosition.
     142   *
     143   * Current time step is used.
     144   *
     145   * @param i component of vector
     146   * @return i-th component of atomic position
     147   */
    88148  const double& operator[](size_t i) const;
     149  /** Getter for AtomicPosition.
     150   *
     151   * Current time step is used.
     152   *
     153   * \sa operator[], this is if instance is a reference.
     154   *
     155   * @param i component of vector
     156   * @return i-th component of atomic position
     157   */
    89158  const double& at(size_t i) const;
     159  /** Getter for AtomicPosition.
     160   *
     161   * \sa operator[], this is if instance is a reference.
     162   *
     163   * @param i index of component of AtomicPosition
     164   * @param _step time step to return
     165   * @return atomic position at time step _step
     166   */
     167  const Vector& atStep(size_t i, int _step) const;
     168  /** Setter for AtomicPosition.
     169   *
     170   * Current time step is used.
     171   *
     172   * @param i component to set
     173   * @param value value to set to
     174   */
    90175  void set(size_t i, const double value);
     176  /** Setter for AtomicPosition.
     177   *
     178   * @param i component to set
     179   * @param _step time step to set
     180   * @param value value to set to
     181   */
     182  void setAtStep(size_t i, int _step, const double value);
     183  /** Getter for AtomicPosition.
     184   *
     185   * Current time step is used.
     186   *
     187   * @return atomic position
     188   */
    91189  const Vector& getPosition() const;
     190  /** Getter for AtomicPosition.
     191   *
     192   * @param _step time step to return
     193   * @return atomic position at time step _step
     194   */
     195  const Vector& getPosition(int _step) const;
    92196
    93197  // Assignment operator
     198  /** Setter for AtomicPosition.
     199   *
     200   * Current time step is used.
     201   *
     202   * @param _vector new position to set
     203   */
    94204  void setPosition(const Vector& _vector);
     205  /** Setter for AtomicPosition.
     206   *
     207   * @param _step time step to set
     208   * @param _vector new position to set for time step _step
     209   */
     210  void setPosition(int _step, const Vector& _vector);
    95211  class VectorInterface &operator=(const Vector& _vector);
    96212
     
    114230  void Scale(const double factor);
    115231
     232  // operations for trajectories
     233  void ResizeTrajectory(size_t MaxSteps);
     234  size_t getTrajectorySize() const;
     235  void CopyStepOnStep(int dest, int src);
     236  void VelocityVerletUpdate(int nr, int MDSteps, config *configuration, ForceMatrix *Force, const size_t offset);
     237  double getKineticEnergy(unsigned int step) const;
     238  Vector getMomentum(unsigned int step) const;
     239  double getMass() const;
     240
    116241  std::ostream & operator << (std::ostream &ost) const;
    117242
     
    122247
    123248  const element *AtomicElement;  //!< pointing to element
     249  bool FixedIon;
    124250};
    125251
  • src/config.cpp

    r54b42e r6625c3  
    462462  int No[MAX_ELEMENTS];
    463463  int verbose = 0;
     464  Vector tempVector;
     465  int _fixedion;
    464466  double value[3];
    465467
     
    525527                    ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], 1, (repetition == 0) ? critical : optional) &&
    526528                    ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], 1, (repetition == 0) ? critical : optional) &&
    527                     ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional));
     529                    ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &_fixedion, 1, (repetition == 0) ? critical : optional));
    528530            if (!status)
    529531              break;
    530             neues ->setPosition(position);
     532            neues->setFixedIon(_fixedion);
     533            neues->setPosition(position);
    531534
    532535            // check size of vectors
    533             if (neues->Trajectory.R.size() <= (unsigned int)(repetition)) {
     536            if (neues->getTrajectorySize() <= (unsigned int)(repetition)) {
    534537              //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl;
    535               neues->Trajectory.R.resize(repetition+10);
    536               neues->Trajectory.U.resize(repetition+10);
    537               neues->Trajectory.F.resize(repetition+10);
     538              neues->ResizeTrajectory(repetition+1);
     539              neues->ResizeTrajectory(repetition+1);
     540              neues->ResizeTrajectory(repetition+1);
    538541            }
    539542
    540             // put into trajectories list
    541             for (int d=0;d<NDIM;d++)
    542               neues->Trajectory.R.at(repetition)[d] = neues->at(d);
    543 
    544543            // parse velocities if present
    545             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->getAtomicVelocity()[0], 1,optional))
    546               neues->getAtomicVelocity()[0] = 0.;
    547             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->getAtomicVelocity()[1], 1,optional))
    548               neues->getAtomicVelocity()[1] = 0.;
    549             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->getAtomicVelocity()[2], 1,optional))
    550               neues->getAtomicVelocity()[2] = 0.;
    551             for (int d=0;d<NDIM;d++)
    552               neues->Trajectory.U.at(repetition)[d] = neues->getAtomicVelocity()[d];
     544            tempVector.Zero();
     545            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &tempVector[0], 1,optional))
     546              tempVector[0] = 0.;
     547            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &tempVector[1], 1,optional))
     548              tempVector[1] = 0.;
     549            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &tempVector[2], 1,optional))
     550              tempVector[2] = 0.;
     551            neues->setAtomicVelocity(repetition, tempVector);
    553552
    554553            // parse forces if present
    555             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 8, 1, double_type, &value[0], 1,optional))
    556               value[0] = 0.;
    557             if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 9, 1, double_type, &value[1], 1,optional))
    558               value[1] = 0.;
    559             if(!ParseForParameter(verbose,FileBuffer, keyword, 1, 10, 1, double_type, &value[2], 1,optional))
    560               value[2] = 0.;
    561             for (int d=0;d<NDIM;d++)
    562               neues->Trajectory.F.at(repetition)[d] = value[d];
     554            tempVector.Zero();
     555            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 8, 1, double_type, &tempVector[0], 1,optional))
     556              tempVector[0] = 0.;
     557            if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 9, 1, double_type, &tempVector[1], 1,optional))
     558              tempVector[1] = 0.;
     559            if(!ParseForParameter(verbose,FileBuffer, keyword, 1, 10, 1, double_type, &tempVector[2], 1,optional))
     560              tempVector[2] = 0.;
     561            neues->setAtomicForce(repetition, tempVector);
    563562
    564563  //            Log() << Verbose(0) << "Parsed position of step " << (repetition) << ": (";
    565   //            for (int d=0;d<NDIM;d++)
    566   //              Log() << Verbose(0) << neues->Trajectory.R.at(repetition).x[d] << " ";          // next step
    567   //            Log() << Verbose(0) << ")\t(";
    568   //            for (int d=0;d<NDIM;d++)
    569   //              Log() << Verbose(0) << neues->Trajectory.U.at(repetition).x[d] << " ";          // next step
    570   //            Log() << Verbose(0) << ")\t(";
    571   //            for (int d=0;d<NDIM;d++)
    572   //              Log() << Verbose(0) << neues->Trajectory.F.at(repetition).x[d] << " ";          // next step
     564  //            Log() << Verbose(0) << neues->getPosition(repetition) << " ";          // next step
     565  //            Log() << Verbose(0) << neues->getAtomicVelocity(repetition) << " ";          // next step
     566  //            Log() << Verbose(0) << neues->getAtomicForce(repetition) << " ";          // next step
    573567  //            Log() << Verbose(0) << ")" << endl;
    574568          }
     
    603597            neues = AtomList[i][j];
    604598          // then parse for each atom the coordinates as often as present
    605           ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], repetition,critical);
    606           ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], repetition,critical);
    607           ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], repetition,critical);
    608           neues->setPosition(position);
    609           ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical);
    610           if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->getAtomicVelocity()[0], repetition,optional))
    611             neues->getAtomicVelocity()[0] = 0.;
    612           if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->getAtomicVelocity()[1], repetition,optional))
    613             neues->getAtomicVelocity()[1] = 0.;
    614           if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->getAtomicVelocity()[2], repetition,optional))
    615             neues->getAtomicVelocity()[2] = 0.;
     599          tempVector.Zero();
     600          ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &tempVector[0], repetition,critical);
     601          ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &tempVector[1], repetition,critical);
     602          ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &tempVector[2], repetition,critical);
     603          neues->setPosition(tempVector);
     604          // fixed ion
     605          ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &_fixedion, repetition,critical);
     606          neues->setFixedIon(_fixedion);
     607          // and velocity
     608          tempVector.Zero();
     609          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &tempVector[0], repetition,optional))
     610            tempVector[0] = 0.;
     611          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &tempVector[1], repetition,optional))
     612            tempVector[1] = 0.;
     613          if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &tempVector[2], repetition,optional))
     614            tempVector[2] = 0.;
     615          neues->setAtomicVelocity(tempVector);
    616616          // here we don't care if forces are present (last in trajectories is always equal to current position)
    617617          neues->setType(elementhash[i]); // find element type
  • src/molecule.cpp

    r54b42e r6625c3  
    365365      FirstOtherAtom->setType(1);  // element is Hydrogen
    366366      FirstOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity
    367       FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
     367      FirstOtherAtom->setFixedIon(TopReplacement->getFixedIon());
    368368      if (TopReplacement->getType()->getAtomicNumber() == 1) { // neither rescale nor replace if it's already hydrogen
    369369        FirstOtherAtom->father = TopReplacement;
     
    430430      SecondOtherAtom->setType(1);
    431431      FirstOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity
    432       FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
     432      FirstOtherAtom->setFixedIon(TopReplacement->getFixedIon());
    433433      SecondOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity
    434       SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
     434      SecondOtherAtom->setFixedIon(TopReplacement->getFixedIon());
    435435      FirstOtherAtom->father = NULL;  // we are just an added hydrogen with no father
    436436      SecondOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
     
    485485      ThirdOtherAtom->setType(1);
    486486      FirstOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity
    487       FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
     487      FirstOtherAtom->setFixedIon(TopReplacement->getFixedIon());
    488488      SecondOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity
    489       SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
     489      SecondOtherAtom->setFixedIon(TopReplacement->getFixedIon());
    490490      ThirdOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity
    491       ThirdOtherAtom->FixedIon = TopReplacement->FixedIon;
     491      ThirdOtherAtom->setFixedIon(TopReplacement->getFixedIon());
    492492      FirstOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
    493493      SecondOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
     
    582582  istringstream *input = NULL;
    583583  int NumberOfAtoms = 0; // atom number in xyz read
    584   int i, j; // loop variables
     584  int i; // loop variables
    585585  atom *Walker = NULL;  // pointer to added atom
    586586  char shorthand[3];  // shorthand for atom name
     
    618618      Walker->setType(1);
    619619    }
    620     if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) {
    621       Walker->Trajectory.R.resize(MDSteps+10);
    622       Walker->Trajectory.U.resize(MDSteps+10);
    623       Walker->Trajectory.F.resize(MDSteps+10);
     620    if (Walker->getTrajectorySize() <= (unsigned int)MDSteps) {
     621      Walker->ResizeTrajectory(MDSteps+10);
    624622    }
    625623    Walker->setPosition(Vector(x));
    626     for(j=NDIM;j--;) {
    627       Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
    628       Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
    629       Walker->Trajectory.F.at(MDSteps-1)[j] = 0;
    630     }
     624    Walker->setPosition(MDSteps-1, Vector(x));
     625    Walker->setAtomicVelocity(MDSteps-1, zeroVec);
     626    Walker->setAtomicForce(MDSteps-1, zeroVec);
    631627    AddAtom(Walker);  // add to molecule
    632628    delete(item);
  • src/molecule_dynamics.cpp

    r54b42e r6625c3  
    6060    // determine normalized trajectories direction vector (n1, n2)
    6161    Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    62     trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);
     62    trajectory1 = Sprinter->getPosition(Params.endstep) - Walker->getPosition(Params.startstep);
    6363    trajectory1.Normalize();
    6464    Norm1 = trajectory1.Norm();
    6565    Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    66     trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
     66    trajectory2 = Sprinter->getPosition(Params.endstep) - (*iter)->getPosition(Params.startstep);
    6767    trajectory2.Normalize();
    6868    Norm2 = trajectory1.Norm();
    6969    // check whether either is zero()
    7070    if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
    71       tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
     71      tmp = Walker->getPosition(Params.startstep).distance((*iter)->getPosition(Params.startstep));
    7272    } else if (Norm1 < MYEPSILON) {
    7373      Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    74       trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
     74      trajectory1 = Sprinter->getPosition(Params.endstep) - (*iter)->getPosition(Params.startstep);
    7575      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    7676      trajectory1 -= trajectory2;   // project the part in norm direction away
     
    7878    } else if (Norm2 < MYEPSILON) {
    7979      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    80       trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
     80      trajectory2 = Sprinter->getPosition(Params.endstep) - Walker->getPosition(Params.startstep);  // copy second offset
    8181      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
    8282      trajectory2 -= trajectory1;   // project the part in norm direction away
     
    8787  //        Log() << Verbose(0) << " and ";
    8888  //        Log() << Verbose(0) << trajectory2;
    89       tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
     89      tmp = Walker->getPosition(Params.startstep).distance((*iter)->getPosition(Params.startstep));
    9090  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    9191    } else { // determine distance by finding minimum distance
     
    106106        gsl_matrix_set(A, 1, i, trajectory2[i]);
    107107        gsl_matrix_set(A, 2, i, normal[i]);
    108         gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i]));
     108        gsl_vector_set(x,i, (Walker->getPosition(Params.startstep)[i] - (*iter)->getPosition(Params.startstep)[i]));
    109109      }
    110110      // solve the linear system by Householder transformations
     
    117117      trajectory2.Scale(gsl_vector_get(x,1));
    118118      normal.Scale(gsl_vector_get(x,2));
    119       TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal
    120                    - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
     119      TestVector = (*iter)->getPosition(Params.startstep) + trajectory2 + normal
     120                   - (Walker->getPosition(Params.startstep) + trajectory1);
    121121      if (TestVector.Norm() < MYEPSILON) {
    122122  //          Log() << Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl;
     
    150150  //    atom *Sprinter = PermutationMap[Walker->nr];
    151151  //        Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at ";
    152   //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
     152  //        Log() << Verbose(0) << Sprinter->getPosition(endstep);
    153153  //        Log() << Verbose(0) << ", penalting." << endl;
    154154      result += Params.PenaltyConstants[2];
     
    183183    // first term: distance to target
    184184    Runner = Params.PermutationMap[(*iter)->nr];   // find target point
    185     tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
     185    tmp = ((*iter)->getPosition(Params.startstep).distance(Runner->getPosition(Params.endstep)));
    186186    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    187187    result += Params.PenaltyConstants[0] * tmp;
     
    239239  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    240240    for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) {
    241       Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) );
     241      Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->getPosition(Params.startstep).distance((*runner)->getPosition(Params.endstep)), (*runner)) );
    242242    }
    243243  }
     
    489489    // set forces
    490490    for (int i=NDIM;i++;)
    491       Force->Matrix[0][_atom->nr][5+i] += 2.*constant*sqrt(_atom->Trajectory.R.at(startstep).distance(Sprinter->Trajectory.R.at(endstep)));
     491      Force->Matrix[0][_atom->nr][5+i] += 2.*constant*sqrt(_atom->getPosition(startstep).distance(Sprinter->getPosition(endstep)));
    492492  }
    493493  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     
    525525
    526526  // check whether we have sufficient space in Trajectories for each atom
    527   for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::ResizeTrajectory),MaxSteps));
     527  LOG(1, "STATUS: Extending each trajectory size to " << MaxSteps+1 << ".");
     528  for_each(atoms.begin(),atoms.end(),bind2nd(mem_fun(&atom::ResizeTrajectory),MaxSteps+1));
    528529  // push endstep to last one
    529530  for_each(atoms.begin(),atoms.end(),boost::bind(&atom::CopyStepOnStep,_1,MaxSteps,endstep));
     
    538539      // add to molecule list
    539540      Sprinter = mol->AddCopyAtom((*iter));
    540       for (int n=NDIM;n--;) {
    541         Sprinter->set(n, (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps));
    542         // add to Trajectories
    543         //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    544         if (step < MaxSteps) {
    545           (*iter)->Trajectory.R.at(step)[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    546           (*iter)->Trajectory.U.at(step)[n] = 0.;
    547           (*iter)->Trajectory.F.at(step)[n] = 0.;
    548         }
    549       }
     541      // add to Trajectories
     542      Vector temp = (*iter)->getPosition(startstep) + (PermutationMap[(*iter)->nr]->getPosition(endstep) - (*iter)->getPosition(startstep))*((double)step/(double)MaxSteps);
     543      Sprinter->setPosition(temp);
     544      (*iter)->setAtomicVelocity(step, zeroVec);
     545      (*iter)->setAtomicForce(step, zeroVec);
     546      //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    550547    }
    551548  }
     
    620617  // and perform Verlet integration for each atom with position, velocity and force vector
    621618  // check size of vectors
    622   for_each(atoms.begin(),
    623            atoms.end(),
    624            boost::bind(&atom::VelocityVerletUpdate,_1,MDSteps+1, &configuration, &Force, (const size_t) 0));
     619  BOOST_FOREACH(atom *_atom, atoms) {
     620    _atom->VelocityVerletUpdate(_atom->nr, MDSteps+1, &configuration, &Force, (const size_t) 0);
     621  }
    625622
    626623  // correct velocities (rather momenta) so that center of mass remains motionless
  • src/molecule_geometry.cpp

    r54b42e r6625c3  
    5858  // go through all atoms
    5959  BOOST_FOREACH(atom* iter, atoms){
     60    std::cout << "atom before is at " << *iter << std::endl;
    6061    *iter -= *Center;
    61     *iter -= *CenterBox;
     62    *iter += *CenterBox;
     63    std::cout << "atom after is at " << *iter << std::endl;
    6264  }
    6365  atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1));
     
    314316{
    315317  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    316     for (int j=0;j<MDSteps;j++)
    317       (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
    318     (*iter)->ScaleAll(*factor);
     318    for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {
     319      Vector temp = (*iter)->getPosition(j);
     320      temp.ScaleAll(*factor);
     321      (*iter)->setPosition(j,temp);
     322    }
    319323  }
    320324};
     
    326330{
    327331  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    328     for (int j=0;j<MDSteps;j++)
    329       (*iter)->Trajectory.R.at(j) += (*trans);
    330     *(*iter) += (*trans);
     332    for (size_t j=0;j<(*iter)->getTrajectorySize();j++) {
     333      Vector temp = (*iter)->getPosition(j);
     334      temp += (*trans);
     335      (*iter)->setPosition(j, temp);
     336    }
    331337  }
    332338};
     
    334340/** Translate the molecule periodically in the box.
    335341 * \param trans[] translation vector.
    336  * TODO treatment of trajetories missing
     342 * TODO treatment of trajectories missing
    337343 */
    338344void molecule::TranslatePeriodically(const Vector *trans)
     
    438444    (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2));
    439445    for (int j=0;j<MDSteps;j++) {
    440       tmp = (*iter)->Trajectory.R.at(j)[0];
    441       (*iter)->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
    442       (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
     446      Vector temp;
     447      temp[0] =  cos(alpha) * (*iter)->getPosition(j)[0] + sin(alpha) * (*iter)->getPosition(j)[2];
     448      temp[2] = -sin(alpha) * (*iter)->getPosition(j)[0] + cos(alpha) * (*iter)->getPosition(j)[2];
     449      (*iter)->setPosition(j,temp);
    443450    }
    444451  }
     
    457464    (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2));
    458465    for (int j=0;j<MDSteps;j++) {
    459       tmp = (*iter)->Trajectory.R.at(j)[1];
    460       (*iter)->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
    461       (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
     466      Vector temp;
     467      temp[1] =  cos(alpha) * (*iter)->getPosition(j)[1] + sin(alpha) * (*iter)->getPosition(j)[2];
     468      temp[2] = -sin(alpha) * (*iter)->getPosition(j)[1] + cos(alpha) * (*iter)->getPosition(j)[2];
     469      (*iter)->setPosition(j,temp);
    462470    }
    463471  }
Note: See TracChangeset for help on using the changeset viewer.