source: src/atom_trajectoryparticle.cpp@ c38826

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
Last change on this file since c38826 was a3948b, checked in by Tillmann Crueger <crueger@…>, 14 years ago

Removed unused TrajectoryParticle::CorrectVelocity() method

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