Changeset 4cbca0


Ignore:
Timestamp:
Feb 7, 2011, 10:45:43 AM (14 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:
1a6bda, 311da7b
Parents:
963321a
git-author:
Frederik Heber <heber@…> (02/04/11 14:03:06)
git-committer:
Frederik Heber <heber@…> (02/07/11 10:45:43)
Message:

Implemented full MpqcParser::load().

  • regression tests for four theories: CLHF, CLKS, MBPT2, MBPT2_R12.
  • extended regression test on set-mpqc-parameters by checking changed value against a written file.
Files:
9 added
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/Parser/MpqcParser.cpp

    r963321a r4cbca0  
    5555void MpqcParser::load(istream *file)
    5656{
    57   bool GeometryFollows = false;
     57  bool MpqcSection = false;
     58  bool MoleculeSection = false;
     59  bool GeometrySection = false;
     60  bool BasisSection = false;
     61  bool AuxBasisSection = false;
    5862  char line[MAXSTRINGSIZE];
    5963  typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
    6064  boost::char_separator<char> sep("[]");
     65  boost::char_separator<char> angularsep("<>");
     66  boost::char_separator<char> equalitysep("=");
    6167  boost::char_separator<char> whitesep(" \t");
    6268  ConvertTo<double> toDouble;
     
    6470  molecule *newmol = World::getInstance().createMolecule();
    6571  newmol->ActiveFlag = true;
     72  // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
     73  World::getInstance().getMolecules()->insert(newmol);
    6674  while (file->good()) {
    6775    file->getline(line, MAXSTRINGSIZE-1);
    6876    std::string linestring(line);
    6977    if ((linestring.find("atoms geometry") == string::npos) && (linestring.find("}") != string::npos)) {
    70       GeometryFollows = false;
    71     }
    72     if (GeometryFollows) { // we have an atom
    73       tokenizer tokens(linestring, sep);
    74 //      if (tokens.size() != 2)
    75 //        throw MpqcParseException;
     78      GeometrySection = false;
     79    }
     80    if ((linestring.find(")") != string::npos)) { // ends a section which do not overlap
     81      MpqcSection = false;
     82      MoleculeSection = false;
     83      BasisSection = false;
     84      AuxBasisSection = false;
     85    }
     86    if (MoleculeSection) {
     87      if (GeometrySection) { // we have an atom
     88        tokenizer tokens(linestring, sep);
     89  //      if (tokens.size() != 2)
     90  //        throw MpqcParseException;
     91        tokenizer::iterator tok_iter = tokens.begin();
     92        std::stringstream whitespacefilter(*tok_iter++);
     93        std::string element;
     94        whitespacefilter >> element;
     95        std::string vector = *tok_iter;
     96        tokenizer vectorcomponents(vector, whitesep);
     97        Vector X;
     98  //      if (vectorcomponents.size() != NDIM)
     99  //        throw MpqcParseException;
     100        tok_iter = vectorcomponents.begin();
     101        for (int i=0; i<NDIM; ++i) {
     102          X[i] = toDouble(*tok_iter++);
     103        }
     104        // create atom
     105        atom *newAtom = World::getInstance().createAtom();
     106        newAtom->setType(World::getInstance().getPeriode()->FindElement(element));
     107        newAtom->setPosition(X);
     108        newmol->AddAtom(newAtom);
     109        DoLog(1) && (Log() << Verbose(1) << "Adding atom " << *newAtom << std::endl);
     110      }
     111    }
     112    if (MpqcSection) {
     113      tokenizer tokens(linestring, equalitysep);
    76114      tokenizer::iterator tok_iter = tokens.begin();
    77115      std::stringstream whitespacefilter(*tok_iter++);
    78       std::string element;
    79       whitespacefilter >> element;
    80       std::string vector = *tok_iter;
    81       tokenizer vectorcomponents(vector, whitesep);
    82       Vector X;
    83 //      if (vectorcomponents.size() != NDIM)
    84 //        throw MpqcParseException;
    85       tok_iter = vectorcomponents.begin();
    86       for (int i=0; i<NDIM; ++i) {
    87         X[i] = toDouble(*tok_iter++);
    88       }
    89       // create atom
    90       atom *newAtom = World::getInstance().createAtom();
    91       newAtom->setType(World::getInstance().getPeriode()->FindElement(element));
    92       newAtom->setPosition(X);
    93       newmol->AddAtom(newAtom);
    94       DoLog(1) && (Log() << Verbose(1) << "Adding atom " << *newAtom << std::endl);
     116      std::string key(*tok_iter++);
     117      if (params.haveParam(key)) {
     118        std::stringstream linestream(linestring);
     119        linestream >> params;
     120      } else if (linestring.find("mole<") != string::npos) { // get theory
     121        tokenizer tokens(linestring, angularsep);
     122        tokenizer::iterator tok_iter = tokens.begin();
     123        std::string value(*(++tok_iter));
     124        std::stringstream linestream("theory = "+value);
     125        linestream >> params;
     126      } else if (linestring.find("integrals<") != string::npos) { // get theory
     127        tokenizer tokens(linestring, angularsep);
     128        tokenizer::iterator tok_iter = tokens.begin();
     129        std::string value(*(++tok_iter));
     130        std::stringstream linestream("integration = "+value);
     131        linestream >> params;
     132      }
     133    }
     134    if (BasisSection) {
     135      tokenizer tokens(linestring, equalitysep);
     136      tokenizer::iterator tok_iter = tokens.begin();
     137      std::string key(*tok_iter++);
     138      std::string value(*tok_iter);
     139      // TODO: use exception instead of ASSERT
     140      ASSERT(tok_iter == tokens.end(),
     141          "MpqcParser::load() - more than (key = value) on line "+linestring+".");
     142      if (key == "name") {
     143        std::stringstream linestream("basis = "+value);
     144        linestream >> params;
     145      }
     146    }
     147    if (AuxBasisSection) {
     148      tokenizer tokens(linestring, equalitysep);
     149      tokenizer::iterator tok_iter = tokens.begin();
     150      std::string key(*tok_iter++);
     151      std::string value(*tok_iter);
     152      // TODO: use exception instead of ASSERT
     153      ASSERT(tok_iter == tokens.end(),
     154          "MpqcParser::load() - more than (key = value) on line "+linestring+".");
     155      if (key == "name") {
     156        std::stringstream linestream("aux_basis = "+value);
     157        linestream >> params;
     158      }
    95159    }
    96160    // set some scan flags
     161    if (linestring.find("mpqc:") != string::npos) {
     162      MpqcSection = true;
     163    }
     164    if (linestring.find("molecule<Molecule>:") != string::npos) {
     165      MoleculeSection = true;
     166    }
    97167    if (linestring.find("atoms geometry") != string::npos) {
    98       GeometryFollows = true;
     168      GeometrySection = true;
     169    }
     170    if ((linestring.find("basis<GaussianBasisSet>:") != string::npos) && ((linestring.find("abasis<") == string::npos))) {
     171      BasisSection = true;
     172    }
     173    if (linestring.find("abasis<") != string::npos) {
     174      AuxBasisSection = true;
    99175    }
    100176  }
  • tests/regression/Parser/Mpqc-SetParameters/testsuite-parser-mpqc-set-parameters.at

    r963321a r4cbca0  
    44AT_KEYWORDS([options])
    55AT_CHECK([pwd],[ignore],[ignore])
    6 AT_CHECK([../../molecuilder -i test.conf -o mpqc -l ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/test.xyz -v 1 --set-mpqc-parameters "basis = 4-31G"], 0, [stdout], [ignore])
     6AT_CHECK([../../molecuilder -i test.conf -o mpqc -l ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc-SetParameters/pre/test.xyz -v 1 --set-mpqc-parameters "basis = 4-31G"], 0, [stdout], [ignore])
    77AT_CHECK([fgrep "name = \"4-31G\"" test.in], 0, [ignore], [ignore])
    88AT_CLEANUP
     
    1111AT_KEYWORDS([options])
    1212AT_CHECK([pwd],[ignore],[ignore])
    13 AT_CHECK([../../molecuilder -i test.conf -o mpqc -l ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/test.xyz -v 1 --set-mpqc-parameters "maxiter = 499"], 0, [stdout], [ignore])
     13AT_CHECK([../../molecuilder -i test.conf -o mpqc -l ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc-SetParameters/pre/test.xyz -v 1 --set-mpqc-parameters "maxiter = 499"], 0, [stdout], [ignore])
    1414AT_CHECK([fgrep "maxiter = 499" test.in], 0, [ignore], [ignore])
    1515AT_CLEANUP
     
    1818AT_KEYWORDS([options])
    1919AT_CHECK([pwd],[ignore],[ignore])
    20 AT_CHECK([../../molecuilder -i test.conf -o mpqc -l ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/test.xyz -v 1 --set-mpqc-parameters "theory=CLKS"], 0, [stdout], [ignore])
     20AT_CHECK([../../molecuilder -i test.conf -o mpqc -l ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc-SetParameters/pre/test.xyz -v 1 --set-mpqc-parameters "theory=CLKS"], 0, [stdout], [ignore])
    2121AT_CHECK([fgrep "<CLKS>" test.in], 0, [ignore], [ignore])
    2222AT_CLEANUP
     23
     24AT_SETUP([Parser - MPQC - check in file])
     25AT_KEYWORDS([options])
     26AT_CHECK([pwd],[ignore],[ignore])
     27AT_CHECK([../../molecuilder -i ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc-SetParameters/pre/testCLHF.in -v 1 --set-mpqc-parameters "basis = 4-31G;maxiter=499;theory=CLKS;"], 0, [stdout], [ignore])
     28AT_CHECK([file=testCLHF.in; diff -I '%.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc-SetParameters/post/$file], 0, [ignore], [ignore])
     29AT_CLEANUP
     30
  • tests/regression/Parser/Mpqc/post/testMBPT2.in

    r963321a r4cbca0  
    1 % Created by MoleCuilder
    21mpqc: (
    32        savestate = no
     
    65                basis = $:basis
    76                molecule = $:molecule
     7                memory = 16000000
    88                reference<CLHF>: (
    99                        maxiter = 1000
    1010                        basis = $:basis
    1111                        molecule = $:molecule
     12                        memory = 16000000
    1213                )
    1314        )
     
    1617        unit = angstrom
    1718        { atoms geometry } = {
    18                 H [ 0   0       0 ]
     19                O [ -0.505735   0       0 ]
     20                H [ 0.252867    0       0.504284 ]
     21                H [ 0.252867    0       -0.504284 ]
    1922        }
    2023)
  • tests/regression/Parser/Mpqc/testsuite-parser-mpqc.at

    r963321a r4cbca0  
    33AT_SETUP([Parser - loading mpqc file])
    44AT_KEYWORDS([parser,mpqc])
    5 AT_XFAIL_IF([/bin/true])
    6 AT_CHECK([../../molecuilder -i test.in  -o mpqc -l ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/test.in], 0, [ignore], [ignore])
    7 AT_CHECK([file=test.in; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/post/$file], 0, [ignore], [ignore])
     5AT_CHECK([../../molecuilder -i ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/testCLHF.in] -o mpqc, 0, [ignore], [ignore])
     6AT_CHECK([file=testCLHF.in; diff -I '%.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/post/$file], 0, [ignore], [ignore])
     7AT_CHECK([../../molecuilder -i ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/testCLKS.in] -o mpqc, 0, [ignore], [ignore])
     8AT_CHECK([file=testCLKS.in; diff -I '%.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/post/$file], 0, [ignore], [ignore])
     9AT_CHECK([../../molecuilder -i ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/testMBPT2.in] -o mpqc, 0, [ignore], [ignore])
     10AT_CHECK([file=testMBPT2.in; diff -I '%.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/post/$file], 0, [ignore], [ignore])
     11AT_CHECK([../../molecuilder -i ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/pre/testMBPT2_R12.in] -o mpqc, 0, [ignore], [ignore])
     12AT_CHECK([file=testMBPT2_R12.in; diff -I '%.*' $file ${abs_top_srcdir}/${AUTOTEST_PATH}/Parser/Mpqc/post/$file], 0, [ignore], [ignore])
    813AT_CLEANUP
    914
Note: See TracChangeset for help on using the changeset viewer.