| 1 | /*
|
|---|
| 2 | * ThermoStatContainer.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: 12.06.2010
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | // include config.h
|
|---|
| 9 | #ifdef HAVE_CONFIG_H
|
|---|
| 10 | #include <config.h>
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| 13 | #include "Helpers/MemDebug.hpp"
|
|---|
| 14 |
|
|---|
| 15 | #include <cstring>
|
|---|
| 16 |
|
|---|
| 17 | #include "ConfigFileBuffer.hpp"
|
|---|
| 18 | #include "config.hpp"
|
|---|
| 19 | #include "Helpers/Log.hpp"
|
|---|
| 20 | #include "ThermoStatContainer.hpp"
|
|---|
| 21 | #include "Helpers/Verbose.hpp"
|
|---|
| 22 |
|
|---|
| 23 | #include <Thermostats/Berendsen.hpp>
|
|---|
| 24 | #include <Thermostats/GaussianThermostat.hpp>
|
|---|
| 25 | #include <Thermostats/Langevin.hpp>
|
|---|
| 26 | #include <Thermostats/NoseHoover.hpp>
|
|---|
| 27 | #include <Thermostats/NoThermostat.hpp>
|
|---|
| 28 | #include <Thermostats/Woodcock.hpp>
|
|---|
| 29 |
|
|---|
| 30 | /** Constructor for class ThermoStatContainer.
|
|---|
| 31 | *
|
|---|
| 32 | */
|
|---|
| 33 | ThermoStatContainer::ThermoStatContainer() :
|
|---|
| 34 | activeThermostat(0),
|
|---|
| 35 | TargetTemp(0.00095004455)
|
|---|
| 36 | {
|
|---|
| 37 | ThermostatTraits<Thermostat> *BerendsenTrait = new ThermostatTraits<Berendsen>();
|
|---|
| 38 | availThermostats[BerendsenTrait->getName()] = BerendsenTrait;
|
|---|
| 39 | ThermostatTraits<Thermostat> *GaussianTrait = new ThermostatTraits<GaussianThermostat>();
|
|---|
| 40 | availThermostats[GaussianTrait->getName()] = GaussianTrait;
|
|---|
| 41 | ThermostatTraits<Thermostat> *LangevinTrait = new ThermostatTraits<Langevin>();
|
|---|
| 42 | availThermostats[LangevinTrait->getName()] = LangevinTrait;
|
|---|
| 43 | ThermostatTraits<Thermostat> *NoseHooverTrait = new ThermostatTraits<NoseHoover>();
|
|---|
| 44 | availThermostats[NoseHooverTrait->getName()] = NoseHooverTrait;
|
|---|
| 45 | ThermostatTraits<Thermostat> *NoThermostatTrait = new ThermostatTraits<NoThermostat>();
|
|---|
| 46 | availThermostats[NoThermostatTrait->getName()] = NoThermostatTrait;
|
|---|
| 47 | ThermostatTraits<Thermostat> *WoodcockTrait = new ThermostatTraits<Woodcock>();
|
|---|
| 48 | availThermostats[WoodcockTrait->getName()] = WoodcockTrait;
|
|---|
| 49 | for(traitsMap::iterator iter = availThermostats.begin();iter!=availThermostats.end();++iter){
|
|---|
| 50 | cout << iter->first << endl;
|
|---|
| 51 | }
|
|---|
| 52 | ASSERT(availThermostats.size()==6,"Not all implemented thermostats referenced!\nDid you check the names in the traits?");
|
|---|
| 53 | activeThermostat=new Berendsen();
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | ThermostatTraits<Thermostat> *ThermoStatContainer::getTraitByName(const std::string name){
|
|---|
| 57 | if(!availThermostats.count(name))
|
|---|
| 58 | return 0;
|
|---|
| 59 | return availThermostats[name];
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | Thermostat *ThermoStatContainer::makeByName(const std::string name,class ConfigFileBuffer * const fb){
|
|---|
| 63 | ThermostatTraits<Thermostat>* trait = getTraitByName(name);
|
|---|
| 64 | if(trait){
|
|---|
| 65 | Thermostat *res = trait->make(fb);
|
|---|
| 66 | res->addToContainer(this);
|
|---|
| 67 | return res;
|
|---|
| 68 | }
|
|---|
| 69 | else{
|
|---|
| 70 | return 0;
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | void ThermoStatContainer::makeActive(const std::string name,class ConfigFileBuffer * const fb){
|
|---|
| 75 | Thermostat* newThermostat = makeByName(name,fb);
|
|---|
| 76 | if(newThermostat){
|
|---|
| 77 | if(activeThermostat){
|
|---|
| 78 | delete activeThermostat;
|
|---|
| 79 | }
|
|---|
| 80 | activeThermostat = newThermostat;
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | void ThermoStatContainer::chooseNone(){
|
|---|
| 85 | if(activeThermostat){
|
|---|
| 86 | delete activeThermostat;
|
|---|
| 87 | }
|
|---|
| 88 | activeThermostat = new NoThermostat();
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | /** Destructor for Class ThermoStatContainer.
|
|---|
| 92 | *
|
|---|
| 93 | */
|
|---|
| 94 | ThermoStatContainer::~ThermoStatContainer()
|
|---|
| 95 | {
|
|---|
| 96 | if(activeThermostat){
|
|---|
| 97 | delete activeThermostat;
|
|---|
| 98 | }
|
|---|
| 99 | for(traitsMap::iterator iter= availThermostats.begin();iter!=availThermostats.end();++iter){
|
|---|
| 100 | delete (iter->second);
|
|---|
| 101 | }
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|