[194649] | 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"
|
---|
[579a81] | 14 | #include "World.hpp"
|
---|
[194649] | 15 |
|
---|
[579a81] | 16 | Berendsen::Berendsen(double _TempFrequency) :
|
---|
| 17 | TempFrequency(_TempFrequency)
|
---|
[194649] | 18 | {}
|
---|
| 19 |
|
---|
| 20 | Berendsen::~Berendsen()
|
---|
| 21 | {}
|
---|
| 22 |
|
---|
[579a81] | 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());
|
---|
[194649] | 30 | }
|
---|
| 31 |
|
---|
[579a81] | 32 | double Berendsen::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::vector) atoms){
|
---|
| 33 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
---|
[194649] | 34 | }
|
---|
| 35 |
|
---|
[579a81] | 36 | double Berendsen::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::set) atoms){
|
---|
| 37 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
---|
[194649] | 38 | }
|
---|
| 39 |
|
---|
| 40 | template <class ForwardIterator>
|
---|
[579a81] | 41 | double Berendsen::doScaleAtoms(unsigned int step,double ActualTemp,ForwardIterator begin, ForwardIterator end){
|
---|
[194649] | 42 | DoLog(2) && (Log() << Verbose(2) << "Applying Berendsen-VanGunsteren thermostat..." << endl);
|
---|
| 43 | double ekin;
|
---|
[579a81] | 44 | double ScaleTempFactor = getContainer().TargetTemp/ActualTemp;
|
---|
[194649] | 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
|
---|
[579a81] | 48 | U *= sqrt(1+(World::getInstance().getConfig()->Deltat/TempFrequency)*(ScaleTempFactor-1));
|
---|
[194649] | 49 | ekin += 0.5*(*iter)->getType()->mass * U.NormSquared();
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 | return ekin;
|
---|
| 53 | }
|
---|
[579a81] | 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 | }
|
---|