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