Changes in / [55240c4:da3024]
- Location:
- src
- Files:
-
- 8 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CmdAction/BondLengthTableAction.cpp
r55240c4 rda3024 9 9 10 10 #include "Actions/CmdAction/BondLengthTableAction.hpp" 11 #include "bondgraph.hpp"12 11 #include "config.hpp" 13 12 #include "log.hpp" -
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
r55240c4 rda3024 10 10 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp"13 12 #include "config.hpp" 14 13 #include "log.hpp" -
src/Actions/FragmentationAction/FragmentationAction.cpp
r55240c4 rda3024 10 10 #include "Actions/FragmentationAction/FragmentationAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp"13 12 #include "config.hpp" 14 13 #include "log.hpp" -
src/Makefile.am
r55240c4 rda3024 88 88 Parser/ChangeTracker.cpp \ 89 89 Parser/FormatParser.cpp \ 90 Parser/MpqcParser.cpp \91 Parser/PcpParser.cpp \92 90 Parser/TremoloParser.cpp \ 93 91 Parser/XyzParser.cpp 94 95 92 PARSERHEADER = \ 96 93 Parser/ChangeTracker.hpp \ 97 94 Parser/FormatParser.hpp \ 98 Parser/MpqcParser.hpp \99 Parser/PcpParser.hpp \100 95 Parser/TremoloParser.hpp \ 101 96 Parser/XyzParser.hpp … … 158 153 CommandLineParser.cpp \ 159 154 config.cpp \ 160 ConfigFileBuffer.cpp \161 155 element.cpp \ 162 156 elements_db.cpp \ … … 184 178 tesselation.cpp \ 185 179 tesselationhelpers.cpp \ 186 ThermoStatContainer.cpp \187 180 triangleintersectionlist.cpp \ 188 181 vector.cpp \ … … 205 198 CommandLineParser.hpp \ 206 199 config.hpp \ 207 ConfigFileBuffer.hpp \208 200 defs.hpp \ 209 201 element.hpp \ … … 228 220 tesselation.hpp \ 229 221 tesselationhelpers.hpp \ 230 ThermoStatContainer.hpp \231 222 triangleintersectionlist.hpp \ 232 223 verbose.hpp \ -
src/World.cpp
r55240c4 rda3024 14 14 #include "molecule.hpp" 15 15 #include "periodentafel.hpp" 16 #include "ThermoStatContainer.hpp"17 16 #include "Descriptors/AtomDescriptor.hpp" 18 17 #include "Descriptors/AtomDescriptor_impl.hpp" … … 90 89 defaultName = name; 91 90 }; 92 93 class ThermoStatContainer * World::getThermostats()94 {95 return Thermostats;96 }97 98 91 99 92 int World::getExitFlag() { … … 288 281 periode(new periodentafel), 289 282 configuration(new config), 290 Thermostats(new ThermoStatContainer),291 283 ExitFlag(0), 292 284 atoms(), … … 314 306 delete periode; 315 307 delete configuration; 316 delete Thermostats;317 308 MoleculeSet::iterator molIter; 318 309 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ -
src/World.hpp
r55240c4 rda3024 30 30 31 31 // forward declarations 32 class config; 33 class periodentafel; 34 class MoleculeListClass; 32 35 class atom; 36 class molecule; 33 37 class AtomDescriptor; 34 38 class AtomDescriptor_impl; 35 template<typename T> class AtomsCalculation;36 class config;37 class ManipulateAtomsProcess;38 class molecule;39 39 class MoleculeDescriptor; 40 40 class MoleculeDescriptor_impl; 41 class M oleculeListClass;42 class periodentafel; 43 class ThermoStatContainer;41 class ManipulateAtomsProcess; 42 template<typename T> 43 class AtomsCalculation; 44 44 45 45 /****************************************** forward declarations *****************************/ … … 142 142 void setDefaultName(std::string name); 143 143 144 /**145 * get pointer to World's ThermoStatContainer146 */147 ThermoStatContainer * getThermostats();148 149 144 /* 150 145 * get the ExitFlag … … 259 254 static double *cell_size; 260 255 std::string defaultName; 261 class ThermoStatContainer *Thermostats;262 256 int ExitFlag; 263 257 public: -
src/atom.cpp
r55240c4 rda3024 159 159 * \return true - \a *out present, false - \a *out is NULL 160 160 */ 161 bool atom::OutputArrayIndexed(o stream * const out, const int *ElementNo, int *AtomNo, const char *comment) const161 bool atom::OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const 162 162 { 163 163 AtomNo[type->Z]++; // increment number … … 236 236 * \param *AtomNo pointer to atom counter that is increased by one 237 237 */ 238 void atom::OutputMPQCLine(o stream * const out, const Vector *center, int *AtomNo = NULL) const238 void atom::OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo = NULL) const 239 239 { 240 240 *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; -
src/atom.hpp
r55240c4 rda3024 51 51 52 52 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const; 53 bool OutputArrayIndexed(o stream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;53 bool OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const; 54 54 bool OutputXYZLine(ofstream *out) const; 55 55 bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const; 56 56 bool OutputTrajectoryXYZ(ofstream * const out, const int step) const; 57 void OutputMPQCLine(o stream * const out, const Vector *center, int *AtomNo) const;57 void OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo) const; 58 58 59 59 void InitComponentNr(); -
src/atom_trajectoryparticle.cpp
r55240c4 rda3024 15 15 #include "log.hpp" 16 16 #include "parser.hpp" 17 #include "ThermoStatContainer.hpp"18 17 #include "verbose.hpp" 19 18 … … 198 197 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 199 198 { 200 double sigma = sqrt(configuration->T hermostats->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)199 double sigma = sqrt(configuration->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) 201 200 Vector &U = Trajectory.U.at(Step); 202 201 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 203 202 // throw a dice to determine whether it gets hit by a heat bath particle 204 if (((((rand()/(double)RAND_MAX))*configuration->T hermostats->TempFrequency) < 1.)) {203 if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) { 205 204 DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> "); 206 205 // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis … … 226 225 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 227 226 for (int d=0; d<NDIM; d++) { 228 U[d] *= sqrt(1+(configuration->Deltat/configuration->T hermostats->TempFrequency)*(ScaleTempFactor-1));227 U[d] *= sqrt(1+(configuration->Deltat/configuration->TempFrequency)*(ScaleTempFactor-1)); 229 228 *ekin += 0.5*type->mass * U[d]*U[d]; 230 229 } … … 256 255 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 257 256 for (int d=0; d<NDIM; d++) { 258 U[d] += configuration->Deltat/type->mass * (configuration-> Thermostats->alpha * (U[d] * type->mass));257 U[d] += configuration->Deltat/type->mass * (configuration->alpha * (U[d] * type->mass)); 259 258 *ekin += (0.5*type->mass) * U[d]*U[d]; 260 259 } -
src/config.cpp
r55240c4 rda3024 10 10 #include <cstring> 11 11 12 #include "World.hpp" 12 13 #include "atom.hpp" 13 14 #include "bond.hpp" 14 #include "bondgraph.hpp"15 15 #include "config.hpp" 16 #include "ConfigFileBuffer.hpp"17 16 #include "element.hpp" 18 17 #include "helpers.hpp" … … 24 23 #include "molecule.hpp" 25 24 #include "periodentafel.hpp" 26 #include "ThermoStatContainer.hpp"27 25 #include "World.hpp" 28 26 27 /******************************** Functions for class ConfigFileBuffer **********************/ 28 29 /** Structure containing compare function for Ion_Type sorting. 30 */ 31 struct IonTypeCompare { 32 bool operator()(const char* s1, const char *s2) const { 33 char number1[8]; 34 char number2[8]; 35 const char *dummy1, *dummy2; 36 //Log() << Verbose(0) << s1 << " " << s2 << endl; 37 dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type" 38 dummy2 = strchr(dummy1, '_'); 39 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 40 number1[dummy2-dummy1]='\0'; 41 dummy1 = strchr(s2, '_')+sizeof(char)*5; // go just after "Ion_Type" 42 dummy2 = strchr(dummy1, '_'); 43 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 44 number2[dummy2-dummy1]='\0'; 45 if (atoi(number1) != atoi(number2)) 46 return (atoi(number1) < atoi(number2)); 47 else { 48 dummy1 = strchr(s1, '_')+sizeof(char); 49 dummy1 = strchr(dummy1, '_')+sizeof(char); 50 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 51 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 52 number1[dummy2-dummy1]='\0'; 53 dummy1 = strchr(s2, '_')+sizeof(char); 54 dummy1 = strchr(dummy1, '_')+sizeof(char); 55 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 56 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 57 number2[dummy2-dummy1]='\0'; 58 return (atoi(number1) < atoi(number2)); 59 } 60 } 61 }; 62 63 /** Constructor for ConfigFileBuffer class. 64 */ 65 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 66 { 67 }; 68 69 /** Constructor for ConfigFileBuffer class with filename to be parsed. 70 * \param *filename file name 71 */ 72 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 73 { 74 ifstream *file = NULL; 75 char line[MAXSTRINGSIZE]; 76 77 // prescan number of lines 78 file= new ifstream(filename); 79 if (file == NULL) { 80 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 81 return; 82 } 83 NoLines = 0; // we're overcounting by one 84 long file_position = file->tellg(); // mark current position 85 do { 86 file->getline(line, 256); 87 NoLines++; 88 } while (!file->eof()); 89 file->clear(); 90 file->seekg(file_position, ios::beg); 91 DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl); 92 93 // allocate buffer's 1st dimension 94 if (buffer != NULL) { 95 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl); 96 return; 97 } else 98 buffer = new char *[NoLines]; 99 100 // scan each line and put into buffer 101 int lines=0; 102 int i; 103 do { 104 buffer[lines] = new char[MAXSTRINGSIZE]; 105 file->getline(buffer[lines], MAXSTRINGSIZE-1); 106 i = strlen(buffer[lines]); 107 buffer[lines][i] = '\n'; 108 buffer[lines][i+1] = '\0'; 109 lines++; 110 } while((!file->eof()) && (lines < NoLines)); 111 DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl); 112 113 // close and exit 114 file->close(); 115 file->clear(); 116 delete(file); 117 } 118 119 /** Destructor for ConfigFileBuffer class. 120 */ 121 ConfigFileBuffer::~ConfigFileBuffer() 122 { 123 for(int i=0;i<NoLines;++i) 124 delete[](buffer[i]); 125 delete[](buffer); 126 delete[](LineMapping); 127 } 128 129 130 /** Create trivial mapping. 131 */ 132 void ConfigFileBuffer::InitMapping() 133 { 134 LineMapping = new int[NoLines]; 135 for (int i=0;i<NoLines;i++) 136 LineMapping[i] = i; 137 } 138 139 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted. 140 * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the 141 * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine 142 * points to first Ion_Type entry. 143 * \param *FileBuffer pointer to buffer structure 144 * \param NoAtoms of subsequent lines to look at 145 */ 146 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms) 147 { 148 map<const char *, int, IonTypeCompare> IonTypeLineMap; 149 if (LineMapping == NULL) { 150 DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl); 151 performCriticalExit(); 152 return; 153 } 154 155 // put all into hashed map 156 for (int i=0; i<NoAtoms; ++i) { 157 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i)); 158 } 159 160 // fill map 161 int nr=0; 162 for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) { 163 if (CurrentLine+nr < NoLines) 164 LineMapping[CurrentLine+(nr++)] = runner->second; 165 else { 166 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl); 167 performCriticalExit(); 168 } 169 } 170 } 171 29 172 /************************************* Functions for class config ***************************/ 30 173 31 174 /** Constructor for config file class. 32 175 */ 33 config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 34 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 176 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 177 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL), 178 ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 35 179 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 36 180 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), … … 44 188 configpath = new char[MAXSTRINGSIZE]; 45 189 configname = new char[MAXSTRINGSIZE]; 46 Thermostats = new ThermoStatContainer();47 190 strcpy(mainname,"pcp"); 48 191 strcpy(defaultpath,"not specified"); … … 51 194 configname[0]='\0'; 52 195 basis = "3-21G"; 196 197 InitThermostats(); 53 198 }; 54 199 … … 63 208 delete[](configpath); 64 209 delete[](configname); 65 if (Thermostats != NULL) 66 delete(Thermostats); 210 delete[](ThermostatImplemented); 211 for (int j=0;j<MaxThermostats;j++) 212 delete[](ThermostatNames[j]); 213 delete[](ThermostatNames); 67 214 68 215 if (BG != NULL) 69 216 delete(BG); 70 217 }; 218 219 /** Initialises variables in class config for Thermostats. 220 */ 221 void config::InitThermostats() 222 { 223 ThermostatImplemented = new int[MaxThermostats]; 224 ThermostatNames = new char *[MaxThermostats]; 225 for (int j=0;j<MaxThermostats;j++) 226 ThermostatNames[j] = new char[12]; 227 228 strcpy(ThermostatNames[0],"None"); 229 ThermostatImplemented[0] = 1; 230 strcpy(ThermostatNames[1],"Woodcock"); 231 ThermostatImplemented[1] = 1; 232 strcpy(ThermostatNames[2],"Gaussian"); 233 ThermostatImplemented[2] = 1; 234 strcpy(ThermostatNames[3],"Langevin"); 235 ThermostatImplemented[3] = 1; 236 strcpy(ThermostatNames[4],"Berendsen"); 237 ThermostatImplemented[4] = 1; 238 strcpy(ThermostatNames[5],"NoseHoover"); 239 ThermostatImplemented[5] = 1; 240 }; 241 242 /** Readin of Thermostat related values from parameter file. 243 * \param *fb file buffer containing the config file 244 */ 245 void config::ParseThermostats(class ConfigFileBuffer * const fb) 246 { 247 char * const thermo = new char[12]; 248 const int verbose = 0; 249 250 // read desired Thermostat from file along with needed additional parameters 251 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) { 252 if (strcmp(thermo, ThermostatNames[0]) == 0) { // None 253 if (ThermostatImplemented[0] == 1) { 254 Thermostat = None; 255 } else { 256 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 257 Thermostat = None; 258 } 259 } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock 260 if (ThermostatImplemented[1] == 1) { 261 Thermostat = Woodcock; 262 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency 263 } else { 264 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 265 Thermostat = None; 266 } 267 } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian 268 if (ThermostatImplemented[2] == 1) { 269 Thermostat = Gaussian; 270 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate 271 } else { 272 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 273 Thermostat = None; 274 } 275 } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin 276 if (ThermostatImplemented[3] == 1) { 277 Thermostat = Langevin; 278 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma 279 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) { 280 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl); 281 } else { 282 alpha = 1.; 283 } 284 } else { 285 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 286 Thermostat = None; 287 } 288 } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen 289 if (ThermostatImplemented[4] == 1) { 290 Thermostat = Berendsen; 291 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T 292 } else { 293 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 294 Thermostat = None; 295 } 296 } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover 297 if (ThermostatImplemented[5] == 1) { 298 Thermostat = NoseHoover; 299 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass 300 alpha = 0.; 301 } else { 302 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 303 Thermostat = None; 304 } 305 } else { 306 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl); 307 Thermostat = None; 308 } 309 } else { 310 if ((MaxOuterStep > 0) && (TargetTemp != 0)) 311 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl); 312 Thermostat = None; 313 } 314 delete[](thermo); 315 }; 316 71 317 72 318 /** Displays menu for editing each entry of the config file. … … 410 656 }; 411 657 658 /** Initializes ConfigFileBuffer from a file. 659 * \param *file input file stream being the opened config file 660 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL 661 */ 662 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer) 663 { 664 if (FileBuffer != NULL) { 665 DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl); 666 delete(FileBuffer); 667 } 668 FileBuffer = new ConfigFileBuffer(filename); 669 670 FileBuffer->InitMapping(); 671 }; 672 412 673 /** Loads a molecule from a ConfigFileBuffer. 413 674 * \param *mol molecule to load … … 606 867 607 868 // ParseParameterFile 608 class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 869 struct ConfigFileBuffer *FileBuffer = NULL; 870 PrepareFileBuffer(filename,FileBuffer); 609 871 610 872 /* Oeffne Hauptparameterdatei */ … … 615 877 int verbose = 0; 616 878 617 //TODO: This is actually sensible?: if (MaxOuterStep > 0)618 879 ParseThermostats(FileBuffer); 619 880 … … 680 941 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 681 942 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 682 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &( Thermostats->TargetTemp), 1, optional);943 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 683 944 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 684 945 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) … … 889 1150 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 890 1151 ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 891 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &( Thermostats->TargetTemp), 1, optional);892 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &( Thermostats->ScaleTempStep), 1, optional);1152 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 1153 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 893 1154 config::EpsWannier = 1e-8; 894 1155 … … 1078 1339 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1079 1340 *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl; 1080 *output << "Thermostat\t" << Thermostat s->ThermostatNames[Thermostats->Thermostat] << "\t";1081 switch(Thermostat s->Thermostat) {1341 *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t"; 1342 switch(Thermostat) { 1082 1343 default: 1083 1344 case None: 1084 1345 break; 1085 1346 case Woodcock: 1086 *output << Thermostats->ScaleTempStep;1347 *output << ScaleTempStep; 1087 1348 break; 1088 1349 case Gaussian: 1089 *output << Thermostats->ScaleTempStep;1350 *output << ScaleTempStep; 1090 1351 break; 1091 1352 case Langevin: 1092 *output << T hermostats->TempFrequency << "\t" << Thermostats->alpha;1353 *output << TempFrequency << "\t" << alpha; 1093 1354 break; 1094 1355 case Berendsen: 1095 *output << T hermostats->TempFrequency;1356 *output << TempFrequency; 1096 1357 break; 1097 1358 case NoseHoover: 1098 *output << Thermostats->HooverMass;1359 *output << HooverMass; 1099 1360 break; 1100 1361 }; … … 1111 1372 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1112 1373 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; 1113 *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;1374 *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl; 1114 1375 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1115 1376 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; … … 1222 1483 // output of atoms 1223 1484 AtomNo = 0; 1224 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const)output, (const Vector *)center, &AtomNo );1485 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1225 1486 delete(center); 1226 1487 *output << "\t}" << endl; … … 1264 1525 // output of atoms 1265 1526 AtomNo = 0; 1266 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const)output, (const Vector *)center, &AtomNo );1527 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1267 1528 delete(center); 1268 1529 *output << "\t}" << endl; … … 2085 2346 return (found); // true if found, false if not 2086 2347 } 2087 2088 /** Reading of Thermostat related values from parameter file.2089 * \param *fb file buffer containing the config file2090 */2091 void config::ParseThermostats(class ConfigFileBuffer * const fb)2092 {2093 char * const thermo = new char[12];2094 const int verbose = 0;2095 2096 // read desired Thermostat from file along with needed additional parameters2097 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {2098 if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None2099 if (Thermostats->ThermostatImplemented[0] == 1) {2100 Thermostats->Thermostat = None;2101 } else {2102 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2103 Thermostats->Thermostat = None;2104 }2105 } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock2106 if (Thermostats->ThermostatImplemented[1] == 1) {2107 Thermostats->Thermostat = Woodcock;2108 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency2109 } else {2110 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2111 Thermostats->Thermostat = None;2112 }2113 } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian2114 if (Thermostats->ThermostatImplemented[2] == 1) {2115 Thermostats->Thermostat = Gaussian;2116 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate2117 } else {2118 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2119 Thermostats->Thermostat = None;2120 }2121 } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin2122 if (Thermostats->ThermostatImplemented[3] == 1) {2123 Thermostats->Thermostat = Langevin;2124 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma2125 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {2126 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);2127 } else {2128 Thermostats->alpha = 1.;2129 }2130 } else {2131 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2132 Thermostats->Thermostat = None;2133 }2134 } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen2135 if (Thermostats->ThermostatImplemented[4] == 1) {2136 Thermostats->Thermostat = Berendsen;2137 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T2138 } else {2139 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2140 Thermostats->Thermostat = None;2141 }2142 } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover2143 if (Thermostats->ThermostatImplemented[5] == 1) {2144 Thermostats->Thermostat = NoseHoover;2145 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass2146 Thermostats->alpha = 0.;2147 } else {2148 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2149 Thermostats->Thermostat = None;2150 }2151 } else {2152 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);2153 Thermostats->Thermostat = None;2154 }2155 } else {2156 if ((Thermostats->TargetTemp != 0))2157 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl);2158 Thermostats->Thermostat = None;2159 }2160 delete[](thermo);2161 };2162 -
src/config.hpp
r55240c4 rda3024 20 20 #include <string> 21 21 22 #include "bondgraph.hpp" 23 22 24 /****************************************** forward declarations *****************************/ 23 25 24 class BondGraph;25 class ConfigFileBuffer;26 26 class molecule; 27 27 class MoleculeListClass; 28 28 class periodentafel; 29 class ThermoStatContainer;30 29 31 30 /********************************************** declarations *******************************/ 31 32 class ConfigFileBuffer { 33 public: 34 char **buffer; 35 int *LineMapping; 36 int CurrentLine; 37 int NoLines; 38 39 ConfigFileBuffer(); 40 ConfigFileBuffer(const char * const filename); 41 ~ConfigFileBuffer(); 42 43 void InitMapping(); 44 void MapIonTypesInBuffer(const int NoAtoms); 45 }; 32 46 33 47 /** The config file. … … 37 51 public: 38 52 class BondGraph *BG; 39 class ThermoStatContainer *Thermostats;40 53 41 54 int PsiType; … … 57 70 int DoConstrainedMD; 58 71 int MaxOuterStep; 72 int Thermostat; 73 int *ThermostatImplemented; 74 char **ThermostatNames; 75 double TempFrequency; 76 double alpha; 77 double HooverMass; 78 double TargetTemp; 79 int ScaleTempStep; 59 80 60 81 private: … … 131 152 char *GetDefaultPath() const; 132 153 void SetDefaultPath(const char * const path); 154 void InitThermostats(); 133 155 void ParseThermostats(class ConfigFileBuffer * const fb); 134 156 }; -
src/molecule.cpp
r55240c4 rda3024 881 881 ElementNo[i] = current++; 882 882 } 883 ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const)output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );883 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 884 884 return true; 885 885 } -
src/molecule.hpp
r55240c4 rda3024 80 80 double *PenaltyConstants; //!< penalty constant in front of each term 81 81 }; 82 83 #define MaxThermostats 6 //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented 84 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover }; //!< Thermostat names for output 85 82 86 83 87 /** The complete molecule. -
src/molecule_dynamics.cpp
r55240c4 rda3024 18 18 #include "parser.hpp" 19 19 #include "Plane.hpp" 20 #include "ThermoStatContainer.hpp"21 20 22 21 /************************************* Functions for class molecule *********************************/ … … 644 643 645 644 // calculate scale configuration 646 ScaleTempFactor = configuration.T hermostats->TargetTemp/ActualTemp;645 ScaleTempFactor = configuration.TargetTemp/ActualTemp; 647 646 648 647 // differentating between the various thermostats … … 652 651 break; 653 652 case Woodcock: 654 if ((configuration. Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {653 if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) { 655 654 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl); 656 655 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); … … 685 684 delta_alpha = 0.; 686 685 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 687 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.T hermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass);688 configuration. Thermostats->alpha += delta_alpha*configuration.Deltat;689 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration. Thermostats->alpha << "." << endl);686 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass); 687 configuration.alpha += delta_alpha*configuration.Deltat; 688 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl); 690 689 // apply updated alpha as additional force 691 690 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration ); -
src/moleculelist.cpp
r55240c4 rda3024 12 12 #include "atom.hpp" 13 13 #include "bond.hpp" 14 #include "bondgraph.hpp"15 14 #include "boundary.hpp" 16 15 #include "config.hpp" -
src/unittests/ParserUnitTest.cpp
r55240c4 rda3024 12 12 #include <cppunit/ui/text/TestRunner.h> 13 13 14 #include "Parser/MpqcParser.hpp" 15 #include "Parser/PcpParser.hpp" 14 #include "Parser/XyzParser.hpp" 16 15 #include "Parser/TremoloParser.hpp" 17 #include "Parser/XyzParser.hpp"18 16 #include "World.hpp" 19 17 #include "atom.hpp" … … 31 29 CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest ); 32 30 33 static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\34 \n\35 mainname\tpcp\t# programm name (for runtime files)\n\36 defaultpath\not specified\t# where to put files during runtime\n\37 pseudopotpath\not specified\t# where to find pseudopotentials\n\38 \n\39 ProcPEGamma\t8\t# for parallel computing: share constants\n\40 ProcPEPsi\t1\t# for parallel computing: share wave functions\n\41 DoOutVis\t0\t# Output data for OpenDX\n\42 DoOutMes\t1\t# Output data for measurements\n\43 DoOutOrbitals\t0\t# Output all Orbitals\n\44 DoOutCurr\t0\t# Ouput current density for OpenDx\n\45 DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\46 DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\47 DoFullCurrent\t0\t# Do full perturbation\n\48 DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\49 Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\50 CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\51 SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\52 VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\53 VectorCut\t0\t# Cut plane axis value\n\54 AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\55 Seed\t1\t# initial value for random seed for Psi coefficients\n\56 \n\57 MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\58 Deltat\t0.01\t# time per MD step\n\59 OutVisStep\t10\t# Output visual data every ...th step\n\60 OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\61 TargetTemp\t0.000950045\t# Target temperature\n\62 MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\63 EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\64 # Values specifying when to stop\n\65 MaxMinStep\t100\t# Maximum number of steps\n\66 RelEpsTotalE\t1e-07\t# relative change in total energy\n\67 RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\68 MaxMinStopStep\t0\t# check every ..th steps\n\69 MaxMinGapStopStep\t1\t# check every ..th steps\n\70 \n\71 # Values specifying when to stop for INIT, otherwise same as above\n\72 MaxInitMinStep\t100\t# Maximum number of steps\n\73 InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\74 InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\75 InitMaxMinStopStep\t0\t# check every ..th steps\n\76 InitMaxMinGapStopStep\t1\t# check every ..th steps\n\77 \n\78 BoxLength\t# (Length of a unit cell)\n\79 20\n\80 0\t20\n\81 0\t0\t20\n\82 \n\83 ECut\t128\t# energy cutoff for discretization in Hartrees\n\84 MaxLevel\t5\t# number of different levels in the code, >=2\n\85 Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\86 RiemannTensor\t0\t# (Use metric)\n\87 PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\88 MaxPsiDouble\t0\t# here: specifying both maximum number of SpinUp- and -Down-states\n\89 PsiMaxNoUp\t0\t# here: specifying maximum number of SpinUp-states\n\90 PsiMaxNoDown\t0\t# here: specifying maximum number of SpinDown-states\n\91 AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\92 \n\93 RCut\t20\t# R-cut for the ewald summation\n\94 StructOpt\t0\t# Do structure optimization beforehand\n\95 IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\96 RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\97 MaxTypes\t2\t# maximum number of different ion types\n\98 \n\99 # Ion type data (PP = PseudoPotential, Z = atomic number)\n\100 #Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\101 Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\102 Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\103 #Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\104 Ion_Type2_1\t0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\105 Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\106 Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n";107 static string waterMpqc ="% Created by MoleCuilder\n\108 mpqc: (\n\109 \tsavestate = no\n\110 \tdo_gradient = yes\n\111 \tmole<MBPT2>: (\n\112 \t\tmaxiter = 200\n\113 \t\tbasis = $:basis\n\114 \t\tmolecule = $:molecule\n\115 \t\treference<CLHF>: (\n\116 \t\t\tbasis = $:basis\n\117 \t\t\tmolecule = $:molecule\n\118 \t\t)\n\119 \t)\n\120 )\n\121 molecule<Molecule>: (\n\122 \tunit = angstrom\n\123 \t{ atoms geometry } = {\n\124 \t\tO [ 0\t0\t0 ]\n\125 \t\tH [ 0.758602\t0\t0.504284 ]\n\126 \t\tH [ 0.758602\t0\t-0.504284 ]\n\127 \t}\n\128 )\n\129 basis<GaussianBasisSet>: (\n\130 \tname = \"3-21G\"\n\131 \tmolecule = $:molecule\n\132 )\n";133 static string waterXyz = "3\nH2O: water molecule\nO\t0.000000\t0.000000\t0.000000\nH\t0.758602\t0.000000\t0.504284\nH\t0.758602\t0.000000\t-0.504284\n";134 static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";135 static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";136 static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";137 static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";138 static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";139 static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";140 static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";141 static string Tremolo_full = "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n";142 31 143 32 void ParserUnitTest::setUp() { 144 33 World::getInstance(); 145 146 // we need hydrogens and oxygens in the following tests147 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);148 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);149 34 } 150 35 … … 158 43 cout << "Testing the XYZ parser." << endl; 159 44 XyzParser* testParser = new XyzParser(); 45 string waterXyz = "3\nH2O: water molecule\nO\t0.000000\t0.000000\t0.000000\nH\t0.758602\t0.000000\t0.504284\nH\t0.758602\t0.000000\t-0.504284\n"; 160 46 stringstream input; 161 47 input << waterXyz; … … 176 62 TremoloParser* testParser = new TremoloParser(); 177 63 stringstream input, output; 64 string waterTremolo; 178 65 179 66 // Atomdata beginning with "# ATOMDATA" 180 input << Tremolo_Atomdata1; 67 waterTremolo = "# ATOMDATA\tId\tname\tType\tx=3\n"; 68 input << waterTremolo; 181 69 testParser->load(&input); 182 70 testParser->save(&output); 183 CPPUNIT_ASSERT( Tremolo_Atomdata1== output.str());71 CPPUNIT_ASSERT(waterTremolo == output.str()); 184 72 input.clear(); 185 73 output.clear(); 186 74 187 75 // Atomdata beginning with "#ATOMDATA" 188 input << Tremolo_Atomdata2; 76 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 77 input << waterTremolo; 189 78 testParser->load(&input); 190 79 testParser->save(&output); … … 194 83 195 84 // Invalid key in Atomdata line 196 input << Tremolo_invalidkey; 85 waterTremolo = "#\n#ATOMDATA Id name foo Type x=3\n\n\n"; 86 input << waterTremolo; 197 87 testParser->load(&input); 198 88 //TODO: proove invalidity … … 203 93 TremoloParser* testParser = new TremoloParser(); 204 94 stringstream input; 95 string waterTremolo; 205 96 206 97 // One simple data line 207 input << Tremolo_Atomdata2; 98 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 99 input << waterTremolo; 208 100 testParser->load(&input); 209 101 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0); … … 214 106 TremoloParser* testParser = new TremoloParser(); 215 107 stringstream input; 108 string waterTremolo; 216 109 217 110 // One simple data line 218 input << Tremolo_velocity; 111 waterTremolo = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 112 input << waterTremolo; 219 113 testParser->load(&input); 220 114 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0); … … 225 119 TremoloParser* testParser = new TremoloParser(); 226 120 stringstream input; 121 string waterTremolo; 227 122 228 123 // Neighbor data 229 input << Tremolo_neighbours; 124 waterTremolo = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; 125 input << waterTremolo; 230 126 testParser->load(&input); 231 127 … … 239 135 TremoloParser* testParser = new TremoloParser(); 240 136 stringstream input, output; 137 string waterTremolo; 241 138 242 139 // Neighbor data 243 input << Tremolo_improper; 140 waterTremolo = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 141 input << waterTremolo; 244 142 testParser->load(&input); 245 143 testParser->save(&output); … … 253 151 TremoloParser* testParser = new TremoloParser(); 254 152 stringstream input, output; 153 string waterTremolo; 255 154 256 155 // Neighbor data 257 input << Tremolo_torsion; 156 waterTremolo = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 157 input << waterTremolo; 258 158 testParser->load(&input); 259 159 testParser->save(&output); … … 273 173 testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion"); 274 174 testParser->save(&output); 275 CPPUNIT_ASSERT(output.str() == Tremolo_full);175 CPPUNIT_ASSERT(output.str() == "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n"); 276 176 277 177 cout << "testing the tremolo parser is done" << endl; 278 178 } 279 280 void ParserUnitTest::readwritePcpTest() {281 stringstream input(waterPcp);282 PcpParser* testParser = new PcpParser();283 testParser->load(&input);284 input.clear();285 286 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());287 288 string newWaterPcp = "";289 stringstream output;290 testParser->save(&output);291 292 input << output;293 PcpParser* testParser2 = new PcpParser();294 testParser2->load(&input);295 296 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());297 298 CPPUNIT_ASSERT(*testParser == *testParser2);299 }300 301 void ParserUnitTest::writeMpqcTest() {302 // build up water molecule303 atom *Walker = NULL;304 Walker = World::getInstance().createAtom();305 Walker->type = World::getInstance().getPeriode()->FindElement(8);306 Walker->x = Vector(0,0,0);307 Walker = World::getInstance().createAtom();308 Walker->type = World::getInstance().getPeriode()->FindElement(1);309 Walker->x = Vector(0.758602,0,0.504284);310 Walker = World::getInstance().createAtom();311 Walker->type = World::getInstance().getPeriode()->FindElement(1);312 Walker->x = Vector(0.758602,0,-0.504284);313 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());314 315 // create two stringstreams, one stored, one created316 stringstream input(waterMpqc);317 MpqcParser* testParser = new MpqcParser();318 stringstream output;319 testParser->save(&output);320 321 // compare both configs322 CPPUNIT_ASSERT(input.str() == output.str());323 } -
src/unittests/ParserUnitTest.hpp
r55240c4 rda3024 22 22 CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest ); 23 23 CPPUNIT_TEST ( writeTremoloTest ); 24 CPPUNIT_TEST ( readwritePcpTest );25 CPPUNIT_TEST ( writeMpqcTest );26 24 CPPUNIT_TEST_SUITE_END(); 27 25 … … 38 36 void readAndWriteTremoloTorsionInformationTest(); 39 37 void writeTremoloTest(); 40 void readwritePcpTest();41 void writeMpqcTest();42 38 }; 43 39
Note:
See TracChangeset
for help on using the changeset viewer.