| [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 | 
 | 
|---|
| [ee50c1] | 29 | #include "Parser/Parameters/ContinuousParameter.hpp"
 | 
|---|
 | 30 | #include "Parser/Parameters/DiscreteParameter.hpp"
 | 
|---|
 | 31 | #include "Parser/Parameters/StringParameter.hpp"
 | 
|---|
| [61d69a4] | 32 | 
 | 
|---|
| [ee50c1] | 33 | template <>
 | 
|---|
 | 34 | const std::string ContinuousValue<bool>::get() const
 | 
|---|
| [c1db05] | 35 | {
 | 
|---|
| [ee50c1] | 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");
 | 
|---|
| [c1db05] | 42 | }
 | 
|---|
 | 43 | 
 | 
|---|
| [ee50c1] | 44 | template <>
 | 
|---|
 | 45 | void ContinuousValue<bool>::set(const std::string _value)
 | 
|---|
| [d3d6c6] | 46 | {
 | 
|---|
| [ee50c1] | 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.");
 | 
|---|
| [d3d6c6] | 54 |   }
 | 
|---|
 | 55 | }
 | 
|---|
 | 56 | 
 | 
|---|
| [ee50c1] | 57 | 
 | 
|---|
 | 58 | MpqcParser_Parameters::MpqcParser_Parameters()
 | 
|---|
 | 59 | {
 | 
|---|
 | 60 |   Init();
 | 
|---|
 | 61 | }
 | 
|---|
 | 62 | 
 | 
|---|
| [c1db05] | 63 | void MpqcParser_Parameters::Init()
 | 
|---|
| [61d69a4] | 64 | {
 | 
|---|
 | 65 |   // add all known basis
 | 
|---|
 | 66 |   initBasis();
 | 
|---|
 | 67 | 
 | 
|---|
| [ee50c1] | 68 |   // add all parameter names
 | 
|---|
 | 69 |   {
 | 
|---|
 | 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";
 | 
|---|
 | 83 |   }
 | 
|---|
| [61d69a4] | 84 | 
 | 
|---|
| [ee50c1] | 85 |   // create theory parameter
 | 
|---|
 | 86 |   {
 | 
|---|
 | 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]));
 | 
|---|
 | 111 |   }
 | 
|---|
| [44fce5] | 112 | 
 | 
|---|
| [ee50c1] | 113 |   // add all continuous parameters
 | 
|---|
 | 114 |   {
 | 
|---|
 | 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"));
 | 
|---|
 | 124 |   }
 | 
|---|
| [61d69a4] | 125 | }
 | 
|---|
 | 126 | 
 | 
|---|
| [ee50c1] | 127 | MpqcParser_Parameters::~MpqcParser_Parameters()
 | 
|---|
 | 128 | {}
 | 
|---|
| [c1db05] | 129 | 
 | 
|---|
| [ee50c1] | 130 | /** Getter for a specific Parameter.
 | 
|---|
 | 131 |  *
 | 
|---|
 | 132 |  * @param param index among enum Parameters
 | 
|---|
 | 133 |  * @return value of the desired Parameters
 | 
|---|
 | 134 |  */
 | 
|---|
 | 135 | const std::string MpqcParser_Parameters::getParameter(const enum Parameters param) const
 | 
|---|
 | 136 | {
 | 
|---|
 | 137 |   return FormatParser_Parameters::getParameter(ParamNames[param])->get();
 | 
|---|
| [c1db05] | 138 | }
 | 
|---|
 | 139 | 
 | 
|---|
| [ee50c1] | 140 | /** Setter for a specific Parameter.
 | 
|---|
 | 141 |  *
 | 
|---|
 | 142 |  * @param param index among enum Parameters
 | 
|---|
 | 143 |  * @param _value value to set desired Parameter to
 | 
|---|
 | 144 |  */
 | 
|---|
 | 145 | void MpqcParser_Parameters::setParameter(const enum Parameters param, const std::string &_value)
 | 
|---|
| [c1db05] | 146 | {
 | 
|---|
| [ee50c1] | 147 |   const std::string &name = getParameterName(param);
 | 
|---|
 | 148 |   FormatParser_Parameters::getParameter(name)->set(_value);
 | 
|---|
| [c1db05] | 149 | }
 | 
|---|
 | 150 | 
 | 
|---|
| [ee50c1] | 151 | /** Getter for name of a specific Parameter.
 | 
|---|
 | 152 |  *
 | 
|---|
 | 153 |  * @param param index among enum Parameters
 | 
|---|
 | 154 |  * @return name of the desired Parameter
 | 
|---|
 | 155 |  */
 | 
|---|
 | 156 | const std::string &MpqcParser_Parameters::getParameterName(const enum Parameters param) const
 | 
|---|
| [c1db05] | 157 | {
 | 
|---|
| [ee50c1] | 158 |   return ParamNames[param];
 | 
|---|
| [c1db05] | 159 | }
 | 
|---|
 | 160 | 
 | 
|---|
| [ee50c1] | 161 | /** Getter for name of a specific Parameter.
 | 
|---|
 | 162 |  *
 | 
|---|
 | 163 |  * @param param index among enum Theory
 | 
|---|
 | 164 |  * @return name of the desired Theory
 | 
|---|
 | 165 |  */
 | 
|---|
 | 166 | const std::string &MpqcParser_Parameters::getTheoryName(const enum Theory theory) const
 | 
|---|
| [c1db05] | 167 | {
 | 
|---|
| [ee50c1] | 168 |   return ValidTheories[theory];
 | 
|---|
| [c1db05] | 169 | }
 | 
|---|
 | 170 | 
 | 
|---|
| [ee50c1] | 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 |  */
 | 
|---|
 | 176 | const std::string &MpqcParser_Parameters::getIntegrationMethodName(const enum IntegrationMethod integration) const
 | 
|---|
| [61d69a4] | 177 | {
 | 
|---|
| [ee50c1] | 178 |   return ValidIntegrationMethods[integration];
 | 
|---|
| [61d69a4] | 179 | }
 | 
|---|
 | 180 | 
 | 
|---|
 | 181 | /** Checks whether all elements in the world also have parameters in the basis.
 | 
|---|
 | 182 |  *
 | 
|---|
 | 183 |  * @return true - all elements parametrized, false - at least one element is missing.
 | 
|---|
 | 184 |  */
 | 
|---|
 | 185 | bool MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() const
 | 
|---|
 | 186 | {
 | 
|---|
| [47d041] | 187 |   ELOG(0, "MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() - not implemented yet.");
 | 
|---|
| [61d69a4] | 188 | 
 | 
|---|
 | 189 |   return false;
 | 
|---|
 | 190 | }
 | 
|---|
 | 191 | 
 | 
|---|