source: src/Thermostats/ThermoStatContainer.cpp@ 4464ef

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 4464ef was f73351, checked in by Frederik Heber <heber@…>, 11 years ago

FIX: Some Thermostats would cause NaN on zero temperature.

  • Berendsen and Woodcock divide through OldTemp which may be zero (because initial velocities are zero). This is now checked.
  • also, default thermostat is now NoThermostat.
  • NOTE: We lack an action to choose a thermostat but this needs some refactoring of the thermostats which are still based on being read from file.
  • TESTFIX: Adapted three regression tests where pcp files were stored that contained still reference to old default Berendsen (with parameter 2.5).
  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * ThermoStatContainer.cpp
25 *
26 * Created on: 12.06.2010
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "CodePatterns/MemDebug.hpp"
36
37#include <cstring>
38
39#include "CodePatterns/Log.hpp"
40#include "Thermostats/ThermoStatContainer.hpp"
41#include "Parser/ConfigFileBuffer.hpp"
42
43#include <Thermostats/Berendsen.hpp>
44#include <Thermostats/GaussianThermostat.hpp>
45#include <Thermostats/Langevin.hpp>
46#include <Thermostats/NoseHoover.hpp>
47#include <Thermostats/NoThermostat.hpp>
48#include <Thermostats/Woodcock.hpp>
49
50/** Constructor for class ThermoStatContainer.
51 *
52 */
53ThermoStatContainer::ThermoStatContainer() :
54 activeThermostat(0),
55 TargetTemp(0.00095004455)
56{
57 ThermostatTraits<Thermostat> *BerendsenTrait = new ThermostatTraits<Berendsen>();
58 availThermostats[BerendsenTrait->getName()] = BerendsenTrait;
59 ThermostatTraits<Thermostat> *GaussianTrait = new ThermostatTraits<GaussianThermostat>();
60 availThermostats[GaussianTrait->getName()] = GaussianTrait;
61 ThermostatTraits<Thermostat> *LangevinTrait = new ThermostatTraits<Langevin>();
62 availThermostats[LangevinTrait->getName()] = LangevinTrait;
63 ThermostatTraits<Thermostat> *NoseHooverTrait = new ThermostatTraits<NoseHoover>();
64 availThermostats[NoseHooverTrait->getName()] = NoseHooverTrait;
65 ThermostatTraits<Thermostat> *NoThermostatTrait = new ThermostatTraits<NoThermostat>();
66 availThermostats[NoThermostatTrait->getName()] = NoThermostatTrait;
67 ThermostatTraits<Thermostat> *WoodcockTrait = new ThermostatTraits<Woodcock>();
68 availThermostats[WoodcockTrait->getName()] = WoodcockTrait;
69
70 // for debugging: list all thermostats
71// cout << "List of known thermostats: ";
72// for(traitsMap::iterator iter = availThermostats.begin();iter!=availThermostats.end();++iter){
73// cout << iter->first << " ";
74// }
75// cout << endl;
76
77 ASSERT(availThermostats.size()==6,"Not all implemented thermostats referenced!\nDid you check the names in the traits?");
78 activeThermostat=new NoThermostat();
79 activeThermostat->addToContainer(this);
80}
81
82ThermostatTraits<Thermostat> *ThermoStatContainer::getTraitByName(const std::string name){
83 if(!availThermostats.count(name))
84 return 0;
85 return availThermostats[name];
86}
87
88Thermostat *ThermoStatContainer::makeByName(const std::string name,class ConfigFileBuffer * const fb){
89 ThermostatTraits<Thermostat>* trait = getTraitByName(name);
90 if(trait){
91 Thermostat *res = trait->make(fb);
92 res->addToContainer(this);
93 return res;
94 }
95 else{
96 return 0;
97 }
98}
99
100void ThermoStatContainer::makeActive(const std::string name,class ConfigFileBuffer * const fb){
101 Thermostat* newThermostat = makeByName(name,fb);
102 if(newThermostat){
103 if(activeThermostat){
104 delete activeThermostat;
105 }
106 activeThermostat = newThermostat;
107 }
108}
109
110void ThermoStatContainer::chooseNone(){
111 if(activeThermostat){
112 delete activeThermostat;
113 }
114 activeThermostat = new NoThermostat();
115}
116
117/** Destructor for Class ThermoStatContainer.
118 *
119 */
120ThermoStatContainer::~ThermoStatContainer()
121{
122 if(activeThermostat){
123 delete activeThermostat;
124 }
125 for(traitsMap::iterator iter= availThermostats.begin();iter!=availThermostats.end();++iter){
126 delete (iter->second);
127 }
128}
129
130
Note: See TracBrowser for help on using the repository browser.