1 | /*
|
---|
2 | * Berendsen.cpp
|
---|
3 | *
|
---|
4 | * Created on: Aug 20, 2010
|
---|
5 | * Author: crueger
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "Berendsen.hpp"
|
---|
9 | #include "element.hpp"
|
---|
10 | #include "config.hpp"
|
---|
11 | #include "Helpers/Verbose.hpp"
|
---|
12 | #include "Helpers/Log.hpp"
|
---|
13 | #include "ThermoStatContainer.hpp"
|
---|
14 | #include "World.hpp"
|
---|
15 |
|
---|
16 | Berendsen::Berendsen(double _TempFrequency) :
|
---|
17 | TempFrequency(_TempFrequency)
|
---|
18 | {}
|
---|
19 |
|
---|
20 | Berendsen::~Berendsen()
|
---|
21 | {}
|
---|
22 |
|
---|
23 | ThermostatTraits<class Berendsen>::ThermostatTraits() :
|
---|
24 | name("Berendsen")
|
---|
25 | {}
|
---|
26 |
|
---|
27 |
|
---|
28 | double Berendsen::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::list) atoms){
|
---|
29 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
---|
30 | }
|
---|
31 |
|
---|
32 | double Berendsen::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::vector) atoms){
|
---|
33 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
---|
34 | }
|
---|
35 |
|
---|
36 | double Berendsen::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::set) atoms){
|
---|
37 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
---|
38 | }
|
---|
39 |
|
---|
40 | template <class ForwardIterator>
|
---|
41 | double Berendsen::doScaleAtoms(unsigned int step,double ActualTemp,ForwardIterator begin, ForwardIterator end){
|
---|
42 | DoLog(2) && (Log() << Verbose(2) << "Applying Berendsen-VanGunsteren thermostat..." << endl);
|
---|
43 | double ekin;
|
---|
44 | double ScaleTempFactor = getContainer().TargetTemp/ActualTemp;
|
---|
45 | for(ForwardIterator iter=begin;iter!=end;++iter){
|
---|
46 | Vector &U = (*iter)->Trajectory.U.at(step);
|
---|
47 | if ((*iter)->FixedIon == 0) { // even FixedIon moves, only not by other's forces
|
---|
48 | U *= sqrt(1+(World::getInstance().getConfig()->Deltat/TempFrequency)*(ScaleTempFactor-1));
|
---|
49 | ekin += 0.5*(*iter)->getType()->mass * U.NormSquared();
|
---|
50 | }
|
---|
51 | }
|
---|
52 | return ekin;
|
---|
53 | }
|
---|
54 |
|
---|
55 | std::string Berendsen::name(){
|
---|
56 | return ThermostatTraits<Berendsen>().name;
|
---|
57 | }
|
---|
58 |
|
---|
59 | std::string Berendsen::writeParam(){
|
---|
60 | stringstream sstr;
|
---|
61 | sstr << TempFrequency;
|
---|
62 | return sstr.str();
|
---|
63 | }
|
---|