| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | /*
 | 
|---|
| 9 |  * MpqcParser_Parameters.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: Feb 3, 2011
 | 
|---|
| 12 |  *      Author: heber
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | // include config.h
 | 
|---|
| 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 17 | #include <config.h>
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include <iostream>
 | 
|---|
| 21 | #include <boost/tokenizer.hpp>
 | 
|---|
| 22 | #include <string>
 | 
|---|
| 23 | 
 | 
|---|
| 24 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #include "CodePatterns/Log.hpp"
 | 
|---|
| 27 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
| 28 | 
 | 
|---|
| 29 | #include "MpqcParser.hpp"
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #include "MpqcParser_Parameters.hpp"
 | 
|---|
| 32 | 
 | 
|---|
| 33 | 
 | 
|---|
| 34 | using boost::any_cast;
 | 
|---|
| 35 | 
 | 
|---|
| 36 | MpqcParser_Parameters::MpqcParser_Parameters()
 | 
|---|
| 37 | {
 | 
|---|
| 38 |   Init();
 | 
|---|
| 39 | }
 | 
|---|
| 40 | 
 | 
|---|
| 41 | void MpqcParser_Parameters::Init()
 | 
|---|
| 42 | {
 | 
|---|
| 43 |   // add all known basis
 | 
|---|
| 44 |   initBasis();
 | 
|---|
| 45 | 
 | 
|---|
| 46 |   // add all theory names
 | 
|---|
| 47 |   TheoryNames[CLHF]="CLHF";
 | 
|---|
| 48 |   TheoryNames[CLKS]="CLKS";
 | 
|---|
| 49 |   TheoryNames[MBPT2]="MBPT2";
 | 
|---|
| 50 |   TheoryNames[MBPT2_R12]="MBPT2_R12";
 | 
|---|
| 51 | 
 | 
|---|
| 52 |   {
 | 
|---|
| 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 |     }
 | 
|---|
| 65 |   }
 | 
|---|
| 66 | 
 | 
|---|
| 67 |   // add all integration names
 | 
|---|
| 68 |   IntegrationNames[IntegralCints] = "IntegralCints";
 | 
|---|
| 69 |   {
 | 
|---|
| 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 |     }
 | 
|---|
| 82 |   }
 | 
|---|
| 83 | 
 | 
|---|
| 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 | 
 | 
|---|
| 97 |   {
 | 
|---|
| 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 |     }
 | 
|---|
| 110 |   }
 | 
|---|
| 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);
 | 
|---|
| 165 | }
 | 
|---|
| 166 | 
 | 
|---|
| 167 | MpqcParser_Parameters::~MpqcParser_Parameters()
 | 
|---|
| 168 | {}
 | 
|---|
| 169 | 
 | 
|---|
| 170 | std::ostream & operator << (std::ostream& ost, MpqcParser_Parameters const &_mpqc_params)
 | 
|---|
| 171 | {
 | 
|---|
| 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;
 | 
|---|
| 188 | }
 | 
|---|
| 189 | 
 | 
|---|
| 190 | std::istream & operator >> (std::istream& ist, MpqcParser_Parameters ¶ms)
 | 
|---|
| 191 | {
 | 
|---|
| 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;
 | 
|---|
| 240 | }
 | 
|---|
| 241 | 
 | 
|---|
| 242 | 
 | 
|---|
| 243 | /** Sets a desired value in the params from a string.
 | 
|---|
| 244 |  *
 | 
|---|
| 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.
 | 
|---|
| 254 |  */
 | 
|---|
| 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;
 | 
|---|
| 294 | }
 | 
|---|
| 295 | 
 | 
|---|
| 296 | 
 | 
|---|
| 297 | void MpqcParser_Parameters::setTheory(enum Theory _theory)
 | 
|---|
| 298 | {
 | 
|---|
| 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 | //  }
 | 
|---|
| 306 | }
 | 
|---|
| 307 | 
 | 
|---|
| 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 | //  }
 | 
|---|
| 316 | }
 | 
|---|
| 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 | 
 | 
|---|
| 468 | 
 | 
|---|
| 469 | /** Checks whether all elements in the world also have parameters in the basis.
 | 
|---|
| 470 |  *
 | 
|---|
| 471 |  * @return true - all elements parametrized, false - at least one element is missing.
 | 
|---|
| 472 |  */
 | 
|---|
| 473 | bool MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() const
 | 
|---|
| 474 | {
 | 
|---|
| 475 |   DoeLog(0) && (eLog() << Verbose(0)
 | 
|---|
| 476 |       << "MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() - not implemented yet."
 | 
|---|
| 477 |       << std::endl);
 | 
|---|
| 478 | 
 | 
|---|
| 479 |   return false;
 | 
|---|
| 480 | }
 | 
|---|
| 481 | 
 | 
|---|