source: src/atom_trajectoryparticle.cpp@ 14c57a

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 Candidate_v1.7.0 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
Last change on this file since 14c57a was 14c57a, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Made all parts of the programm use the new thermostat structure

  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 * atom_trajectoryparticle.cpp
3 *
4 * Created on: Oct 19, 2009
5 * Author: heber
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include "Helpers/MemDebug.hpp"
14
15#include "atom.hpp"
16#include "atom_trajectoryparticle.hpp"
17#include "config.hpp"
18#include "element.hpp"
19#include "Helpers/Info.hpp"
20#include "Helpers/Log.hpp"
21#include "parser.hpp"
22#include "ThermoStatContainer.hpp"
23#include "Helpers/Verbose.hpp"
24
25/** Constructor of class TrajectoryParticle.
26 */
27TrajectoryParticle::TrajectoryParticle()
28{
29};
30
31/** Destructor of class TrajectoryParticle.
32 */
33TrajectoryParticle::~TrajectoryParticle()
34{
35};
36
37/**
38 * returns the kinetic energy of this atom at a given time step
39 */
40double TrajectoryParticle::getKineticEnergy(unsigned int step) const{
41 return getType()->mass * Trajectory.U.at(step).NormSquared();
42}
43
44/** Evaluates some constraint potential if atom moves from \a startstep at once to \endstep in trajectory.
45 * \param startstep trajectory begins at
46 * \param endstep trajectory ends at
47 * \param **PermutationMap if atom switches places with some other atom, there is no translation but a permutaton noted here (not in the trajectories of ea
48 * \param *Force Force matrix to store result in
49 */
50void TrajectoryParticle::EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force) const
51{
52 double constant = 10.;
53 TrajectoryParticle *Sprinter = PermutationMap[nr];
54 // set forces
55 for (int i=NDIM;i++;)
56 Force->Matrix[0][nr][5+i] += 2.*constant*sqrt(Trajectory.R.at(startstep).distance(Sprinter->Trajectory.R.at(endstep)));
57};
58
59/** Correct velocity against the summed \a CoGVelocity for \a step.
60 * \param *ActualTemp sum up actual temperature meanwhile
61 * \param Step MD step in atom::Tracjetory
62 * \param *CoGVelocity remnant velocity (i.e. vector sum of all atom velocities)
63 */
64void TrajectoryParticle::CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity)
65{
66 for(int d=0;d<NDIM;d++) {
67 Trajectory.U.at(Step)[d] -= CoGVelocity->at(d);
68 *ActualTemp += 0.5 * getType()->mass * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d];
69 }
70};
71
72/** Extends the trajectory STL vector to the new size.
73 * Does nothing if \a MaxSteps is smaller than current size.
74 * \param MaxSteps
75 */
76void TrajectoryParticle::ResizeTrajectory(int MaxSteps)
77{
78 Info FunctionInfo(__func__);
79 if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) {
80 DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array of " << nr << " from " << Trajectory.R.size() << " to " << (MaxSteps+1) << "." << endl);
81 Trajectory.R.resize(MaxSteps+1);
82 Trajectory.U.resize(MaxSteps+1);
83 Trajectory.F.resize(MaxSteps+1);
84 }
85};
86
87/** Copies a given trajectory step \a src onto another \a dest
88 * \param dest index of destination step
89 * \param src index of source step
90 */
91void TrajectoryParticle::CopyStepOnStep(int dest, int src)
92{
93 if (dest == src) // self assignment check
94 return;
95
96 for (int n=NDIM;n--;) {
97 Trajectory.R.at(dest)[n] = Trajectory.R.at(src)[n];
98 Trajectory.U.at(dest)[n] = Trajectory.U.at(src)[n];
99 Trajectory.F.at(dest)[n] = Trajectory.F.at(src)[n];
100 }
101};
102
103/** Performs a velocity verlet update of the trajectory.
104 * Parameters are according to those in configuration class.
105 * \param NextStep index of sequential step to set
106 * \param *configuration pointer to configuration with parameters
107 * \param *Force matrix with forces
108 */
109void TrajectoryParticle::VelocityVerletUpdate(int NextStep, config *configuration, ForceMatrix *Force, const size_t offset)
110{
111 //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
112 for (int d=0; d<NDIM; d++) {
113 Trajectory.F.at(NextStep)[d] = -Force->Matrix[0][nr][d+offset]*(configuration->GetIsAngstroem() ? AtomicLengthToAngstroem : 1.);
114 Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d];
115 Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]); // s(t) = s(0) + v * deltat + 1/2 a * deltat^2
116 Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/getType()->mass); // F = m * a and s =
117 }
118 // Update U
119 for (int d=0; d<NDIM; d++) {
120 Trajectory.U.at(NextStep)[d] = Trajectory.U.at(NextStep-1)[d];
121 Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/getType()->mass); // v = F/m * t
122 }
123 // Update R (and F)
124// out << "Integrated position&velocity of step " << (NextStep) << ": (";
125// for (int d=0;d<NDIM;d++)
126// out << Trajectory.R.at(NextStep).x[d] << " "; // next step
127// out << ")\t(";
128// for (int d=0;d<NDIM;d++)
129// Log() << Verbose(0) << Trajectory.U.at(NextStep).x[d] << " "; // next step
130// out << ")" << endl;
131};
132
133/** Sums up mass and kinetics.
134 * \param Step step to sum for
135 * \param *TotalMass pointer to total mass sum
136 * \param *TotalVelocity pointer to tota velocity sum
137 */
138void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const
139{
140 *TotalMass += getType()->mass; // sum up total mass
141 for(int d=0;d<NDIM;d++) {
142 TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*getType()->mass;
143 }
144};
145
146std::ostream & TrajectoryParticle::operator << (std::ostream &ost) const
147{
148 ParticleInfo::operator<<(ost);
149 ost << "," << getPosition();
150 return ost;
151}
152
153std::ostream & operator << (std::ostream &ost, const TrajectoryParticle &a)
154{
155 a.ParticleInfo::operator<<(ost);
156 ost << "," << a.getPosition();
157 return ost;
158}
159
Note: See TracBrowser for help on using the repository browser.