Changes in src/atom_trajectoryparticle.cpp [952f38:83f176]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/atom_trajectoryparticle.cpp
r952f38 r83f176 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 1 8 /* 2 9 * atom_trajectoryparticle.cpp … … 5 12 * Author: heber 6 13 */ 14 15 // include config.h 16 #ifdef HAVE_CONFIG_H 17 #include <config.h> 18 #endif 7 19 8 20 #include "Helpers/MemDebug.hpp" … … 38 50 { 39 51 for (int i=NDIM;i--;) 40 *temperature += type->mass* Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i];52 *temperature += getType()->getMass() * Trajectory.U.at(step)[i]* Trajectory.U.at(step)[i]; 41 53 }; 42 54 … … 65 77 for(int d=0;d<NDIM;d++) { 66 78 Trajectory.U.at(Step)[d] -= CoGVelocity->at(d); 67 *ActualTemp += 0.5 * type->mass* Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d];79 *ActualTemp += 0.5 * getType()->getMass() * Trajectory.U.at(Step)[d] * Trajectory.U.at(Step)[d]; 68 80 } 69 81 }; … … 113 125 Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d]; 114 126 Trajectory.R.at(NextStep)[d] += configuration->Deltat*(Trajectory.U.at(NextStep-1)[d]); // s(t) = s(0) + v * deltat + 1/2 a * deltat^2 115 Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/ type->mass); // F = m * a and s =127 Trajectory.R.at(NextStep)[d] += 0.5*configuration->Deltat*configuration->Deltat*(Trajectory.F.at(NextStep)[d]/getType()->getMass()); // F = m * a and s = 116 128 } 117 129 // Update U 118 130 for (int d=0; d<NDIM; d++) { 119 131 Trajectory.U.at(NextStep)[d] = Trajectory.U.at(NextStep-1)[d]; 120 Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/ type->mass); // v = F/m * t132 Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/getType()->getMass()); // v = F/m * t 121 133 } 122 134 // Update R (and F) … … 137 149 void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const 138 150 { 139 *TotalMass += type->mass; // sum up total mass151 *TotalMass += getType()->getMass(); // sum up total mass 140 152 for(int d=0;d<NDIM;d++) { 141 TotalVelocity->at(d) += Trajectory.U.at(Step)[d]* type->mass;153 TotalVelocity->at(d) += Trajectory.U.at(Step)[d]*getType()->getMass(); 142 154 } 143 155 }; … … 154 166 for (int d=0; d<NDIM; d++) { 155 167 U[d] *= ScaleTempFactor; 156 *ekin += 0.5* type->mass* U[d]*U[d];168 *ekin += 0.5*getType()->getMass() * U[d]*U[d]; 157 169 } 158 170 }; … … 170 182 for (int d=0; d<NDIM; d++) { 171 183 *G += U[d] * F[d]; 172 *E += U[d]*U[d]* type->mass;184 *E += U[d]*U[d]*getType()->getMass(); 173 185 } 174 186 }; … … 185 197 if (FixedIon == 0) // even FixedIon moves, only not by other's forces 186 198 for (int d=0; d<NDIM; d++) { 187 U[d] += configuration->Deltat/ type->mass * ( (G_over_E) * (U[d]*type->mass) );188 *ekin += type->mass* U[d]*U[d];199 U[d] += configuration->Deltat/getType()->getMass() * ( (G_over_E) * (U[d]*getType()->getMass()) ); 200 *ekin += getType()->getMass() * U[d]*U[d]; 189 201 } 190 202 }; … … 198 210 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 199 211 { 200 double sigma = sqrt(configuration->Thermostats->TargetTemp/ type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)212 double sigma = sqrt(configuration->Thermostats->TargetTemp/getType()->getMass()); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) 201 213 Vector &U = Trajectory.U.at(Step); 202 214 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces … … 211 223 } 212 224 for (int d=0; d<NDIM; d++) 213 *ekin += 0.5* type->mass* U[d]*U[d];225 *ekin += 0.5*getType()->getMass() * U[d]*U[d]; 214 226 } 215 227 }; … … 227 239 for (int d=0; d<NDIM; d++) { 228 240 U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1)); 229 *ekin += 0.5* type->mass* U[d]*U[d];241 *ekin += 0.5*getType()->getMass() * U[d]*U[d]; 230 242 } 231 243 } … … 241 253 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 242 254 for (int d=0; d<NDIM; d++) { 243 *delta_alpha += U[d]*U[d]* type->mass;255 *delta_alpha += U[d]*U[d]*getType()->getMass(); 244 256 } 245 257 } … … 256 268 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 257 269 for (int d=0; d<NDIM; d++) { 258 U[d] += configuration->Deltat/ type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass));259 *ekin += (0.5* type->mass) * U[d]*U[d];270 U[d] += configuration->Deltat/getType()->getMass() * (configuration->Thermostats->alpha * (U[d] * getType()->getMass())); 271 *ekin += (0.5*getType()->getMass()) * U[d]*U[d]; 260 272 } 261 273 } 262 274 }; 275 276 277 std::ostream & TrajectoryParticle::operator << (std::ostream &ost) const 278 { 279 ParticleInfo::operator<<(ost); 280 ost << "," << getPosition(); 281 return ost; 282 } 283 284 std::ostream & operator << (std::ostream &ost, const TrajectoryParticle &a) 285 { 286 a.ParticleInfo::operator<<(ost); 287 ost << "," << a.getPosition(); 288 return ost; 289 } 290
Note:
See TracChangeset
for help on using the changeset viewer.