MaMiCo 1.2
Loading...
Searching...
No Matches
ComputeMeanPotentialEnergyMapping.h
1// Copyright (C) 2015 Technische Universitaet Muenchen
2// This file is part of the Mamico project. For conditions of distribution
3// and use, please see the copyright notice in Mamico's main folder, or at
4// www5.in.tum.de/mamico
5#ifndef _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMEANPOTENTIALENERGYMAPPING_H_
6#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMEANPOTENTIALENERGYMAPPING_H_
7
8#include "coupling/BoundaryForceController.h"
9#include "coupling/interface/MDSolverInterface.h"
10#include "coupling/interface/Molecule.h"
11#include <iostream>
12
13namespace coupling {
14namespace cellmappings {
15template <class LinkedCell, unsigned int dim> class ComputeMeanPotentialEnergyMapping;
16}
17} // namespace coupling
18
26template <class LinkedCell, unsigned int dim> class coupling::cellmappings::ComputeMeanPotentialEnergyMapping {
27public:
33 const coupling::BoundaryForceController<LinkedCell, dim>& boundaryForceController)
34 : _mdSolverInterface(mdSolverInterface), _meanPotentialEnergy(0.0), _particleCounter(0), _boundaryForceController(boundaryForceController) {}
35
38
43 _meanPotentialEnergy = 0.0;
44 _particleCounter = 0;
45 }
46
52 if (_particleCounter != 0) {
53 _meanPotentialEnergy = _meanPotentialEnergy / _particleCounter;
54 }
55 }
56
61 void handleCell(LinkedCell& cell) {
62 coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
63 it->begin();
64 while (it->continueIteration()) {
65 const coupling::interface::Molecule<dim>& wrapper(it->getConst());
66 _meanPotentialEnergy += wrapper.getPotentialEnergy();
67 _meanPotentialEnergy += _boundaryForceController.getPotentialEnergy(wrapper.getPosition());
68 _particleCounter++;
69
70 it->next();
71 }
72 delete it;
73 }
74
78 double getPotentialEnergy() const { return _meanPotentialEnergy; }
79
80private:
82 double _meanPotentialEnergy;
83 unsigned int _particleCounter;
84 const coupling::BoundaryForceController<LinkedCell, dim>& _boundaryForceController;
85};
86#endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_COMPUTEMEANPOTENTIALENERGYMAPPING_H_
controller for forces acting at open MD boundaries
Definition BoundaryForceController.h:25
This class computes the mean potential energy over this coupling cell.
Definition ComputeMeanPotentialEnergyMapping.h:26
double getPotentialEnergy() const
Definition ComputeMeanPotentialEnergyMapping.h:78
~ComputeMeanPotentialEnergyMapping()
Definition ComputeMeanPotentialEnergyMapping.h:37
void beginCellIteration()
Definition ComputeMeanPotentialEnergyMapping.h:42
void handleCell(LinkedCell &cell)
Definition ComputeMeanPotentialEnergyMapping.h:61
void endCellIteration()
Definition ComputeMeanPotentialEnergyMapping.h:51
ComputeMeanPotentialEnergyMapping(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, const coupling::BoundaryForceController< LinkedCell, dim > &boundaryForceController)
Definition ComputeMeanPotentialEnergyMapping.h:32
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 const coupling::interface::Molecule< dim > & getConst()=0
interface to access a single molecule in the MD simulation.
Definition Molecule.h:23
virtual double getPotentialEnergy() const =0
virtual tarch::la::Vector< dim, double > getPosition() const =0
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15