Changeset 1b2d30 for src


Ignore:
Timestamp:
Jun 12, 2010, 10:19:48 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
55240c4
Parents:
43dad6
git-author:
Frederik Heber <heber@…> (06/12/10 21:59:36)
git-committer:
Frederik Heber <heber@…> (06/12/10 22:19:48)
Message:

Extended PcpParser, completed MpqcParser.

  • BUGFIX: ConfigFileBuffer::InitFileBuffer() did not clear istream before re-use.
  • class PcpParser
    • operator== - compares every variable by ASSERTs.
    • constructor initializes variables all to sensible values.
  • class MpqcParser
    • new function save() - calls either SaveHessian() or Save() according to flag HessianPresent.
    • new functions SaveHessian() and Save() which contain both parts of config::SaveMPQC().
    • no function load() - this functionality has not been present and is not needed right away.
  • Extended ParserUnitTest
    • new test case readwritePcpTest() - load from static string, store, load again and compare both.
    • new test case writeMpqcTest() - write a state of the world and compare to one from static string.
    • all static strings have been made static and set before all functions.
    • new string containing an example pcp config file.
    • we check whether hydrogen and oxygen are known to the world as we test with these two elements.
  • atom::OutputMPQCLine() - now takes ostream instead of ofstream.
  • config::SaveMPQC() - adapted accordingly (cast is necessary)
Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/ConfigFileBuffer.cpp

    r43dad6 r1b2d30  
    8282  long file_position = file->tellg(); // mark current position
    8383  do {
    84     file->getline(line, 256);
     84    file->getline(line, MAXSTRINGSIZE-1);
    8585    NoLines++;
    8686  } while (!file->eof());
     
    108108  } while((!file->eof()) && (lines < NoLines));
    109109  DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
     110  file->clear();
     111  file->seekg(file_position, ios::beg);
    110112
    111113  InitMapping();
  • src/Parser/MpqcParser.cpp

    r43dad6 r1b2d30  
    66 */
    77
     8#include <iostream>
     9
     10#include "MpqcParser.hpp"
     11
     12#include "atom.hpp"
     13#include "config.hpp"
     14#include "element.hpp"
     15#include "log.hpp"
     16#include "periodentafel.hpp"
     17#include "vector.hpp"
     18#include "verbose.hpp"
     19#include "World.hpp"
     20
     21
     22/** Constructor of MpqcParser.
     23 *
     24 */
     25MpqcParser::MpqcParser()
     26{
     27
     28}
     29
     30/** Destructor of MpqcParser.
     31 *
     32 */
     33MpqcParser::~MpqcParser() {
     34
     35}
     36
     37/** Load an MPQC config file into the World.
     38 * \param *file input stream
     39 */
     40void MpqcParser::load(istream *file)
     41{
     42  DoeLog(0) && (Log() << Verbose(0) << "Not yet implemented" << endl) ;
     43}
     44
     45void MpqcParser::save(ostream *file)
     46{
     47  if (HessianPresent)
     48    saveHessian(file);
     49  else
     50    saveSimple(file);
     51}
     52
     53/** Saves all atoms and data into a MPQC config file without hessian.
     54 * \param *file output stream
     55 */
     56void MpqcParser::saveSimple(ostream *file)
     57{
     58  int AtomNo = 0;
     59  Vector center;
     60  vector<atom *> allatoms = World::getInstance().getAllAtoms();
     61
     62  // first without hessian
     63  if (file->fail()) {
     64    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
     65  } else {
     66    *file << "% Created by MoleCuilder" << endl;
     67    *file << "mpqc: (" << endl;
     68    *file << "\tsavestate = no" << endl;
     69    *file << "\tdo_gradient = yes" << endl;
     70    *file << "\tmole<MBPT2>: (" << endl;
     71    *file << "\t\tmaxiter = 200" << endl;
     72    *file << "\t\tbasis = $:basis" << endl;
     73    *file << "\t\tmolecule = $:molecule" << endl;
     74    *file << "\t\treference<CLHF>: (" << endl;
     75    *file << "\t\t\tbasis = $:basis" << endl;
     76    *file << "\t\t\tmolecule = $:molecule" << endl;
     77    *file << "\t\t)" << endl;
     78    *file << "\t)" << endl;
     79    *file << ")" << endl;
     80    *file << "molecule<Molecule>: (" << endl;
     81    *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
     82    *file << "\t{ atoms geometry } = {" << endl;
     83    // output of atoms
     84    for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
     85      (*AtomRunner)->OutputMPQCLine(file, &center, &AtomNo);
     86    }
     87    *file << "\t}" << endl;
     88    *file << ")" << endl;
     89    *file << "basis<GaussianBasisSet>: (" << endl;
     90    *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
     91    *file << "\tmolecule = $:molecule" << endl;
     92    *file << ")" << endl;
     93  }
     94}
     95
     96/** Saves all atoms and data into a MPQC config file with hessian.
     97 * \param *file output stream
     98 */
     99void MpqcParser::saveHessian(ostream *file)
     100{
     101  int AtomNo = 0;
     102  Vector center;
     103  vector<atom *> allatoms = World::getInstance().getAllAtoms();
     104
     105  // with hessian
     106  if (file->fail()) {
     107    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
     108  } else {
     109    *file << "% Created by MoleCuilder" << endl;
     110    *file << "mpqc: (" << endl;
     111    *file << "\tsavestate = no" << endl;
     112    *file << "\tdo_gradient = yes" << endl;
     113    *file << "\tmole<CLHF>: (" << endl;
     114    *file << "\t\tmaxiter = 200" << endl;
     115    *file << "\t\tbasis = $:basis" << endl;
     116    *file << "\t\tmolecule = $:molecule" << endl;
     117    *file << "\t)" << endl;
     118    *file << "\tfreq<MolecularFrequencies>: (" << endl;
     119    *file << "\t\tmolecule=$:molecule" << endl;
     120    *file << "\t)" << endl;
     121    *file << ")" << endl;
     122    *file << "molecule<Molecule>: (" << endl;
     123    *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
     124    *file << "\t{ atoms geometry } = {" << endl;
     125    // output of atoms
     126    for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
     127      (*AtomRunner)->OutputMPQCLine(file, &center, &AtomNo);
     128    }
     129    *file << "\t}" << endl;
     130    *file << ")" << endl;
     131    *file << "basis<GaussianBasisSet>: (" << endl;
     132    *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
     133    *file << "\tmolecule = $:molecule" << endl;
     134    *file << ")" << endl;
     135  }
     136}
     137
     138/** Sets whether hessian is desired or not
     139 * \param hessian statement
     140 */
     141void MpqcParser::setHessian(bool hessian)
     142{
     143  HessianPresent = hessian;
     144}
  • src/Parser/MpqcParser.hpp

    r43dad6 r1b2d30  
    2323  void save(std::ostream* file);
    2424
     25  void setHessian(bool hessian);
    2526
    2627private:
    27 }
     28  // whether output with computing hessian is desired.
     29  bool HessianPresent;
     30
     31  void saveSimple(std::ostream *file);
     32  void saveHessian(std::ostream *file);
     33};
    2834
    2935#endif /* MPQCPARSER_HPP_ */
  • src/Parser/PcpParser.cpp

    r43dad6 r1b2d30  
    1212#include "ConfigFileBuffer.hpp"
    1313#include "element.hpp"
     14#include "Helpers/Assert.hpp"
    1415#include "log.hpp"
    1516#include "molecule.hpp"
     
    2425 */
    2526PcpParser::PcpParser()
    26 {}
     27{
     28  Parallelization.ProcPEGamma = 1;
     29  Parallelization.ProcPEPsi = 1;
     30
     31  Paths.databasepath = NULL;
     32  Paths.configpath = NULL;
     33  Paths.configname = NULL;
     34  Paths.mainname = NULL;
     35  Paths.defaultpath = NULL;
     36  Paths.pseudopotpath = NULL;
     37
     38  Switches.DoConstrainedMD = 0;
     39  Switches.DoOutVis = 0;
     40  Switches.DoOutMes = 1;
     41  Switches.DoOutNICS = 0;
     42  Switches.DoOutOrbitals = 0;
     43  Switches.DoOutCurrent = 0;
     44  Switches.DoFullCurrent = 0;
     45  Switches.DoPerturbation = 0;
     46  Switches.DoWannier = 0;
     47
     48  LocalizedOrbitals.CommonWannier = 0;
     49  LocalizedOrbitals.SawtoothStart = 0.01;
     50  LocalizedOrbitals.VectorPlane = 0;
     51  LocalizedOrbitals.VectorCut = 0;
     52  LocalizedOrbitals.UseAddGramSch = 1;
     53  LocalizedOrbitals.Seed = 1;
     54  LocalizedOrbitals.EpsWannier = 1e-7;
     55
     56  StepCounts.MaxMinStopStep = 0;
     57  StepCounts.InitMaxMinStopStep = 0;
     58  StepCounts.OutVisStep = 10;
     59  StepCounts.OutSrcStep = 5;
     60  StepCounts.MaxPsiStep = 3;
     61  StepCounts.MaxOuterStep = 0;
     62  StepCounts.MaxMinStep = 100;
     63  StepCounts.RelEpsTotalEnergy = 1e-07;
     64  StepCounts.RelEpsKineticEnergy = 1e-05;
     65  StepCounts.MaxMinGapStopStep = 0;
     66  StepCounts.MaxInitMinStep = 100;
     67  StepCounts.InitRelEpsTotalEnergy = 1e-05;
     68  StepCounts.InitRelEpsKineticEnergy = 0.0001;
     69  StepCounts.InitMaxMinGapStopStep = 1;
     70
     71  PlaneWaveSpecifics.PsiType = 0;
     72  PlaneWaveSpecifics.MaxPsiDouble = 0;
     73  PlaneWaveSpecifics.PsiMaxNoUp = 0;
     74  PlaneWaveSpecifics.PsiMaxNoDown = 0;
     75  PlaneWaveSpecifics.ECut = 128;
     76  PlaneWaveSpecifics.MaxLevel = 5;
     77  PlaneWaveSpecifics.RiemannTensor = 0;
     78  PlaneWaveSpecifics.LevRFactor = 0;
     79  PlaneWaveSpecifics.RiemannLevel = 0;
     80  PlaneWaveSpecifics.Lev0Factor = 2;
     81  PlaneWaveSpecifics.RTActualUse = 0;
     82  PlaneWaveSpecifics.AddPsis = 0;
     83  PlaneWaveSpecifics.RCut = 20;
     84  PlaneWaveSpecifics.PsiType = 0;
     85
     86  FastParsing = false;
     87
     88  Deltat = 0.01;
     89  IsAngstroem = 1;
     90  RelativeCoord = 0;
     91  MaxTypes = 0;
     92}
    2793
    2894/** Destructor of PcpParser.
     
    415481  map<int, int> ZtoCountMap;
    416482  pair <   map<int, int>::iterator, bool > Inserter;
     483  int nr = 0;
    417484  for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
    418485    Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->type->Z, 1) );
    419486    if (!Inserter.second)
    420487      Inserter.first->second += 1;
    421     (*AtomRunner)->OutputArrayIndexed(file, &ZtoIndexMap[(*AtomRunner)->type->Z], &ZtoCountMap[Inserter.first->second], NULL);
     488    *file << "Ion_Type" << ZtoIndexMap[(*AtomRunner)->type->Z] << "_" << ZtoCountMap[Inserter.first->second] << "\t"  << fixed << setprecision(9) << showpoint;
     489    *file << (*AtomRunner)->x[0] << "\t" << (*AtomRunner)->x[1] << "\t" << (*AtomRunner)->x[2];
     490    *file << "\t" << (*AtomRunner)->FixedIon;
     491    if ((*AtomRunner)->v.Norm() > MYEPSILON)
     492      *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->v[0] << "\t" << (*AtomRunner)->v[1] << "\t" << (*AtomRunner)->v[2] << "\t";
     493    *file << " # molecule nr " << nr++ << endl;
    422494  }
    423495}
     
    499571};
    500572
     573bool PcpParser::operator==(const PcpParser& b) const
     574{
     575  ASSERT(Parallelization.ProcPEGamma == b.Parallelization.ProcPEGamma, "PcpParser ==: ProcPEGamma not");
     576  ASSERT(Parallelization.ProcPEPsi == b.Parallelization.ProcPEPsi, "PcpParser ==: ProcPEPsi not");
     577
     578  if ((Paths.databasepath != NULL) && (b.Paths.databasepath != NULL))
     579    ASSERT(strcmp(Paths.databasepath, b.Paths.databasepath), "PcpParser ==: databasepath not");
     580  if ((Paths.configpath != NULL) && (b.Paths.configpath != NULL))
     581    ASSERT(strcmp(Paths.configpath, b.Paths.configpath), "PcpParser ==: configpath not");
     582  if ((Paths.configname != NULL) && (b.Paths.configname != NULL))
     583    ASSERT(strcmp(Paths.configname, b.Paths.configname), "PcpParser ==: configname not");
     584  if ((Paths.mainname != NULL) && (b.Paths.mainname != NULL))
     585    ASSERT(strcmp(Paths.mainname, b.Paths.mainname), "PcpParser ==: mainname not");
     586  if ((Paths.defaultpath != NULL) && (b.Paths.defaultpath != NULL))
     587    ASSERT(strcmp(Paths.defaultpath, b.Paths.defaultpath), "PcpParser ==: defaultpath not");
     588  if ((Paths.pseudopotpath != NULL) && (b.Paths.pseudopotpath != NULL))
     589    ASSERT(strcmp(Paths.pseudopotpath, b.Paths.pseudopotpath), "PcpParser ==: pseudopotpath not");
     590
     591  ASSERT(Switches.DoConstrainedMD == b.Switches.DoConstrainedMD, "PcpParser ==: DoConstrainedMD not");
     592  ASSERT(Switches.DoOutVis == b.Switches.DoOutVis, "PcpParser ==: DoOutVis not");
     593  ASSERT(Switches.DoOutMes == b.Switches.DoOutMes, "PcpParser ==: DoOutMes not");
     594  ASSERT(Switches.DoOutNICS == b.Switches.DoOutNICS, "PcpParser ==: DoOutNICS not");
     595  ASSERT(Switches.DoOutOrbitals == b.Switches.DoOutOrbitals, "PcpParser ==: DoOutOrbitals not");
     596  ASSERT(Switches.DoOutCurrent == b.Switches.DoOutCurrent, "PcpParser ==: DoOutCurrent not");
     597  ASSERT(Switches.DoFullCurrent == b.Switches.DoFullCurrent, "PcpParser ==: DoFullCurrent not");
     598  ASSERT(Switches.DoPerturbation == b.Switches.DoPerturbation, "PcpParser ==: DoPerturbation not");
     599  ASSERT(Switches.DoWannier == b.Switches.DoWannier, "PcpParser ==: DoWannier not");
     600
     601  ASSERT(LocalizedOrbitals.CommonWannier == b.LocalizedOrbitals.CommonWannier, "PcpParser ==: CommonWannier not");
     602  ASSERT(LocalizedOrbitals.SawtoothStart == b.LocalizedOrbitals.SawtoothStart, "PcpParser ==: SawtoothStart not");
     603  ASSERT(LocalizedOrbitals.VectorPlane == b.LocalizedOrbitals.VectorPlane, "PcpParser ==: VectorPlane not");
     604  ASSERT(LocalizedOrbitals.VectorCut == b.LocalizedOrbitals.VectorCut, "PcpParser ==: VectorCut not");
     605  ASSERT(LocalizedOrbitals.UseAddGramSch == b.LocalizedOrbitals.UseAddGramSch, "PcpParser ==: UseAddGramSch not");
     606  ASSERT(LocalizedOrbitals.Seed == b.LocalizedOrbitals.Seed, "PcpParser ==: Seed not");
     607  ASSERT(LocalizedOrbitals.EpsWannier == b.LocalizedOrbitals.EpsWannier, "PcpParser ==: EpsWannier not");
     608
     609  ASSERT(StepCounts.MaxMinStopStep == b.StepCounts.MaxMinStopStep, "PcpParser ==: MaxMinStopStep not");
     610  ASSERT(StepCounts.InitMaxMinStopStep == b.StepCounts.InitMaxMinStopStep, "PcpParser ==: InitMaxMinStopStep not");
     611  ASSERT(StepCounts.OutVisStep == b.StepCounts.OutVisStep, "PcpParser ==: OutVisStep not");
     612  ASSERT(StepCounts.OutSrcStep == b.StepCounts.OutSrcStep, "PcpParser ==: OutSrcStep not");
     613  ASSERT(StepCounts.MaxPsiStep == b.StepCounts.MaxPsiStep, "PcpParser ==: MaxPsiStep not");
     614  ASSERT(StepCounts.MaxOuterStep == b.StepCounts.MaxOuterStep, "PcpParser ==: MaxOuterStep not");
     615  ASSERT(StepCounts.MaxMinStep == b.StepCounts.MaxMinStep, "PcpParser ==: MaxMinStep not");
     616  ASSERT(StepCounts.RelEpsTotalEnergy == b.StepCounts.RelEpsTotalEnergy, "PcpParser ==: RelEpsTotalEnergy not");
     617  ASSERT(StepCounts.MaxMinGapStopStep == b.StepCounts.MaxMinGapStopStep, "PcpParser ==: MaxMinGapStopStep not");
     618  ASSERT(StepCounts.MaxInitMinStep == b.StepCounts.MaxInitMinStep, "PcpParser ==: MaxInitMinStep not");
     619  ASSERT(StepCounts.InitRelEpsTotalEnergy == b.StepCounts.InitRelEpsTotalEnergy, "PcpParser ==: InitRelEpsTotalEnergy not");
     620  ASSERT(StepCounts.InitRelEpsKineticEnergy == b.StepCounts.InitRelEpsKineticEnergy, "PcpParser ==: InitRelEpsKineticEnergy not");
     621  ASSERT(StepCounts.InitMaxMinGapStopStep == b.StepCounts.InitMaxMinGapStopStep, "PcpParser ==: InitMaxMinGapStopStep not");
     622
     623  ASSERT(PlaneWaveSpecifics.PsiType == b.PlaneWaveSpecifics.PsiType, "PcpParser ==: PsiType not");
     624  ASSERT(PlaneWaveSpecifics.MaxPsiDouble == b.PlaneWaveSpecifics.MaxPsiDouble, "PcpParser ==: MaxPsiDouble not");
     625  ASSERT(PlaneWaveSpecifics.PsiMaxNoUp == b.PlaneWaveSpecifics.PsiMaxNoUp, "PcpParser ==: PsiMaxNoUp not");
     626  ASSERT(PlaneWaveSpecifics.PsiMaxNoDown == b.PlaneWaveSpecifics.PsiMaxNoDown, "PcpParser ==: PsiMaxNoDown not");
     627  ASSERT(PlaneWaveSpecifics.ECut == b.PlaneWaveSpecifics.ECut, "PcpParser ==: ECut not");
     628  ASSERT(PlaneWaveSpecifics.MaxLevel == b.PlaneWaveSpecifics.MaxLevel, "PcpParser ==: MaxLevel not");
     629  ASSERT(PlaneWaveSpecifics.RiemannTensor == b.PlaneWaveSpecifics.RiemannTensor, "PcpParser ==: RiemannTensor not");
     630  ASSERT(PlaneWaveSpecifics.LevRFactor == b.PlaneWaveSpecifics.LevRFactor, "PcpParser ==: LevRFactor not");
     631  ASSERT(PlaneWaveSpecifics.RiemannLevel == b.PlaneWaveSpecifics.RiemannLevel, "PcpParser ==: RiemannLevel not");
     632  ASSERT(PlaneWaveSpecifics.Lev0Factor == b.PlaneWaveSpecifics.Lev0Factor, "PcpParser ==: Lev0Factor not");
     633  ASSERT(PlaneWaveSpecifics.RTActualUse == b.PlaneWaveSpecifics.RTActualUse, "PcpParser ==: RTActualUse not");
     634  ASSERT(PlaneWaveSpecifics.AddPsis == b.PlaneWaveSpecifics.AddPsis, "PcpParser ==: AddPsis not");
     635  ASSERT(PlaneWaveSpecifics.AddPsis == b.PlaneWaveSpecifics.AddPsis, "PcpParser ==: AddPsis not");
     636  ASSERT(PlaneWaveSpecifics.RCut == b.PlaneWaveSpecifics.RCut, "PcpParser ==: RCut not");
     637
     638  ASSERT(FastParsing == b.FastParsing, "PcpParser ==: FastParsing not");
     639
     640  ASSERT(Deltat == b.Deltat, "PcpParser ==: Deltat not");
     641  ASSERT(IsAngstroem == b.IsAngstroem, "PcpParser ==: IsAngstroem not");
     642  ASSERT(RelativeCoord == b.RelativeCoord, "PcpParser ==: RelativeCoord not");
     643  ASSERT(StructOpt == b.StructOpt, "PcpParser ==: StructOpt not");
     644  ASSERT(MaxTypes == b.MaxTypes, "PcpParser ==: MaxTypes not");
     645  ASSERT(basis == b.basis, "PcpParser ==: basis not");
     646
     647  return true;
     648}
  • src/Parser/PcpParser.hpp

    r43dad6 r1b2d30  
    2121  void load(std::istream* file);
    2222  void save(std::ostream* file);
     23
     24  bool operator==(const PcpParser& b) const;
    2325
    2426private:
  • src/atom.cpp

    r43dad6 r1b2d30  
    226226 * \param *AtomNo pointer to atom counter that is increased by one
    227227 */
    228 void atom::OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo = NULL) const
     228void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
    229229{
    230230  *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

    r43dad6 r1b2d30  
    5656  bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
    5757  bool OutputTrajectoryXYZ(ofstream * const out, const int step) const;
    58   void OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo) const;
     58  void OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo) const;
    5959
    6060  void InitComponentNr();
  • src/config.cpp

    r43dad6 r1b2d30  
    12201220    // output of atoms
    12211221    AtomNo = 0;
    1222     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1222    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    12231223    delete(center);
    12241224    *output << "\t}" << endl;
     
    12621262    // output of atoms
    12631263    AtomNo = 0;
    1264     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1264    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    12651265    delete(center);
    12661266    *output << "\t}" << endl;
  • src/unittests/ParserUnitTest.cpp

    r43dad6 r1b2d30  
    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

    r43dad6 r1b2d30  
    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.