Changes in / [da3024:55240c4]


Ignore:
Location:
src
Files:
8 added
17 edited

Legend:

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

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

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

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

    rda3024 r55240c4  
    8888  Parser/ChangeTracker.cpp \
    8989  Parser/FormatParser.cpp \
     90  Parser/MpqcParser.cpp \
     91  Parser/PcpParser.cpp \
    9092  Parser/TremoloParser.cpp \
    9193  Parser/XyzParser.cpp
     94
    9295PARSERHEADER = \
    9396  Parser/ChangeTracker.hpp \
    9497  Parser/FormatParser.hpp \
     98  Parser/MpqcParser.hpp \
     99  Parser/PcpParser.hpp \
    95100  Parser/TremoloParser.hpp \
    96101  Parser/XyzParser.hpp
     
    153158  CommandLineParser.cpp \
    154159  config.cpp \
     160  ConfigFileBuffer.cpp \
    155161  element.cpp \
    156162  elements_db.cpp \
     
    178184  tesselation.cpp \
    179185  tesselationhelpers.cpp \
     186  ThermoStatContainer.cpp \
    180187  triangleintersectionlist.cpp \
    181188  vector.cpp \
     
    198205  CommandLineParser.hpp \
    199206  config.hpp \
     207  ConfigFileBuffer.hpp \
    200208  defs.hpp \
    201209  element.hpp \
     
    220228  tesselation.hpp \
    221229  tesselationhelpers.hpp \
     230  ThermoStatContainer.hpp \
    222231  triangleintersectionlist.hpp \
    223232  verbose.hpp \
  • src/World.cpp

    rda3024 r55240c4  
    1414#include "molecule.hpp"
    1515#include "periodentafel.hpp"
     16#include "ThermoStatContainer.hpp"
    1617#include "Descriptors/AtomDescriptor.hpp"
    1718#include "Descriptors/AtomDescriptor_impl.hpp"
     
    8990  defaultName = name;
    9091};
     92
     93class ThermoStatContainer * World::getThermostats()
     94{
     95  return Thermostats;
     96}
     97
    9198
    9299int World::getExitFlag() {
     
    281288    periode(new periodentafel),
    282289    configuration(new config),
     290    Thermostats(new ThermoStatContainer),
    283291    ExitFlag(0),
    284292    atoms(),
     
    306314  delete periode;
    307315  delete configuration;
     316  delete Thermostats;
    308317  MoleculeSet::iterator molIter;
    309318  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
  • src/World.hpp

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

    rda3024 r55240c4  
    159159  * \return true - \a *out present, false - \a *out is NULL
    160160 */
    161 bool atom::OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
     161bool atom::OutputArrayIndexed(ostream * 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(ofstream * const out, const Vector *center, int *AtomNo = NULL) const
     238void atom::OutputMPQCLine(ostream * 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

    rda3024 r55240c4  
    5151
    5252  bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const;
    53   bool OutputArrayIndexed(ofstream * 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;
    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(ofstream * const out, const Vector *center, int *AtomNo) const;
     57  void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const;
    5858
    5959  void InitComponentNr();
  • src/atom_trajectoryparticle.cpp

    rda3024 r55240c4  
    1515#include "log.hpp"
    1616#include "parser.hpp"
     17#include "ThermoStatContainer.hpp"
    1718#include "verbose.hpp"
    1819
     
    197198void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
    198199{
    199   double sigma  = sqrt(configuration->TargetTemp/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)
    200201  Vector &U = Trajectory.U.at(Step);
    201202  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    202203    // throw a dice to determine whether it gets hit by a heat bath particle
    203     if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) {
     204    if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) {
    204205      DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
    205206      // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
     
    225226  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    226227    for (int d=0; d<NDIM; d++) {
    227       U[d] *= sqrt(1+(configuration->Deltat/configuration->TempFrequency)*(ScaleTempFactor-1));
     228      U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1));
    228229      *ekin += 0.5*type->mass * U[d]*U[d];
    229230    }
     
    255256  if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    256257    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));
    258259        *ekin += (0.5*type->mass) * U[d]*U[d];
    259260      }
  • src/config.cpp

    rda3024 r55240c4  
    1010#include <cstring>
    1111
    12 #include "World.hpp"
    1312#include "atom.hpp"
    1413#include "bond.hpp"
     14#include "bondgraph.hpp"
    1515#include "config.hpp"
     16#include "ConfigFileBuffer.hpp"
    1617#include "element.hpp"
    1718#include "helpers.hpp"
     
    2324#include "molecule.hpp"
    2425#include "periodentafel.hpp"
     26#include "ThermoStatContainer.hpp"
    2527#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 number
    40     number1[dummy2-dummy1]='\0';
    41     dummy1 = strchr(s2, '_')+sizeof(char)*5;  // go just after "Ion_Type"
    42     dummy2 = strchr(dummy1, '_');
    43     strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    44     number2[dummy2-dummy1]='\0';
    45     if (atoi(number1) != atoi(number2))
    46       return (atoi(number1) < atoi(number2));
    47     else {
    48       dummy1 = strchr(s1, '_')+sizeof(char);
    49       dummy1 = strchr(dummy1, '_')+sizeof(char);
    50       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    51       strncpy(number1, dummy1, dummy2-dummy1); // copy the number
    52       number1[dummy2-dummy1]='\0';
    53       dummy1 = strchr(s2, '_')+sizeof(char);
    54       dummy1 = strchr(dummy1, '_')+sizeof(char);
    55       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    56       strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    57       number2[dummy2-dummy1]='\0';
    58       return (atoi(number1) < atoi(number2));
    59     }
    60   }
    61 };
    62 
    63 /** Constructor for ConfigFileBuffer class.
    64  */
    65 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    66 {
    67 };
    68 
    69 /** Constructor for ConfigFileBuffer class with filename to be parsed.
    70  * \param *filename file name
    71  */
    72 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    73 {
    74   ifstream *file = NULL;
    75   char line[MAXSTRINGSIZE];
    76 
    77   // prescan number of lines
    78   file= new ifstream(filename);
    79   if (file == NULL) {
    80     DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    81     return;
    82   }
    83   NoLines = 0; // we're overcounting by one
    84   long file_position = file->tellg(); // mark current position
    85   do {
    86     file->getline(line, 256);
    87     NoLines++;
    88   } while (!file->eof());
    89   file->clear();
    90   file->seekg(file_position, ios::beg);
    91   DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);
    92 
    93   // allocate buffer's 1st dimension
    94   if (buffer != NULL) {
    95     DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);
    96     return;
    97   } else
    98     buffer = new char *[NoLines];
    99 
    100   // scan each line and put into buffer
    101   int lines=0;
    102   int i;
    103   do {
    104     buffer[lines] = new char[MAXSTRINGSIZE];
    105     file->getline(buffer[lines], MAXSTRINGSIZE-1);
    106     i = strlen(buffer[lines]);
    107     buffer[lines][i] = '\n';
    108     buffer[lines][i+1] = '\0';
    109     lines++;
    110   } while((!file->eof()) && (lines < NoLines));
    111   DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
    112 
    113   // close and exit
    114   file->close();
    115   file->clear();
    116   delete(file);
    117 }
    118 
    119 /** Destructor for ConfigFileBuffer class.
    120  */
    121 ConfigFileBuffer::~ConfigFileBuffer()
    122 {
    123   for(int i=0;i<NoLines;++i)
    124     delete[](buffer[i]);
    125   delete[](buffer);
    126   delete[](LineMapping);
    127 }
    128 
    129 
    130 /** Create trivial mapping.
    131  */
    132 void ConfigFileBuffer::InitMapping()
    133 {
    134   LineMapping = new int[NoLines];
    135   for (int i=0;i<NoLines;i++)
    136     LineMapping[i] = i;
    137 }
    138 
    139 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted.
    140  * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the
    141  * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine
    142  * points to first Ion_Type entry.
    143  * \param *FileBuffer pointer to buffer structure
    144  * \param NoAtoms of subsequent lines to look at
    145  */
    146 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    147 {
    148   map<const char *, int, IonTypeCompare> IonTypeLineMap;
    149   if (LineMapping == NULL) {
    150     DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl);
    151     performCriticalExit();
    152     return;
    153   }
    154 
    155   // put all into hashed map
    156   for (int i=0; i<NoAtoms; ++i) {
    157     IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
    158   }
    159 
    160   // fill map
    161   int nr=0;
    162   for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
    163     if (CurrentLine+nr < NoLines)
    164       LineMapping[CurrentLine+(nr++)] = runner->second;
    165     else {
    166       DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);
    167       performCriticalExit();
    168     }
    169   }
    170 }
    17128
    17229/************************************* Functions for class config ***************************/
     
    17431/** Constructor for config file class.
    17532 */
    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),
     33config::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),
    17935    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
    18036    VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7),
     
    18844  configpath = new char[MAXSTRINGSIZE];
    18945  configname = new char[MAXSTRINGSIZE];
     46  Thermostats = new ThermoStatContainer();
    19047  strcpy(mainname,"pcp");
    19148  strcpy(defaultpath,"not specified");
     
    19451  configname[0]='\0';
    19552  basis = "3-21G";
    196 
    197   InitThermostats();
    19853};
    19954
     
    20863  delete[](configpath);
    20964  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);
    21467
    21568  if (BG != NULL)
    21669    delete(BG);
    21770};
    218 
    219 /** Initialises variables in class config for Thermostats.
    220  */
    221 void config::InitThermostats()
    222 {
    223   ThermostatImplemented = new int[MaxThermostats];
    224   ThermostatNames = new char *[MaxThermostats];
    225   for (int j=0;j<MaxThermostats;j++)
    226     ThermostatNames[j] = new char[12];
    227 
    228   strcpy(ThermostatNames[0],"None");
    229   ThermostatImplemented[0] = 1;
    230   strcpy(ThermostatNames[1],"Woodcock");
    231   ThermostatImplemented[1] = 1;
    232   strcpy(ThermostatNames[2],"Gaussian");
    233   ThermostatImplemented[2] = 1;
    234   strcpy(ThermostatNames[3],"Langevin");
    235   ThermostatImplemented[3] = 1;
    236   strcpy(ThermostatNames[4],"Berendsen");
    237   ThermostatImplemented[4] = 1;
    238   strcpy(ThermostatNames[5],"NoseHoover");
    239   ThermostatImplemented[5] = 1;
    240 };
    241 
    242 /** Readin of Thermostat related values from parameter file.
    243  * \param *fb file buffer containing the config file
    244  */
    245 void config::ParseThermostats(class ConfigFileBuffer * const fb)
    246 {
    247   char * const thermo = new char[12];
    248   const int verbose = 0;
    249 
    250   // read desired Thermostat from file along with needed additional parameters
    251   if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
    252     if (strcmp(thermo, ThermostatNames[0]) == 0) { // None
    253       if (ThermostatImplemented[0] == 1) {
    254         Thermostat = None;
    255       } else {
    256         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    257         Thermostat = None;
    258       }
    259     } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock
    260       if (ThermostatImplemented[1] == 1) {
    261         Thermostat = Woodcock;
    262         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
    263       } else {
    264         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    265         Thermostat = None;
    266       }
    267     } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian
    268       if (ThermostatImplemented[2] == 1) {
    269         Thermostat = Gaussian;
    270         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate
    271       } else {
    272         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    273         Thermostat = None;
    274       }
    275     } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin
    276       if (ThermostatImplemented[3] == 1) {
    277         Thermostat = Langevin;
    278         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma
    279         if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {
    280           DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);
    281         } else {
    282           alpha = 1.;
    283         }
    284       } else {
    285         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    286         Thermostat = None;
    287       }
    288     } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen
    289       if (ThermostatImplemented[4] == 1) {
    290         Thermostat = Berendsen;
    291         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T
    292       } else {
    293         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    294         Thermostat = None;
    295       }
    296     } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover
    297       if (ThermostatImplemented[5] == 1) {
    298         Thermostat = NoseHoover;
    299         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass
    300         alpha = 0.;
    301       } else {
    302         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    303         Thermostat = None;
    304       }
    305     } else {
    306       DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
    307       Thermostat = None;
    308     }
    309   } else {
    310     if ((MaxOuterStep > 0) && (TargetTemp != 0))
    311       DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
    312     Thermostat = None;
    313   }
    314   delete[](thermo);
    315 };
    316 
    31771
    31872/** Displays menu for editing each entry of the config file.
     
    656410};
    657411
    658 /** Initializes ConfigFileBuffer from a file.
    659  * \param *file input file stream being the opened config file
    660  * \param *FileBuffer pointer to FileBuffer on return, should point to NULL
    661  */
    662 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)
    663 {
    664   if (FileBuffer != NULL) {
    665     DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);
    666     delete(FileBuffer);
    667   }
    668   FileBuffer = new ConfigFileBuffer(filename);
    669 
    670   FileBuffer->InitMapping();
    671 };
    672 
    673412/** Loads a molecule from a ConfigFileBuffer.
    674413 * \param *mol molecule to load
     
    867606
    868607  // ParseParameterFile
    869   struct ConfigFileBuffer *FileBuffer = NULL;
    870   PrepareFileBuffer(filename,FileBuffer);
     608  class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename);
    871609
    872610  /* Oeffne Hauptparameterdatei */
     
    877615  int verbose = 0;
    878616 
     617  //TODO: This is actually sensible?: if (MaxOuterStep > 0)
    879618  ParseThermostats(FileBuffer);
    880619 
     
    941680  ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    942681  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);
    944683  //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
    945684  if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional))
     
    1150889  ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    1151890  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);
    1154893  config::EpsWannier = 1e-8;
    1155894
     
    13391078    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
    13401079    *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" << ThermostatNames[Thermostat] << "\t";
    1342     switch(Thermostat) {
     1080    *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
     1081    switch(Thermostats->Thermostat) {
    13431082      default:
    13441083      case None:
    13451084        break;
    13461085      case Woodcock:
    1347         *output << ScaleTempStep;
     1086        *output << Thermostats->ScaleTempStep;
    13481087        break;
    13491088      case Gaussian:
    1350         *output << ScaleTempStep;
     1089        *output << Thermostats->ScaleTempStep;
    13511090        break;
    13521091      case Langevin:
    1353         *output << TempFrequency << "\t" << alpha;
     1092        *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
    13541093        break;
    13551094      case Berendsen:
    1356         *output << TempFrequency;
     1095        *output << Thermostats->TempFrequency;
    13571096        break;
    13581097      case NoseHoover:
    1359         *output << HooverMass;
     1098        *output << Thermostats->HooverMass;
    13601099        break;
    13611100    };
     
    13721111    *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl;
    13731112    *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;
    13751114    *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
    13761115    *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
     
    14831222    // output of atoms
    14841223    AtomNo = 0;
    1485     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1224    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    14861225    delete(center);
    14871226    *output << "\t}" << endl;
     
    15251264    // output of atoms
    15261265    AtomNo = 0;
    1527     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1266    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    15281267    delete(center);
    15291268    *output << "\t}" << endl;
     
    23462085  return (found); // true if found, false if not
    23472086}
     2087
     2088/** Reading of Thermostat related values from parameter file.
     2089 * \param *fb file buffer containing the config file
     2090 */
     2091void 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  
    2020#include <string>
    2121
    22 #include "bondgraph.hpp"
    23 
    2422/****************************************** forward declarations *****************************/
    2523
     24class BondGraph;
     25class ConfigFileBuffer;
    2626class molecule;
    2727class MoleculeListClass;
    2828class periodentafel;
     29class ThermoStatContainer;
    2930
    3031/********************************************** 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 };
    4632
    4733/** The config file.
     
    5137  public:
    5238    class BondGraph *BG;
     39    class ThermoStatContainer *Thermostats;
    5340
    5441    int PsiType;
     
    7057    int DoConstrainedMD;
    7158    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;
    8059
    8160  private:
     
    152131  char *GetDefaultPath() const;
    153132  void SetDefaultPath(const char * const path);
    154   void InitThermostats();
    155133  void ParseThermostats(class ConfigFileBuffer * const fb);
    156134};
  • src/molecule.cpp

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

    rda3024 r55240c4  
    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
    84 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover };   //!< Thermostat names for output
    85 
    8682
    8783/** The complete molecule.
  • src/molecule_dynamics.cpp

    rda3024 r55240c4  
    1818#include "parser.hpp"
    1919#include "Plane.hpp"
     20#include "ThermoStatContainer.hpp"
    2021
    2122/************************************* Functions for class molecule *********************************/
     
    643644
    644645  // calculate scale configuration
    645   ScaleTempFactor = configuration.TargetTemp/ActualTemp;
     646  ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;
    646647
    647648  // differentating between the various thermostats
     
    651652      break;
    652653     case Woodcock:
    653       if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {
     654      if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {
    654655        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
    655656        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
     
    684685      delta_alpha = 0.;
    685686      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    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);
     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);
    689690      // apply updated alpha as additional force
    690691      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
  • src/moleculelist.cpp

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

    rda3024 r55240c4  
    1212#include <cppunit/ui/text/TestRunner.h>
    1313
     14#include "Parser/MpqcParser.hpp"
     15#include "Parser/PcpParser.hpp"
     16#include "Parser/TremoloParser.hpp"
    1417#include "Parser/XyzParser.hpp"
    15 #include "Parser/TremoloParser.hpp"
    1618#include "World.hpp"
    1719#include "atom.hpp"
     
    2931CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest );
    3032
     33static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\
     34\n\
     35mainname\tpcp\t# programm name (for runtime files)\n\
     36defaultpath\not specified\t# where to put files during runtime\n\
     37pseudopotpath\not specified\t# where to find pseudopotentials\n\
     38\n\
     39ProcPEGamma\t8\t# for parallel computing: share constants\n\
     40ProcPEPsi\t1\t# for parallel computing: share wave functions\n\
     41DoOutVis\t0\t# Output data for OpenDX\n\
     42DoOutMes\t1\t# Output data for measurements\n\
     43DoOutOrbitals\t0\t# Output all Orbitals\n\
     44DoOutCurr\t0\t# Ouput current density for OpenDx\n\
     45DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\
     46DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\
     47DoFullCurrent\t0\t# Do full perturbation\n\
     48DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\
     49Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\
     50CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\
     51SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\
     52VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\
     53VectorCut\t0\t# Cut plane axis value\n\
     54AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\
     55Seed\t1\t# initial value for random seed for Psi coefficients\n\
     56\n\
     57MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\
     58Deltat\t0.01\t# time per MD step\n\
     59OutVisStep\t10\t# Output visual data every ...th step\n\
     60OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\
     61TargetTemp\t0.000950045\t# Target temperature\n\
     62MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\
     63EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\
     64# Values specifying when to stop\n\
     65MaxMinStep\t100\t# Maximum number of steps\n\
     66RelEpsTotalE\t1e-07\t# relative change in total energy\n\
     67RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\
     68MaxMinStopStep\t0\t# check every ..th steps\n\
     69MaxMinGapStopStep\t1\t# check every ..th steps\n\
     70\n\
     71# Values specifying when to stop for INIT, otherwise same as above\n\
     72MaxInitMinStep\t100\t# Maximum number of steps\n\
     73InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\
     74InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\
     75InitMaxMinStopStep\t0\t# check every ..th steps\n\
     76InitMaxMinGapStopStep\t1\t# check every ..th steps\n\
     77\n\
     78BoxLength\t# (Length of a unit cell)\n\
     7920\n\
     800\t20\n\
     810\t0\t20\n\
     82\n\
     83ECut\t128\t# energy cutoff for discretization in Hartrees\n\
     84MaxLevel\t5\t# number of different levels in the code, >=2\n\
     85Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\
     86RiemannTensor\t0\t# (Use metric)\n\
     87PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\
     88MaxPsiDouble\t0\t# here: specifying both maximum number of SpinUp- and -Down-states\n\
     89PsiMaxNoUp\t0\t# here: specifying maximum number of SpinUp-states\n\
     90PsiMaxNoDown\t0\t# here: specifying maximum number of SpinDown-states\n\
     91AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\
     92\n\
     93RCut\t20\t# R-cut for the ewald summation\n\
     94StructOpt\t0\t# Do structure optimization beforehand\n\
     95IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\
     96RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\
     97MaxTypes\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\
     101Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\
     102Ion_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\
     104Ion_Type2_1\t0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\
     105Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\
     106Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n";
     107static string waterMpqc ="% Created by MoleCuilder\n\
     108mpqc: (\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\
     121molecule<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\
     129basis<GaussianBasisSet>: (\n\
     130\tname = \"3-21G\"\n\
     131\tmolecule = $:molecule\n\
     132)\n";
     133static 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";
     134static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";
     135static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
     136static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";
     137static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
     138static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";
     139static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
     140static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";
     141static 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";
    31142
    32143void ParserUnitTest::setUp() {
    33144  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);
    34149}
    35150
     
    43158  cout << "Testing the XYZ parser." << endl;
    44159  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";
    46160  stringstream input;
    47161  input << waterXyz;
     
    62176  TremoloParser* testParser = new TremoloParser();
    63177  stringstream input, output;
    64   string waterTremolo;
    65178
    66179  // 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());
    72184  input.clear();
    73185  output.clear();
    74186
    75187  // 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;
    78189  testParser->load(&input);
    79190  testParser->save(&output);
     
    83194
    84195  // 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;
    87197  testParser->load(&input);
    88198  //TODO: proove invalidity
     
    93203  TremoloParser* testParser = new TremoloParser();
    94204  stringstream input;
    95   string waterTremolo;
    96205
    97206  // 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;
    100208  testParser->load(&input);
    101209  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0);
     
    106214  TremoloParser* testParser = new TremoloParser();
    107215  stringstream input;
    108   string waterTremolo;
    109216
    110217  // 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;
    113219  testParser->load(&input);
    114220  CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0);
     
    119225  TremoloParser* testParser = new TremoloParser();
    120226  stringstream input;
    121   string waterTremolo;
    122227
    123228  // 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;
    126230  testParser->load(&input);
    127231
     
    135239  TremoloParser* testParser = new TremoloParser();
    136240  stringstream input, output;
    137   string waterTremolo;
    138241
    139242  // 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;
    142244  testParser->load(&input);
    143245  testParser->save(&output);
     
    151253  TremoloParser* testParser = new TremoloParser();
    152254  stringstream input, output;
    153   string waterTremolo;
    154255
    155256  // 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;
    158258  testParser->load(&input);
    159259  testParser->save(&output);
     
    173273  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");
    174274  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);
    176276
    177277  cout << "testing the tremolo parser is done" << endl;
    178278}
     279
     280void 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
     301void 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  
    2222  CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest );
    2323  CPPUNIT_TEST ( writeTremoloTest );
     24  CPPUNIT_TEST ( readwritePcpTest );
     25  CPPUNIT_TEST ( writeMpqcTest );
    2426  CPPUNIT_TEST_SUITE_END();
    2527
     
    3638  void readAndWriteTremoloTorsionInformationTest();
    3739  void writeTremoloTest();
     40  void readwritePcpTest();
     41  void writeMpqcTest();
    3842};
    3943
Note: See TracChangeset for help on using the changeset viewer.