| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010-2012 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 "CodePatterns/MemDebug.hpp"
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include <string>
 | 
|---|
| 23 | 
 | 
|---|
| 24 | #include "CodePatterns/Log.hpp"
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #include "MpqcParser.hpp"
 | 
|---|
| 27 | #include "MpqcParser_Parameters.hpp"
 | 
|---|
| 28 | 
 | 
|---|
| 29 | #include "Parameters/Parameter.hpp"
 | 
|---|
| 30 | 
 | 
|---|
| 31 | template <>
 | 
|---|
| 32 | const std::string Value<bool>::getAsString() const throw(ParameterValueException)
 | 
|---|
| 33 | {
 | 
|---|
| 34 |   if(!ValueSet)
 | 
|---|
| 35 |     throw ParameterValueException();
 | 
|---|
| 36 |   if (value)
 | 
|---|
| 37 |     return std::string("yes");
 | 
|---|
| 38 |   else
 | 
|---|
| 39 |     return std::string("no");
 | 
|---|
| 40 | }
 | 
|---|
| 41 | 
 | 
|---|
| 42 | template <>
 | 
|---|
| 43 | void Value<bool>::setAsString(const std::string _value) throw(ParameterException)
 | 
|---|
| 44 | {
 | 
|---|
| 45 |   if (_value == std::string("yes")) {
 | 
|---|
| 46 |     set(true);
 | 
|---|
| 47 |   } else if (_value == std::string("no")) {
 | 
|---|
| 48 |     set(false);
 | 
|---|
| 49 |   } else {
 | 
|---|
| 50 |     throw ParameterValueException();
 | 
|---|
| 51 |   }
 | 
|---|
| 52 | }
 | 
|---|
| 53 | 
 | 
|---|
| 54 | 
 | 
|---|
| 55 | MpqcParser_Parameters::MpqcParser_Parameters()
 | 
|---|
| 56 | {
 | 
|---|
| 57 |   Init();
 | 
|---|
| 58 | }
 | 
|---|
| 59 | 
 | 
|---|
| 60 | void MpqcParser_Parameters::Init()
 | 
|---|
| 61 | {
 | 
|---|
| 62 |   // add all known basis
 | 
|---|
| 63 |   initBasis();
 | 
|---|
| 64 | 
 | 
|---|
| 65 |   // add all parameter names
 | 
|---|
| 66 |   {
 | 
|---|
| 67 |     ParamNames.clear();
 | 
|---|
| 68 |     ParamNames.resize(unknownParam);
 | 
|---|
| 69 |     ParamNames[hessianParam] = "Hessian";
 | 
|---|
| 70 |     ParamNames[savestateParam] = "savestate";
 | 
|---|
| 71 |     ParamNames[do_gradientParam] = "do_gradient";
 | 
|---|
| 72 |     ParamNames[maxiterParam] = "maxiter";
 | 
|---|
| 73 |     ParamNames[memoryParam] = "memory";
 | 
|---|
| 74 |     ParamNames[stdapproxParam] = "stdapprox";
 | 
|---|
| 75 |     ParamNames[nfzcParam] = "nfzc";
 | 
|---|
| 76 |     ParamNames[basisParam] = "basis";
 | 
|---|
| 77 |     ParamNames[aux_basisParam] = "aux_basis";
 | 
|---|
| 78 |     ParamNames[integrationParam] = "integration";
 | 
|---|
| 79 |     ParamNames[theoryParam] = "theory";
 | 
|---|
| 80 |   }
 | 
|---|
| 81 | 
 | 
|---|
| 82 |   // create theory parameter
 | 
|---|
| 83 |   {
 | 
|---|
| 84 |     ValidTheories.clear();
 | 
|---|
| 85 |     ValidTheories.resize(unknownTheory);
 | 
|---|
| 86 |     ValidTheories[CLHF]="CLHF";
 | 
|---|
| 87 |     ValidTheories[CLKS]="CLKS";
 | 
|---|
| 88 |     ValidTheories[MBPT2]="MBPT2";
 | 
|---|
| 89 |     ValidTheories[MBPT2_R12]="MBPT2_R12";
 | 
|---|
| 90 |     appendParameter(
 | 
|---|
| 91 |         new Parameter<std::string>(
 | 
|---|
| 92 |             ParamNames[theoryParam],
 | 
|---|
| 93 |             ValidTheories,
 | 
|---|
| 94 |             ValidTheories[MBPT2]));
 | 
|---|
| 95 |   }
 | 
|---|
| 96 |   //InvertMap<TheoryNamesType,TheoryLookupType>(TheoryNames,TheoryLookup);
 | 
|---|
| 97 | 
 | 
|---|
| 98 |   // create integration parameter
 | 
|---|
| 99 |   {
 | 
|---|
| 100 |     ValidIntegrationMethods.clear();
 | 
|---|
| 101 |     ValidIntegrationMethods.resize(unknownIntegration);
 | 
|---|
| 102 |     ValidIntegrationMethods[IntegralCints] = "IntegralCints";
 | 
|---|
| 103 |     appendParameter(
 | 
|---|
| 104 |         new Parameter<std::string>(
 | 
|---|
| 105 |             ParamNames[integrationParam],
 | 
|---|
| 106 |             ValidIntegrationMethods,
 | 
|---|
| 107 |             ValidIntegrationMethods[IntegralCints]));
 | 
|---|
| 108 |   }
 | 
|---|
| 109 | 
 | 
|---|
| 110 |   // add all continuous parameters
 | 
|---|
| 111 |   {
 | 
|---|
| 112 |     appendParameter(new Parameter<bool>(ParamNames[hessianParam], false));
 | 
|---|
| 113 |     appendParameter(new Parameter<bool>(ParamNames[savestateParam], false));
 | 
|---|
| 114 |     appendParameter(new Parameter<bool>(ParamNames[do_gradientParam], true));
 | 
|---|
| 115 |     appendParameter(new Parameter<int>(ParamNames[maxiterParam], 1000));
 | 
|---|
| 116 |     appendParameter(new Parameter<int>(ParamNames[memoryParam], 16000000));
 | 
|---|
| 117 |     appendParameter(new Parameter<std::string>(ParamNames[stdapproxParam], "A'"));
 | 
|---|
| 118 |     appendParameter(new Parameter<int>(ParamNames[nfzcParam], 1));
 | 
|---|
| 119 |     appendParameter(new Parameter<std::string>(ParamNames[basisParam], "3-21G"));
 | 
|---|
| 120 |     appendParameter(new Parameter<std::string>(ParamNames[aux_basisParam], "aug-cc-pVDZ"));
 | 
|---|
| 121 |   }
 | 
|---|
| 122 | }
 | 
|---|
| 123 | 
 | 
|---|
| 124 | MpqcParser_Parameters::~MpqcParser_Parameters()
 | 
|---|
| 125 | {}
 | 
|---|
| 126 | 
 | 
|---|
| 127 | /** Getter for a specific Parameter.
 | 
|---|
| 128 |  *
 | 
|---|
| 129 |  * @param param index among enum Parameters
 | 
|---|
| 130 |  * @return value of the desired Parameters
 | 
|---|
| 131 |  */
 | 
|---|
| 132 | const std::string MpqcParser_Parameters::getParameter(const enum Parameters param) const
 | 
|---|
| 133 | {
 | 
|---|
| 134 |   return FormatParser_Parameters::getParameter(ParamNames[param])->getAsString();
 | 
|---|
| 135 | }
 | 
|---|
| 136 | 
 | 
|---|
| 137 | /** Setter for a specific Parameter.
 | 
|---|
| 138 |  *
 | 
|---|
| 139 |  * @param param index among enum Parameters
 | 
|---|
| 140 |  * @param _value value to set desired Parameter to
 | 
|---|
| 141 |  */
 | 
|---|
| 142 | void MpqcParser_Parameters::setParameter(const enum Parameters param, const std::string &_value)
 | 
|---|
| 143 | {
 | 
|---|
| 144 |   const std::string &name = getParameterName(param);
 | 
|---|
| 145 |   FormatParser_Parameters::getParameter(name)->setAsString(_value);
 | 
|---|
| 146 | }
 | 
|---|
| 147 | 
 | 
|---|
| 148 | /** Getter for name of a specific Parameter.
 | 
|---|
| 149 |  *
 | 
|---|
| 150 |  * @param param index among enum Parameters
 | 
|---|
| 151 |  * @return name of the desired Parameter
 | 
|---|
| 152 |  */
 | 
|---|
| 153 | const std::string &MpqcParser_Parameters::getParameterName(const enum Parameters param) const
 | 
|---|
| 154 | {
 | 
|---|
| 155 |   return ParamNames[param];
 | 
|---|
| 156 | }
 | 
|---|
| 157 | 
 | 
|---|
| 158 | /** Getter for name of a specific Parameter.
 | 
|---|
| 159 |  *
 | 
|---|
| 160 |  * @param param index among enum Theory
 | 
|---|
| 161 |  * @return name of the desired Theory
 | 
|---|
| 162 |  */
 | 
|---|
| 163 | const std::string &MpqcParser_Parameters::getTheoryName(const enum Theory theory) const
 | 
|---|
| 164 | {
 | 
|---|
| 165 |   return ValidTheories[theory];
 | 
|---|
| 166 | }
 | 
|---|
| 167 | 
 | 
|---|
| 168 | /** Getter for the name of specific of IntegrationMethod.
 | 
|---|
| 169 |  *
 | 
|---|
| 170 |  * @param param index among enum IntegrationMethod
 | 
|---|
| 171 |  * @return value of the desired IntegrationMethod
 | 
|---|
| 172 |  */
 | 
|---|
| 173 | const std::string &MpqcParser_Parameters::getIntegrationMethodName(const enum IntegrationMethod integration) const
 | 
|---|
| 174 | {
 | 
|---|
| 175 |   return ValidIntegrationMethods[integration];
 | 
|---|
| 176 | }
 | 
|---|
| 177 | 
 | 
|---|
| 178 | /** Checks whether all elements in the world also have parameters in the basis.
 | 
|---|
| 179 |  *
 | 
|---|
| 180 |  * @return true - all elements parametrized, false - at least one element is missing.
 | 
|---|
| 181 |  */
 | 
|---|
| 182 | bool MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() const
 | 
|---|
| 183 | {
 | 
|---|
| 184 |   ELOG(0, "MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() - not implemented yet.");
 | 
|---|
| 185 | 
 | 
|---|
| 186 |   return false;
 | 
|---|
| 187 | }
 | 
|---|
| 188 | 
 | 
|---|