Changes in src/config.cpp [68f03d:35b698]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r68f03d r35b698 5 5 */ 6 6 7 #include "Helpers/MemDebug.hpp" 8 7 9 #include <stdio.h> 8 10 #include <cstring> 9 11 10 #include "World.hpp"11 12 #include "atom.hpp" 12 13 #include "bond.hpp" 14 #include "bondgraph.hpp" 13 15 #include "config.hpp" 16 #include "ConfigFileBuffer.hpp" 14 17 #include "element.hpp" 15 18 #include "helpers.hpp" 19 #include "info.hpp" 16 20 #include "lists.hpp" 17 21 #include "log.hpp" … … 20 24 #include "molecule.hpp" 21 25 #include "periodentafel.hpp" 26 #include "ThermoStatContainer.hpp" 22 27 #include "World.hpp" 23 24 /******************************** Functions for class ConfigFileBuffer **********************/25 26 /** Structure containing compare function for Ion_Type sorting.27 */28 struct IonTypeCompare {29 bool operator()(const char* s1, const char *s2) const {30 char number1[8];31 char number2[8];32 const char *dummy1, *dummy2;33 //Log() << Verbose(0) << s1 << " " << s2 << endl;34 dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type"35 dummy2 = strchr(dummy1, '_');36 strncpy(number1, dummy1, dummy2-dummy1); // copy the number37 number1[dummy2-dummy1]='\0';38 dummy1 = strchr(s2, '_')+sizeof(char)*5; // go just after "Ion_Type"39 dummy2 = strchr(dummy1, '_');40 strncpy(number2, dummy1, dummy2-dummy1); // copy the number41 number2[dummy2-dummy1]='\0';42 if (atoi(number1) != atoi(number2))43 return (atoi(number1) < atoi(number2));44 else {45 dummy1 = strchr(s1, '_')+sizeof(char);46 dummy1 = strchr(dummy1, '_')+sizeof(char);47 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');48 strncpy(number1, dummy1, dummy2-dummy1); // copy the number49 number1[dummy2-dummy1]='\0';50 dummy1 = strchr(s2, '_')+sizeof(char);51 dummy1 = strchr(dummy1, '_')+sizeof(char);52 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');53 strncpy(number2, dummy1, dummy2-dummy1); // copy the number54 number2[dummy2-dummy1]='\0';55 return (atoi(number1) < atoi(number2));56 }57 }58 };59 60 /** Constructor for ConfigFileBuffer class.61 */62 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)63 {64 };65 66 /** Constructor for ConfigFileBuffer class with filename to be parsed.67 * \param *filename file name68 */69 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)70 {71 ifstream *file = NULL;72 char line[MAXSTRINGSIZE];73 74 // prescan number of lines75 file= new ifstream(filename);76 if (file == NULL) {77 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);78 return;79 }80 NoLines = 0; // we're overcounting by one81 long file_position = file->tellg(); // mark current position82 do {83 file->getline(line, 256);84 NoLines++;85 } while (!file->eof());86 file->clear();87 file->seekg(file_position, ios::beg);88 DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);89 90 // allocate buffer's 1st dimension91 if (buffer != NULL) {92 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);93 return;94 } else95 buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");96 97 // scan each line and put into buffer98 int lines=0;99 int i;100 do {101 buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");102 file->getline(buffer[lines], MAXSTRINGSIZE-1);103 i = strlen(buffer[lines]);104 buffer[lines][i] = '\n';105 buffer[lines][i+1] = '\0';106 lines++;107 } while((!file->eof()) && (lines < NoLines));108 DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);109 110 // close and exit111 file->close();112 file->clear();113 delete(file);114 }115 116 /** Destructor for ConfigFileBuffer class.117 */118 ConfigFileBuffer::~ConfigFileBuffer()119 {120 for(int i=0;i<NoLines;++i)121 Free(&buffer[i]);122 Free(&buffer);123 Free(&LineMapping);124 }125 126 127 /** Create trivial mapping.128 */129 void ConfigFileBuffer::InitMapping()130 {131 LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");132 for (int i=0;i<NoLines;i++)133 LineMapping[i] = i;134 }135 136 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted.137 * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the138 * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine139 * points to first Ion_Type entry.140 * \param *FileBuffer pointer to buffer structure141 * \param NoAtoms of subsequent lines to look at142 */143 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)144 {145 map<const char *, int, IonTypeCompare> IonTypeLineMap;146 if (LineMapping == NULL) {147 DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl);148 performCriticalExit();149 return;150 }151 152 // put all into hashed map153 for (int i=0; i<NoAtoms; ++i) {154 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));155 }156 157 // fill map158 int nr=0;159 for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {160 if (CurrentLine+nr < NoLines)161 LineMapping[CurrentLine+(nr++)] = runner->second;162 else {163 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);164 performCriticalExit();165 }166 }167 }168 28 169 29 /************************************* Functions for class config ***************************/ … … 171 31 /** Constructor for config file class. 172 32 */ 173 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 174 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL), 175 ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 33 config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), 34 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 176 35 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 177 36 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), … … 179 38 MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0), 180 39 MaxTypes(0) { 181 mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname");182 defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath");183 pseudopotpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: pseudopotpath");184 databasepath = Malloc<char>(MAXSTRINGSIZE,"config constructor: databasepath");185 config path = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath");186 configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname");40 mainname = new char[MAXSTRINGSIZE]; 41 defaultpath = new char[MAXSTRINGSIZE]; 42 pseudopotpath = new char[MAXSTRINGSIZE]; 43 databasepath = new char[MAXSTRINGSIZE]; 44 configname = new char[MAXSTRINGSIZE]; 45 Thermostats = new ThermoStatContainer(); 187 46 strcpy(mainname,"pcp"); 188 47 strcpy(defaultpath,"not specified"); 189 48 strcpy(pseudopotpath,"not specified"); 190 configpath[0]='\0';191 49 configname[0]='\0'; 192 50 basis = "3-21G"; 193 194 InitThermostats();195 51 }; 196 52 … … 199 55 config::~config() 200 56 { 201 Free(&mainname); 202 Free(&defaultpath); 203 Free(&pseudopotpath); 204 Free(&databasepath); 205 Free(&configpath); 206 Free(&configname); 207 Free(&ThermostatImplemented); 208 for (int j=0;j<MaxThermostats;j++) 209 Free(&ThermostatNames[j]); 210 Free(&ThermostatNames); 57 delete[](mainname); 58 delete[](defaultpath); 59 delete[](pseudopotpath); 60 delete[](databasepath); 61 delete[](configname); 62 if (Thermostats != NULL) 63 delete(Thermostats); 211 64 212 65 if (BG != NULL) 213 66 delete(BG); 214 67 }; 215 216 /** Initialises variables in class config for Thermostats.217 */218 void config::InitThermostats()219 {220 ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");221 ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");222 for (int j=0;j<MaxThermostats;j++)223 ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");224 225 strcpy(ThermostatNames[0],"None");226 ThermostatImplemented[0] = 1;227 strcpy(ThermostatNames[1],"Woodcock");228 ThermostatImplemented[1] = 1;229 strcpy(ThermostatNames[2],"Gaussian");230 ThermostatImplemented[2] = 1;231 strcpy(ThermostatNames[3],"Langevin");232 ThermostatImplemented[3] = 1;233 strcpy(ThermostatNames[4],"Berendsen");234 ThermostatImplemented[4] = 1;235 strcpy(ThermostatNames[5],"NoseHoover");236 ThermostatImplemented[5] = 1;237 };238 239 /** Readin of Thermostat related values from parameter file.240 * \param *fb file buffer containing the config file241 */242 void config::ParseThermostats(class ConfigFileBuffer * const fb)243 {244 char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");245 const int verbose = 0;246 247 // read desired Thermostat from file along with needed additional parameters248 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {249 if (strcmp(thermo, ThermostatNames[0]) == 0) { // None250 if (ThermostatImplemented[0] == 1) {251 Thermostat = None;252 } else {253 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);254 Thermostat = None;255 }256 } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock257 if (ThermostatImplemented[1] == 1) {258 Thermostat = Woodcock;259 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency260 } else {261 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);262 Thermostat = None;263 }264 } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian265 if (ThermostatImplemented[2] == 1) {266 Thermostat = Gaussian;267 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate268 } else {269 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);270 Thermostat = None;271 }272 } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin273 if (ThermostatImplemented[3] == 1) {274 Thermostat = Langevin;275 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma276 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {277 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);278 } else {279 alpha = 1.;280 }281 } else {282 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);283 Thermostat = None;284 }285 } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen286 if (ThermostatImplemented[4] == 1) {287 Thermostat = Berendsen;288 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T289 } else {290 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);291 Thermostat = None;292 }293 } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover294 if (ThermostatImplemented[5] == 1) {295 Thermostat = NoseHoover;296 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass297 alpha = 0.;298 } else {299 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);300 Thermostat = None;301 }302 } else {303 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);304 Thermostat = None;305 }306 } else {307 if ((MaxOuterStep > 0) && (TargetTemp != 0))308 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl);309 Thermostat = None;310 }311 Free(thermo);312 };313 314 68 315 69 /** Displays menu for editing each entry of the config file. … … 626 380 }; 627 381 628 /** Retrieves the path in the given config file name.629 * \param filename config file string630 */631 void config::RetrieveConfigPathAndName(const string filename)632 {633 char *ptr = NULL;634 char *buffer = new char[MAXSTRINGSIZE];635 strncpy(buffer, filename.c_str(), MAXSTRINGSIZE);636 int last = -1;637 for(last=MAXSTRINGSIZE;last--;) {638 if (buffer[last] == '/')639 break;640 }641 if (last == -1) { // no path in front, set to local directory.642 strcpy(configpath, "./");643 ptr = buffer;644 } else {645 strncpy(configpath, buffer, last+1);646 ptr = &buffer[last+1];647 if (last < 254)648 configpath[last+1]='\0';649 }650 strcpy(configname, ptr);651 DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);652 delete[](buffer);653 };654 655 /** Initializes ConfigFileBuffer from a file.656 * \param *file input file stream being the opened config file657 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL658 */659 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)660 {661 if (FileBuffer != NULL) {662 DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);663 delete(FileBuffer);664 }665 FileBuffer = new ConfigFileBuffer(filename);666 667 FileBuffer->InitMapping();668 };669 670 382 /** Loads a molecule from a ConfigFileBuffer. 671 383 * \param *mol molecule to load … … 861 573 file->close(); 862 574 delete(file); 863 RetrieveConfigPathAndName(filename);864 575 865 576 // ParseParameterFile 866 struct ConfigFileBuffer *FileBuffer = NULL; 867 PrepareFileBuffer(filename,FileBuffer); 577 class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 868 578 869 579 /* Oeffne Hauptparameterdatei */ … … 874 584 int verbose = 0; 875 585 586 //TODO: This is actually sensible?: if (MaxOuterStep > 0) 876 587 ParseThermostats(FileBuffer); 877 588 … … 938 649 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 939 650 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 940 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &( config::TargetTemp), 1, optional);651 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional); 941 652 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 942 653 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) … … 1098 809 return; 1099 810 } 1100 RetrieveConfigPathAndName(filename);1101 811 // ParseParameters 1102 812 … … 1147 857 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 1148 858 ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 1149 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &( config::TargetTemp), 1, optional);1150 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &( config::ScaleTempStep), 1, optional);859 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional); 860 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(Thermostats->ScaleTempStep), 1, optional); 1151 861 config::EpsWannier = 1e-8; 1152 862 … … 1336 1046 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1337 1047 *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl; 1338 *output << "Thermostat\t" << Thermostat Names[Thermostat] << "\t";1339 switch(Thermostat ) {1048 *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t"; 1049 switch(Thermostats->Thermostat) { 1340 1050 default: 1341 1051 case None: 1342 1052 break; 1343 1053 case Woodcock: 1344 *output << ScaleTempStep;1054 *output << Thermostats->ScaleTempStep; 1345 1055 break; 1346 1056 case Gaussian: 1347 *output << ScaleTempStep;1057 *output << Thermostats->ScaleTempStep; 1348 1058 break; 1349 1059 case Langevin: 1350 *output << T empFrequency << "\t" <<alpha;1060 *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha; 1351 1061 break; 1352 1062 case Berendsen: 1353 *output << T empFrequency;1063 *output << Thermostats->TempFrequency; 1354 1064 break; 1355 1065 case NoseHoover: 1356 *output << HooverMass;1066 *output << Thermostats->HooverMass; 1357 1067 break; 1358 1068 }; … … 1369 1079 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1370 1080 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; 1371 *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl;1081 *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl; 1372 1082 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1373 1083 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; … … 1480 1190 // output of atoms 1481 1191 AtomNo = 0; 1482 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1192 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1483 1193 delete(center); 1484 1194 *output << "\t}" << endl; … … 1522 1232 // output of atoms 1523 1233 AtomNo = 0; 1524 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1234 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1525 1235 delete(center); 1526 1236 *output << "\t}" << endl; … … 1547 1257 int AtomNo = -1; 1548 1258 int MolNo = 0; 1549 atom *Walker = NULL;1550 1259 FILE *f = NULL; 1551 1260 … … 1560 1269 fprintf(f, "# Created by MoleCuilder\n"); 1561 1270 1562 for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) { 1563 Walker = (*Runner)->start; 1564 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1271 for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) { 1272 int *elementNo = new int[MAX_ELEMENTS]; 1273 for (int i=0;i<MAX_ELEMENTS;i++) 1274 elementNo[i] = 0; 1565 1275 AtomNo = 0; 1566 while (Walker->next != (*Runner)->end) { 1567 Walker = Walker->next; 1568 sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]); 1569 elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100; // confine to two digits 1276 for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) { 1277 sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]); 1278 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1570 1279 fprintf(f, 1571 1280 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", 1572 Walker->nr, /* atom serial number */1281 (*iter)->nr, /* atom serial number */ 1573 1282 name, /* atom name */ 1574 (* Runner)->name, /* residue name */1283 (*MolRunner)->name, /* residue name */ 1575 1284 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1576 1285 MolNo, /* residue sequence number */ 1577 Walker->node->at(0), /* position X in Angstroem */1578 Walker->node->at(1), /* position Y in Angstroem */1579 Walker->node->at(2), /* position Z in Angstroem */1580 (double) Walker->type->Valence, /* occupancy */1581 (double) Walker->type->NoValenceOrbitals, /* temperature factor */1286 (*iter)->node->at(0), /* position X in Angstroem */ 1287 (*iter)->node->at(1), /* position Y in Angstroem */ 1288 (*iter)->node->at(2), /* position Z in Angstroem */ 1289 (double)(*iter)->type->Valence, /* occupancy */ 1290 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1582 1291 "0", /* segment identifier */ 1583 Walker->type->symbol, /* element symbol */1292 (*iter)->type->symbol, /* element symbol */ 1584 1293 "0"); /* charge */ 1585 1294 AtomNo++; 1586 1295 } 1587 Free(&elementNo);1296 delete[](elementNo); 1588 1297 MolNo++; 1589 1298 } … … 1601 1310 { 1602 1311 int AtomNo = -1; 1603 atom *Walker = NULL;1604 1312 FILE *f = NULL; 1605 1313 1606 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1314 int *elementNo = new int[MAX_ELEMENTS]; 1315 for (int i=0;i<MAX_ELEMENTS;i++) 1316 elementNo[i] = 0; 1607 1317 char name[MAXSTRINGSIZE]; 1608 1318 strncpy(name, filename, MAXSTRINGSIZE-1); … … 1611 1321 if (f == NULL) { 1612 1322 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl); 1613 Free(&elementNo);1323 delete[](elementNo); 1614 1324 return false; 1615 1325 } 1616 1326 fprintf(f, "# Created by MoleCuilder\n"); 1617 1327 1618 Walker = mol->start;1619 1328 AtomNo = 0; 1620 while (Walker->next != mol->end) { 1621 Walker = Walker->next; 1622 sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]); 1623 elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100; // confine to two digits 1329 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1330 sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]); 1331 elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100; // confine to two digits 1624 1332 fprintf(f, 1625 1333 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n", 1626 Walker->nr, /* atom serial number */1334 (*iter)->nr, /* atom serial number */ 1627 1335 name, /* atom name */ 1628 1336 mol->name, /* residue name */ 1629 1337 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1630 1338 0, /* residue sequence number */ 1631 Walker->node->at(0), /* position X in Angstroem */1632 Walker->node->at(1), /* position Y in Angstroem */1633 Walker->node->at(2), /* position Z in Angstroem */1634 (double) Walker->type->Valence, /* occupancy */1635 (double) Walker->type->NoValenceOrbitals, /* temperature factor */1339 (*iter)->node->at(0), /* position X in Angstroem */ 1340 (*iter)->node->at(1), /* position Y in Angstroem */ 1341 (*iter)->node->at(2), /* position Z in Angstroem */ 1342 (double)(*iter)->type->Valence, /* occupancy */ 1343 (double)(*iter)->type->NoValenceOrbitals, /* temperature factor */ 1636 1344 "0", /* segment identifier */ 1637 Walker->type->symbol, /* element symbol */1345 (*iter)->type->symbol, /* element symbol */ 1638 1346 "0"); /* charge */ 1639 1347 AtomNo++; 1640 1348 } 1641 1349 fclose(f); 1642 Free(&elementNo);1350 delete[](elementNo); 1643 1351 1644 1352 return true; … … 1653 1361 bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const 1654 1362 { 1655 atom *Walker = NULL;1656 1363 ofstream *output = NULL; 1657 1364 stringstream * const fname = new stringstream; … … 1666 1373 1667 1374 // scan maximum number of neighbours 1668 Walker = mol->start;1669 1375 int MaxNeighbours = 0; 1670 while (Walker->next != mol->end) { 1671 Walker = Walker->next; 1672 const int count = Walker->ListOfBonds.size(); 1376 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1377 const int count = (*iter)->ListOfBonds.size(); 1673 1378 if (MaxNeighbours < count) 1674 1379 MaxNeighbours = count; 1675 1380 } 1676 *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl; 1677 1678 Walker = mol->start; 1679 while (Walker->next != mol->end) { 1680 Walker = Walker->next; 1681 *output << Walker->nr << "\t"; 1682 *output << Walker->getName() << "\t"; 1381 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl; 1382 1383 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1384 *output << (*iter)->nr << "\t"; 1385 *output << (*iter)->getName() << "\t"; 1683 1386 *output << mol->name << "\t"; 1684 1387 *output << 0 << "\t"; 1685 *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";1686 *output << static_cast<double>( Walker->type->Valence) << "\t";1687 *output << Walker->type->symbol << "\t";1688 for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)1689 *output << (*runner)->GetOtherAtom( Walker)->nr << "\t";1690 for(int i= Walker->ListOfBonds.size(); i < MaxNeighbours; i++)1388 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1389 *output << static_cast<double>((*iter)->type->Valence) << "\t"; 1390 *output << (*iter)->type->symbol << "\t"; 1391 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1392 *output << (*runner)->GetOtherAtom(*iter)->nr << "\t"; 1393 for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++) 1691 1394 *output << "-\t"; 1692 1395 *output << endl; … … 1708 1411 bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const 1709 1412 { 1710 atom *Walker = NULL;1413 Info FunctionInfo(__func__); 1711 1414 ofstream *output = NULL; 1712 1415 stringstream * const fname = new stringstream; … … 1723 1426 int MaxNeighbours = 0; 1724 1427 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) { 1725 Walker = (*MolWalker)->start; 1726 while (Walker->next != (*MolWalker)->end) { 1727 Walker = Walker->next; 1728 const int count = Walker->ListOfBonds.size(); 1428 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 1429 const int count = (*iter)->ListOfBonds.size(); 1729 1430 if (MaxNeighbours < count) 1730 1431 MaxNeighbours = count; 1731 1432 } 1732 1433 } 1733 *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;1434 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl; 1734 1435 1735 1436 // create global to local id map 1736 int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap");1437 map<int, int> LocalNotoGlobalNoMap; 1737 1438 { 1738 int MolCounter = 0;1739 int AtomNo = 0;1439 unsigned int MolCounter = 0; 1440 int AtomNo = 1; 1740 1441 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) { 1741 LocalNotoGlobalNoMap[MolCounter] = Calloc<int>(MolList->CountAllAtoms(), "config::SaveTREMOLO - *LocalNotoGlobalNoMap[]"); 1742 1743 (*MolWalker)->SetIndexedArrayForEachAtomTo( LocalNotoGlobalNoMap[MolCounter], &atom::nr, IncrementalAbsoluteValue, &AtomNo); 1744 1442 for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) { 1443 LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) ); 1444 } 1745 1445 MolCounter++; 1746 1446 } 1447 ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule"); 1747 1448 } 1748 1449 … … 1752 1453 int AtomNo = 0; 1753 1454 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) { 1754 Walker = (*MolWalker)->start; 1755 while (Walker->next != (*MolWalker)->end) { 1756 Walker = Walker->next; 1757 *output << AtomNo+1 << "\t"; 1758 *output << Walker->getName() << "\t"; 1455 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) { 1456 *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t"; 1457 *output << (*iter)->getName() << "\t"; 1759 1458 *output << (*MolWalker)->name << "\t"; 1760 1459 *output << MolCounter+1 << "\t"; 1761 *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";1762 *output << (double) Walker->type->Valence << "\t";1763 *output << Walker->type->symbol << "\t";1764 for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)1765 *output << LocalNotoGlobalNoMap[ MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1<< "\t";1766 for(int i= Walker->ListOfBonds.size(); i < MaxNeighbours; i++)1460 *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t"; 1461 *output << (double)(*iter)->type->Valence << "\t"; 1462 *output << (*iter)->type->symbol << "\t"; 1463 for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++) 1464 *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t"; 1465 for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++) 1767 1466 *output << "-\t"; 1768 1467 *output << endl; … … 1778 1477 delete(output); 1779 1478 delete(fname); 1780 for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)1781 Free(&LocalNotoGlobalNoMap[i]);1782 Free(&LocalNotoGlobalNoMap);1783 1479 1784 1480 return true; … … 1795 1491 char filename[MAXSTRINGSIZE]; 1796 1492 ofstream output; 1797 molecule *mol = World::getInstance().createMolecule(); 1798 mol->SetNameFromFilename(ConfigFileName); 1799 1800 if (!strcmp(configpath, GetDefaultPath())) { 1801 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1802 } 1803 1493 molecule *mol = NULL; 1804 1494 1805 1495 // first save as PDB data … … 1808 1498 if (output == NULL) 1809 1499 strcpy(filename,"main_pcp_linux"); 1810 Log() << Verbose(0) << "Saving as pdb input ";1500 Log() << Verbose(0) << "Saving as pdb input ... " << endl; 1811 1501 if (SavePDB(filename, molecules)) 1812 Log() << Verbose(0) << " done." << endl;1502 Log() << Verbose(0) << "\t... done." << endl; 1813 1503 else 1814 Log() << Verbose(0) << " failed." << endl;1504 Log() << Verbose(0) << "\t... failed." << endl; 1815 1505 1816 1506 // then save as tremolo data file … … 1819 1509 if (output == NULL) 1820 1510 strcpy(filename,"main_pcp_linux"); 1821 Log() << Verbose(0) << "Saving as tremolo data input ";1511 Log() << Verbose(0) << "Saving as tremolo data input ... " << endl; 1822 1512 if (SaveTREMOLO(filename, molecules)) 1823 Log() << Verbose(0) << " done." << endl;1513 Log() << Verbose(0) << "\t... done." << endl; 1824 1514 else 1825 Log() << Verbose(0) << " failed." << endl;1515 Log() << Verbose(0) << "\t... failed." << endl; 1826 1516 1827 1517 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1828 1518 int N = molecules->ListOfMolecules.size(); 1829 int *src = new int[N]; 1830 N=0; 1831 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1832 src[N++] = (*ListRunner)->IndexNr; 1833 (*ListRunner)->Translate(&(*ListRunner)->Center); 1834 } 1835 molecules->SimpleMultiAdd(mol, src, N); 1836 delete[](src); 1837 1838 // ... and translate back 1839 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1840 (*ListRunner)->Center.Scale(-1.); 1841 (*ListRunner)->Translate(&(*ListRunner)->Center); 1842 (*ListRunner)->Center.Scale(-1.); 1519 if (N != 1) { // don't do anything in case of only one molecule (shifts mol ids otherwise) 1520 int *src = new int[N]; 1521 N=0; 1522 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1523 src[N++] = (*ListRunner)->IndexNr; 1524 (*ListRunner)->Translate(&(*ListRunner)->Center); 1525 } 1526 mol = World::getInstance().createMolecule(); 1527 mol->SetNameFromFilename(ConfigFileName); 1528 molecules->SimpleMultiMerge(mol, src, N); 1529 mol->doCountAtoms(); 1530 mol->CountElements(); 1531 //mol->CalculateOrbitals(*this); 1532 delete[](src); 1533 } else { 1534 if (!molecules->ListOfMolecules.empty()) { 1535 mol = *(molecules->ListOfMolecules.begin()); 1536 mol->doCountAtoms(); 1537 //mol->CalculateOrbitals(*this); 1538 } else { 1539 DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl); 1540 } 1843 1541 } 1844 1542 1845 1543 Log() << Verbose(0) << "Storing configuration ... " << endl; 1846 1544 // get correct valence orbitals 1847 mol->CalculateOrbitals(*this);1848 InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;1849 1545 if (ConfigFileName != NULL) { // test the file name 1850 1546 strcpy(filename, ConfigFileName); … … 1859 1555 output.close(); 1860 1556 output.clear(); 1861 Log() << Verbose(0) << "Saving of config file ";1557 Log() << Verbose(0) << "Saving of config file ... " << endl; 1862 1558 if (Save(filename, periode, mol)) 1863 Log() << Verbose(0) << " successful." << endl;1559 Log() << Verbose(0) << "\t... successful." << endl; 1864 1560 else 1865 Log() << Verbose(0) << " failed." << endl;1561 Log() << Verbose(0) << "\t... failed." << endl; 1866 1562 1867 1563 // and save to xyz file … … 1876 1572 output.open(filename, ios::trunc); 1877 1573 } 1878 Log() << Verbose(0) << "Saving of XYZ file ";1574 Log() << Verbose(0) << "Saving of XYZ file ... " << endl; 1879 1575 if (mol->MDSteps <= 1) { 1880 1576 if (mol->OutputXYZ(&output)) 1881 Log() << Verbose(0) << " successful." << endl;1577 Log() << Verbose(0) << "\t... successful." << endl; 1882 1578 else 1883 Log() << Verbose(0) << " failed." << endl;1579 Log() << Verbose(0) << "\t... failed." << endl; 1884 1580 } else { 1885 1581 if (mol->OutputTrajectoriesXYZ(&output)) 1886 Log() << Verbose(0) << " successful." << endl;1582 Log() << Verbose(0) << "\t... successful." << endl; 1887 1583 else 1888 Log() << Verbose(0) << " failed." << endl;1584 Log() << Verbose(0) << "\t... failed." << endl; 1889 1585 } 1890 1586 output.close(); … … 1896 1592 if (output == NULL) 1897 1593 strcpy(filename,"main_pcp_linux"); 1898 Log() << Verbose(0) << "Saving as mpqc input ";1594 Log() << Verbose(0) << "Saving as mpqc input .. " << endl; 1899 1595 if (SaveMPQC(filename, mol)) 1900 Log() << Verbose(0) << " done." << endl;1596 Log() << Verbose(0) << "\t... done." << endl; 1901 1597 else 1902 Log() << Verbose(0) << "failed." << endl; 1903 1904 if (!strcmp(configpath, GetDefaultPath())) { 1905 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1906 } 1907 1908 World::getInstance().destroyMolecule(mol); 1598 Log() << Verbose(0) << "\t... failed." << endl; 1599 1600 // don't destroy molecule as it contains all our atoms 1601 //World::getInstance().destroyMolecule(mol); 1909 1602 }; 1910 1603 … … 1938 1631 char *dummy1 = NULL; 1939 1632 char *dummy = NULL; 1940 char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); // pointers in the line that is read in per step1633 char free_dummy[MAXSTRINGSIZE]; // pointers in the line that is read in per step 1941 1634 dummy1 = free_dummy; 1942 1635 … … 1954 1647 if (file->eof()) { 1955 1648 if ((critical) && (found == 0)) { 1956 Free(free_dummy);1957 1649 //Error(InitReading, name); 1958 1650 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1962 1654 file->clear(); 1963 1655 file->seekg(file_position, ios::beg); // rewind to start position 1964 Free(free_dummy);1965 1656 return 0; 1966 1657 } … … 1993 1684 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 1994 1685 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1995 //Free((void **)&free_dummy);1996 1686 //Error(FileOpenParams, NULL); 1997 1687 } else { … … 2014 1704 if (file->eof()) { 2015 1705 if ((critical) && (found == 0)) { 2016 Free(free_dummy);2017 1706 //Error(InitReading, name); 2018 1707 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 2022 1711 file->clear(); 2023 1712 file->seekg(file_position, ios::beg); // rewind to start position 2024 Free(free_dummy);2025 1713 return 0; 2026 1714 } … … 2063 1751 if (critical) { 2064 1752 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 2065 Free(free_dummy);2066 1753 //return 0; 2067 1754 exit(255); … … 2071 1758 file->clear(); 2072 1759 file->seekg(file_position, ios::beg); // rewind to start position 2073 Free(free_dummy);2074 1760 return 0; 2075 1761 } … … 2084 1770 file->seekg(file_position, ios::beg); // rewind to start position 2085 1771 } 2086 Free(free_dummy);2087 1772 return 0; 2088 1773 } … … 2140 1825 if ((type >= row_int) && (verbose)) 2141 1826 fprintf(stderr,"\n"); 2142 Free(free_dummy);2143 1827 if (!sequential) { 2144 1828 file->clear(); … … 2221 1905 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) 2222 1906 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 2223 //Free(&free_dummy);2224 1907 //Error(FileOpenParams, NULL); 2225 1908 } else { … … 2361 2044 return (found); // true if found, false if not 2362 2045 } 2046 2047 /** Reading of Thermostat related values from parameter file. 2048 * \param *fb file buffer containing the config file 2049 */ 2050 void config::ParseThermostats(class ConfigFileBuffer * const fb) 2051 { 2052 char * const thermo = new char[12]; 2053 const int verbose = 0; 2054 2055 // read desired Thermostat from file along with needed additional parameters 2056 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) { 2057 if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None 2058 if (Thermostats->ThermostatImplemented[0] == 1) { 2059 Thermostats->Thermostat = None; 2060 } else { 2061 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2062 Thermostats->Thermostat = None; 2063 } 2064 } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock 2065 if (Thermostats->ThermostatImplemented[1] == 1) { 2066 Thermostats->Thermostat = Woodcock; 2067 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency 2068 } else { 2069 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2070 Thermostats->Thermostat = None; 2071 } 2072 } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian 2073 if (Thermostats->ThermostatImplemented[2] == 1) { 2074 Thermostats->Thermostat = Gaussian; 2075 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate 2076 } else { 2077 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2078 Thermostats->Thermostat = None; 2079 } 2080 } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin 2081 if (Thermostats->ThermostatImplemented[3] == 1) { 2082 Thermostats->Thermostat = Langevin; 2083 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma 2084 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) { 2085 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl); 2086 } else { 2087 Thermostats->alpha = 1.; 2088 } 2089 } else { 2090 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2091 Thermostats->Thermostat = None; 2092 } 2093 } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen 2094 if (Thermostats->ThermostatImplemented[4] == 1) { 2095 Thermostats->Thermostat = Berendsen; 2096 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T 2097 } else { 2098 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2099 Thermostats->Thermostat = None; 2100 } 2101 } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover 2102 if (Thermostats->ThermostatImplemented[5] == 1) { 2103 Thermostats->Thermostat = NoseHoover; 2104 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass 2105 Thermostats->alpha = 0.; 2106 } else { 2107 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 2108 Thermostats->Thermostat = None; 2109 } 2110 } else { 2111 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl); 2112 Thermostats->Thermostat = None; 2113 } 2114 } else { 2115 if ((Thermostats->TargetTemp != 0)) 2116 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl); 2117 Thermostats->Thermostat = None; 2118 } 2119 delete[](thermo); 2120 }; 2121
Note:
See TracChangeset
for help on using the changeset viewer.