float StatisticsSampler::averageVelocity(System *system) { Particles *particles = system->particles(); double averageVelocity = 0; for(unsigned int i=0; i<particles->numberOfParticles(); i++) { averageVelocity += sqrt(particles->velocitySquared(i)); } averageVelocity /= particles->numberOfParticles(); return averageVelocity; }
void StatisticsSampler::sampleKineticEnergy(System *system) { m_kineticEnergy = 0; Particles *particles = system->particles(); float constant = 0.5*system->settings()->mass*system->settings()->atomsPerParticle; for(unsigned int i=0; i<particles->numberOfParticles(); i++) { m_kineticEnergy += constant*particles->velocitySquared(i); } }