Changeset a3fded for src/config.cpp
- Timestamp:
- Jun 12, 2010, 1:12:51 PM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 43dad6
- Parents:
- 88104f
- git-author:
- Frederik Heber <heber@…> (06/12/10 13:05:12)
- git-committer:
- Frederik Heber <heber@…> (06/12/10 13:12:51)
- File:
-
- 1 edited
-
src/config.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r88104f ra3fded 10 10 #include "atom.hpp" 11 11 #include "bond.hpp" 12 #include "bondgraph.hpp" 12 13 #include "config.hpp" 14 #include "ConfigFileBuffer.hpp" 13 15 #include "element.hpp" 14 16 #include "helpers.hpp" … … 20 22 #include "molecule.hpp" 21 23 #include "periodentafel.hpp" 24 #include "ThermoStatContainer.hpp" 22 25 #include "World.hpp" 23 26 … … 26 29 /** Constructor for config file class. 27 30 */ 28 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 29 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL), 30 ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 31 config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 32 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 31 33 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 32 34 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), … … 40 42 configpath = new char[MAXSTRINGSIZE]; 41 43 configname = new char[MAXSTRINGSIZE]; 44 Thermostats = new ThermoStatContainer(); 42 45 strcpy(mainname,"pcp"); 43 46 strcpy(defaultpath,"not specified"); … … 46 49 configname[0]='\0'; 47 50 basis = "3-21G"; 48 49 InitThermostats();50 51 }; 51 52 … … 60 61 delete[](configpath); 61 62 delete[](configname); 62 delete[](ThermostatImplemented); 63 for (int j=0;j<MaxThermostats;j++) 64 delete[](ThermostatNames[j]); 65 delete[](ThermostatNames); 63 if (Thermostats != NULL) 64 delete(Thermostats); 66 65 67 66 if (BG != NULL) 68 67 delete(BG); 69 68 }; 70 71 /** Initialises variables in class config for Thermostats.72 */73 void config::InitThermostats()74 {75 ThermostatImplemented = new int[MaxThermostats];76 ThermostatNames = new char *[MaxThermostats];77 for (int j=0;j<MaxThermostats;j++)78 ThermostatNames[j] = new char[12];79 80 strcpy(ThermostatNames[0],"None");81 ThermostatImplemented[0] = 1;82 strcpy(ThermostatNames[1],"Woodcock");83 ThermostatImplemented[1] = 1;84 strcpy(ThermostatNames[2],"Gaussian");85 ThermostatImplemented[2] = 1;86 strcpy(ThermostatNames[3],"Langevin");87 ThermostatImplemented[3] = 1;88 strcpy(ThermostatNames[4],"Berendsen");89 ThermostatImplemented[4] = 1;90 strcpy(ThermostatNames[5],"NoseHoover");91 ThermostatImplemented[5] = 1;92 };93 94 /** Readin of Thermostat related values from parameter file.95 * \param *fb file buffer containing the config file96 */97 void config::ParseThermostats(class ConfigFileBuffer * const fb)98 {99 char * const thermo = new char[12];100 const int verbose = 0;101 102 // read desired Thermostat from file along with needed additional parameters103 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {104 if (strcmp(thermo, ThermostatNames[0]) == 0) { // None105 if (ThermostatImplemented[0] == 1) {106 Thermostat = None;107 } else {108 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);109 Thermostat = None;110 }111 } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock112 if (ThermostatImplemented[1] == 1) {113 Thermostat = Woodcock;114 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency115 } else {116 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);117 Thermostat = None;118 }119 } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian120 if (ThermostatImplemented[2] == 1) {121 Thermostat = Gaussian;122 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate123 } else {124 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);125 Thermostat = None;126 }127 } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin128 if (ThermostatImplemented[3] == 1) {129 Thermostat = Langevin;130 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma131 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {132 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);133 } else {134 alpha = 1.;135 }136 } else {137 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);138 Thermostat = None;139 }140 } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen141 if (ThermostatImplemented[4] == 1) {142 Thermostat = Berendsen;143 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T144 } else {145 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);146 Thermostat = None;147 }148 } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover149 if (ThermostatImplemented[5] == 1) {150 Thermostat = NoseHoover;151 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass152 alpha = 0.;153 } else {154 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);155 Thermostat = None;156 }157 } else {158 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);159 Thermostat = None;160 }161 } else {162 if ((MaxOuterStep > 0) && (TargetTemp != 0))163 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl);164 Thermostat = None;165 }166 delete[](thermo);167 };168 169 69 170 70 /** Displays menu for editing each entry of the config file. … … 508 408 }; 509 409 510 /** Initializes ConfigFileBuffer from a file.511 * \param *file input file stream being the opened config file512 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL513 */514 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)515 {516 if (FileBuffer != NULL) {517 DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);518 delete(FileBuffer);519 }520 FileBuffer = new ConfigFileBuffer(filename);521 522 FileBuffer->InitMapping();523 };524 525 410 /** Loads a molecule from a ConfigFileBuffer. 526 411 * \param *mol molecule to load … … 719 604 720 605 // ParseParameterFile 721 struct ConfigFileBuffer *FileBuffer = NULL; 722 PrepareFileBuffer(filename,FileBuffer); 606 class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 723 607 724 608 /* Oeffne Hauptparameterdatei */ … … 729 613 int verbose = 0; 730 614 731 ParseThermostats(FileBuffer); 615 //TODO: This is actually sensible?: if (MaxOuterStep > 0) 616 Thermostats->ParseThermostats(FileBuffer); 732 617 733 618 /* Namen einlesen */ … … 793 678 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 794 679 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 795 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &( config::TargetTemp), 1, optional);680 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional); 796 681 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 797 682 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) … … 1002 887 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 1003 888 ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 1004 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &( config::TargetTemp), 1, optional);1005 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &( config::ScaleTempStep), 1, optional);889 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional); 890 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(Thermostats->ScaleTempStep), 1, optional); 1006 891 config::EpsWannier = 1e-8; 1007 892 … … 1191 1076 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1192 1077 *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl; 1193 *output << "Thermostat\t" << Thermostat Names[Thermostat] << "\t";1194 switch(Thermostat ) {1078 *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t"; 1079 switch(Thermostats->Thermostat) { 1195 1080 default: 1196 1081 case None: 1197 1082 break; 1198 1083 case Woodcock: 1199 *output << ScaleTempStep;1084 *output << Thermostats->ScaleTempStep; 1200 1085 break; 1201 1086 case Gaussian: 1202 *output << ScaleTempStep;1087 *output << Thermostats->ScaleTempStep; 1203 1088 break; 1204 1089 case Langevin: 1205 *output << T empFrequency << "\t" <<alpha;1090 *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha; 1206 1091 break; 1207 1092 case Berendsen: 1208 *output << T empFrequency;1093 *output << Thermostats->TempFrequency; 1209 1094 break; 1210 1095 case NoseHoover: 1211 *output << HooverMass;1096 *output << Thermostats->HooverMass; 1212 1097 break; 1213 1098 }; … … 1224 1109 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1225 1110 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; 1226 *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl;1111 *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl; 1227 1112 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1228 1113 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
Note:
See TracChangeset
for help on using the changeset viewer.
