| [61d69a4] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [61d69a4] | 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 | 
 | 
|---|
| [7f570c] | 22 | #include <string>
 | 
|---|
 | 23 | 
 | 
|---|
| [61d69a4] | 24 | #include "CodePatterns/Log.hpp"
 | 
|---|
 | 25 | 
 | 
|---|
 | 26 | #include "MpqcParser.hpp"
 | 
|---|
 | 27 | #include "MpqcParser_Parameters.hpp"
 | 
|---|
 | 28 | 
 | 
|---|
| [118f1e] | 29 | #include "Parameters/Parameter.hpp"
 | 
|---|
| [61d69a4] | 30 | 
 | 
|---|
| [ee50c1] | 31 | template <>
 | 
|---|
| [e45c1d] | 32 | const std::string Value<bool>::getAsString() const throw(ParameterValueException)
 | 
|---|
| [c1db05] | 33 | {
 | 
|---|
| [e45c1d] | 34 |   if(!ValueSet)
 | 
|---|
 | 35 |     throw ParameterValueException();
 | 
|---|
| [ee50c1] | 36 |   if (value)
 | 
|---|
 | 37 |     return std::string("yes");
 | 
|---|
 | 38 |   else
 | 
|---|
 | 39 |     return std::string("no");
 | 
|---|
| [c1db05] | 40 | }
 | 
|---|
 | 41 | 
 | 
|---|
| [ee50c1] | 42 | template <>
 | 
|---|
| [e45c1d] | 43 | void Value<bool>::setAsString(const std::string _value) throw(ParameterException)
 | 
|---|
| [d3d6c6] | 44 | {
 | 
|---|
| [ee50c1] | 45 |   if (_value == std::string("yes")) {
 | 
|---|
| [118f1e] | 46 |     set(true);
 | 
|---|
| [ee50c1] | 47 |   } else if (_value == std::string("no")) {
 | 
|---|
| [118f1e] | 48 |     set(false);
 | 
|---|
| [ee50c1] | 49 |   } else {
 | 
|---|
| [e45c1d] | 50 |     throw ParameterValueException();
 | 
|---|
| [d3d6c6] | 51 |   }
 | 
|---|
 | 52 | }
 | 
|---|
 | 53 | 
 | 
|---|
| [ee50c1] | 54 | 
 | 
|---|
 | 55 | MpqcParser_Parameters::MpqcParser_Parameters()
 | 
|---|
 | 56 | {
 | 
|---|
 | 57 |   Init();
 | 
|---|
 | 58 | }
 | 
|---|
 | 59 | 
 | 
|---|
| [c1db05] | 60 | void MpqcParser_Parameters::Init()
 | 
|---|
| [61d69a4] | 61 | {
 | 
|---|
 | 62 |   // add all known basis
 | 
|---|
 | 63 |   initBasis();
 | 
|---|
 | 64 | 
 | 
|---|
| [ee50c1] | 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 |   }
 | 
|---|
| [61d69a4] | 81 | 
 | 
|---|
| [ee50c1] | 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(
 | 
|---|
| [118f1e] | 91 |         new Parameter<std::string>(
 | 
|---|
| [ee50c1] | 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(
 | 
|---|
| [118f1e] | 104 |         new Parameter<std::string>(
 | 
|---|
| [ee50c1] | 105 |             ParamNames[integrationParam],
 | 
|---|
 | 106 |             ValidIntegrationMethods,
 | 
|---|
 | 107 |             ValidIntegrationMethods[IntegralCints]));
 | 
|---|
 | 108 |   }
 | 
|---|
| [44fce5] | 109 | 
 | 
|---|
| [ee50c1] | 110 |   // add all continuous parameters
 | 
|---|
 | 111 |   {
 | 
|---|
| [118f1e] | 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"));
 | 
|---|
| [ee50c1] | 121 |   }
 | 
|---|
| [61d69a4] | 122 | }
 | 
|---|
 | 123 | 
 | 
|---|
| [ee50c1] | 124 | MpqcParser_Parameters::~MpqcParser_Parameters()
 | 
|---|
 | 125 | {}
 | 
|---|
| [c1db05] | 126 | 
 | 
|---|
| [ee50c1] | 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 | {
 | 
|---|
| [118f1e] | 134 |   return FormatParser_Parameters::getParameter(ParamNames[param])->getAsString();
 | 
|---|
| [c1db05] | 135 | }
 | 
|---|
 | 136 | 
 | 
|---|
| [ee50c1] | 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)
 | 
|---|
| [c1db05] | 143 | {
 | 
|---|
| [ee50c1] | 144 |   const std::string &name = getParameterName(param);
 | 
|---|
| [118f1e] | 145 |   FormatParser_Parameters::getParameter(name)->setAsString(_value);
 | 
|---|
| [c1db05] | 146 | }
 | 
|---|
 | 147 | 
 | 
|---|
| [ee50c1] | 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
 | 
|---|
| [c1db05] | 154 | {
 | 
|---|
| [ee50c1] | 155 |   return ParamNames[param];
 | 
|---|
| [c1db05] | 156 | }
 | 
|---|
 | 157 | 
 | 
|---|
| [ee50c1] | 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
 | 
|---|
| [c1db05] | 164 | {
 | 
|---|
| [ee50c1] | 165 |   return ValidTheories[theory];
 | 
|---|
| [c1db05] | 166 | }
 | 
|---|
 | 167 | 
 | 
|---|
| [ee50c1] | 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
 | 
|---|
| [61d69a4] | 174 | {
 | 
|---|
| [ee50c1] | 175 |   return ValidIntegrationMethods[integration];
 | 
|---|
| [61d69a4] | 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 | {
 | 
|---|
| [47d041] | 184 |   ELOG(0, "MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() - not implemented yet.");
 | 
|---|
| [61d69a4] | 185 | 
 | 
|---|
 | 186 |   return false;
 | 
|---|
 | 187 | }
 | 
|---|
 | 188 | 
 | 
|---|