MaMiCo 1.2
Loading...
Searching...
No Matches
SetTemperatureMapping.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_SETTEMPERATUREMAPPING_H_
6#define _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_SETTEMPERATUREMAPPING_H_
7
8#include "coupling/interface/MDSolverInterface.h"
9#include "coupling/interface/Molecule.h"
10#include <cmath>
11#include <iostream>
12
13namespace coupling {
14namespace cellmappings {
15template <class LinkedCell, unsigned int dim> class SetTemperatureMapping;
16}
17} // namespace coupling
18
25template <class LinkedCell, unsigned int dim> class coupling::cellmappings::SetTemperatureMapping {
26public:
34 SetTemperatureMapping(const double& oldTemperature, const double& newTemperature, const tarch::la::Vector<dim, double>& meanVelocity,
36 : _mdSolverInterface(mdSolverInterface), _factor(getScalingFactor(oldTemperature, newTemperature)), _meanVelocity(meanVelocity) {}
37
40
44
48
53 void handleCell(LinkedCell& cell) {
54 coupling::interface::MoleculeIterator<LinkedCell, dim>* it = _mdSolverInterface->getMoleculeIterator(cell);
55 it->begin();
56 while (it->continueIteration()) {
59 // scale velocity
60 velocity = _meanVelocity + _factor * (velocity - _meanVelocity);
61 wrapper.setVelocity(velocity);
62 it->next();
63 }
64 delete it;
65 }
66
67private:
75 double getScalingFactor(const double& oldTemperature, const double& newTemperature) const {
76
77 if (oldTemperature != 0.0) {
78 return sqrt(newTemperature / oldTemperature);
79 } else {
80 return 1.0;
81 }
82 }
83
85 const double _factor;
86 const tarch::la::Vector<dim, double> _meanVelocity;
87};
88#endif // _MOLECULARDYNAMICS_COUPLING_CELLMAPPINGS_SETTEMPERATUREMAPPING_H_
This class sets a certain temperature over several linked cells.
Definition SetTemperatureMapping.h:25
void endCellIteration()
Definition SetTemperatureMapping.h:47
double getScalingFactor(const double &oldTemperature, const double &newTemperature) const
Definition SetTemperatureMapping.h:75
void handleCell(LinkedCell &cell)
Definition SetTemperatureMapping.h:53
void beginCellIteration()
Definition SetTemperatureMapping.h:43
SetTemperatureMapping(const double &oldTemperature, const double &newTemperature, const tarch::la::Vector< dim, double > &meanVelocity, coupling::interface::MDSolverInterface< LinkedCell, dim > *const mdSolverInterface)
Definition SetTemperatureMapping.h:34
~SetTemperatureMapping()
Definition SetTemperatureMapping.h:39
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
Definition Vector.h:24
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15