| [61d69a4] | 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()
 | 
|---|
| [c1db05] | 37 | {
 | 
|---|
 | 38 |   Init();
 | 
|---|
 | 39 | }
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 | void MpqcParser_Parameters::Init()
 | 
|---|
| [61d69a4] | 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 | 
 | 
|---|
| [44fce5] | 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 | 
 | 
|---|
| [61d69a4] | 67 |   // add all integration names
 | 
|---|
 | 68 |   IntegrationNames[IntegralCints] = "IntegralCints";
 | 
|---|
| [44fce5] | 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 |   }
 | 
|---|
| [61d69a4] | 83 | 
 | 
|---|
 | 84 |   // have names for all parmaters
 | 
|---|
| [44fce5] | 85 |   ParamNames[hessianParam] = "Hessian";
 | 
|---|
| [61d69a4] | 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 | 
 | 
|---|
| [44fce5] | 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 | 
 | 
|---|
| [61d69a4] | 112 |   initParameters();
 | 
|---|
 | 113 | }
 | 
|---|
 | 114 | 
 | 
|---|
| [c1db05] | 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 | 
 | 
|---|
| [61d69a4] | 152 | void MpqcParser_Parameters::initParameters()
 | 
|---|
 | 153 | {
 | 
|---|
| [44fce5] | 154 |         appendParameter(hessianParam, bool(false));
 | 
|---|
| [61d69a4] | 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 | 
 | 
|---|
| [963321a] | 170 | std::ostream & operator << (std::ostream& ost, MpqcParser_Parameters const &_mpqc_params)
 | 
|---|
| [61d69a4] | 171 | {
 | 
|---|
| [963321a] | 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);
 | 
|---|
| [61d69a4] | 174 |   std::ostringstream output;
 | 
|---|
| [963321a] | 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) << ";";
 | 
|---|
| [61d69a4] | 180 |   output << "stdapprox=" << mpqc_params.getString(MpqcParser_Parameters::stdapproxParam) << ";";
 | 
|---|
| [963321a] | 181 |   output << "nfzc=" << mpqc_params.getInt(MpqcParser_Parameters::nfzcParam) << ";";
 | 
|---|
| [61d69a4] | 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(";");
 | 
|---|
| [44fce5] | 195 |   boost::char_separator<char> equalitysep(" =");
 | 
|---|
| [311da7b] | 196 |   boost::char_separator<char> ticksep("\"");
 | 
|---|
| [61d69a4] | 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(),
 | 
|---|
| [311da7b] | 202 |       "operator<< on MpqcParser_Parameters - empty string, need at least ';' in line "+line+"!");
 | 
|---|
| [61d69a4] | 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;
 | 
|---|
| [311da7b] | 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);
 | 
|---|
| [61d69a4] | 228 | 
 | 
|---|
| [44fce5] | 229 |       // TODO: throw exception instead of DoeLog()
 | 
|---|
| [311da7b] | 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);
 | 
|---|
| [61d69a4] | 235 |     } else {
 | 
|---|
 | 236 |       ist.setstate(std::ios::eofbit);
 | 
|---|
 | 237 |     }
 | 
|---|
 | 238 |   }
 | 
|---|
 | 239 |   return ist;
 | 
|---|
 | 240 | }
 | 
|---|
 | 241 | 
 | 
|---|
 | 242 | 
 | 
|---|
| [44fce5] | 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.
 | 
|---|
| [61d69a4] | 254 |  */
 | 
|---|
| [44fce5] | 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;
 | 
|---|
| [35bf6b] | 279 |     if ((tmp == "yes") || (tmp == "1")) {
 | 
|---|
| [44fce5] | 280 |       params[_param] = bool(true);
 | 
|---|
| [35bf6b] | 281 |     } else if ((tmp == "no") || (tmp == "0")) {
 | 
|---|
| [44fce5] | 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 {
 | 
|---|
| [61d69a4] | 289 |     DoeLog(0) && (eLog() << Verbose(0)
 | 
|---|
| [44fce5] | 290 |         << "MpqcParser_Parameters::setter() - unknown type!" << std::endl);
 | 
|---|
 | 291 |     return false;
 | 
|---|
| [61d69a4] | 292 |   }
 | 
|---|
| [44fce5] | 293 |   return true;
 | 
|---|
| [61d69a4] | 294 | }
 | 
|---|
 | 295 | 
 | 
|---|
| [44fce5] | 296 | 
 | 
|---|
| [61d69a4] | 297 | void MpqcParser_Parameters::setTheory(enum Theory _theory)
 | 
|---|
 | 298 | {
 | 
|---|
| [44fce5] | 299 |   // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 300 | //  try {
 | 
|---|
| [61d69a4] | 301 |     params[theoryParam] = _theory;
 | 
|---|
| [311da7b] | 302 | //  } catch(const boost::bad_any_cast &) {
 | 
|---|
 | 303 | //    DoeLog(0) && (eLog() << Verbose(0)
 | 
|---|
 | 304 | //        << "MpqcParser_Parameters::setTheory() - could not set boolean!" << std::endl);
 | 
|---|
 | 305 | //  }
 | 
|---|
| [44fce5] | 306 | }
 | 
|---|
 | 307 | 
 | 
|---|
 | 308 | void MpqcParser_Parameters::setIntegration(enum MpqcParser_Parameters::IntegrationMethod _integration){
 | 
|---|
 | 309 |   // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 310 | //  try {
 | 
|---|
| [44fce5] | 311 |     params[integrationParam] = _integration;
 | 
|---|
| [311da7b] | 312 | //  } catch(const boost::bad_any_cast &) {
 | 
|---|
 | 313 | //    DoeLog(0) && (eLog() << Verbose(0)
 | 
|---|
 | 314 | //        << "MpqcParser_Parameters::setIntegration() - could not set boolean!" << std::endl);
 | 
|---|
 | 315 | //  }
 | 
|---|
| [61d69a4] | 316 | }
 | 
|---|
 | 317 | 
 | 
|---|
| [44fce5] | 318 | bool MpqcParser_Parameters::haveParam(std::string _name) const
 | 
|---|
 | 319 | {
 | 
|---|
 | 320 |   return ParamLookup.count(_name) != 0;
 | 
|---|
 | 321 | }
 | 
|---|
 | 322 | 
 | 
|---|
| [c1db05] | 323 | enum MpqcParser_Parameters::Parameters MpqcParser_Parameters::getParam(std::string _name) const
 | 
|---|
| [44fce5] | 324 | {
 | 
|---|
| [c1db05] | 325 |   ParamLookupType::const_iterator iter = ParamLookup.find(_name);
 | 
|---|
 | 326 |   return iter->second;
 | 
|---|
| [44fce5] | 327 | }
 | 
|---|
 | 328 | 
 | 
|---|
| [c1db05] | 329 | enum MpqcParser_Parameters::IntegrationMethod MpqcParser_Parameters::getIntegration() const
 | 
|---|
| [61d69a4] | 330 | {
 | 
|---|
| [c1db05] | 331 |   parameterlist::const_iterator iter = params.find(integrationParam);
 | 
|---|
| [61d69a4] | 332 |   enum IntegrationMethod value;
 | 
|---|
| [44fce5] | 333 |   // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 334 | //  try {
 | 
|---|
| [c1db05] | 335 |     value = boost::any_cast<enum IntegrationMethod>(iter->second);
 | 
|---|
| [311da7b] | 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 | //  }
 | 
|---|
| [61d69a4] | 341 |   return value;
 | 
|---|
 | 342 | }
 | 
|---|
 | 343 | 
 | 
|---|
| [c1db05] | 344 | enum MpqcParser_Parameters::Theory MpqcParser_Parameters::getTheory() const
 | 
|---|
| [61d69a4] | 345 | {
 | 
|---|
| [c1db05] | 346 |   parameterlist::const_iterator iter = params.find(theoryParam);
 | 
|---|
| [61d69a4] | 347 |   enum Theory value;
 | 
|---|
| [44fce5] | 348 |   // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 349 | //  try {
 | 
|---|
| [c1db05] | 350 |     value = boost::any_cast<enum Theory>(iter->second);
 | 
|---|
| [311da7b] | 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 | //  }
 | 
|---|
| [61d69a4] | 356 |   return value;
 | 
|---|
 | 357 | }
 | 
|---|
 | 358 | 
 | 
|---|
| [c1db05] | 359 | std::string MpqcParser_Parameters::getString(enum Parameters _param) const
 | 
|---|
| [61d69a4] | 360 | {
 | 
|---|
 | 361 |   std::string value;
 | 
|---|
 | 362 |   enum IntegrationMethod Iindex;
 | 
|---|
 | 363 |   enum Theory Tindex;
 | 
|---|
 | 364 |   bool test;
 | 
|---|
| [c1db05] | 365 |   parameterlist::const_iterator iter = params.find(_param);
 | 
|---|
| [61d69a4] | 366 |   switch (_param) {
 | 
|---|
| [44fce5] | 367 |     case hessianParam:
 | 
|---|
| [61d69a4] | 368 |     case savestateParam:
 | 
|---|
 | 369 |     case do_gradientParam:
 | 
|---|
| [c1db05] | 370 |       test = boost::any_cast<bool>(iter->second);
 | 
|---|
| [61d69a4] | 371 |       if (test)
 | 
|---|
 | 372 |         value = "yes";
 | 
|---|
 | 373 |       else
 | 
|---|
 | 374 |         value = "no";
 | 
|---|
 | 375 |       break;
 | 
|---|
 | 376 |     case integrationParam:
 | 
|---|
| [44fce5] | 377 |       // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 378 | //      try {
 | 
|---|
| [c1db05] | 379 |         Iindex = boost::any_cast<enum IntegrationMethod>(iter->second);
 | 
|---|
| [311da7b] | 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 | //      }
 | 
|---|
| [c1db05] | 385 |       {
 | 
|---|
 | 386 |         IntegrationNamesType::const_iterator Iiter = IntegrationNames.find(Iindex);
 | 
|---|
 | 387 |         value = Iiter->second;
 | 
|---|
 | 388 |       }
 | 
|---|
| [61d69a4] | 389 |       break;
 | 
|---|
 | 390 |     case theoryParam:
 | 
|---|
| [44fce5] | 391 |       // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 392 | //      try {
 | 
|---|
| [c1db05] | 393 |         Tindex = boost::any_cast<enum Theory>(iter->second);
 | 
|---|
| [311da7b] | 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 | //      }
 | 
|---|
| [c1db05] | 399 |         {
 | 
|---|
 | 400 |           TheoryNamesType::const_iterator Titer = TheoryNames.find(Tindex);
 | 
|---|
 | 401 |           value = Titer->second;
 | 
|---|
 | 402 |         }
 | 
|---|
| [61d69a4] | 403 |       break;
 | 
|---|
 | 404 |     default:
 | 
|---|
| [44fce5] | 405 |       // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 406 | //      try {
 | 
|---|
| [c1db05] | 407 |         value = boost::any_cast<std::string>(iter->second);
 | 
|---|
| [311da7b] | 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 | //      }
 | 
|---|
| [61d69a4] | 413 |       break;
 | 
|---|
 | 414 |   }
 | 
|---|
 | 415 | 
 | 
|---|
 | 416 |   return value;
 | 
|---|
 | 417 | }
 | 
|---|
 | 418 | 
 | 
|---|
| [c1db05] | 419 | int MpqcParser_Parameters::getInt(enum Parameters _param) const
 | 
|---|
| [61d69a4] | 420 | {
 | 
|---|
 | 421 |   int value;
 | 
|---|
| [c1db05] | 422 |   parameterlist::const_iterator iter = params.find(_param);
 | 
|---|
| [61d69a4] | 423 |   switch (_param) {
 | 
|---|
 | 424 |     default:
 | 
|---|
| [44fce5] | 425 |       // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 426 | //      try {
 | 
|---|
| [c1db05] | 427 |         value = boost::any_cast<int>(iter->second);
 | 
|---|
| [311da7b] | 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 | //      }
 | 
|---|
| [61d69a4] | 433 |       break;
 | 
|---|
 | 434 |   }
 | 
|---|
 | 435 |   return value;
 | 
|---|
 | 436 | }
 | 
|---|
 | 437 | 
 | 
|---|
| [c1db05] | 438 | double MpqcParser_Parameters::getDouble(enum Parameters _param) const
 | 
|---|
| [44fce5] | 439 | {
 | 
|---|
| [61d69a4] | 440 |   double value;
 | 
|---|
| [c1db05] | 441 |   parameterlist::const_iterator iter = params.find(_param);
 | 
|---|
| [44fce5] | 442 |   // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 443 | //  try {
 | 
|---|
| [c1db05] | 444 |     value = boost::any_cast<double>(iter->second);
 | 
|---|
| [311da7b] | 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 | //  }
 | 
|---|
| [61d69a4] | 450 |   return value;
 | 
|---|
 | 451 | }
 | 
|---|
 | 452 | 
 | 
|---|
| [c1db05] | 453 | bool MpqcParser_Parameters::getBool(enum Parameters _param) const
 | 
|---|
| [61d69a4] | 454 | {
 | 
|---|
 | 455 |   bool value;
 | 
|---|
| [c1db05] | 456 |   parameterlist::const_iterator iter = params.find(_param);
 | 
|---|
| [44fce5] | 457 |   // TODO: throw exception instead of eLog()
 | 
|---|
| [311da7b] | 458 | //  try {
 | 
|---|
| [c1db05] | 459 |     value = boost::any_cast<bool>(iter->second);
 | 
|---|
| [311da7b] | 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 | //  }
 | 
|---|
| [61d69a4] | 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 | 
 | 
|---|