Changes in / [da3024:55240c4]
- Location:
- src
- Files:
-
- 8 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CmdAction/BondLengthTableAction.cpp
rda3024 r55240c4 9 9 10 10 #include "Actions/CmdAction/BondLengthTableAction.hpp" 11 #include "bondgraph.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" -
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
rda3024 r55240c4 10 10 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp" 12 13 #include "config.hpp" 13 14 #include "log.hpp" -
src/Actions/FragmentationAction/FragmentationAction.cpp
rda3024 r55240c4 10 10 #include "Actions/FragmentationAction/FragmentationAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp" 12 13 #include "config.hpp" 13 14 #include "log.hpp" -
src/Makefile.am
rda3024 r55240c4 88 88 Parser/ChangeTracker.cpp \ 89 89 Parser/FormatParser.cpp \ 90 Parser/MpqcParser.cpp \ 91 Parser/PcpParser.cpp \ 90 92 Parser/TremoloParser.cpp \ 91 93 Parser/XyzParser.cpp 94 92 95 PARSERHEADER = \ 93 96 Parser/ChangeTracker.hpp \ 94 97 Parser/FormatParser.hpp \ 98 Parser/MpqcParser.hpp \ 99 Parser/PcpParser.hpp \ 95 100 Parser/TremoloParser.hpp \ 96 101 Parser/XyzParser.hpp … … 153 158 CommandLineParser.cpp \ 154 159 config.cpp \ 160 ConfigFileBuffer.cpp \ 155 161 element.cpp \ 156 162 elements_db.cpp \ … … 178 184 tesselation.cpp \ 179 185 tesselationhelpers.cpp \ 186 ThermoStatContainer.cpp \ 180 187 triangleintersectionlist.cpp \ 181 188 vector.cpp \ … … 198 205 CommandLineParser.hpp \ 199 206 config.hpp \ 207 ConfigFileBuffer.hpp \ 200 208 defs.hpp \ 201 209 element.hpp \ … … 220 228 tesselation.hpp \ 221 229 tesselationhelpers.hpp \ 230 ThermoStatContainer.hpp \ 222 231 triangleintersectionlist.hpp \ 223 232 verbose.hpp \ -
src/World.cpp
rda3024 r55240c4 14 14 #include "molecule.hpp" 15 15 #include "periodentafel.hpp" 16 #include "ThermoStatContainer.hpp" 16 17 #include "Descriptors/AtomDescriptor.hpp" 17 18 #include "Descriptors/AtomDescriptor_impl.hpp" … … 89 90 defaultName = name; 90 91 }; 92 93 class ThermoStatContainer * World::getThermostats() 94 { 95 return Thermostats; 96 } 97 91 98 92 99 int World::getExitFlag() { … … 281 288 periode(new periodentafel), 282 289 configuration(new config), 290 Thermostats(new ThermoStatContainer), 283 291 ExitFlag(0), 284 292 atoms(), … … 306 314 delete periode; 307 315 delete configuration; 316 delete Thermostats; 308 317 MoleculeSet::iterator molIter; 309 318 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ -
src/World.hpp
rda3024 r55240c4 30 30 31 31 // forward declarations 32 class config;33 class periodentafel;34 class MoleculeListClass;35 32 class atom; 36 class molecule;37 33 class AtomDescriptor; 38 34 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 anipulateAtomsProcess;42 template<typename T> 43 class AtomsCalculation;41 class MoleculeListClass; 42 class periodentafel; 43 class ThermoStatContainer; 44 44 45 45 /****************************************** forward declarations *****************************/ … … 142 142 void setDefaultName(std::string name); 143 143 144 /** 145 * get pointer to World's ThermoStatContainer 146 */ 147 ThermoStatContainer * getThermostats(); 148 144 149 /* 145 150 * get the ExitFlag … … 254 259 static double *cell_size; 255 260 std::string defaultName; 261 class ThermoStatContainer *Thermostats; 256 262 int ExitFlag; 257 263 public: -
src/atom.cpp
rda3024 r55240c4 159 159 * \return true - \a *out present, false - \a *out is NULL 160 160 */ 161 bool atom::OutputArrayIndexed(o fstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const161 bool atom::OutputArrayIndexed(ostream * 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 fstream * const out, const Vector *center, int *AtomNo = NULL) const238 void atom::OutputMPQCLine(ostream * 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
rda3024 r55240c4 51 51 52 52 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const; 53 bool OutputArrayIndexed(o fstream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;53 bool OutputArrayIndexed(ostream * 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 fstream * const out, const Vector *center, int *AtomNo) const;57 void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const; 58 58 59 59 void InitComponentNr(); -
src/atom_trajectoryparticle.cpp
rda3024 r55240c4 15 15 #include "log.hpp" 16 16 #include "parser.hpp" 17 #include "ThermoStatContainer.hpp" 17 18 #include "verbose.hpp" 18 19 … … 197 198 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 198 199 { 199 double sigma = sqrt(configuration->T argetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)200 double sigma = sqrt(configuration->Thermostats->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) 200 201 Vector &U = Trajectory.U.at(Step); 201 202 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 202 203 // throw a dice to determine whether it gets hit by a heat bath particle 203 if (((((rand()/(double)RAND_MAX))*configuration->T empFrequency) < 1.)) {204 if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) { 204 205 DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> "); 205 206 // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis … … 225 226 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 226 227 for (int d=0; d<NDIM; d++) { 227 U[d] *= sqrt(1+(configuration->Deltat/configuration->T empFrequency)*(ScaleTempFactor-1));228 U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1)); 228 229 *ekin += 0.5*type->mass * U[d]*U[d]; 229 230 } … … 255 256 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 256 257 for (int d=0; d<NDIM; d++) { 257 U[d] += configuration->Deltat/type->mass * (configuration-> alpha * (U[d] * type->mass));258 U[d] += configuration->Deltat/type->mass * (configuration->Thermostats->alpha * (U[d] * type->mass)); 258 259 *ekin += (0.5*type->mass) * U[d]*U[d]; 259 260 } -
src/config.cpp
rda3024 r55240c4 10 10 #include <cstring> 11 11 12 #include "World.hpp"13 12 #include "atom.hpp" 14 13 #include "bond.hpp" 14 #include "bondgraph.hpp" 15 15 #include "config.hpp" 16 #include "ConfigFileBuffer.hpp" 16 17 #include "element.hpp" 17 18 #include "helpers.hpp" … … 23 24 #include "molecule.hpp" 24 25 #include "periodentafel.hpp" 26 #include "ThermoStatContainer.hpp" 25 27 #include "World.hpp" 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 number40 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 number44 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 number52 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 number57 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 name71 */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 lines78 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 one84 long file_position = file->tellg(); // mark current position85 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 dimension94 if (buffer != NULL) {95 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);96 return;97 } else98 buffer = new char *[NoLines];99 100 // scan each line and put into buffer101 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 exit114 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 the141 * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine142 * points to first Ion_Type entry.143 * \param *FileBuffer pointer to buffer structure144 * \param NoAtoms of subsequent lines to look at145 */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 map156 for (int i=0; i<NoAtoms; ++i) {157 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));158 }159 160 // fill map161 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 28 172 29 /************************************* Functions for class config ***************************/ … … 174 31 /** Constructor for config file class. 175 32 */ 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), 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), 179 35 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 180 36 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), … … 188 44 configpath = new char[MAXSTRINGSIZE]; 189 45 configname = new char[MAXSTRINGSIZE]; 46 Thermostats = new ThermoStatContainer(); 190 47 strcpy(mainname,"pcp"); 191 48 strcpy(defaultpath,"not specified"); … … 194 51 configname[0]='\0'; 195 52 basis = "3-21G"; 196 197 InitThermostats();198 53 }; 199 54 … … 208 63 delete[](configpath); 209 64 delete[](configname); 210 delete[](ThermostatImplemented); 211 for (int j=0;j<MaxThermostats;j++) 212 delete[](ThermostatNames[j]); 213 delete[](ThermostatNames); 65 if (Thermostats != NULL) 66 delete(Thermostats); 214 67 215 68 if (BG != NULL) 216 69 delete(BG); 217 70 }; 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 file244 */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 parameters251 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {252 if (strcmp(thermo, ThermostatNames[0]) == 0) { // None253 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) { // Woodcock260 if (ThermostatImplemented[1] == 1) {261 Thermostat = Woodcock;262 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency263 } 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) { // Gaussian268 if (ThermostatImplemented[2] == 1) {269 Thermostat = Gaussian;270 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate271 } 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) { // Langevin276 if (ThermostatImplemented[3] == 1) {277 Thermostat = Langevin;278 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma279 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) { // Berendsen289 if (ThermostatImplemented[4] == 1) {290 Thermostat = Berendsen;291 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T292 } 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-Hoover297 if (ThermostatImplemented[5] == 1) {298 Thermostat = NoseHoover;299 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass300 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 317 71 318 72 /** Displays menu for editing each entry of the config file. … … 656 410 }; 657 411 658 /** Initializes ConfigFileBuffer from a file.659 * \param *file input file stream being the opened config file660 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL661 */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 673 412 /** Loads a molecule from a ConfigFileBuffer. 674 413 * \param *mol molecule to load … … 867 606 868 607 // ParseParameterFile 869 struct ConfigFileBuffer *FileBuffer = NULL; 870 PrepareFileBuffer(filename,FileBuffer); 608 class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 871 609 872 610 /* Oeffne Hauptparameterdatei */ … … 877 615 int verbose = 0; 878 616 617 //TODO: This is actually sensible?: if (MaxOuterStep > 0) 879 618 ParseThermostats(FileBuffer); 880 619 … … 941 680 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 942 681 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 943 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &( config::TargetTemp), 1, optional);682 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional); 944 683 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 945 684 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) … … 1150 889 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 1151 890 ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 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);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); 1154 893 config::EpsWannier = 1e-8; 1155 894 … … 1339 1078 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1340 1079 *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl; 1341 *output << "Thermostat\t" << Thermostat Names[Thermostat] << "\t";1342 switch(Thermostat ) {1080 *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t"; 1081 switch(Thermostats->Thermostat) { 1343 1082 default: 1344 1083 case None: 1345 1084 break; 1346 1085 case Woodcock: 1347 *output << ScaleTempStep;1086 *output << Thermostats->ScaleTempStep; 1348 1087 break; 1349 1088 case Gaussian: 1350 *output << ScaleTempStep;1089 *output << Thermostats->ScaleTempStep; 1351 1090 break; 1352 1091 case Langevin: 1353 *output << T empFrequency << "\t" <<alpha;1092 *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha; 1354 1093 break; 1355 1094 case Berendsen: 1356 *output << T empFrequency;1095 *output << Thermostats->TempFrequency; 1357 1096 break; 1358 1097 case NoseHoover: 1359 *output << HooverMass;1098 *output << Thermostats->HooverMass; 1360 1099 break; 1361 1100 }; … … 1372 1111 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1373 1112 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; 1374 *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl;1113 *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl; 1375 1114 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1376 1115 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; … … 1483 1222 // output of atoms 1484 1223 AtomNo = 0; 1485 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1224 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1486 1225 delete(center); 1487 1226 *output << "\t}" << endl; … … 1525 1264 // output of atoms 1526 1265 AtomNo = 0; 1527 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );1266 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo ); 1528 1267 delete(center); 1529 1268 *output << "\t}" << endl; … … 2346 2085 return (found); // true if found, false if not 2347 2086 } 2087 2088 /** Reading of Thermostat related values from parameter file. 2089 * \param *fb file buffer containing the config file 2090 */ 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 parameters 2097 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) { 2098 if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None 2099 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) { // Woodcock 2106 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 frequency 2109 } 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) { // Gaussian 2114 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 rate 2117 } 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) { // Langevin 2122 if (Thermostats->ThermostatImplemented[3] == 1) { 2123 Thermostats->Thermostat = Langevin; 2124 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma 2125 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) { // Berendsen 2135 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_T 2138 } 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-Hoover 2143 if (Thermostats->ThermostatImplemented[5] == 1) { 2144 Thermostats->Thermostat = NoseHoover; 2145 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass 2146 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
rda3024 r55240c4 20 20 #include <string> 21 21 22 #include "bondgraph.hpp"23 24 22 /****************************************** forward declarations *****************************/ 25 23 24 class BondGraph; 25 class ConfigFileBuffer; 26 26 class molecule; 27 27 class MoleculeListClass; 28 28 class periodentafel; 29 class ThermoStatContainer; 29 30 30 31 /********************************************** 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 };46 32 47 33 /** The config file. … … 51 37 public: 52 38 class BondGraph *BG; 39 class ThermoStatContainer *Thermostats; 53 40 54 41 int PsiType; … … 70 57 int DoConstrainedMD; 71 58 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;80 59 81 60 private: … … 152 131 char *GetDefaultPath() const; 153 132 void SetDefaultPath(const char * const path); 154 void InitThermostats();155 133 void ParseThermostats(class ConfigFileBuffer * const fb); 156 134 }; -
src/molecule.cpp
rda3024 r55240c4 881 881 ElementNo[i] = current++; 882 882 } 883 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );883 ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 884 884 return true; 885 885 } -
src/molecule.hpp
rda3024 r55240c4 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#ThermostatImplemented84 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover }; //!< Thermostat names for output85 86 82 87 83 /** The complete molecule. -
src/molecule_dynamics.cpp
rda3024 r55240c4 18 18 #include "parser.hpp" 19 19 #include "Plane.hpp" 20 #include "ThermoStatContainer.hpp" 20 21 21 22 /************************************* Functions for class molecule *********************************/ … … 643 644 644 645 // calculate scale configuration 645 ScaleTempFactor = configuration.T argetTemp/ActualTemp;646 ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp; 646 647 647 648 // differentating between the various thermostats … … 651 652 break; 652 653 case Woodcock: 653 if ((configuration. ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {654 if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) { 654 655 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl); 655 656 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); … … 684 685 delta_alpha = 0.; 685 686 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 686 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.T argetTemp)/(configuration.HooverMass*Units2Electronmass);687 configuration. alpha += delta_alpha*configuration.Deltat;688 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration. alpha << "." << endl);687 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.Thermostats->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); 689 690 // apply updated alpha as additional force 690 691 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration ); -
src/moleculelist.cpp
rda3024 r55240c4 12 12 #include "atom.hpp" 13 13 #include "bond.hpp" 14 #include "bondgraph.hpp" 14 15 #include "boundary.hpp" 15 16 #include "config.hpp" -
src/unittests/ParserUnitTest.cpp
rda3024 r55240c4 12 12 #include <cppunit/ui/text/TestRunner.h> 13 13 14 #include "Parser/MpqcParser.hpp" 15 #include "Parser/PcpParser.hpp" 16 #include "Parser/TremoloParser.hpp" 14 17 #include "Parser/XyzParser.hpp" 15 #include "Parser/TremoloParser.hpp"16 18 #include "World.hpp" 17 19 #include "atom.hpp" … … 29 31 CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest ); 30 32 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"; 31 142 32 143 void ParserUnitTest::setUp() { 33 144 World::getInstance(); 145 146 // we need hydrogens and oxygens in the following tests 147 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL); 148 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL); 34 149 } 35 150 … … 43 158 cout << "Testing the XYZ parser." << endl; 44 159 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";46 160 stringstream input; 47 161 input << waterXyz; … … 62 176 TremoloParser* testParser = new TremoloParser(); 63 177 stringstream input, output; 64 string waterTremolo;65 178 66 179 // Atomdata beginning with "# ATOMDATA" 67 waterTremolo = "# ATOMDATA\tId\tname\tType\tx=3\n"; 68 input << waterTremolo; 69 testParser->load(&input); 70 testParser->save(&output); 71 CPPUNIT_ASSERT(waterTremolo == output.str()); 180 input << Tremolo_Atomdata1; 181 testParser->load(&input); 182 testParser->save(&output); 183 CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str()); 72 184 input.clear(); 73 185 output.clear(); 74 186 75 187 // Atomdata beginning with "#ATOMDATA" 76 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 77 input << waterTremolo; 188 input << Tremolo_Atomdata2; 78 189 testParser->load(&input); 79 190 testParser->save(&output); … … 83 194 84 195 // Invalid key in Atomdata line 85 waterTremolo = "#\n#ATOMDATA Id name foo Type x=3\n\n\n"; 86 input << waterTremolo; 196 input << Tremolo_invalidkey; 87 197 testParser->load(&input); 88 198 //TODO: proove invalidity … … 93 203 TremoloParser* testParser = new TremoloParser(); 94 204 stringstream input; 95 string waterTremolo;96 205 97 206 // One simple data line 98 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 99 input << waterTremolo; 207 input << Tremolo_Atomdata2; 100 208 testParser->load(&input); 101 209 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0); … … 106 214 TremoloParser* testParser = new TremoloParser(); 107 215 stringstream input; 108 string waterTremolo;109 216 110 217 // One simple data line 111 waterTremolo = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 112 input << waterTremolo; 218 input << Tremolo_velocity; 113 219 testParser->load(&input); 114 220 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0); … … 119 225 TremoloParser* testParser = new TremoloParser(); 120 226 stringstream input; 121 string waterTremolo;122 227 123 228 // Neighbor data 124 waterTremolo = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; 125 input << waterTremolo; 229 input << Tremolo_neighbours; 126 230 testParser->load(&input); 127 231 … … 135 239 TremoloParser* testParser = new TremoloParser(); 136 240 stringstream input, output; 137 string waterTremolo;138 241 139 242 // Neighbor data 140 waterTremolo = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 141 input << waterTremolo; 243 input << Tremolo_improper; 142 244 testParser->load(&input); 143 245 testParser->save(&output); … … 151 253 TremoloParser* testParser = new TremoloParser(); 152 254 stringstream input, output; 153 string waterTremolo;154 255 155 256 // Neighbor data 156 waterTremolo = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 157 input << waterTremolo; 257 input << Tremolo_torsion; 158 258 testParser->load(&input); 159 259 testParser->save(&output); … … 173 273 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"); 174 274 testParser->save(&output); 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");275 CPPUNIT_ASSERT(output.str() == Tremolo_full); 176 276 177 277 cout << "testing the tremolo parser is done" << endl; 178 278 } 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 molecule 303 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 created 316 stringstream input(waterMpqc); 317 MpqcParser* testParser = new MpqcParser(); 318 stringstream output; 319 testParser->save(&output); 320 321 // compare both configs 322 CPPUNIT_ASSERT(input.str() == output.str()); 323 } -
src/unittests/ParserUnitTest.hpp
rda3024 r55240c4 22 22 CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest ); 23 23 CPPUNIT_TEST ( writeTremoloTest ); 24 CPPUNIT_TEST ( readwritePcpTest ); 25 CPPUNIT_TEST ( writeMpqcTest ); 24 26 CPPUNIT_TEST_SUITE_END(); 25 27 … … 36 38 void readAndWriteTremoloTorsionInformationTest(); 37 39 void writeTremoloTest(); 40 void readwritePcpTest(); 41 void writeMpqcTest(); 38 42 }; 39 43
Note:
See TracChangeset
for help on using the changeset viewer.