Changeset 30f2815 for src/Parser


Ignore:
Timestamp:
Apr 17, 2013, 6:55:54 PM (12 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:
69f38a
Parents:
a676f9
git-author:
Frederik Heber <heber@…> (03/14/13 08:38:23)
git-committer:
Frederik Heber <heber@…> (04/17/13 18:55:54)
Message:

MpqcParser now also understands "_n_ atoms geometry" lines.

  • optimization throws out an additional id per atom which caused havoc when copy&pasted and parsed so far. Right now, we discard the id, assuming they are simply ascending, throwing exception if something else comes along.
  • also added regression test on this.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/MpqcParser.cpp

    ra676f9 r30f2815  
    5454#include "molecule.hpp"
    5555#include "MoleculeListClass.hpp"
     56#include "Parser/Exceptions.hpp"
    5657#include "World.hpp"
    5758
     
    8586  bool MoleculeSection = false;
    8687  bool GeometrySection = false;
     88  bool GeometrySection_n = false;
    8789  bool BasisSection = false;
    8890  bool AuxBasisSection = false;
     
    9496  boost::char_separator<char> whitesep(" \t");
    9597  ConvertTo<double> toDouble;
     98  int old_n = -1; // note down the last parsed "n" to ascertain it's ascending
    9699
    97100  molecule *newmol = World::getInstance().createMolecule();
     
    102105    file->getline(line, MAXSTRINGSIZE-1);
    103106    std::string linestring(line);
    104     if ((linestring.find("atoms geometry") == string::npos) && (linestring.find("}") != string::npos)) {
     107    if (((linestring.find("atoms") == string::npos)
     108        || (linestring.find("geometry") == string::npos))
     109        && (linestring.find("}") != string::npos)) {
    105110      GeometrySection = false;
    106111    }
     
    113118    if (MoleculeSection) {
    114119      if (GeometrySection) { // we have an atom
     120//        LOG(2, "DEBUG: Full line is '" << linestring << "'.");
     121        // separate off [..] part
    115122        tokenizer tokens(linestring, sep);
    116   //      if (tokens.size() != 2)
    117   //        throw MpqcParseException;
    118         tokenizer::iterator tok_iter = tokens.begin();
    119         ASSERT(tok_iter != tokens.end(),
    120             "FormatParser< mpqc >::load() - missing token for MoleculeSection in line "+linestring+"!");
    121         std::stringstream whitespacefilter(*tok_iter++);
     123        // split part prior to [..] into tokens
     124        std::string prior_part(*tokens.begin());
     125        tokenizer prefixtokens(prior_part, whitesep);
     126        tokenizer::iterator tok_iter = prefixtokens.begin();
     127//        LOG(2, "DEBUG: Current tok_iter is " << *tok_iter << ".");
     128        if (GeometrySection_n) {
     129          ASSERT(tok_iter != prefixtokens.end(),
     130              "FormatParser< mpqc >::load() - missing n entry for MoleculeSection in line "
     131              +linestring+"!");
     132          // if additional n is given, parse and check but discard eventually
     133          int n;
     134          std::stringstream whitespacefilter(*tok_iter++);
     135          whitespacefilter >> ws >> n;
     136          if ((old_n != -1) && ((n-1) != old_n))
     137            ELOG(2, "n index is not simply ascending by one but "
     138                << n-old_n << ", specific ids are lost!");
     139          if (old_n >= n) {
     140            ELOG(1, "n index is not simply ascending, coordinates might get mixed!");
     141            throw ParserException();
     142          }
     143          old_n = n;
     144        }
     145        ASSERT(tok_iter != prefixtokens.end(),
     146            "FormatParser< mpqc >::load() - missing atoms entry for MoleculeSection in line "
     147            +linestring+"!");
     148//        LOG(2, "DEBUG: Current tok_iter is " << *tok_iter << ".");
    122149        std::string element;
    123         whitespacefilter >> ws >> element;
    124         ASSERT(tok_iter != tokens.end(),
    125             "FormatParser< mpqc >::load() - missing token for MoleculeSection in line "+linestring+"!");
    126         std::string vector = *tok_iter;
     150        {
     151          std::stringstream whitespacefilter(*tok_iter++);
     152          whitespacefilter >> ws >> element;
     153        }
     154        // split [..] part and parse
     155        tok_iter = (++tokens.begin());
     156        ASSERT (tok_iter != tokens.end(),
     157            "FormatParser< mpqc >::load() - missing geometry entry for MoleculeSection in line "
     158            +linestring+"!");
     159//        LOG(2, "DEBUG: Current tok_iter is " << *tok_iter << ".");
     160        std::string vector(*tok_iter);
    127161        tokenizer vectorcomponents(vector, whitesep);
    128162        Vector X;
    129   //      if (vectorcomponents.size() != NDIM)
    130   //        throw MpqcParseException;
     163//        if (vectorcomponents.size() != NDIM)
     164//          throw ParserException();
    131165        tok_iter = vectorcomponents.begin();
    132166        for (int i=0; i<NDIM; ++i) {
     167//          LOG(2, "DEBUG: Current tok_iter is " << *tok_iter << ".");
    133168          X[i] = toDouble(*tok_iter++);
    134169        }
     
    220255      MoleculeSection = true;
    221256    }
    222     if (linestring.find("atoms geometry") != string::npos) {
     257    if ((linestring.find("atoms") != string::npos)
     258        && (linestring.find("geometry") != string::npos)) {
    223259      GeometrySection = true;
     260      if (linestring.find("n") != string::npos) // neither atoms nor geometry contains a letter n
     261        GeometrySection_n = true;
    224262    }
    225263    if ((linestring.find("basis<GaussianBasisSet>:") != string::npos) && ((linestring.find("abasis<") == string::npos))) {
Note: See TracChangeset for help on using the changeset viewer.