| 1 | /*
|
|---|
| 2 | * Woodcock.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Aug 20, 2010
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include "Woodcock.hpp"
|
|---|
| 9 |
|
|---|
| 10 | #include "element.hpp"
|
|---|
| 11 | #include "config.hpp"
|
|---|
| 12 | #include "Helpers/Verbose.hpp"
|
|---|
| 13 | #include "Helpers/Log.hpp"
|
|---|
| 14 | #include "ThermoStatContainer.hpp"
|
|---|
| 15 |
|
|---|
| 16 | #include <sstream>
|
|---|
| 17 |
|
|---|
| 18 | Woodcock::Woodcock(int _ScaleTempStep) :
|
|---|
| 19 | ScaleTempStep(_ScaleTempStep)
|
|---|
| 20 | {}
|
|---|
| 21 |
|
|---|
| 22 | Woodcock::Woodcock() :
|
|---|
| 23 | ScaleTempStep(25)
|
|---|
| 24 | {}
|
|---|
| 25 |
|
|---|
| 26 | Woodcock::~Woodcock()
|
|---|
| 27 | {}
|
|---|
| 28 |
|
|---|
| 29 | const char *ThermostatTraits<Woodcock>::name = "Woodcock";
|
|---|
| 30 |
|
|---|
| 31 | std::string ThermostatTraits<Woodcock>::getName(){
|
|---|
| 32 | return ThermostatTraits<Woodcock>::name;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | Thermostat *ThermostatTraits<Woodcock>::make(class ConfigFileBuffer * const fb){
|
|---|
| 36 | int ScaleTempStep;
|
|---|
| 37 | const int verbose = 0;
|
|---|
| 38 | ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
|
|---|
| 39 | return new Woodcock(ScaleTempStep);
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | double Woodcock::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::list) atoms){
|
|---|
| 43 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | double Woodcock::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::vector) atoms){
|
|---|
| 47 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | double Woodcock::scaleAtoms(unsigned int step,double ActualTemp,ATOMSET(std::set) atoms){
|
|---|
| 51 | return doScaleAtoms(step,ActualTemp,atoms.begin(),atoms.end());
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | template <class ForwardIterator>
|
|---|
| 55 | double Woodcock::doScaleAtoms(unsigned int step,double ActualTemp,ForwardIterator begin,ForwardIterator end){
|
|---|
| 56 | double ekin=0;
|
|---|
| 57 | if ((ScaleTempStep > 0) && ((step-1) % ScaleTempStep == 0)) {
|
|---|
| 58 | double ScaleTempFactor = sqrt(getContainer().TargetTemp/ActualTemp);
|
|---|
| 59 | DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl);
|
|---|
| 60 | double ekin;
|
|---|
| 61 | for (ForwardIterator iter = begin; iter!=end;++iter){
|
|---|
| 62 | Vector &U = (*iter)->Trajectory.U.at(step);
|
|---|
| 63 | if ((*iter)->FixedIon == 0){ // even FixedIon moves, only not by other's forces
|
|---|
| 64 | U *= ScaleTempFactor;
|
|---|
| 65 | ekin += 0.5*(*iter)->getType()->getMass() * U.NormSquared();
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 | return ekin;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | std::string Woodcock::name(){
|
|---|
| 73 | return ThermostatTraits<Woodcock>::name;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | std::string Woodcock::writeParams(){
|
|---|
| 77 | std::stringstream sstr;
|
|---|
| 78 | sstr << ScaleTempStep;
|
|---|
| 79 | return sstr.str();
|
|---|
| 80 | }
|
|---|