Ignore:
Timestamp:
Oct 17, 2011, 4:56:36 PM (13 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:
1bef07
Parents:
89a67f
git-author:
Frederik Heber <heber@…> (09/30/11 16:20:34)
git-committer:
Frederik Heber <heber@…> (10/17/11 16:56:36)
Message:

Complete rewrite of MpqcParser_Parameters to incorporate new Parameter(Storage) structure.

  • FormatParser_Parameters now contains a ParameterStorage instance which contains all parameters and is easy to clone.
  • MpqcParser_Parameters is basically just an Init() function that fills this storage for the specific case of the FormatParser<mpqc>.
  • additionally, there are some convenience functions, enums and maps which contains strings and make setting and getting parameters more easy.
  • adapted MpqcParser.
  • adapted Unit test for MpqcParser accordingly:
    • no more tests on type
  • TESTFIX: regression test Parser/Mpqc/post/empty.in was CLHF instead of default MBPT2. As the cloning is now working flawlessly, this has been fixed.
Location:
src/Parser/unittests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/unittests/ParserMpqcUnitTest.cpp

    r89a67f ree50c1  
    183183/************************************ tests ***********************************/
    184184
    185 void ParserMpqcUnitTest::ParameterTypeTest() {
    186   // check types in boost::any map
    187   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() == typeid(bool));
    188   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::hessianParam].type() != typeid(int));
    189   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::savestateParam].type() == typeid(bool));
    190   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool));
    191   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::maxiterParam].type() == typeid(int));
    192   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::memoryParam].type() == typeid(int));
    193   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string));
    194   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::nfzcParam].type() == typeid(int));
    195   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::basisParam].type() == typeid(std::string));
    196   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string));
    197   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints));
    198   CPPUNIT_ASSERT(parser->getParams().params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2));
    199 }
    200 
    201185void ParserMpqcUnitTest::ParameterDefaultTest() {
    202186  // check default values
    203   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "no");
    204   CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::hessianParam));
    205   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::savestateParam) == "no");
    206   CPPUNIT_ASSERT(!parser->getParams().getBool(MpqcParser_Parameters::savestateParam));
    207   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::do_gradientParam) == "yes");
    208   CPPUNIT_ASSERT(parser->getParams().getBool(MpqcParser_Parameters::do_gradientParam));
    209   CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 1000);
    210   CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::memoryParam) == 16000000);
    211   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::stdapproxParam) == "A'");
    212   CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::nfzcParam) == 1);
    213   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::basisParam) == "3-21G");
    214   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ");
    215   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::integrationParam) == "IntegralCints");
    216   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
    217   CPPUNIT_ASSERT(parser->getParams().getTheory() == MpqcParser_Parameters::MBPT2);
    218   CPPUNIT_ASSERT(parser->getParams().getIntegration() == MpqcParser_Parameters::IntegralCints);
    219 
    220   // check that values are not removed
    221   CPPUNIT_ASSERT(!parser->getParams().params[MpqcParser_Parameters::theoryParam].empty());
    222 
    223   // check throw, for the moment aren't, are caught in getInt()
    224   CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast);
    225   CPPUNIT_ASSERT_THROW(parser->getParams().getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast);
    226 
     187  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("no"));
     188  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::savestateParam) == std::string("no"));
     189  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::do_gradientParam) == std::string("yes"));
     190  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("1000"));
     191  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::memoryParam) == std::string("16000000"));
     192  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::stdapproxParam) == std::string("A'"));
     193  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::nfzcParam) == std::string("1"));
     194  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::basisParam) == std::string("3-21G"));
     195  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::aux_basisParam) == std::string("aug-cc-pVDZ"));
     196  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::integrationParam) == std::string("IntegralCints"));
     197  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2"));
    227198}
    228199
    229200void ParserMpqcUnitTest::ParameterCloneTest() {
    230201  FormatParser_Parameters *clone = parser->getParams().clone();
    231   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
     202  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2"));
    232203  std::stringstream setvalue("theory = CLHF");
    233204  setvalue >> parser->getParams();
    234   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");
     205  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF"));
    235206  parser->getParams().makeClone(*clone);
    236   CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
     207  CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("MBPT2"));
    237208}
    238209
     
    244215//    std::cout << "integration method is "
    245216//        << parser->getParams().getString(MpqcParser_Parameters::theoryParam) << std::endl;
    246     CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::theoryParam) == "CLHF");
     217    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::theoryParam) == std::string("CLHF"));
    247218  }
    248219  // test a bool
     
    252223//    std::cout << "Hessian is "
    253224//        << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;
    254     CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");
     225    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes"));
    255226  }
    256227  // test int
     
    260231//    std::cout << "maxiter is "
    261232//        << parser->getParams().getString(MpqcParser_Parameters::maxiterParam) << std::endl;
    262     CPPUNIT_ASSERT(parser->getParams().getInt(MpqcParser_Parameters::maxiterParam) == 500);
     233    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::maxiterParam) == std::string("500"));
    263234  }
    264235  // test whether unknown key fails
     
    274245//    std::cout << "Hessian is still "
    275246//        << parser->getParams().getString(MpqcParser_Parameters::hessianParam) << std::endl;
    276     CPPUNIT_ASSERT(parser->getParams().getString(MpqcParser_Parameters::hessianParam) == "yes");
     247    CPPUNIT_ASSERT(parser->getParams().getParameter(MpqcParser_Parameters::hessianParam) == std::string("yes"));
    277248  }
    278249}
     
    280251void ParserMpqcUnitTest::readMpqcTest() {
    281252  stringstream input(waterMpqc_CLHF);
    282   parser->getParams().setTheory(MpqcParser_Parameters::CLHF);
     253  parser->getParams().setParameter(
     254      MpqcParser_Parameters::theoryParam,
     255      parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF)
     256          );
    283257  parser->load(&input);
    284258
     
    308282    // compare both configs for CLHF
    309283    stringstream output;
    310     parser->getParams().setTheory(MpqcParser_Parameters::CLHF);
     284    parser->getParams().setParameter(
     285        MpqcParser_Parameters::theoryParam,
     286        parser->getParams().getTheoryName(MpqcParser_Parameters::CLHF)
     287            );
    311288    parser->save(&output, atoms);
    312289    stringstream input(waterMpqc_CLHF);
     
    319296    // compare both configs for CLKS
    320297    stringstream output;
    321     parser->getParams().setTheory(MpqcParser_Parameters::CLKS);
    322     parser->save(&output, atoms);
     298    parser->getParams().setParameter(
     299        MpqcParser_Parameters::theoryParam,
     300        parser->getParams().getTheoryName(MpqcParser_Parameters::CLKS)
     301            );
    323302    stringstream input(waterMpqc_CLKS);
    324303    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    330309    // compare both configs for MBPT2
    331310    stringstream output;
    332     parser->getParams().setTheory(MpqcParser_Parameters::MBPT2);
    333     parser->save(&output, atoms);
     311    parser->getParams().setParameter(
     312        MpqcParser_Parameters::theoryParam,
     313        parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2)
     314            );
    334315    stringstream input(waterMpqc_MBPT2);
    335316    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    341322    // compare both configs for MBPT2_R12
    342323    stringstream output;
    343     parser->getParams().setTheory(MpqcParser_Parameters::MBPT2_R12);
    344     parser->save(&output, atoms);
     324    parser->getParams().setParameter(
     325        MpqcParser_Parameters::theoryParam,
     326        parser->getParams().getTheoryName(MpqcParser_Parameters::MBPT2_R12)
     327            );
    345328    stringstream input(waterMpqc_MBPT2_R12);
    346329    for (; std::getline(input, first) && std::getline(output, second); ) {
  • src/Parser/unittests/ParserMpqcUnitTest.hpp

    r89a67f ree50c1  
    2121{
    2222  CPPUNIT_TEST_SUITE( ParserMpqcUnitTest ) ;
    23   CPPUNIT_TEST ( ParameterTypeTest );
    2423  CPPUNIT_TEST ( ParameterDefaultTest );
    2524  CPPUNIT_TEST ( ParameterSetterTest );
     
    3332  void tearDown();
    3433
    35   void ParameterTypeTest();
    3634  void ParameterDefaultTest();
    3735  void ParameterSetterTest();
Note: See TracChangeset for help on using the changeset viewer.