Changeset 61d69a4


Ignore:
Timestamp:
Feb 7, 2011, 10:43:35 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:
44fce5
Parents:
9cff8b
git-author:
Frederik Heber <heber@…> (02/03/11 11:56:26)
git-committer:
Frederik Heber <heber@…> (02/07/11 10:43:35)
Message:

Added MpqcParser_Parameter class to MpqcParser.

  • contains all extra info for the mpqc style config file.
  • so far not prepared for setting details via action.
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/Makefile.am

    r9cff8b r61d69a4  
    1212  FormatParserStorage.cpp \
    1313  MpqcParser.cpp \
     14  MpqcParser_Parameters.cpp \
    1415  PcpParser.cpp \
    1516  PdbAtomInfoContainer.cpp \
     
    2425  FormatParserStorage.hpp \
    2526  MpqcParser.hpp \
     27  MpqcParser_Parameters.hpp \
    2628  PcpParser.hpp \
    2729  PdbAtomInfoContainer.hpp \
  • src/Parser/MpqcParser.cpp

    r9cff8b r61d69a4  
    4141 *
    4242 */
    43 MpqcParser::MpqcParser() :
    44   HessianPresent(false),
    45   theory(MBPT2)
     43MpqcParser::MpqcParser()
    4644{}
    4745
     
    115113  for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
    116114    center += (*runner)->getPosition();
    117   center.Scale(1./allatoms.size());
     115  center.Scale(1./(double)allatoms.size());
    118116
    119117  // first without hessian
     
    123121    *file << "% Created by MoleCuilder" << endl;
    124122    *file << "mpqc: (" << endl;
    125     *file << "\tsavestate = no" << endl;
    126     *file << "\tdo_gradient = yes" << endl;
    127     if (HessianPresent) {
     123    *file << "\tsavestate = " << params.getString(MpqcParser_Parameters::savestateParam) << endl;
     124    *file << "\tdo_gradient = " << params.getString(MpqcParser_Parameters::do_gradientParam) << endl;
     125    if (params.getBool(MpqcParser_Parameters::HessianParam)) {
    128126      *file << "\tfreq<MolecularFrequencies>: (" << endl;
    129127      *file << "\t\tmolecule=$:molecule" << endl;
    130128      *file << "\t)" << endl;
    131129    }
    132     switch (theory) {
    133       case CLHF:
    134         *file << "\tmole<CLHF>: (" << endl;
    135         *file << "\t\tmolecule = $:molecule" << endl;
    136         *file << "\t\tbasis = $:basis" << endl;
    137         *file << "\t\tmemory = 16000000" << endl;
    138         *file << "\t)" << endl;
    139         break;
    140       case CLKS:
    141         *file << "\tmole<CLKS>: (" << endl;
     130    switch (params.getTheory()) {
     131      case MpqcParser_Parameters::CLHF:
     132        *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     133        *file << "\t\tmolecule = $:molecule" << endl;
     134        *file << "\t\tbasis = $:basis" << endl;
     135        *file << "\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam))<< endl;
     136        *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     137        *file << "\t)" << endl;
     138        break;
     139      case MpqcParser_Parameters::CLKS:
     140        *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    142141        *file << "\t\tfunctional<StdDenFunctional>:(name=B3LYP)" << endl;
    143142        *file << "\t\tmolecule = $:molecule" << endl;
    144143        *file << "\t\tbasis = $:basis" << endl;
    145         *file << "\t\tmemory = 16000000" << endl;
    146         *file << "\t)" << endl;
    147         break;
    148       case MBPT2:
    149         *file << "\tmole<MBPT2>: (" << endl;
    150         *file << "\t\tbasis = $:basis" << endl;
    151         *file << "\t\tmolecule = $:molecule" << endl;
     144        *file << "\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam))<< endl;
     145        *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     146        *file << "\t)" << endl;
     147        break;
     148      case MpqcParser_Parameters::MBPT2:
     149        *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     150        *file << "\t\tbasis = $:basis" << endl;
     151        *file << "\t\tmolecule = $:molecule" << endl;
     152        *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
    152153        *file << "\t\treference<CLHF>: (" << endl;
    153         *file << "\t\t\tmaxiter = 1000" << endl;
     154        *file << "\t\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam))<< endl;
    154155        *file << "\t\t\tbasis = $:basis" << endl;
    155156        *file << "\t\t\tmolecule = $:molecule" << endl;
     157        *file << "\t\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
    156158        *file << "\t\t)" << endl;
    157159        *file << "\t)" << endl;
    158160        break;
    159       case MBPT2_R12:
    160         *file << "\tmole<MBPT2_R12>: (" << endl;
     161      case MpqcParser_Parameters::MBPT2_R12:
     162        *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    161163        *file << "\t\tmolecule = $:molecule" << endl;
    162164        *file << "\t\tbasis = $:basis" << endl;
    163165        *file << "\t\taux_basis = $:abasis" << endl;
    164         *file << "\t\tstdapprox = \"A'\"" << endl;
    165         *file << "\t\tnfzc = 1" << endl;
    166         *file << "\t\tmemory = 16000000" << endl;
     166        *file << "\t\tstdapprox = \"" << params.getString(MpqcParser_Parameters::stdapproxParam) << "\"" << endl;
     167        *file << "\t\tnfzc = " << toString(params.getInt(MpqcParser_Parameters::nfzcParam)) << endl;
     168        *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
    167169        *file << "\t\tintegrals<IntegralCints>:()" << endl;
    168170        *file << "\t\treference<CLHF>: (" << endl;
    169171        *file << "\t\t\tmolecule = $:molecule" << endl;
    170172        *file << "\t\t\tbasis = $:basis" << endl;
    171         *file << "\t\t\tmaxiter = 1000" << endl;
    172         *file << "\t\t\tmemory = 16000000" << endl;
    173         *file << "\t\t\tintegrals<IntegralCints>:()" << endl;
     173        *file << "\t\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam)) << endl;
     174        *file << "\t\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     175        *file << "\t\t\tintegrals<" << params.getString(MpqcParser_Parameters::integrationParam) << ">:()" << endl;
    174176        *file << "\t\t)" << endl;
    175177        *file << "\t)" << endl;
     
    191193    *file << ")" << endl;
    192194    *file << "basis<GaussianBasisSet>: (" << endl;
    193     *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
     195    *file << "\tname = \"" << params.getString(MpqcParser_Parameters::basisParam) << "\"" << endl;
    194196    *file << "\tmolecule = $:molecule" << endl;
    195197    *file << ")" << endl;
    196     if (theory == MBPT2_R12) {
     198    if (params.getTheory() == MpqcParser_Parameters::MBPT2_R12) {
    197199      *file << "% auxiliary basis set specification" << endl;
    198200      *file << "\tabasis<GaussianBasisSet>: (" << endl;
    199       *file << "\tname = \"aug-cc-pVDZ\"" << endl;
     201      *file << "\tname = \"" << params.getString(MpqcParser_Parameters::aux_basisParam) << "\"" << endl;
    200202      *file << "\tmolecule = $:molecule" << endl;
    201203      *file << ")" << endl;
     
    204206}
    205207
    206 /** Sets whether hessian is desired or not
    207  * \param hessian statement
    208  */
    209 void MpqcParser::setHessian(bool hessian)
    210 {
    211   HessianPresent = hessian;
    212 }
    213 
    214 /** Sets the desired level of solving theory to use
    215  * \param _theory shorthand of the theory
    216  */
    217 void MpqcParser::setTheory(enum Theory _theory)
    218 {
    219   theory = _theory;
    220 }
  • src/Parser/MpqcParser.hpp

    r9cff8b r61d69a4  
    1616
    1717#include "FormatParser.hpp"
     18#include "MpqcParser_Parameters.hpp"
    1819
    1920#include <iosfwd>
     
    2425class MpqcParser : public FormatParser
    2526{
     27  friend class ParserMpqcUnitTest;
    2628public:
    27 
    28   enum Theory { CLHF, CLKS, MBPT2, MBPT2_R12, unknown };
    2929
    3030  MpqcParser();
     
    3333  void save(std::ostream* file, const std::vector<atom *> &atoms);
    3434
    35   void setHessian(bool hessian);
    36   void setTheory(enum Theory _theory);
    37 
    3835private:
    39   // whether output with computing hessian is desired.
    40   bool HessianPresent;
    41   enum Theory theory;
    42 
    43   void saveSimple(std::ostream *file, const std::vector<atom *> &atoms);
    44   void saveHessian(std::ostream *file, const std::vector<atom *> &atoms);
     36  MpqcParser_Parameters params;
    4537};
    4638
     39
    4740#endif /* MPQCPARSER_HPP_ */
  • src/Parser/unittests/ParserMpqcUnitTest.cpp

    r9cff8b r61d69a4  
    2424#include <cppunit/ui/text/TestRunner.h>
    2525
    26 #include "Parser/MpqcParser.hpp"
     26#include <boost/any.hpp>
     27
    2728#include "World.hpp"
    2829#include "atom.hpp"
     
    4748\t\tmolecule = $:molecule\n\
    4849\t\tbasis = $:basis\n\
     50\t\tmaxiter = 1000\n\
    4951\t\tmemory = 16000000\n\
    5052\t)\n\
     
    7072\t\tmolecule = $:molecule\n\
    7173\t\tbasis = $:basis\n\
     74\t\tmaxiter = 1000\n\
    7275\t\tmemory = 16000000\n\
    7376\t)\n\
     
    9295\t\tbasis = $:basis\n\
    9396\t\tmolecule = $:molecule\n\
     97\t\tmemory = 16000000\n\
    9498\t\treference<CLHF>: (\n\
    9599\t\t\tmaxiter = 1000\n\
    96100\t\t\tbasis = $:basis\n\
    97101\t\t\tmolecule = $:molecule\n\
     102\t\t\tmemory = 16000000\n\
    98103\t\t)\n\
    99104\t)\n\
     
    151156
    152157void ParserMpqcUnitTest::setUp() {
     158  mpqc = new MpqcParser();
     159
    153160  World::getInstance();
    154161
     
    161168
    162169void ParserMpqcUnitTest::tearDown() {
     170  delete mpqc;
    163171  ChangeTracker::purgeInstance();
    164172  World::purgeInstance();
     
    167175/************************************ tests ***********************************/
    168176
     177void ParserMpqcUnitTest::ParameterTypeTest() {
     178  // check types in boost::any map
     179  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::HessianParam].type() == typeid(bool));
     180  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::HessianParam].type() != typeid(int));
     181  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::savestateParam].type() == typeid(bool));
     182  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::do_gradientParam].type() == typeid(bool));
     183  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::maxiterParam].type() == typeid(int));
     184  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::memoryParam].type() == typeid(int));
     185  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::stdapproxParam].type() == typeid(std::string));
     186  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::nfzcParam].type() == typeid(int));
     187  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::basisParam].type() == typeid(std::string));
     188  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::aux_basisParam].type() == typeid(std::string));
     189  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::integrationParam].type() == typeid(MpqcParser_Parameters::IntegralCints));
     190  CPPUNIT_ASSERT(mpqc->params.params[MpqcParser_Parameters::theoryParam].type() == typeid(MpqcParser_Parameters::MBPT2));
     191}
     192
     193void ParserMpqcUnitTest::ParameterDefaultTest() {
     194  // check default values
     195  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::HessianParam) == "no");
     196  CPPUNIT_ASSERT(!mpqc->params.getBool(MpqcParser_Parameters::HessianParam));
     197  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::savestateParam) == "no");
     198  CPPUNIT_ASSERT(!mpqc->params.getBool(MpqcParser_Parameters::savestateParam));
     199  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::do_gradientParam) == "yes");
     200  CPPUNIT_ASSERT(mpqc->params.getBool(MpqcParser_Parameters::do_gradientParam));
     201  CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::maxiterParam) == 1000);
     202  CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::memoryParam) == 16000000);
     203  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::stdapproxParam) == "A'");
     204  CPPUNIT_ASSERT(mpqc->params.getInt(MpqcParser_Parameters::nfzcParam) == 1);
     205  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::basisParam) == "3-21G");
     206  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::aux_basisParam) == "aug-cc-pVDZ");
     207  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::integrationParam) == "IntegralCints");
     208  CPPUNIT_ASSERT(mpqc->params.getString(MpqcParser_Parameters::theoryParam) == "MBPT2");
     209  CPPUNIT_ASSERT(mpqc->params.getTheory() == MpqcParser_Parameters::MBPT2);
     210  CPPUNIT_ASSERT(mpqc->params.getIntegration() == MpqcParser_Parameters::IntegralCints);
     211
     212  // check that values are not removed
     213  CPPUNIT_ASSERT(!mpqc->params.params[MpqcParser_Parameters::theoryParam].empty());
     214
     215  // check throw, for the moment aren't, are caught in getInt()
     216  //CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::integrationParam), boost::bad_any_cast);
     217  //CPPUNIT_ASSERT_THROW(mpqc->params.getInt(MpqcParser_Parameters::theoryParam), boost::bad_any_cast);
     218
     219}
     220
    169221void ParserMpqcUnitTest::readMpqcTest() {
    170222  stringstream input(waterMpqc_CLHF);
    171   MpqcParser* testParser = new MpqcParser();
    172   testParser->setTheory(MpqcParser::CLHF);
    173   testParser->load(&input);
     223  mpqc->params.setTheory(MpqcParser_Parameters::CLHF);
     224  mpqc->load(&input);
    174225
    175226  CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());
     
    194245  // create two stringstreams, one stored, one created
    195246
    196   MpqcParser* testParser = new MpqcParser();
    197247  std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    198248  {
    199249    // compare both configs for CLHF
    200250    stringstream output;
    201     testParser->setTheory(MpqcParser::CLHF);
    202     testParser->save(&output, atoms);
     251    mpqc->params.setTheory(MpqcParser_Parameters::CLHF);
     252    mpqc->save(&output, atoms);
    203253    stringstream input(waterMpqc_CLHF);
    204254    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    210260    // compare both configs for CLKS
    211261    stringstream output;
    212     testParser->setTheory(MpqcParser::CLKS);
    213     testParser->save(&output, atoms);
     262    mpqc->params.setTheory(MpqcParser_Parameters::CLKS);
     263    mpqc->save(&output, atoms);
    214264    stringstream input(waterMpqc_CLKS);
    215265    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    221271    // compare both configs for MBPT2
    222272    stringstream output;
    223     testParser->setTheory(MpqcParser::MBPT2);
    224     testParser->save(&output, atoms);
     273    mpqc->params.setTheory(MpqcParser_Parameters::MBPT2);
     274    mpqc->save(&output, atoms);
    225275    stringstream input(waterMpqc_MBPT2);
    226276    for (; std::getline(input, first) && std::getline(output, second); ) {
     
    232282    // compare both configs for MBPT2_R12
    233283    stringstream output;
    234     testParser->setTheory(MpqcParser::MBPT2_R12);
    235     testParser->save(&output, atoms);
     284    mpqc->params.setTheory(MpqcParser_Parameters::MBPT2_R12);
     285    mpqc->save(&output, atoms);
    236286    stringstream input(waterMpqc_MBPT2_R12);
    237287    for (; std::getline(input, first) && std::getline(output, second); ) {
  • src/Parser/unittests/ParserMpqcUnitTest.hpp

    r9cff8b r61d69a4  
    1313#endif
    1414
     15#include "Parser/MpqcParser.hpp"
    1516
    1617#include <cppunit/extensions/HelperMacros.h>
     
    2021{
    2122  CPPUNIT_TEST_SUITE( ParserMpqcUnitTest ) ;
     23  CPPUNIT_TEST ( ParameterTypeTest );
     24  CPPUNIT_TEST ( ParameterDefaultTest );
     25  CPPUNIT_TEST ( readMpqcTest );
    2226  CPPUNIT_TEST ( writeMpqcTest );
    23   CPPUNIT_TEST ( readMpqcTest );
    2427  CPPUNIT_TEST_SUITE_END();
    2528
     
    2831  void tearDown();
    2932
     33  void ParameterTypeTest();
     34  void ParameterDefaultTest();
    3035  void readMpqcTest();
    3136  void writeMpqcTest();
     37
     38private:
     39  MpqcParser *mpqc;
    3240};
    3341
  • tests/regression/Atoms/Add/post/test.in

    r9cff8b r61d69a4  
    66                basis = $:basis
    77                molecule = $:molecule
     8                memory = 16000000
    89                reference<CLHF>: (
    910                        maxiter = 1000
    1011                        basis = $:basis
    1112                        molecule = $:molecule
     13                        memory = 16000000
    1214                )
    1315        )
  • tests/regression/Atoms/Remove/post/test.in

    r9cff8b r61d69a4  
    66                basis = $:basis
    77                molecule = $:molecule
     8                memory = 16000000
    89                reference<CLHF>: (
    910                        maxiter = 1000
    1011                        basis = $:basis
    1112                        molecule = $:molecule
     13                        memory = 16000000
    1214                )
    1315        )
  • tests/regression/Parser/Mpqc/post/test.in

    r9cff8b r61d69a4  
    66                basis = $:basis
    77                molecule = $:molecule
     8                memory = 16000000
    89                reference<CLHF>: (
    910                        maxiter = 1000
    1011                        basis = $:basis
    1112                        molecule = $:molecule
     13                        memory = 16000000
    1214                )
    1315        )
Note: See TracChangeset for help on using the changeset viewer.