5#ifndef _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_SETKINETICENERGYMAPPING_H_
6#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_SETKINETICENERGYMAPPING_H_
8#include "coupling/interface/MDSolverInterface.h"
9#include "coupling/interface/Molecule.h"
14namespace cellmappings {
35 SetKineticEnergyMapping(
const double& oldKineticEnergy,
const double& newKineticEnergy,
const unsigned int& numberParticles,
37 : _mdSolverInterface(mdSolverInterface), _meanVelocity(meanVelocity),
38 _correctionFactor(
getCorrectionFactor(oldKineticEnergy, newKineticEnergy, numberParticles, meanVelocity)) {}
64 velocity = _meanVelocity + _correctionFactor * (velocity - _meanVelocity);
80 double getCorrectionFactor(
const double& oldKineticEnergy,
const double& newKineticEnergy,
const unsigned int& numberParticles,
82 const double mass = _mdSolverInterface->getMoleculeMass();
86 if (oldKineticEnergy - 0.5 * mass * numberParticles * tarch::la::dot(meanVelocity, meanVelocity) < 1e-7) {
90 double correctionFactor = newKineticEnergy - 0.5 * mass * numberParticles * tarch::la::dot(meanVelocity, meanVelocity);
91 correctionFactor = correctionFactor / (oldKineticEnergy - 0.5 * mass * numberParticles * tarch::la::dot(meanVelocity, meanVelocity));
92 correctionFactor = sqrt(correctionFactor);
93 return correctionFactor;
98 const double _correctionFactor;
This class sets kinetic energy over several linked cells.
Definition SetKineticEnergyMapping.h:25
void beginCellIteration()
Definition SetKineticEnergyMapping.h:45
~SetKineticEnergyMapping()
Definition SetKineticEnergyMapping.h:41
SetKineticEnergyMapping(const double &oldKineticEnergy, const double &newKineticEnergy, const unsigned int &numberParticles, const tarch::la::Vector< dim, double > &meanVelocity, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition SetKineticEnergyMapping.h:35
void endCellIteration()
Definition SetKineticEnergyMapping.h:49
void handleCell(LinkedCell &cell)
Definition SetKineticEnergyMapping.h:55
double getCorrectionFactor(const double &oldKineticEnergy, const double &newKineticEnergy, const unsigned int &numberParticles, const tarch::la::Vector< dim, double > &meanVelocity) const
Definition SetKineticEnergyMapping.h:80
interface to the MD simulation
Definition MDSolverInterface.h:25
some iterator scheme for traversing the molecules within a linked cell.
Definition MoleculeIterator.h:24
virtual bool continueIteration() const =0
virtual coupling::interface::Molecule< dim > & get()=0
interface to access a single molecule in the MD simulation.
Definition Molecule.h:23
virtual void setVelocity(const tarch::la::Vector< dim, double > &velocity)=0
virtual tarch::la::Vector< dim, double > getVelocity() const =0
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15