Changes in / [55240c4:da3024]


Ignore:
Location:
src
Files:
8 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/CmdAction/BondLengthTableAction.cpp

    r55240c4 rda3024  
    99
    1010#include "Actions/CmdAction/BondLengthTableAction.hpp"
    11 #include "bondgraph.hpp"
    1211#include "config.hpp"
    1312#include "log.hpp"
  • src/Actions/FragmentationAction/DepthFirstSearchAction.cpp

    r55240c4 rda3024  
    1010#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
    1111#include "atom.hpp"
    12 #include "bondgraph.hpp"
    1312#include "config.hpp"
    1413#include "log.hpp"
  • src/Actions/FragmentationAction/FragmentationAction.cpp

    r55240c4 rda3024  
    1010#include "Actions/FragmentationAction/FragmentationAction.hpp"
    1111#include "atom.hpp"
    12 #include "bondgraph.hpp"
    1312#include "config.hpp"
    1413#include "log.hpp"
  • src/Makefile.am

    r55240c4 rda3024  
    8888  Parser/ChangeTracker.cpp \
    8989  Parser/FormatParser.cpp \
    90   Parser/MpqcParser.cpp \
    91   Parser/PcpParser.cpp \
    9290  Parser/TremoloParser.cpp \
    9391  Parser/XyzParser.cpp
    94 
    9592PARSERHEADER = \
    9693  Parser/ChangeTracker.hpp \
    9794  Parser/FormatParser.hpp \
    98   Parser/MpqcParser.hpp \
    99   Parser/PcpParser.hpp \
    10095  Parser/TremoloParser.hpp \
    10196  Parser/XyzParser.hpp
     
    158153  CommandLineParser.cpp \
    159154  config.cpp \
    160   ConfigFileBuffer.cpp \
    161155  element.cpp \
    162156  elements_db.cpp \
     
    184178  tesselation.cpp \
    185179  tesselationhelpers.cpp \
    186   ThermoStatContainer.cpp \
    187180  triangleintersectionlist.cpp \
    188181  vector.cpp \
     
    205198  CommandLineParser.hpp \
    206199  config.hpp \
    207   ConfigFileBuffer.hpp \
    208200  defs.hpp \
    209201  element.hpp \
     
    228220  tesselation.hpp \
    229221  tesselationhelpers.hpp \
    230   ThermoStatContainer.hpp \
    231222  triangleintersectionlist.hpp \
    232223  verbose.hpp \
  • src/World.cpp

    r55240c4 rda3024  
    1414#include "molecule.hpp"
    1515#include "periodentafel.hpp"
    16 #include "ThermoStatContainer.hpp"
    1716#include "Descriptors/AtomDescriptor.hpp"
    1817#include "Descriptors/AtomDescriptor_impl.hpp"
     
    9089  defaultName = name;
    9190};
    92 
    93 class ThermoStatContainer * World::getThermostats()
    94 {
    95   return Thermostats;
    96 }
    97 
    9891
    9992int World::getExitFlag() {
     
    288281    periode(new periodentafel),
    289282    configuration(new config),
    290     Thermostats(new ThermoStatContainer),
    291283    ExitFlag(0),
    292284    atoms(),
     
    314306  delete periode;
    315307  delete configuration;
    316   delete Thermostats;
    317308  MoleculeSet::iterator molIter;
    318309  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
  • src/World.hpp

    r55240c4 rda3024  
    3030
    3131// forward declarations
     32class config;
     33class periodentafel;
     34class MoleculeListClass;
    3235class atom;
     36class molecule;
    3337class AtomDescriptor;
    3438class AtomDescriptor_impl;
    35 template<typename T> class AtomsCalculation;
    36 class config;
    37 class ManipulateAtomsProcess;
    38 class molecule;
    3939class MoleculeDescriptor;
    4040class MoleculeDescriptor_impl;
    41 class MoleculeListClass;
    42 class periodentafel;
    43 class ThermoStatContainer;
     41class ManipulateAtomsProcess;
     42template<typename T>
     43class AtomsCalculation;
    4444
    4545/****************************************** forward declarations *****************************/
     
    142142  void setDefaultName(std::string name);
    143143
    144   /**
    145    * get pointer to World's ThermoStatContainer
    146    */
    147   ThermoStatContainer * getThermostats();
    148 
    149144  /*
    150145   * get the ExitFlag
     
    259254  static double *cell_size;
    260255  std::string defaultName;
    261   class ThermoStatContainer *Thermostats;
    262256  int ExitFlag;
    263257public:
  • src/atom.cpp

    r55240c4 rda3024  
    159159  * \return true - \a *out present, false - \a *out is NULL
    160160 */
    161 bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
     161bool atom::OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
    162162{
    163163  AtomNo[type->Z]++;  // increment number
     
    236236 * \param *AtomNo pointer to atom counter that is increased by one
    237237 */
    238 void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
     238void atom::OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo = NULL) const
    239239{
    240240  *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  
    5151
    5252  bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
    53   bool OutputArrayIndexed(ostream * 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;
    5454  bool OutputXYZLine(ofstream *out) const;
    5555  bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
    5656  bool OutputTrajectoryXYZ(ofstream * const out, const int step) const;
    57   void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const;
     57  void OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo) const;
    5858
    5959  void InitComponentNr();
  • src/atom_trajectoryparticle.cpp

    r55240c4 rda3024  
    1515#include "log.hpp"
    1616#include "parser.hpp"
    17 #include "ThermoStatContainer.hpp"
    1817#include "verbose.hpp"
    1918
     
    198197void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
    199198{
    200   double sigma  = sqrt(configuration->Thermostats->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)
    201200  Vector &U = Trajectory.U.at(Step);
    202201  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    203202    // throw a dice to determine whether it gets hit by a heat bath particle
    204     if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) {
     203    if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) {
    205204      DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
    206205      // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
     
    226225  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    227226    for (int d=0; d<NDIM; d++) {
    228       U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1));
     227      U[d] *= sqrt(1+(configuration->Deltat/configuration->TempFrequency)*(ScaleTempFactor-1));
    229228      *ekin += 0.5*type->mass * U[d]*U[d];
    230229    }
     
    256255  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    257256    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));
    259258        *ekin += (0.5*type->mass) * U[d]*U[d];
    260259      }
  • src/config.cpp

    r55240c4 rda3024  
    1010#include <cstring>
    1111
     12#include "World.hpp"
    1213#include "atom.hpp"
    1314#include "bond.hpp"
    14 #include "bondgraph.hpp"
    1515#include "config.hpp"
    16 #include "ConfigFileBuffer.hpp"
    1716#include "element.hpp"
    1817#include "helpers.hpp"
     
    2423#include "molecule.hpp"
    2524#include "periodentafel.hpp"
    26 #include "ThermoStatContainer.hpp"
    2725#include "World.hpp"
    2826
     27/******************************** Functions for class ConfigFileBuffer **********************/
     28
     29/** Structure containing compare function for Ion_Type sorting.
     30 */
     31struct 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 */
     65ConfigFileBuffer::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 */
     72ConfigFileBuffer::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 */
     121ConfigFileBuffer::~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 */
     132void 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 */
     146void 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
    29172/************************************* Functions for class config ***************************/
    30173
    31174/** Constructor for config file class.
    32175 */
    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),
     176config::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),
    35179    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
    36180    VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7),
     
    44188  configpath = new char[MAXSTRINGSIZE];
    45189  configname = new char[MAXSTRINGSIZE];
    46   Thermostats = new ThermoStatContainer();
    47190  strcpy(mainname,"pcp");
    48191  strcpy(defaultpath,"not specified");
     
    51194  configname[0]='\0';
    52195  basis = "3-21G";
     196
     197  InitThermostats();
    53198};
    54199
     
    63208  delete[](configpath);
    64209  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);
    67214
    68215  if (BG != NULL)
    69216    delete(BG);
    70217};
     218
     219/** Initialises variables in class config for Thermostats.
     220 */
     221void 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 */
     245void 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
    71317
    72318/** Displays menu for editing each entry of the config file.
     
    410656};
    411657
     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 */
     662void 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
    412673/** Loads a molecule from a ConfigFileBuffer.
    413674 * \param *mol molecule to load
     
    606867
    607868  // ParseParameterFile
    608   class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename);
     869  struct ConfigFileBuffer *FileBuffer = NULL;
     870  PrepareFileBuffer(filename,FileBuffer);
    609871
    610872  /* Oeffne Hauptparameterdatei */
     
    615877  int verbose = 0;
    616878 
    617   //TODO: This is actually sensible?: if (MaxOuterStep > 0)
    618879  ParseThermostats(FileBuffer);
    619880 
     
    680941  ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    681942  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);
    683944  //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
    684945  if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional))
     
    8891150  ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    8901151  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);
    8931154  config::EpsWannier = 1e-8;
    8941155
     
    10781339    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
    10791340    *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" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
    1081     switch(Thermostats->Thermostat) {
     1341    *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t";
     1342    switch(Thermostat) {
    10821343      default:
    10831344      case None:
    10841345        break;
    10851346      case Woodcock:
    1086         *output << Thermostats->ScaleTempStep;
     1347        *output << ScaleTempStep;
    10871348        break;
    10881349      case Gaussian:
    1089         *output << Thermostats->ScaleTempStep;
     1350        *output << ScaleTempStep;
    10901351        break;
    10911352      case Langevin:
    1092         *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
     1353        *output << TempFrequency << "\t" << alpha;
    10931354        break;
    10941355      case Berendsen:
    1095         *output << Thermostats->TempFrequency;
     1356        *output << TempFrequency;
    10961357        break;
    10971358      case NoseHoover:
    1098         *output << Thermostats->HooverMass;
     1359        *output << HooverMass;
    10991360        break;
    11001361    };
     
    11111372    *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl;
    11121373    *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;
    11141375    *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
    11151376    *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
     
    12221483    // output of atoms
    12231484    AtomNo = 0;
    1224     mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
     1485    mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
    12251486    delete(center);
    12261487    *output << "\t}" << endl;
     
    12641525    // output of atoms
    12651526    AtomNo = 0;
    1266     mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
     1527    mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
    12671528    delete(center);
    12681529    *output << "\t}" << endl;
     
    20852346  return (found); // true if found, false if not
    20862347}
    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

    r55240c4 rda3024  
    2020#include <string>
    2121
     22#include "bondgraph.hpp"
     23
    2224/****************************************** forward declarations *****************************/
    2325
    24 class BondGraph;
    25 class ConfigFileBuffer;
    2626class molecule;
    2727class MoleculeListClass;
    2828class periodentafel;
    29 class ThermoStatContainer;
    3029
    3130/********************************************** declarations *******************************/
     31
     32class 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};
    3246
    3347/** The config file.
     
    3751  public:
    3852    class BondGraph *BG;
    39     class ThermoStatContainer *Thermostats;
    4053
    4154    int PsiType;
     
    5770    int DoConstrainedMD;
    5871    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;
    5980
    6081  private:
     
    131152  char *GetDefaultPath() const;
    132153  void SetDefaultPath(const char * const path);
     154  void InitThermostats();
    133155  void ParseThermostats(class ConfigFileBuffer * const fb);
    134156};
  • src/molecule.cpp

    r55240c4 rda3024  
    881881        ElementNo[i] = current++;
    882882    }
    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 );
    884884    return true;
    885885  }
  • src/molecule.hpp

    r55240c4 rda3024  
    8080  double *PenaltyConstants;   //!<  penalty constant in front of each term
    8181};
     82
     83#define MaxThermostats 6      //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented
     84enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover };   //!< Thermostat names for output
     85
    8286
    8387/** The complete molecule.
  • src/molecule_dynamics.cpp

    r55240c4 rda3024  
    1818#include "parser.hpp"
    1919#include "Plane.hpp"
    20 #include "ThermoStatContainer.hpp"
    2120
    2221/************************************* Functions for class molecule *********************************/
     
    644643
    645644  // calculate scale configuration
    646   ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;
     645  ScaleTempFactor = configuration.TargetTemp/ActualTemp;
    647646
    648647  // differentating between the various thermostats
     
    652651      break;
    653652     case Woodcock:
    654       if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {
     653      if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {
    655654        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
    656655        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
     
    685684      delta_alpha = 0.;
    686685      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    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);
     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);
    690689      // apply updated alpha as additional force
    691690      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
  • src/moleculelist.cpp

    r55240c4 rda3024  
    1212#include "atom.hpp"
    1313#include "bond.hpp"
    14 #include "bondgraph.hpp"
    1514#include "boundary.hpp"
    1615#include "config.hpp"
  • src/unittests/ParserUnitTest.cpp

    r55240c4 rda3024  
    1212#include <cppunit/ui/text/TestRunner.h>
    1313
    14 #include "Parser/MpqcParser.hpp"
    15 #include "Parser/PcpParser.hpp"
     14#include "Parser/XyzParser.hpp"
    1615#include "Parser/TremoloParser.hpp"
    17 #include "Parser/XyzParser.hpp"
    1816#include "World.hpp"
    1917#include "atom.hpp"
     
    3129CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest );
    3230
    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";
    14231
    14332void ParserUnitTest::setUp() {
    14433  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);
    14934}
    15035
     
    15843  cout << "Testing the XYZ parser." << endl;
    15944  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";
    16046  stringstream input;
    16147  input << waterXyz;
     
    17662  TremoloParser* testParser = new TremoloParser();
    17763  stringstream input, output;
     64  string waterTremolo;
    17865
    17966  // Atomdata beginning with "# ATOMDATA"
    180   input << Tremolo_Atomdata1;
     67  waterTremolo = "# ATOMDATA\tId\tname\tType\tx=3\n";
     68  input << waterTremolo;
    18169  testParser->load(&input);
    18270  testParser->save(&output);
    183   CPPUNIT_ASSERT(Tremolo_Atomdata1 == output.str());
     71  CPPUNIT_ASSERT(waterTremolo == output.str());
    18472  input.clear();
    18573  output.clear();
    18674
    18775  // 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;
    18978  testParser->load(&input);
    19079  testParser->save(&output);
     
    19483
    19584  // 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;
    19787  testParser->load(&input);
    19888  //TODO: proove invalidity
     
    20393  TremoloParser* testParser = new TremoloParser();
    20494  stringstream input;
     95  string waterTremolo;
    20596
    20697  // 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;
    208100  testParser->load(&input);
    209101  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0);
     
    214106  TremoloParser* testParser = new TremoloParser();
    215107  stringstream input;
     108  string waterTremolo;
    216109
    217110  // 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;
    219113  testParser->load(&input);
    220114  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0);
     
    225119  TremoloParser* testParser = new TremoloParser();
    226120  stringstream input;
     121  string waterTremolo;
    227122
    228123  // 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;
    230126  testParser->load(&input);
    231127
     
    239135  TremoloParser* testParser = new TremoloParser();
    240136  stringstream input, output;
     137  string waterTremolo;
    241138
    242139  // 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;
    244142  testParser->load(&input);
    245143  testParser->save(&output);
     
    253151  TremoloParser* testParser = new TremoloParser();
    254152  stringstream input, output;
     153  string waterTremolo;
    255154
    256155  // 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;
    258158  testParser->load(&input);
    259159  testParser->save(&output);
     
    273173  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");
    274174  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");
    276176
    277177  cout << "testing the tremolo parser is done" << endl;
    278178}
    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

    r55240c4 rda3024  
    2222  CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest );
    2323  CPPUNIT_TEST ( writeTremoloTest );
    24   CPPUNIT_TEST ( readwritePcpTest );
    25   CPPUNIT_TEST ( writeMpqcTest );
    2624  CPPUNIT_TEST_SUITE_END();
    2725
     
    3836  void readAndWriteTremoloTorsionInformationTest();
    3937  void writeTremoloTest();
    40   void readwritePcpTest();
    41   void writeMpqcTest();
    4238};
    4339
Note: See TracChangeset for help on using the changeset viewer.