Ignore:
Timestamp:
Oct 20, 2011, 10:42:16 PM (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, Candidate_v1.7.0, 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:
f94953
Parents:
fa9d1d (diff), 752bb4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Frederik Heber <heber@…> (10/20/11 22:40:59)
git-committer:
Frederik Heber <heber@…> (10/20/11 22:42:16)
Message:

Merge branch 'Adding_Psi3Parser' into stable

Conflicts:

src/Parser/FormatParser.hpp
src/Parser/unittests/ParserTremoloUnitTest.cpp

Issues:

  • Element and periodentafel have been moved to folder src/Element.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/MpqcParser_Parameters.cpp

    rfa9d1d r360c8b  
    1818#endif
    1919
    20 #include <iostream>
    21 #include <boost/tokenizer.hpp>
     20#include "CodePatterns/MemDebug.hpp"
     21
    2222#include <string>
    2323
    24 #include "CodePatterns/MemDebug.hpp"
    25 
    2624#include "CodePatterns/Log.hpp"
    27 #include "CodePatterns/Verbose.hpp"
    2825
    2926#include "MpqcParser.hpp"
    30 
    3127#include "MpqcParser_Parameters.hpp"
    3228
     29#include "Parser/Parameters/ContinuousParameter.hpp"
     30#include "Parser/Parameters/DiscreteParameter.hpp"
     31#include "Parser/Parameters/StringParameter.hpp"
    3332
    34 using boost::any_cast;
     33template <>
     34const std::string ContinuousValue<bool>::get() const
     35{
     36  ASSERT(ValueSet,
     37      "ContinuousValue<bool>::get() - requesting unset value.");
     38  if (value)
     39    return std::string("yes");
     40  else
     41    return std::string("no");
     42}
     43
     44template <>
     45void ContinuousValue<bool>::set(const std::string _value)
     46{
     47  if (_value == std::string("yes")) {
     48    setValue(true);
     49  } else if (_value == std::string("no")) {
     50    setValue(false);
     51  } else {
     52    ASSERT(0,
     53        "void ContinuousValue<bool>::set() - value "+_value+" is neither yes or no.");
     54  }
     55}
     56
    3557
    3658MpqcParser_Parameters::MpqcParser_Parameters()
     
    4466  initBasis();
    4567
    46   // add all theory names
    47   TheoryNames[CLHF]="CLHF";
    48   TheoryNames[CLKS]="CLKS";
    49   TheoryNames[MBPT2]="MBPT2";
    50   TheoryNames[MBPT2_R12]="MBPT2_R12";
    51 
     68  // add all parameter names
    5269  {
    53     // TODO: throw exception instead of eLog()
    54     std::pair<TheoryLookupType::iterator, bool> inserter;
    55     for (TheoryNamesType::iterator iter = TheoryNames.begin();
    56         iter != TheoryNames.end();
    57         ++iter) {
    58       inserter = TheoryLookup.insert( make_pair(iter->second, iter->first) );
    59       if (!inserter.second)
    60         DoeLog(0) && (eLog() << Verbose(0)
    61             << "MpqcParser_Parameters::MpqcParser_Parameters() - Theory name already present: "
    62             << (inserter.first)->second << " and " << iter->first << "!"
    63             << std::endl);
    64     }
     70    ParamNames.clear();
     71    ParamNames.resize(unknownParam);
     72    ParamNames[hessianParam] = "Hessian";
     73    ParamNames[savestateParam] = "savestate";
     74    ParamNames[do_gradientParam] = "do_gradient";
     75    ParamNames[maxiterParam] = "maxiter";
     76    ParamNames[memoryParam] = "memory";
     77    ParamNames[stdapproxParam] = "stdapprox";
     78    ParamNames[nfzcParam] = "nfzc";
     79    ParamNames[basisParam] = "basis";
     80    ParamNames[aux_basisParam] = "aux_basis";
     81    ParamNames[integrationParam] = "integration";
     82    ParamNames[theoryParam] = "theory";
    6583  }
    6684
    67   // add all integration names
    68   IntegrationNames[IntegralCints] = "IntegralCints";
     85  // create theory parameter
    6986  {
    70     // TODO: throw exception instead of eLog()
    71     std::pair<IntegrationLookupType::iterator, bool> inserter;
    72     for (IntegrationNamesType::iterator iter = IntegrationNames.begin();
    73         iter != IntegrationNames.end();
    74         ++iter) {
    75       inserter = IntegrationLookup.insert( make_pair(iter->second, iter->first) );
    76       if (!inserter.second)
    77         DoeLog(0) && (eLog() << Verbose(0)
    78             << "MpqcParser_Parameters::MpqcParser_Parameters() - Integration name already present: "
    79             << (inserter.first)->second << " and " << iter->first << "!"
    80             << std::endl);
    81     }
     87    ValidTheories.clear();
     88    ValidTheories.resize(unknownTheory);
     89    ValidTheories[CLHF]="CLHF";
     90    ValidTheories[CLKS]="CLKS";
     91    ValidTheories[MBPT2]="MBPT2";
     92    ValidTheories[MBPT2_R12]="MBPT2_R12";
     93    appendParameter(
     94        new DiscreteParameter<std::string>(
     95            ParamNames[theoryParam],
     96            ValidTheories,
     97            ValidTheories[MBPT2]));
     98  }
     99  //InvertMap<TheoryNamesType,TheoryLookupType>(TheoryNames,TheoryLookup);
     100
     101  // create integration parameter
     102  {
     103    ValidIntegrationMethods.clear();
     104    ValidIntegrationMethods.resize(unknownIntegration);
     105    ValidIntegrationMethods[IntegralCints] = "IntegralCints";
     106    appendParameter(
     107        new DiscreteParameter<std::string>(
     108            ParamNames[integrationParam],
     109            ValidIntegrationMethods,
     110            ValidIntegrationMethods[IntegralCints]));
    82111  }
    83112
    84   // have names for all parmaters
    85   ParamNames[hessianParam] = "Hessian";
    86   ParamNames[savestateParam] = "savestate";
    87   ParamNames[do_gradientParam] = "do_gradient";
    88   ParamNames[maxiterParam] = "maxiter";
    89   ParamNames[memoryParam] = "memory";
    90   ParamNames[stdapproxParam] = "stdapprox";
    91   ParamNames[nfzcParam] = "nfzc";
    92   ParamNames[basisParam] = "basis";
    93   ParamNames[aux_basisParam] = "aux_basis";
    94   ParamNames[integrationParam] = "integration";
    95   ParamNames[theoryParam] = "theory";
    96 
     113  // add all continuous parameters
    97114  {
    98     // TODO: throw exception instead of eLog()
    99     std::pair<ParamLookupType::iterator, bool> inserter;
    100     for (ParamNamesType::iterator iter = ParamNames.begin();
    101         iter != ParamNames.end();
    102         ++iter) {
    103       inserter = ParamLookup.insert( make_pair(iter->second, iter->first) );
    104       if (!inserter.second)
    105         DoeLog(0) && (eLog() << Verbose(0)
    106             << "MpqcParser_Parameters::MpqcParser_Parameters() - parameter name already present: "
    107             << (inserter.first)->second << " and " << iter->first << "!"
    108             << std::endl);
    109     }
     115    appendParameter(new ContinuousParameter<bool>(ParamNames[hessianParam], false));
     116    appendParameter(new ContinuousParameter<bool>(ParamNames[savestateParam], false));
     117    appendParameter(new ContinuousParameter<bool>(ParamNames[do_gradientParam], true));
     118    appendParameter(new ContinuousParameter<int>(ParamNames[maxiterParam], 1000));
     119    appendParameter(new ContinuousParameter<int>(ParamNames[memoryParam], 16000000));
     120    appendParameter(new StringParameter(ParamNames[stdapproxParam], "A'"));
     121    appendParameter(new ContinuousParameter<int>(ParamNames[nfzcParam], 1));
     122    appendParameter(new StringParameter(ParamNames[basisParam], "3-21G"));
     123    appendParameter(new StringParameter(ParamNames[aux_basisParam], "aug-cc-pVDZ"));
    110124  }
    111 
    112   initParameters();
    113 }
    114 
    115 MpqcParser_Parameters::MpqcParser_Parameters(const MpqcParser_Parameters & state)
    116 {
    117   // init
    118   Init();
    119 
    120   // copy values
    121   copyParameters(state);
    122 }
    123 
    124 void MpqcParser_Parameters::copyParameters(const MpqcParser_Parameters & state)
    125 {
    126   appendParameter(hessianParam, state.getBool(hessianParam));
    127   appendParameter(savestateParam, state.getBool(savestateParam));
    128   appendParameter(do_gradientParam, state.getBool(do_gradientParam));
    129   appendParameter(maxiterParam, state.getInt(maxiterParam));
    130   appendParameter(memoryParam, state.getInt(memoryParam));
    131   appendParameter(stdapproxParam, state.getString(stdapproxParam));
    132   appendParameter(nfzcParam, state.getInt(nfzcParam));
    133   appendParameter(basisParam, state.getString(basisParam));
    134   appendParameter(aux_basisParam, state.getString(aux_basisParam));
    135   appendParameter(integrationParam, state.getIntegration());
    136   appendParameter(theoryParam, state.getTheory());
    137 }
    138 
    139 FormatParser_Parameters* MpqcParser_Parameters::clone() const
    140 {
    141   //LOG(3, "Cloning parameters.");
    142   MpqcParser_Parameters *instance = new MpqcParser_Parameters(*this);
    143   return instance;
    144 }
    145 
    146 void MpqcParser_Parameters::makeClone(const FormatParser_Parameters & _state)
    147 {
    148   //LOG(3, "Cloning parameters from other instance.");
    149   copyParameters(static_cast<const MpqcParser_Parameters &>(_state));
    150 }
    151 
    152 void MpqcParser_Parameters::initParameters()
    153 {
    154         appendParameter(hessianParam, bool(false));
    155         appendParameter(savestateParam, bool(false));
    156         appendParameter(do_gradientParam, bool(true));
    157         appendParameter(maxiterParam, int(1000));
    158         appendParameter(memoryParam, int(16000000));
    159         appendParameter(stdapproxParam, std::string("A'"));
    160         appendParameter(nfzcParam, int(1));
    161         appendParameter(basisParam, std::string("3-21G"));
    162         appendParameter(aux_basisParam, std::string("aug-cc-pVDZ"));
    163         appendParameter(integrationParam, IntegralCints);
    164         appendParameter(theoryParam, MBPT2);
    165125}
    166126
     
    168128{}
    169129
    170 std::ostream & operator << (std::ostream& ost, MpqcParser_Parameters const &_mpqc_params)
     130/** Getter for a specific Parameter.
     131 *
     132 * @param param index among enum Parameters
     133 * @return value of the desired Parameters
     134 */
     135const std::string MpqcParser_Parameters::getParameter(const enum Parameters param) const
    171136{
    172   // this is ugly, but with boost::any to safeguard const-ness is plain impossible
    173   MpqcParser_Parameters &mpqc_params = const_cast<MpqcParser_Parameters &>(_mpqc_params);
    174   std::ostringstream output;
    175   output << "Hessian=" << mpqc_params.getBool(MpqcParser_Parameters::hessianParam) << ";";
    176   output << "savestate=" << mpqc_params.getBool(MpqcParser_Parameters::savestateParam) << ";";
    177   output << "do_gradient=" << mpqc_params.getBool(MpqcParser_Parameters::do_gradientParam) << ";";
    178   output << "maxiter=" << mpqc_params.getInt(MpqcParser_Parameters::maxiterParam) << ";";
    179   output << "memory=" << mpqc_params.getInt(MpqcParser_Parameters::memoryParam) << ";";
    180   output << "stdapprox=" << mpqc_params.getString(MpqcParser_Parameters::stdapproxParam) << ";";
    181   output << "nfzc=" << mpqc_params.getInt(MpqcParser_Parameters::nfzcParam) << ";";
    182   output << "basis=" << mpqc_params.getString(MpqcParser_Parameters::basisParam) << ";";
    183   output << "aux_basis=" << mpqc_params.getString(MpqcParser_Parameters::aux_basisParam) << ";";
    184   output << "integration=" << mpqc_params.getString(MpqcParser_Parameters::integrationParam) << ";";
    185   output << "theory=" << mpqc_params.getString(MpqcParser_Parameters::theoryParam) << ";";
    186   ost << output.str();
    187   return ost;
     137  return FormatParser_Parameters::getParameter(ParamNames[param])->get();
    188138}
    189139
    190 std::istream & operator >> (std::istream& ist, MpqcParser_Parameters &params)
     140/** Setter for a specific Parameter.
     141 *
     142 * @param param index among enum Parameters
     143 * @param _value value to set desired Parameter to
     144 */
     145void MpqcParser_Parameters::setParameter(const enum Parameters param, const std::string &_value)
    191146{
    192   typedef boost::tokenizer<boost::char_separator<char> >
    193       tokenizer;
    194   boost::char_separator<char> semicolonsep(";");
    195   boost::char_separator<char> equalitysep(" =");
    196   boost::char_separator<char> ticksep("\"");
    197   std::string line;
    198   std::getline( ist, line );
    199   //DoLog(0) && (Log() << Verbose(0) << "INFO: full line of parameters is '" << line << "'" << std::endl);
    200   tokenizer tokens(line, semicolonsep);
    201   ASSERT(tokens.begin() != tokens.end(),
    202       "operator<< on MpqcParser_Parameters - empty string, need at least ';' in line "+line+"!");
    203   for (tokenizer::iterator tok_iter = tokens.begin();
    204         tok_iter != tokens.end(); ++tok_iter) {
    205     tokenizer paramtokens(*tok_iter, equalitysep);
    206     if (paramtokens.begin() != paramtokens.end()) {
    207       tokenizer::iterator tok_paramiter = paramtokens.begin();
    208       tokenizer::iterator tok_valueiter = tok_paramiter;
    209       tokenizer::iterator tok_checkiter = ++tok_valueiter;
    210       ++tok_checkiter;
    211       // TODO: throw exception instead of ASSERT
    212       ASSERT(tok_paramiter != paramtokens.end(),
    213           "operator<< on MpqcParser_Parameters - missing value before ' =' in token "+*tok_iter+"!");
    214       ASSERT(tok_valueiter != paramtokens.end(),
    215           "operator<< on MpqcParser_Parameters - missing value after ' =' in token "+*tok_iter+"!");
    216       ASSERT(tok_checkiter == paramtokens.end(),
    217           "operator<< on MpqcParser_Parameters - still more tokens after ' =' in token "+*tok_iter+":"
    218           +*tok_checkiter+"!");
    219       std::stringstream keystream(*tok_paramiter);
    220       std::string key;
    221       keystream >> ws >> key;
    222       tokenizer ticklesstokens(*tok_valueiter, ticksep);
    223       ASSERT(ticklesstokens.begin() != ticklesstokens.end(),
    224           "operator<< on MpqcParser_Parameters - no tokens present after removing ticks in token "+*tok_valueiter+"!");
    225       std::stringstream valuestream(*(ticklesstokens.begin()));
    226       DoLog(2) && (Log() << Verbose(2)
    227           << "INFO: Token pair is " << key << "," << valuestream.str() << std::endl);
    228 
    229       // TODO: throw exception instead of DoeLog()
    230       ASSERT(params.haveParam(key),
    231           "operator >> on MpqcParser_Parameters - unknown parameter name '"
    232           +key+"' with value "+valuestream.str()+"!");
    233       if (params.haveParam(key))
    234         params.setter(params.getParam(key), valuestream);
    235     } else {
    236       ist.setstate(std::ios::eofbit);
    237     }
    238   }
    239   return ist;
     147  const std::string &name = getParameterName(param);
     148  FormatParser_Parameters::getParameter(name)->set(_value);
    240149}
    241150
    242 
    243 /** Sets a desired value in the params from a string.
     151/** Getter for name of a specific Parameter.
    244152 *
    245  * This is due to strict typing of C++ very ugly and boost::any does not make
    246  * it any better because it offers to functions to use values directly from
    247  * stringstream. Probably, because value is unknown to is as well and hence
    248  * the author could not implement it beautifully, so he dropped it altogether.
    249  * Grrr ....
    250  *
    251  * @param _param param to set
    252  * @param _desired stringstream containing value as next argument
    253  * @return true - type ok, false - unknown type in params.
     153 * @param param index among enum Parameters
     154 * @return name of the desired Parameter
    254155 */
    255 bool MpqcParser_Parameters::setter(enum Parameters _param, std::stringstream& _desired) {
    256   if (_param == integrationParam) {
    257      std::string tmp;
    258     _desired >> tmp;
    259     params[_param] = IntegrationLookup[tmp];
    260   } else if(_param == theoryParam) {
    261     std::string tmp;
    262     _desired >> tmp;
    263     params[_param] = TheoryLookup[tmp];
    264   } else if (params[_param].type() == typeid(std::string)) {
    265     std::string tmp;
    266     _desired >> tmp;
    267     params[_param] = tmp;
    268   } else if (params[_param].type() ==  typeid(int)) {
    269     int tmp;
    270     _desired >> tmp;
    271     params[_param] = tmp;
    272   } else if (params[_param].type() == typeid(double)) {
    273     double tmp;
    274     _desired >> tmp;
    275     params[_param] = tmp;
    276   } else if (params[_param].type() == typeid(bool)) {
    277     std::string tmp;
    278     _desired >> tmp;
    279     if ((tmp == "yes") || (tmp == "1")) {
    280       params[_param] = bool(true);
    281     } else if ((tmp == "no") || (tmp == "0")) {
    282       params[_param] = bool(false);
    283     } else {
    284       DoeLog(0) && (eLog() << Verbose(0)
    285           << "MpqcParser_Parameters::setter() - unknown boolean key "
    286           << tmp << "!" << std::endl);
    287     }
    288   } else {
    289     DoeLog(0) && (eLog() << Verbose(0)
    290         << "MpqcParser_Parameters::setter() - unknown type!" << std::endl);
    291     return false;
    292   }
    293   return true;
     156const std::string &MpqcParser_Parameters::getParameterName(const enum Parameters param) const
     157{
     158  return ParamNames[param];
    294159}
    295160
    296 
    297 void MpqcParser_Parameters::setTheory(enum Theory _theory)
     161/** Getter for name of a specific Parameter.
     162 *
     163 * @param param index among enum Theory
     164 * @return name of the desired Theory
     165 */
     166const std::string &MpqcParser_Parameters::getTheoryName(const enum Theory theory) const
    298167{
    299   // TODO: throw exception instead of eLog()
    300 //  try {
    301     params[theoryParam] = _theory;
    302 //  } catch(const boost::bad_any_cast &) {
    303 //    DoeLog(0) && (eLog() << Verbose(0)
    304 //        << "MpqcParser_Parameters::setTheory() - could not set boolean!" << std::endl);
    305 //  }
     168  return ValidTheories[theory];
    306169}
    307170
    308 void MpqcParser_Parameters::setIntegration(enum MpqcParser_Parameters::IntegrationMethod _integration){
    309   // TODO: throw exception instead of eLog()
    310 //  try {
    311     params[integrationParam] = _integration;
    312 //  } catch(const boost::bad_any_cast &) {
    313 //    DoeLog(0) && (eLog() << Verbose(0)
    314 //        << "MpqcParser_Parameters::setIntegration() - could not set boolean!" << std::endl);
    315 //  }
     171/** Getter for the name of specific of IntegrationMethod.
     172 *
     173 * @param param index among enum IntegrationMethod
     174 * @return value of the desired IntegrationMethod
     175 */
     176const std::string &MpqcParser_Parameters::getIntegrationMethodName(const enum IntegrationMethod integration) const
     177{
     178  return ValidIntegrationMethods[integration];
    316179}
    317 
    318 bool MpqcParser_Parameters::haveParam(std::string _name) const
    319 {
    320   return ParamLookup.count(_name) != 0;
    321 }
    322 
    323 enum MpqcParser_Parameters::Parameters MpqcParser_Parameters::getParam(std::string _name) const
    324 {
    325   ParamLookupType::const_iterator iter = ParamLookup.find(_name);
    326   return iter->second;
    327 }
    328 
    329 enum MpqcParser_Parameters::IntegrationMethod MpqcParser_Parameters::getIntegration() const
    330 {
    331   parameterlist::const_iterator iter = params.find(integrationParam);
    332   enum IntegrationMethod value;
    333   // TODO: throw exception instead of eLog()
    334 //  try {
    335     value = boost::any_cast<enum IntegrationMethod>(iter->second);
    336 //  } catch(const boost::bad_any_cast &) {
    337 //    DoeLog(0) && (eLog() << Verbose(0)
    338 //        << "MpqcParser_Parameters::getIntegration() - could not convert "
    339 //        +ParamNames[integrationParam]+" to enum IntegrationMethod!" << std::endl);
    340 //  }
    341   return value;
    342 }
    343 
    344 enum MpqcParser_Parameters::Theory MpqcParser_Parameters::getTheory() const
    345 {
    346   parameterlist::const_iterator iter = params.find(theoryParam);
    347   enum Theory value;
    348   // TODO: throw exception instead of eLog()
    349 //  try {
    350     value = boost::any_cast<enum Theory>(iter->second);
    351 //  } catch(const boost::bad_any_cast &) {
    352 //    DoeLog(0) && (eLog() << Verbose(0)
    353 //        << "MpqcParser_Parameters::getTheory() - could not convert "
    354 //        +ParamNames[theoryParam]+" to enum Theory!" << std::endl);
    355 //  }
    356   return value;
    357 }
    358 
    359 std::string MpqcParser_Parameters::getString(enum Parameters _param) const
    360 {
    361   std::string value;
    362   enum IntegrationMethod Iindex;
    363   enum Theory Tindex;
    364   bool test;
    365   parameterlist::const_iterator iter = params.find(_param);
    366   switch (_param) {
    367     case hessianParam:
    368     case savestateParam:
    369     case do_gradientParam:
    370       test = boost::any_cast<bool>(iter->second);
    371       if (test)
    372         value = "yes";
    373       else
    374         value = "no";
    375       break;
    376     case integrationParam:
    377       // TODO: throw exception instead of eLog()
    378 //      try {
    379         Iindex = boost::any_cast<enum IntegrationMethod>(iter->second);
    380 //      } catch(const boost::bad_any_cast &) {
    381 //        DoeLog(0) && (eLog() << Verbose(0)
    382 //            << "MpqcParser_Parameters::getString() - could not convert "
    383 //            +ParamNames[_param]+" to string!" << std::endl);
    384 //      }
    385       {
    386         IntegrationNamesType::const_iterator Iiter = IntegrationNames.find(Iindex);
    387         value = Iiter->second;
    388       }
    389       break;
    390     case theoryParam:
    391       // TODO: throw exception instead of eLog()
    392 //      try {
    393         Tindex = boost::any_cast<enum Theory>(iter->second);
    394 //      } catch(const boost::bad_any_cast &) {
    395 //        DoeLog(0) && (eLog() << Verbose(0)
    396 //            << "MpqcParser_Parameters::getString() - could not convert "
    397 //            +ParamNames[_param]+" to string!" << std::endl);
    398 //      }
    399         {
    400           TheoryNamesType::const_iterator Titer = TheoryNames.find(Tindex);
    401           value = Titer->second;
    402         }
    403       break;
    404     default:
    405       // TODO: throw exception instead of eLog()
    406 //      try {
    407         value = boost::any_cast<std::string>(iter->second);
    408 //      } catch(const boost::bad_any_cast &) {
    409 //        DoeLog(0) && (eLog() << Verbose(0)
    410 //            << "MpqcParser_Parameters::getString() - could not convert "
    411 //            +ParamNames[_param]+" to string!" << std::endl);
    412 //      }
    413       break;
    414   }
    415 
    416   return value;
    417 }
    418 
    419 int MpqcParser_Parameters::getInt(enum Parameters _param) const
    420 {
    421   int value;
    422   parameterlist::const_iterator iter = params.find(_param);
    423   switch (_param) {
    424     default:
    425       // TODO: throw exception instead of eLog()
    426 //      try {
    427         value = boost::any_cast<int>(iter->second);
    428 //      } catch(const boost::bad_any_cast &) {
    429 //        DoeLog(0) && (eLog() << Verbose(0)
    430 //            << "MpqcParser_Parameters::getInt() - could not convert "
    431 //            +ParamNames[_param]+" to int!" << std::endl);
    432 //      }
    433       break;
    434   }
    435   return value;
    436 }
    437 
    438 double MpqcParser_Parameters::getDouble(enum Parameters _param) const
    439 {
    440   double value;
    441   parameterlist::const_iterator iter = params.find(_param);
    442   // TODO: throw exception instead of eLog()
    443 //  try {
    444     value = boost::any_cast<double>(iter->second);
    445 //  } catch(const boost::bad_any_cast &) {
    446 //    DoeLog(0) && (eLog() << Verbose(0)
    447 //        << "MpqcParser_Parameters::getDouble() - could not convert "
    448 //        +ParamNames[_param]+" to double!" << std::endl);
    449 //  }
    450   return value;
    451 }
    452 
    453 bool MpqcParser_Parameters::getBool(enum Parameters _param) const
    454 {
    455   bool value;
    456   parameterlist::const_iterator iter = params.find(_param);
    457   // TODO: throw exception instead of eLog()
    458 //  try {
    459     value = boost::any_cast<bool>(iter->second);
    460 //  } catch(const boost::bad_any_cast &) {
    461 //    DoeLog(0) && (eLog() << Verbose(0)
    462 //        << "MpqcParser_Parameters::getBool() - could not convert "
    463 //        +ParamNames[_param]+" to bool!" << std::endl);
    464 //  }
    465   return value;
    466 }
    467 
    468180
    469181/** Checks whether all elements in the world also have parameters in the basis.
Note: See TracChangeset for help on using the changeset viewer.