Ignore:
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
    18/*
    29 * atom_trajectoryparticle.cpp
     
    512 *      Author: heber
    613 */
     14
     15// include config.h
     16#ifdef HAVE_CONFIG_H
     17#include <config.h>
     18#endif
    719
    820#include "Helpers/MemDebug.hpp"
     
    3850{
    3951  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];
    4153};
    4254
     
    6577  for(int d=0;d<NDIM;d++) {
    6678    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];
    6880  }
    6981};
     
    113125    Trajectory.R.at(NextStep)[d] = Trajectory.R.at(NextStep-1)[d];
    114126    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 =
    116128  }
    117129  // Update U
    118130  for (int d=0; d<NDIM; d++) {
    119131    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 * t
     132    Trajectory.U.at(NextStep)[d] += configuration->Deltat * (Trajectory.F.at(NextStep)[d]+Trajectory.F.at(NextStep-1)[d]/getType()->getMass()); // v = F/m * t
    121133  }
    122134  // Update R (and F)
     
    137149void TrajectoryParticle::SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity ) const
    138150{
    139   *TotalMass += type->mass;  // sum up total mass
     151  *TotalMass += getType()->getMass();  // sum up total mass
    140152  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();
    142154  }
    143155};
     
    154166    for (int d=0; d<NDIM; d++) {
    155167      U[d] *= ScaleTempFactor;
    156       *ekin += 0.5*type->mass * U[d]*U[d];
     168      *ekin += 0.5*getType()->getMass() * U[d]*U[d];
    157169    }
    158170};
     
    170182    for (int d=0; d<NDIM; d++) {
    171183      *G += U[d] * F[d];
    172       *E += U[d]*U[d]*type->mass;
     184      *E += U[d]*U[d]*getType()->getMass();
    173185    }
    174186};
     
    185197  if (FixedIon == 0) // even FixedIon moves, only not by other's forces
    186198    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];
    189201    }
    190202};
     
    198210void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
    199211{
    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)
    201213  Vector &U = Trajectory.U.at(Step);
    202214  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
     
    211223    }
    212224    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];
    214226  }
    215227};
     
    227239    for (int d=0; d<NDIM; d++) {
    228240      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];
    230242    }
    231243  }
     
    241253  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    242254    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();
    244256    }
    245257  }
     
    256268  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    257269    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];
    260272      }
    261273  }
    262274};
     275
     276
     277std::ostream & TrajectoryParticle::operator << (std::ostream &ost) const
     278{
     279  ParticleInfo::operator<<(ost);
     280  ost << "," << getPosition();
     281  return ost;
     282}
     283
     284std::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.