Molecular Dynamics Simulation  1.0
Functions
RelativeThermostat.cpp File Reference
#include "RelativeThermostat.h"
#include <cmath>
#include "utils/ArrayUtils.h"
Include dependency graph for RelativeThermostat.cpp:

Go to the source code of this file.

Functions

std::array< double, 3 > averageVelocity (const std::unique_ptr< ParticleContainer > &particle_container)
 

Function Documentation

◆ averageVelocity()

std::array<double, 3> averageVelocity ( const std::unique_ptr< ParticleContainer > &  particle_container)

Definition at line 10 of file RelativeThermostat.cpp.

10  {
11  std::array<double, 3> average_velocity = {0, 0, 0};
12  size_t count = 0;
13  for (auto& particle : *particle_container) {
14  if (particle.isLocked()) continue;
15  average_velocity = average_velocity + particle.getV();
16  count++;
17  }
18  average_velocity = (1.0 / count) * average_velocity;
19  return average_velocity;
20 }