- Timestamp:
- Feb 24, 2011, 5:46:46 PM (14 years ago)
- 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)
- Location:
- src
- Files:
-
- 4 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AtomSet.hpp
r54b42e r6625c3 82 82 template<class T> 83 83 struct valueSum { 84 valueSum(T ( atom::*_f)() const,T startValue) :84 valueSum(T (AtomInfo::*_f)() const,T startValue) : 85 85 f(_f), 86 86 value(startValue) 87 87 {} 88 T operator+( atom*atom){88 T operator+(AtomInfo *atom){ 89 89 return value + (atom->*f)(); 90 90 } … … 93 93 return value; 94 94 } 95 T ( atom::*f)() const;95 T (AtomInfo::*f)() const; 96 96 T value; 97 97 }; … … 99 99 template<class T> 100 100 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) : 102 102 step(_step), 103 103 f(_f), 104 104 value(startValue) 105 105 {} 106 T operator+( atom*atom){106 T operator+(AtomInfo *atom){ 107 107 return value + (atom->*f)(step); 108 108 } … … 112 112 } 113 113 unsigned int step; 114 T ( atom::*f)(unsigned int) const;114 T (AtomInfo::*f)(unsigned int) const; 115 115 T value; 116 116 }; … … 119 119 template<class Set> 120 120 inline void AtomSetMixin<Set>::translate(const Vector &translater){ 121 BOOST_FOREACH( atom*atom,*this){121 BOOST_FOREACH(AtomInfo *atom,*this){ 122 122 *(atom) += translater; 123 123 } … … 126 126 template<class Set> 127 127 inline 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; 130 130 } 131 131 } … … 141 141 template<class Set> 142 142 inline 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; 144 144 } 145 145 146 146 template<class Set> 147 147 inline 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; 149 149 } 150 150 151 151 template<class Set> 152 152 inline 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; 154 154 } 155 155 -
src/Makefile.am
r54b42e r6625c3 21 21 atom_graphnode.cpp \ 22 22 atom_graphnodeinfo.cpp \ 23 atom_particleinfo.cpp \ 24 atom_trajectoryparticle.cpp \ 25 atom_trajectoryparticleinfo.cpp 23 atom_particleinfo.cpp 26 24 ATOMHEADER = \ 27 25 atom.hpp \ … … 32 30 atom_graphnode.hpp \ 33 31 atom_graphnodeinfo.hpp \ 34 atom_particleinfo.hpp \ 35 atom_trajectoryparticle.hpp \ 36 atom_trajectoryparticleinfo.hpp 32 atom_particleinfo.hpp 37 33 38 34 ANALYSISSOURCE = \ -
src/Parser/PcpParser.cpp
r54b42e r6625c3 557 557 *file << "Ion_Type" << ZtoIndexMap[Z] << "_" << ZtoCountMap[Z] << "\t" << fixed << setprecision(9) << showpoint; 558 558 *file << (*AtomRunner)->at(0) << "\t" << (*AtomRunner)->at(1) << "\t" << (*AtomRunner)->at(2); 559 *file << "\t" << ( *AtomRunner)->FixedIon;559 *file << "\t" << (int)((*AtomRunner)->getFixedIon()); 560 560 if ((*AtomRunner)->getAtomicVelocity().Norm() > MYEPSILON) 561 561 *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->getAtomicVelocity()[0] << "\t" << (*AtomRunner)->getAtomicVelocity()[1] << "\t" << (*AtomRunner)->getAtomicVelocity()[2] << "\t"; -
src/Thermostats/Berendsen.cpp
r54b42e r6625c3 63 63 double ScaleTempFactor = getContainer().TargetTemp/ActualTemp; 64 64 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 forces65 Vector &U = (*iter)->getAtomicVelocity(step); 66 if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces 67 67 U *= sqrt(1+(World::getInstance().getConfig()->Deltat/TempFrequency)*(ScaleTempFactor-1)); 68 68 ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared(); -
src/Thermostats/GaussianThermostat.cpp
r54b42e r6625c3 70 70 double ekin =0; 71 71 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 forces72 Vector &U = (*iter)->getAtomicVelocity(step); 73 if ((*iter)->getFixedIon() == 0) {// even FixedIon moves, only not by other's forces 74 74 U += World::getInstance().getConfig()->Deltat * G_over_E * U; 75 75 ekin += (*iter)->getType()->getMass() * U.NormSquared(); … … 84 84 G=0; 85 85 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 forces86 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 89 89 G += U.ScalarProduct(F); 90 90 E += U.NormSquared()*(*iter)->getType()->getMass(); -
src/Thermostats/Langevin.cpp
r54b42e r6625c3 20 20 #include "ThermoStatContainer.hpp" 21 21 22 #include <boost/random/mersenne_twister.hpp> 23 #include <boost/random/normal_distribution.hpp> 24 #include <boost/random/variate_generator.hpp> 25 22 26 #include "RandomNumbers/RandomNumberGeneratorFactory.hpp" 23 27 #include "RandomNumbers/RandomNumberGenerator.hpp" … … 25 29 Langevin::Langevin(double _TempFrequency,double _alpha) : 26 30 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 {} 33 35 34 36 Langevin::Langevin() : 35 37 TempFrequency(2.5), 36 alpha(0.) 38 alpha(0.), 39 rng_engine(new boost::mt19937), 40 rng_distribution(NULL) 37 41 {} 38 42 39 43 Langevin::~Langevin() 40 44 { 41 gsl_rng_free (r); 45 delete rng_engine; 46 delete rng_distribution; 42 47 } 43 48 … … 76 81 double Langevin::doScaleAtoms(unsigned int step,double ActualTemp,ForwardIterator begin, ForwardIterator end){ 77 82 DoLog(2) && (Log() << Verbose(2) << "Applying Langevin thermostat..." << endl); 78 RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator( );83 RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator("mt19937", "normal_distribution"); 79 84 const double rng_min = random.min(); 80 85 const double rng_max = random.max(); … … 82 87 for(ForwardIterator iter=begin;iter!=end;++iter){ 83 88 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 86 93 // throw a dice to determine whether it gets hit by a heat bath particle 87 94 if (((((random()/(rng_max-rng_min)))*TempFrequency) < 1.)) { … … 89 96 // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis 90 97 for (int d=0; d<NDIM; d++) { 91 U[d] = gsl_ran_gaussian (r, sigma);98 U[d] = rng(); 92 99 } 93 100 DoLog(2) && (Log() << Verbose(2) << U.Norm() << endl); … … 95 102 ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared(); 96 103 } 104 delete rng_distribution; 105 rng_distribution = NULL; 97 106 } 98 107 return ekin; -
src/Thermostats/Langevin.hpp
r54b42e r6625c3 14 14 #endif 15 15 16 #include "Thermostats/Thermostat.hpp" 16 17 17 #include "Thermostats/Thermostat.hpp" 18 #include <boost/random/mersenne_twister.hpp> 19 #include <boost/random/normal_distribution.hpp> 18 20 19 21 class Langevin : public Thermostat … … 38 40 double TempFrequency; 39 41 double alpha; 40 gsl_rng * r; 41 const gsl_rng_type * T; 42 43 boost::mt19937 *rng_engine; 44 boost::normal_distribution<> *rng_distribution; 42 45 }; 43 46 -
src/Thermostats/NoseHoover.cpp
r54b42e r6625c3 68 68 double ekin =0; 69 69 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 forces70 Vector &U = (*iter)->getAtomicVelocity(step); 71 if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces 72 72 U += World::getInstance().getConfig()->Deltat/(*iter)->getType()->getMass() * (alpha * (U * (*iter)->getType()->getMass())); 73 73 ekin += (0.5*(*iter)->getType()->getMass()) * U.NormSquared(); … … 82 82 count=0; 83 83 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 forces84 const Vector &U = (*iter)->getAtomicVelocity(step); 85 if ((*iter)->getFixedIon() == 0) { // even FixedIon moves, only not by other's forces 86 86 delta_alpha += U.NormSquared()*(*iter)->getType()->getMass(); 87 87 } -
src/Thermostats/Woodcock.cpp
r54b42e r6625c3 67 67 double ekin; 68 68 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 forces69 Vector &U = (*iter)->getAtomicVelocity(step); 70 if ((*iter)->getFixedIon() == 0){ // even FixedIon moves, only not by other's forces 71 71 U *= ScaleTempFactor; 72 72 ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared(); -
src/atom.cpp
r54b42e r6625c3 55 55 setPosition(pointer->getPosition()); // copy coordination 56 56 setAtomicVelocity(pointer->getAtomicVelocity()); // copy velocity 57 FixedIon = pointer->FixedIon;57 setFixedIon(pointer->getFixedIon()); 58 58 }; 59 59 … … 152 152 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint; 153 153 *out << at(0) << "\t" << at(1) << "\t" << at(2); 154 *out << "\t" << FixedIon;154 *out << "\t" << (int)(getFixedIon()); 155 155 if (getAtomicVelocity().Norm() > MYEPSILON) 156 156 *out << "\t" << scientific << setprecision(6) << getAtomicVelocity()[0] << "\t" << getAtomicVelocity()[1] << "\t" << getAtomicVelocity()[2] << "\t"; … … 179 179 *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[elemental->getAtomicNumber()] << "\t" << fixed << setprecision(9) << showpoint; 180 180 *out << at(0) << "\t" << at(1) << "\t" << at(2); 181 *out << "\t" << FixedIon;181 *out << "\t" << getFixedIon(); 182 182 if (getAtomicVelocity().Norm() > MYEPSILON) 183 183 *out << "\t" << scientific << setprecision(6) << getAtomicVelocity()[0] << "\t" << getAtomicVelocity()[1] << "\t" << getAtomicVelocity()[2] << "\t"; … … 191 191 }; 192 192 193 /** Output of a single atom as one lin in xyz file.193 /** Output of a single atom as one line in xyz file. 194 194 * \param *out stream to output to 195 195 * \return true - \a *out present, false - \a *out is NULL … … 204 204 }; 205 205 206 /** Output of a single atom as one lin in xyz file.206 /** Output of a single atom as one line in xyz file. 207 207 * \param *out stream to output to 208 208 * \param *ElementNo array with ion type number in the config file this atom's element shall have … … 218 218 ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration"); 219 219 *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"; 226 226 *out << "\t# Number in molecule " << nr << endl; 227 227 return true; … … 239 239 if (out != NULL) { 240 240 *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; 244 244 return true; 245 245 } else … … 383 383 } 384 384 385 double atom::getMass() const{386 return getType()->getMass();387 }388 389 385 int atom::getNr() const{ 390 386 return nr; -
src/atom.hpp
r54b42e r6625c3 27 27 #include "atom_graphnode.hpp" 28 28 #include "atom_particleinfo.hpp" 29 #include "atom_trajectoryparticle.hpp"30 29 #include "TesselPoint.hpp" 31 30 #include "types.hpp" … … 45 44 * Class incorporates position, type 46 45 */ 47 class atom : public TrajectoryParticle, publicGraphNode, public BondedParticle, public TesselPoint {46 class atom : public GraphNode, public BondedParticle, public TesselPoint { 48 47 friend atom* NewAtom(atomId_t); 49 48 friend void DeleteAtom(atom*); … … 98 97 void removeFromMolecule(); 99 98 100 double getMass() const;101 99 int getNr() const; 102 100 -
src/atom_atominfo.cpp
r54b42e r6625c3 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include "CodePatterns/Log.hpp" 23 #include "CodePatterns/Verbose.hpp" 24 #include "config.hpp" 25 #include "element.hpp" 26 #include "parser.hpp" 22 27 #include "periodentafel.hpp" 23 28 #include "World.hpp" 24 #include "element.hpp"25 29 #include "atom_atominfo.hpp" 26 30 … … 28 32 */ 29 33 AtomInfo::AtomInfo() : 30 AtomicElement(NULL) 34 AtomicElement(NULL), 35 FixedIon(false) 31 36 { 32 37 AtomicPosition.reserve(1); … … 42 47 AtomInfo::AtomInfo(const AtomInfo &_atom) : 43 48 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 }; 46 57 47 58 AtomInfo::AtomInfo(const VectorInterface &_v) : 48 AtomicElement(NULL) 59 AtomicElement(NULL), 60 FixedIon(false) 49 61 { 50 62 AtomicPosition[0] = _v.getPosition(); 63 AtomicVelocity.reserve(1); 64 AtomicVelocity.push_back(zeroVec); 65 AtomicForce.reserve(1); 66 AtomicForce.push_back(zeroVec); 51 67 }; 52 68 … … 80 96 { 81 97 return AtomicPosition[0]; 98 } 99 100 const Vector& AtomInfo::getPosition(const int _step) const 101 { 102 ASSERT(_step < AtomicPosition.size(), 103 "AtomInfo::getPosition() - Access out of range."); 104 return AtomicPosition[_step]; 82 105 } 83 106 … … 96 119 } 97 120 121 Vector& AtomInfo::getAtomicVelocity(const int _step) 122 { 123 ASSERT(_step < AtomicVelocity.size(), 124 "AtomInfo::getAtomicVelocity() - Access out of range."); 125 return AtomicVelocity[_step]; 126 } 127 98 128 const Vector& AtomInfo::getAtomicVelocity() const 99 129 { … … 101 131 } 102 132 133 const 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 103 140 void AtomInfo::setAtomicVelocity(const Vector &_newvelocity) 104 141 { … … 106 143 } 107 144 145 void 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 108 156 const Vector& AtomInfo::getAtomicForce() const 109 157 { … … 111 159 } 112 160 161 const 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 113 168 void AtomInfo::setAtomicForce(const Vector &_newforce) 114 169 { … … 116 171 } 117 172 173 void 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 184 bool AtomInfo::getFixedIon() const 185 { 186 return FixedIon; 187 } 188 189 void AtomInfo::setFixedIon(const bool _fixedion) 190 { 191 FixedIon = _fixedion; 192 } 193 118 194 void AtomInfo::setPosition(const Vector& _vector) 119 195 { 120 196 AtomicPosition[0] = _vector; 197 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; 198 } 199 200 void 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 } 121 209 //cout << "AtomInfo::setPosition: " << getType()->symbol << " at " << getPosition() << endl; 122 210 } … … 204 292 } 205 293 294 /** 295 * returns the kinetic energy of this atom at a given time step 296 */ 297 double AtomInfo::getKineticEnergy(unsigned int step) const{ 298 return getMass() * AtomicVelocity[step].NormSquared(); 299 } 300 301 Vector 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 */ 309 void 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 319 size_t AtomInfo::getTrajectorySize() const 320 { 321 return AtomicPosition.size(); 322 } 323 324 double 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 */ 332 void 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 */ 354 void 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 206 380 const AtomInfo& operator*=(AtomInfo& a, const double m) 207 381 { -
src/atom_atominfo.hpp
r54b42e r6625c3 27 27 28 28 class AtomInfo; 29 class config; 29 30 class element; 31 class ForceMatrix; 30 32 class RealSpaceMatrix; 31 33 … … 58 60 /** Getter for AtomicVelocity. 59 61 * 62 * Current time step is used. 63 * 60 64 * @return constant reference to AtomicVelocity 61 65 */ … … 63 67 /** Getter for AtomicVelocity. 64 68 * 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 * 65 77 * @return constant reference to AtomicVelocity 66 78 */ 67 79 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; 68 86 /** Setter for AtomicVelocity. 69 87 * 88 * Current time step is used. 89 * 70 90 * @param _newvelocity new velocity to set 71 91 */ 72 92 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); 73 99 74 100 /** Getter for AtomicForce. 75 101 * 102 * Current time step is used. 103 * 76 104 * @return constant reference to AtomicForce 77 105 */ 78 106 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; 79 113 /** Setter for AtomicForce. 80 114 * 115 * Current time step is used. 116 * 81 117 * @param _newvelocity new force vector to set 82 118 */ 83 119 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); 84 137 85 138 ///// manipulation of the atomic position 86 139 87 140 // 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 */ 88 148 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 */ 89 158 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 */ 90 175 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 */ 91 189 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; 92 196 93 197 // Assignment operator 198 /** Setter for AtomicPosition. 199 * 200 * Current time step is used. 201 * 202 * @param _vector new position to set 203 */ 94 204 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); 95 211 class VectorInterface &operator=(const Vector& _vector); 96 212 … … 114 230 void Scale(const double factor); 115 231 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 116 241 std::ostream & operator << (std::ostream &ost) const; 117 242 … … 122 247 123 248 const element *AtomicElement; //!< pointing to element 249 bool FixedIon; 124 250 }; 125 251 -
src/config.cpp
r54b42e r6625c3 462 462 int No[MAX_ELEMENTS]; 463 463 int verbose = 0; 464 Vector tempVector; 465 int _fixedion; 464 466 double value[3]; 465 467 … … 525 527 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], 1, (repetition == 0) ? critical : optional) && 526 528 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)); 528 530 if (!status) 529 531 break; 530 neues ->setPosition(position); 532 neues->setFixedIon(_fixedion); 533 neues->setPosition(position); 531 534 532 535 // check size of vectors 533 if (neues-> Trajectory.R.size() <= (unsigned int)(repetition)) {536 if (neues->getTrajectorySize() <= (unsigned int)(repetition)) { 534 537 //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); 538 541 } 539 542 540 // put into trajectories list541 for (int d=0;d<NDIM;d++)542 neues->Trajectory.R.at(repetition)[d] = neues->at(d);543 544 543 // 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); 553 552 554 553 // 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); 563 562 564 563 // 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 573 567 // Log() << Verbose(0) << ")" << endl; 574 568 } … … 603 597 neues = AtomList[i][j]; 604 598 // 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); 616 616 // here we don't care if forces are present (last in trajectories is always equal to current position) 617 617 neues->setType(elementhash[i]); // find element type -
src/molecule.cpp
r54b42e r6625c3 365 365 FirstOtherAtom->setType(1); // element is Hydrogen 366 366 FirstOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity 367 FirstOtherAtom-> FixedIon = TopReplacement->FixedIon;367 FirstOtherAtom->setFixedIon(TopReplacement->getFixedIon()); 368 368 if (TopReplacement->getType()->getAtomicNumber() == 1) { // neither rescale nor replace if it's already hydrogen 369 369 FirstOtherAtom->father = TopReplacement; … … 430 430 SecondOtherAtom->setType(1); 431 431 FirstOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity 432 FirstOtherAtom-> FixedIon = TopReplacement->FixedIon;432 FirstOtherAtom->setFixedIon(TopReplacement->getFixedIon()); 433 433 SecondOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity 434 SecondOtherAtom-> FixedIon = TopReplacement->FixedIon;434 SecondOtherAtom->setFixedIon(TopReplacement->getFixedIon()); 435 435 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father 436 436 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father … … 485 485 ThirdOtherAtom->setType(1); 486 486 FirstOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity 487 FirstOtherAtom-> FixedIon = TopReplacement->FixedIon;487 FirstOtherAtom->setFixedIon(TopReplacement->getFixedIon()); 488 488 SecondOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity 489 SecondOtherAtom-> FixedIon = TopReplacement->FixedIon;489 SecondOtherAtom->setFixedIon(TopReplacement->getFixedIon()); 490 490 ThirdOtherAtom->setAtomicVelocity(TopReplacement->getAtomicVelocity()); // copy velocity 491 ThirdOtherAtom-> FixedIon = TopReplacement->FixedIon;491 ThirdOtherAtom->setFixedIon(TopReplacement->getFixedIon()); 492 492 FirstOtherAtom->father = NULL; // we are just an added hydrogen with no father 493 493 SecondOtherAtom->father = NULL; // we are just an added hydrogen with no father … … 582 582 istringstream *input = NULL; 583 583 int NumberOfAtoms = 0; // atom number in xyz read 584 int i , j; // loop variables584 int i; // loop variables 585 585 atom *Walker = NULL; // pointer to added atom 586 586 char shorthand[3]; // shorthand for atom name … … 618 618 Walker->setType(1); 619 619 } 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); 624 622 } 625 623 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); 631 627 AddAtom(Walker); // add to molecule 632 628 delete(item); -
src/molecule_dynamics.cpp
r54b42e r6625c3 60 60 // determine normalized trajectories direction vector (n1, n2) 61 61 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); 63 63 trajectory1.Normalize(); 64 64 Norm1 = trajectory1.Norm(); 65 65 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); 67 67 trajectory2.Normalize(); 68 68 Norm2 = trajectory1.Norm(); 69 69 // check whether either is zero() 70 70 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)); 72 72 } else if (Norm1 < MYEPSILON) { 73 73 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); 75 75 trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything 76 76 trajectory1 -= trajectory2; // project the part in norm direction away … … 78 78 } else if (Norm2 < MYEPSILON) { 79 79 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 offset80 trajectory2 = Sprinter->getPosition(Params.endstep) - Walker->getPosition(Params.startstep); // copy second offset 81 81 trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything 82 82 trajectory2 -= trajectory1; // project the part in norm direction away … … 87 87 // Log() << Verbose(0) << " and "; 88 88 // 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)); 90 90 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 91 91 } else { // determine distance by finding minimum distance … … 106 106 gsl_matrix_set(A, 1, i, trajectory2[i]); 107 107 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])); 109 109 } 110 110 // solve the linear system by Householder transformations … … 117 117 trajectory2.Scale(gsl_vector_get(x,1)); 118 118 normal.Scale(gsl_vector_get(x,2)); 119 TestVector = (*iter)-> Trajectory.R.at(Params.startstep) + trajectory2 + normal120 - (Walker-> Trajectory.R.at(Params.startstep) + trajectory1);119 TestVector = (*iter)->getPosition(Params.startstep) + trajectory2 + normal 120 - (Walker->getPosition(Params.startstep) + trajectory1); 121 121 if (TestVector.Norm() < MYEPSILON) { 122 122 // Log() << Verbose(2) << "Test: ok.\tDistance of " << tmp << " is correct." << endl; … … 150 150 // atom *Sprinter = PermutationMap[Walker->nr]; 151 151 // 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); 153 153 // Log() << Verbose(0) << ", penalting." << endl; 154 154 result += Params.PenaltyConstants[2]; … … 183 183 // first term: distance to target 184 184 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))); 186 186 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 187 187 result += Params.PenaltyConstants[0] * tmp; … … 239 239 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 240 240 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)) ); 242 242 } 243 243 } … … 489 489 // set forces 490 490 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))); 492 492 } 493 493 DoLog(1) && (Log() << Verbose(1) << "done." << endl); … … 525 525 526 526 // 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)); 528 529 // push endstep to last one 529 530 for_each(atoms.begin(),atoms.end(),boost::bind(&atom::CopyStepOnStep,_1,MaxSteps,endstep)); … … 538 539 // add to molecule list 539 540 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; 550 547 } 551 548 } … … 620 617 // and perform Verlet integration for each atom with position, velocity and force vector 621 618 // 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 } 625 622 626 623 // correct velocities (rather momenta) so that center of mass remains motionless -
src/molecule_geometry.cpp
r54b42e r6625c3 58 58 // go through all atoms 59 59 BOOST_FOREACH(atom* iter, atoms){ 60 std::cout << "atom before is at " << *iter << std::endl; 60 61 *iter -= *Center; 61 *iter -= *CenterBox; 62 *iter += *CenterBox; 63 std::cout << "atom after is at " << *iter << std::endl; 62 64 } 63 65 atoms.transformNodes(boost::bind(&Box::WrapPeriodically,domain,_1)); … … 314 316 { 315 317 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 } 319 323 } 320 324 }; … … 326 330 { 327 331 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 } 331 337 } 332 338 }; … … 334 340 /** Translate the molecule periodically in the box. 335 341 * \param trans[] translation vector. 336 * TODO treatment of traje tories missing342 * TODO treatment of trajectories missing 337 343 */ 338 344 void molecule::TranslatePeriodically(const Vector *trans) … … 438 444 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 439 445 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); 443 450 } 444 451 } … … 457 464 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 458 465 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); 462 470 } 463 471 }
Note:
See TracChangeset
for help on using the changeset viewer.