MaMiCo 1.2
Loading...
Searching...
No Matches
UsherParticleInsertion.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_USHERPARTICLEINSERTION_H_
6#define _MOLECULARDYNAMICS_COUPLING_USHERPARTICLEINSERTION_H_
7
8#include "coupling/CouplingMDDefinitions.h"
9#include "coupling/ParticleInsertion.h"
10#include "coupling/cell-mappings/ComputeMassMapping.h"
11#include "coupling/cell-mappings/ComputeMomentumMapping.h"
12#include "coupling/cell-mappings/ComputeTemperatureMapping.h"
13#include "coupling/cell-mappings/DeleteParticleMapping.h"
14#include "coupling/datastructures/CouplingCell.h"
15#include "coupling/datastructures/Molecule.h"
16#include "coupling/interface/MDSolverInterface.h"
17#include "tarch/utils/RandomNumberService.h"
18
19// #define USHER_DEBUG
20
21namespace coupling {
22template <class LinkedCell, unsigned int dim> class UsherParticleInsertion;
23}
24
36template <class LinkedCell, unsigned int dim> class coupling::UsherParticleInsertion : public coupling::ParticleInsertion<LinkedCell, dim> {
37public:
55 UsherParticleInsertion(unsigned int insertDeleteMassEveryTimestep, double rSigmaCoeff, double meanPotentialEnergyFactor, double uOverlapCoeff,
56 double stepRefCoeff, unsigned int iterMax, unsigned int restartMax, double tolerance, double offsetFromOuterBoundary,
60
62 // enum Action{NoAction=0,Insertion=1,Deletion=2};
63
79 const tarch::la::Vector<dim, double>& couplingCellSize, const tarch::la::Vector<dim, double>& meanVelocity, const double& temperature,
80 const coupling::BoundaryForceController<LinkedCell, dim>& boundaryForceController);
81
85 virtual bool requiresPotentialEnergyLandscape() { return true; }
86
87#ifdef USHER_DEBUG
89 double _energyInserted;
91 double _energyRemoved;
94 double _ZhouEnergyInserted;
97 double _ZhouEnergyRemoved;
99 int _particlesInserted;
101 int _particlesRemoved;
102#endif
103
104private:
118 const tarch::la::Vector<dim, double>& couplingCellSize, const tarch::la::Vector<dim, double>& meanVelocity, const double& temperature,
119 const coupling::BoundaryForceController<LinkedCell, dim>& boundaryForceController);
120
130 const coupling::BoundaryForceController<LinkedCell, dim>& boundaryForceController);
131
132protected:
148 const tarch::la::Vector<dim, double>& couplingCellPosition, const tarch::la::Vector<dim, double>& couplingCellSize,
150
154 public:
165 unsigned int _iterMax;
167 unsigned int _restartMax;
174
176 UsherParams(double rSigmaCoeff, double meanPotentialEnergyFactor, double uOverlapCoeff, double stepRefCoeff, unsigned int iterMax, unsigned int restartMax,
177 double tolerance, double offsetFromOuterBoundary)
178 : _rSigmaCoeff(rSigmaCoeff), _meanPotentialEnergyFactor(meanPotentialEnergyFactor), _uOverlapCoeff(uOverlapCoeff), _stepRefCoeff(stepRefCoeff),
179 _iterMax(iterMax), _restartMax(restartMax), _tolerance(tolerance), _offsetFromOuterBoundary(offsetFromOuterBoundary) {}
180
182
186 double getStepRef(double numberDensity, double sigma) const {
187 // if the coeff. was not parsed and thus set to -1.0, we choose the
188 // strategy described in the usher paper...
189 if (_stepRefCoeff == -1.0) {
190 return 0.1 * pow((1.0 / numberDensity), 3.0 / 2.0) * sigma;
191 // ... otherwise we fix the step size in units of sigma
192 } else {
193 return _stepRefCoeff * sigma;
194 }
195 }
196 };
197
202};
203#include "coupling/UsherParticleInsertion.cpph"
204#endif // _MOLECULARDYNAMICS_COUPLING_USHERPARTICLEINSERTION_H_
controller for forces acting at open MD boundaries
Definition BoundaryForceController.h:25
interface for particle insertion/removal on coupling cell basis.
Definition ParticleInsertion.h:23
Action
Definition ParticleInsertion.h:27
collects all the parameters necessary for the Usher algorithm
Definition UsherParticleInsertion.h:153
double _uOverlapCoeff
Definition UsherParticleInsertion.h:161
unsigned int _restartMax
Definition UsherParticleInsertion.h:167
double getStepRef(double numberDensity, double sigma) const
returns the maximal displacement parameter for the usher method, ref. figure 7 in the paper
Definition UsherParticleInsertion.h:186
double _meanPotentialEnergyFactor
Definition UsherParticleInsertion.h:159
UsherParams(double rSigmaCoeff, double meanPotentialEnergyFactor, double uOverlapCoeff, double stepRefCoeff, unsigned int iterMax, unsigned int restartMax, double tolerance, double offsetFromOuterBoundary)
a simple destructor
Definition UsherParticleInsertion.h:176
double _stepRefCoeff
Definition UsherParticleInsertion.h:163
unsigned int _iterMax
Definition UsherParticleInsertion.h:165
double _offsetFromOuterBoundary
Definition UsherParticleInsertion.h:173
double _rSigmaCoeff
Definition UsherParticleInsertion.h:157
~UsherParams()
a dummy destructor
Definition UsherParticleInsertion.h:181
double _tolerance
Definition UsherParticleInsertion.h:170
handles particle insertion (via Usher algorithm) and random particle deletion.
Definition UsherParticleInsertion.h:36
coupling::ParticleInsertion< LinkedCell, dim >::Action insertParticle(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, const tarch::la::Vector< dim, double > &couplingCellPosition, const tarch::la::Vector< dim, double > &couplingCellSize, const tarch::la::Vector< dim, double > &meanVelocity, const double &temperature, const coupling::BoundaryForceController< LinkedCell, dim > &boundaryForceController)
tries to insert a particle in the respective coupling cell.
virtual bool requiresPotentialEnergyLandscape()
since the Usher algorithm requires the potential energy landscape, the function returns true
Definition UsherParticleInsertion.h:85
virtual coupling::ParticleInsertion< LinkedCell, dim >::Action findParticlePosition(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &thisCell, const tarch::la::Vector< dim, double > &couplingCellPosition, const tarch::la::Vector< dim, double > &couplingCellSize, coupling::datastructures::Molecule< dim > &molecule, const coupling::BoundaryForceController< LinkedCell, dim > &boundaryForceController)
determines the position of a new particle within the coupling cell
virtual ~UsherParticleInsertion()
a dummy destructor
Definition UsherParticleInsertion.h:59
virtual coupling::ParticleInsertion< LinkedCell, dim >::Action insertDeleteMass(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, const tarch::la::Vector< dim, double > &couplingCellPosition, const tarch::la::Vector< dim, double > &couplingCellSize, const tarch::la::Vector< dim, double > &meanVelocity, const double &temperature, const coupling::BoundaryForceController< LinkedCell, dim > &boundaryForceController)
checks if a particle needs to be inserted or deleted in a cell
coupling::ParticleInsertion< LinkedCell, dim >::Action deleteParticle(coupling::datastructures::CouplingCellWithLinkedCells< LinkedCell, dim > &cell, const coupling::BoundaryForceController< LinkedCell, dim > &boundaryForceController)
tries to delete a particle from the coupling cell.
coupling::interface::MDSolverInterface< LinkedCell, dim > *const _mdSolverInterface
interface to the md solver
Definition UsherParticleInsertion.h:199
const UsherParams _usherParams
instance of the UsherParams, stores all necessary parameters
Definition UsherParticleInsertion.h:201
UsherParticleInsertion(unsigned int insertDeleteMassEveryTimestep, double rSigmaCoeff, double meanPotentialEnergyFactor, double uOverlapCoeff, double stepRefCoeff, unsigned int iterMax, unsigned int restartMax, double tolerance, double offsetFromOuterBoundary, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
a simple constructor
defines the cell type with cell-averaged quantities. Derived from the class coupling::datastructures:...
Definition CouplingCellWithLinkedCells.h:26
molecule representation for coupling component. Dericed from the class coupling::interface::Molecule
Definition Molecule.h:24
interface to the MD simulation
Definition MDSolverInterface.h:25
Definition Vector.h:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15