/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * ThermoStatContainer.cpp * * Created on: 12.06.2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include #include "CodePatterns/Log.hpp" #include "Thermostats/ThermoStatContainer.hpp" #include "Parser/ConfigFileBuffer.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(); activeThermostat->addToContainer(this); } 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); } }