MaMiCo
1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
coupling
cell-mappings
PerturbateVelocityMapping.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 _COUPLING_CELLMAPPINGS_PERTURBATEVELOCITYMAPPING_H_
6
#define _COUPLING_CELLMAPPINGS_PERTURBATEVELOCITYMAPPING_H_
7
8
#include "coupling/interface/MDSolverInterface.h"
9
#include "tarch/utils/RandomNumberService.h"
10
11
namespace
coupling
{
12
namespace
cellmappings {
13
template
<
class
LinkedCell,
unsigned
int
dim>
class
PerturbateVelocityMapping
;
14
}
15
}
// namespace coupling
16
26
template
<
class
LinkedCell,
unsigned
int
dim>
class
coupling::cellmappings::PerturbateVelocityMapping
{
27
public
:
33
PerturbateVelocityMapping
(
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
mdSolverInterface,
const
tarch::la::Vector<dim, double>
& velocity,
34
const
double
& temperature)
35
: _mdSolverInterface(mdSolverInterface), _molecularMass(mdSolverInterface->getMoleculeMass()), _kB(mdSolverInterface->getKB()), _temperature(temperature),
36
_velocity(velocity), _sigma(_mdSolverInterface->getMoleculeSigma()) {}
37
39
~PerturbateVelocityMapping
() {}
40
43
void
beginCellIteration
() {}
46
void
endCellIteration
() {}
47
51
void
handleCell
(LinkedCell& cell) {
52
53
double
stdDeviation = std::sqrt(dim * _kB * _temperature / _molecularMass);
54
55
tarch::la::Vector<dim, double>
randomNumbers(0.0);
56
57
coupling::interface::MoleculeIterator<LinkedCell, dim>
* molecule = _mdSolverInterface->getMoleculeIterator(cell);
58
molecule->
begin
();
59
while
(molecule->
continueIteration
()) {
60
coupling::interface::Molecule<dim>
& wrapper(molecule->
get
());
61
randomNumbers[0] = tarch::utils::RandomNumberService::getInstance().getGaussianRandomNumber();
62
for
(
unsigned
int
d = 1; d < dim; ++d) {
63
randomNumbers[d] = tarch::utils::RandomNumberService::getInstance().getGaussianRandomNumber();
64
}
65
66
tarch::la::Vector<dim, double>
mVelocity = wrapper.
getVelocity
();
67
if
(dim == 3) {
68
mVelocity[0] = _velocity[0] + stdDeviation * (randomNumbers[0] * std::sin(randomNumbers[1]) * std::cos(randomNumbers[2]));
69
mVelocity[1] = _velocity[1] + stdDeviation * (randomNumbers[0] * std::sin(randomNumbers[1]) * std::sin(randomNumbers[2]));
70
mVelocity[2] = _velocity[2] + stdDeviation * (randomNumbers[0] * std::cos(randomNumbers[1]));
71
}
else
if
(dim == 1) {
72
mVelocity = _velocity + stdDeviation * randomNumbers;
73
}
else
if
(dim == 2) {
74
mVelocity[0] = _velocity[0] + stdDeviation * (randomNumbers[0] * std::cos(randomNumbers[1]));
75
mVelocity[1] = _velocity[1] + stdDeviation * (randomNumbers[0] * std::sin(randomNumbers[1]));
76
}
77
wrapper.
setVelocity
(mVelocity);
78
79
molecule->
next
();
80
}
81
delete
molecule;
82
}
83
84
private
:
85
coupling::interface::MDSolverInterface<LinkedCell, dim>
*
const
_mdSolverInterface;
86
const
double
_molecularMass;
87
const
double
_kB;
88
const
double
_temperature;
89
const
tarch::la::Vector<dim, double>
_velocity;
90
const
double
_sigma;
91
};
92
93
#endif
//_COUPLING_CELLMAPPINGS_VARYCHECKPOINTMAPPING_H_
coupling::cellmappings::PerturbateVelocityMapping
This class is used to superimpose a random perturbation to the mean velocity in all directions.
Definition
PerturbateVelocityMapping.h:26
coupling::cellmappings::PerturbateVelocityMapping::~PerturbateVelocityMapping
~PerturbateVelocityMapping()
Definition
PerturbateVelocityMapping.h:39
coupling::cellmappings::PerturbateVelocityMapping::PerturbateVelocityMapping
PerturbateVelocityMapping(coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface, const tarch::la::Vector< dim, double > &velocity, const double &temperature)
Definition
PerturbateVelocityMapping.h:33
coupling::cellmappings::PerturbateVelocityMapping::endCellIteration
void endCellIteration()
Definition
PerturbateVelocityMapping.h:46
coupling::cellmappings::PerturbateVelocityMapping::beginCellIteration
void beginCellIteration()
Definition
PerturbateVelocityMapping.h:43
coupling::cellmappings::PerturbateVelocityMapping::handleCell
void handleCell(LinkedCell &cell)
Definition
PerturbateVelocityMapping.h:51
coupling::interface::MDSolverInterface
interface to the MD simulation
Definition
MDSolverInterface.h:25
coupling::interface::MoleculeIterator
some iterator scheme for traversing the molecules within a linked cell.
Definition
MoleculeIterator.h:24
coupling::interface::MoleculeIterator::continueIteration
virtual bool continueIteration() const =0
coupling::interface::MoleculeIterator::next
virtual void next()=0
coupling::interface::MoleculeIterator::begin
virtual void begin()=0
coupling::interface::MoleculeIterator::get
virtual coupling::interface::Molecule< dim > & get()=0
coupling::interface::Molecule
interface to access a single molecule in the MD simulation.
Definition
Molecule.h:23
coupling::interface::Molecule::setVelocity
virtual void setVelocity(const tarch::la::Vector< dim, double > &velocity)=0
coupling::interface::Molecule::getVelocity
virtual tarch::la::Vector< dim, double > getVelocity() const =0
tarch::la::Vector
Definition
Vector.h:25
coupling
everything necessary for coupling operations, is defined in here
Definition
AdditiveMomentumInsertion.h:15
Generated by
1.17.0