/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * ThermoStatContainer.cpp * * Created on: 12.06.2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include #include "ConfigFileBuffer.hpp" #include "config.hpp" #include "CodePatterns/Log.hpp" #include "ThermoStatContainer.hpp" #include "CodePatterns/Verbose.hpp" #include #include #include #include #include #include /** Constructor for class ThermoStatContainer. * */ ThermoStatContainer::ThermoStatContainer() : activeThermostat(0), TargetTemp(0.00095004455) { ThermostatTraits *BerendsenTrait = new ThermostatTraits(); availThermostats[BerendsenTrait->getName()] = BerendsenTrait; ThermostatTraits *GaussianTrait = new ThermostatTraits(); availThermostats[GaussianTrait->getName()] = GaussianTrait; ThermostatTraits *LangevinTrait = new ThermostatTraits(); availThermostats[LangevinTrait->getName()] = LangevinTrait; ThermostatTraits *NoseHooverTrait = new ThermostatTraits(); availThermostats[NoseHooverTrait->getName()] = NoseHooverTrait; ThermostatTraits *NoThermostatTrait = new ThermostatTraits(); availThermostats[NoThermostatTrait->getName()] = NoThermostatTrait; ThermostatTraits *WoodcockTrait = new ThermostatTraits(); availThermostats[WoodcockTrait->getName()] = WoodcockTrait; // for debugging: list all thermostats // cout << "List of known thermostats: "; // for(traitsMap::iterator iter = availThermostats.begin();iter!=availThermostats.end();++iter){ // cout << iter->first << " "; // } // cout << endl; ASSERT(availThermostats.size()==6,"Not all implemented thermostats referenced!\nDid you check the names in the traits?"); activeThermostat=new Berendsen(); } ThermostatTraits *ThermoStatContainer::getTraitByName(const std::string name){ if(!availThermostats.count(name)) return 0; return availThermostats[name]; } Thermostat *ThermoStatContainer::makeByName(const std::string name,class ConfigFileBuffer * const fb){ ThermostatTraits* trait = getTraitByName(name); if(trait){ Thermostat *res = trait->make(fb); res->addToContainer(this); return res; } else{ return 0; } } void ThermoStatContainer::makeActive(const std::string name,class ConfigFileBuffer * const fb){ Thermostat* newThermostat = makeByName(name,fb); if(newThermostat){ if(activeThermostat){ delete activeThermostat; } activeThermostat = newThermostat; } } void ThermoStatContainer::chooseNone(){ if(activeThermostat){ delete activeThermostat; } activeThermostat = new NoThermostat(); } /** Destructor for Class ThermoStatContainer. * */ ThermoStatContainer::~ThermoStatContainer() { if(activeThermostat){ delete activeThermostat; } for(traitsMap::iterator iter= availThermostats.begin();iter!=availThermostats.end();++iter){ delete (iter->second); } }