| [1bef07] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [1bef07] | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | /*
 | 
|---|
 | 9 |  * Psi3Parser_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 | 
 | 
|---|
 | 24 | #include "CodePatterns/Assert.hpp"
 | 
|---|
| [1bef07] | 25 | #include "CodePatterns/Log.hpp"
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | #include "Psi3Parser.hpp"
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | #include "Psi3Parser_Parameters.hpp"
 | 
|---|
 | 30 | 
 | 
|---|
| [118f1e] | 31 | #include "Parameters/Parameter.hpp"
 | 
|---|
| [1bef07] | 32 | 
 | 
|---|
| [118f1e] | 33 | // TODO: Value<bool>::getAsString() must be defined inline otherwise we get multiple definition of virtual thunk compilation errors
 | 
|---|
| [1bef07] | 34 | template <>
 | 
|---|
| [118f1e] | 35 | inline const std::string Value<bool>::getAsString() const
 | 
|---|
| [1bef07] | 36 | {
 | 
|---|
 | 37 |   ASSERT(ValueSet,
 | 
|---|
| [118f1e] | 38 |       "Value<bool>::getAsString() - requesting unset value.");
 | 
|---|
| [1bef07] | 39 |   if (value)
 | 
|---|
 | 40 |     return std::string("yes");
 | 
|---|
 | 41 |   else
 | 
|---|
 | 42 |     return std::string("no");
 | 
|---|
 | 43 | }
 | 
|---|
 | 44 | 
 | 
|---|
| [118f1e] | 45 | // TODO: Value<bool>::setAsString must be defined inline otherwise we get multiple definition of virtual thunk compilation errors
 | 
|---|
| [1bef07] | 46 | template <>
 | 
|---|
| [118f1e] | 47 | inline void Value<bool>::setAsString(const std::string _value)
 | 
|---|
| [1bef07] | 48 | {
 | 
|---|
 | 49 |   if (_value == std::string("yes")) {
 | 
|---|
| [118f1e] | 50 |     set(true);
 | 
|---|
| [1bef07] | 51 |   } else if (_value == std::string("no")) {
 | 
|---|
| [118f1e] | 52 |     set(false);
 | 
|---|
| [1bef07] | 53 |   } else {
 | 
|---|
 | 54 |     ASSERT(0,
 | 
|---|
 | 55 |         "void ContinuousValue<bool>::set() - value "+_value+" is neither yes or no.");
 | 
|---|
 | 56 |   }
 | 
|---|
 | 57 | }
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 | Psi3Parser_Parameters::Psi3Parser_Parameters()
 | 
|---|
 | 61 | {
 | 
|---|
 | 62 |   Init();
 | 
|---|
 | 63 | }
 | 
|---|
 | 64 | 
 | 
|---|
 | 65 | void Psi3Parser_Parameters::Init()
 | 
|---|
 | 66 | {
 | 
|---|
 | 67 |   // add all known basis
 | 
|---|
 | 68 |   //initBasis();
 | 
|---|
 | 69 | 
 | 
|---|
 | 70 |   // add all parameter names
 | 
|---|
 | 71 |   {
 | 
|---|
 | 72 |     ParamNames.clear();
 | 
|---|
 | 73 |     ParamNames.resize(unknownParam);
 | 
|---|
 | 74 |     ParamNames[labelParam] = "label";
 | 
|---|
 | 75 |     ParamNames[jobtypeParam] = "jobtype";
 | 
|---|
 | 76 |     ParamNames[wavefunctionParam] = "wfn";
 | 
|---|
 | 77 |     ParamNames[maxiterParam] = "maxiter";
 | 
|---|
 | 78 |     ParamNames[referenceParam] = "reference";
 | 
|---|
 | 79 |     ParamNames[basisParam] = "basis";
 | 
|---|
 | 80 |     ParamNames[freeze_coreParam] = "freeze_core";
 | 
|---|
 | 81 |     ParamNames[unitsParam] = "units";
 | 
|---|
 | 82 |     ParamNames[dertypeParam] = "dertype";
 | 
|---|
 | 83 |     ParamNames[originParam] = "origin";
 | 
|---|
| [a67cf0] | 84 |     ParamNames[multiplicityParam] = "multp";
 | 
|---|
| [1bef07] | 85 |     ParamNames[chargeParam] = "charge";
 | 
|---|
 | 86 |     ParamNames[soccParam] = "socc";
 | 
|---|
 | 87 |     ParamNames[doccParam] = "docc";
 | 
|---|
 | 88 |     ParamNames[subgroupParam] = "subgroup";
 | 
|---|
 | 89 |     ParamNames[unique_axisParam] = "unique_axis";
 | 
|---|
 | 90 |   }
 | 
|---|
 | 91 | 
 | 
|---|
 | 92 |   // create freeze_core parameter
 | 
|---|
 | 93 |   {
 | 
|---|
 | 94 |     ValidFreezeCore.clear();
 | 
|---|
 | 95 |     ValidFreezeCore.resize(unknownFreezeCore);
 | 
|---|
 | 96 |     ValidFreezeCore[YES]="yes";
 | 
|---|
 | 97 |     ValidFreezeCore[TRUE]="true";
 | 
|---|
 | 98 |     ValidFreezeCore[NO]="no";
 | 
|---|
 | 99 |     ValidFreezeCore[FALSE]="false";
 | 
|---|
 | 100 |     ValidFreezeCore[SMALL]="small";
 | 
|---|
 | 101 |     ValidFreezeCore[LARGE]="large";
 | 
|---|
 | 102 |     appendParameter(
 | 
|---|
| [118f1e] | 103 |         new Parameter<std::string>(
 | 
|---|
| [1bef07] | 104 |             ParamNames[freeze_coreParam],
 | 
|---|
 | 105 |             ValidFreezeCore,
 | 
|---|
 | 106 |             ValidFreezeCore[YES]));
 | 
|---|
 | 107 |   }
 | 
|---|
 | 108 | 
 | 
|---|
 | 109 |   // create units parameter
 | 
|---|
 | 110 |   {
 | 
|---|
 | 111 |     ValidUnits.clear();
 | 
|---|
 | 112 |     ValidUnits.resize(unknownUnits);
 | 
|---|
 | 113 |     ValidUnits[angstrom]="angstrom";
 | 
|---|
 | 114 |     ValidUnits[bohr]="bohr";
 | 
|---|
 | 115 |     appendParameter(
 | 
|---|
| [118f1e] | 116 |         new Parameter<std::string>(
 | 
|---|
| [1bef07] | 117 |             ParamNames[unitsParam],
 | 
|---|
 | 118 |             ValidUnits,
 | 
|---|
 | 119 |             ValidUnits[angstrom]));
 | 
|---|
 | 120 |   }
 | 
|---|
 | 121 | 
 | 
|---|
 | 122 |   // create dertype parameter
 | 
|---|
 | 123 |   {
 | 
|---|
 | 124 |     ValidDerivativeType.clear();
 | 
|---|
 | 125 |     ValidDerivativeType.resize(unknownDerivativeType);
 | 
|---|
 | 126 |     ValidDerivativeType[NONE]="none";
 | 
|---|
 | 127 |     appendParameter(
 | 
|---|
| [118f1e] | 128 |         new Parameter<std::string>(
 | 
|---|
| [1bef07] | 129 |             ParamNames[dertypeParam],
 | 
|---|
 | 130 |             ValidDerivativeType,
 | 
|---|
 | 131 |             ValidDerivativeType[NONE]));
 | 
|---|
 | 132 |   }
 | 
|---|
 | 133 | 
 | 
|---|
 | 134 |   // create unique_axis parameter
 | 
|---|
 | 135 |   {
 | 
|---|
 | 136 |     ValidUniqueAxis.clear();
 | 
|---|
 | 137 |     ValidUniqueAxis.resize(unknownUniqueAxis);
 | 
|---|
 | 138 |     ValidUniqueAxis[X]="x";
 | 
|---|
 | 139 |     ValidUniqueAxis[Y]="y";
 | 
|---|
 | 140 |     ValidUniqueAxis[Z]="z";
 | 
|---|
 | 141 |     appendParameter(
 | 
|---|
| [118f1e] | 142 |         new Parameter<std::string>(
 | 
|---|
| [1bef07] | 143 |             ParamNames[unique_axisParam],
 | 
|---|
 | 144 |             ValidUniqueAxis,
 | 
|---|
 | 145 |             ValidUniqueAxis[X]));
 | 
|---|
 | 146 |   }
 | 
|---|
 | 147 | 
 | 
|---|
 | 148 |   // create jobtype parameter
 | 
|---|
 | 149 |   {
 | 
|---|
 | 150 |     ValidJobtypes.clear();
 | 
|---|
 | 151 |     ValidJobtypes.resize(unknownJobtype);
 | 
|---|
 | 152 |     ValidJobtypes[SP]="sp";
 | 
|---|
 | 153 |     ValidJobtypes[OPT]="opt";
 | 
|---|
 | 154 |     ValidJobtypes[DISP]="disp";
 | 
|---|
 | 155 |     ValidJobtypes[FREQ]="freq";
 | 
|---|
 | 156 |     ValidJobtypes[SYMM_FREQ]="symm_freq";
 | 
|---|
 | 157 |     ValidJobtypes[DBOC]="dboc";
 | 
|---|
 | 158 |     ValidJobtypes[RESPONSE]="response";
 | 
|---|
 | 159 |     appendParameter(
 | 
|---|
| [118f1e] | 160 |         new Parameter<std::string>(
 | 
|---|
| [1bef07] | 161 |             ParamNames[jobtypeParam],
 | 
|---|
 | 162 |             ValidJobtypes,
 | 
|---|
 | 163 |             ValidJobtypes[SP]));
 | 
|---|
 | 164 |   }
 | 
|---|
 | 165 | 
 | 
|---|
 | 166 |   // create wavefunction parameter
 | 
|---|
 | 167 |   {
 | 
|---|
 | 168 |     ValidWavefunction.clear();
 | 
|---|
 | 169 |     ValidWavefunction.resize(unknownWavefunction);
 | 
|---|
 | 170 |     ValidWavefunction[SCF]="scf";
 | 
|---|
 | 171 |     ValidWavefunction[MP2]="mp2";
 | 
|---|
 | 172 |     ValidWavefunction[MP2R12]="mp2r12";
 | 
|---|
 | 173 |     ValidWavefunction[CIS]="cis";
 | 
|---|
 | 174 |     ValidWavefunction[DETCI]="detci";
 | 
|---|
 | 175 |     ValidWavefunction[CASSCF]="casscf";
 | 
|---|
 | 176 |     ValidWavefunction[RASSCF]="rasscf";
 | 
|---|
 | 177 |     ValidWavefunction[CCSD]="ccsd";
 | 
|---|
 | 178 |     ValidWavefunction[CCSD_T]="ccsd_t";
 | 
|---|
 | 179 |     ValidWavefunction[BCCD]="bccd";
 | 
|---|
 | 180 |     ValidWavefunction[BCCD_T]="bccd_t";
 | 
|---|
 | 181 |     ValidWavefunction[EOM_CCSD]="eom_ccsd";
 | 
|---|
 | 182 |     ValidWavefunction[ZAPTN]="zaptn";
 | 
|---|
 | 183 |     appendParameter(
 | 
|---|
| [118f1e] | 184 |         new Parameter<std::string>(
 | 
|---|
| [1bef07] | 185 |             ParamNames[wavefunctionParam],
 | 
|---|
 | 186 |             ValidWavefunction,
 | 
|---|
 | 187 |             ValidWavefunction[SCF]));
 | 
|---|
 | 188 |   }
 | 
|---|
 | 189 | 
 | 
|---|
 | 190 |   // create reference parameter
 | 
|---|
 | 191 |   {
 | 
|---|
 | 192 |     ValidReference.clear();
 | 
|---|
 | 193 |     ValidReference.resize(unknownReference);
 | 
|---|
 | 194 |     ValidReference[RHF]="rhf";
 | 
|---|
 | 195 |     ValidReference[ROHF]="rohf";
 | 
|---|
 | 196 |     ValidReference[UHF]="uhf";
 | 
|---|
 | 197 |     ValidReference[TWOCON]="twocon";
 | 
|---|
 | 198 |     appendParameter(
 | 
|---|
| [118f1e] | 199 |         new Parameter<std::string>(
 | 
|---|
| [1bef07] | 200 |             ParamNames[referenceParam],
 | 
|---|
 | 201 |             ValidReference,
 | 
|---|
 | 202 |             ValidReference[RHF]));
 | 
|---|
 | 203 |   }
 | 
|---|
 | 204 | 
 | 
|---|
 | 205 |   // add all continuous parameters
 | 
|---|
 | 206 |   {
 | 
|---|
| [118f1e] | 207 |     appendParameter(new Parameter<string>(ParamNames[labelParam], std::string("unknown job")));
 | 
|---|
 | 208 |     appendParameter(new Parameter<int>(ParamNames[maxiterParam], 80));
 | 
|---|
 | 209 |     appendParameter(new Parameter<string>(ParamNames[basisParam], std::string("cc-pVTZ")));
 | 
|---|
 | 210 |     appendParameter(new Parameter<string>(ParamNames[originParam], std::string("(0.0\t0.0\t0.0)"))); // TODO: this should be a vector
 | 
|---|
 | 211 |     appendParameter(new Parameter<int>(ParamNames[multiplicityParam], 1));
 | 
|---|
 | 212 |     appendParameter(new Parameter<int>(ParamNames[chargeParam], 0));
 | 
|---|
 | 213 |     appendParameter(new Parameter<string>(ParamNames[soccParam], std::string("()")));
 | 
|---|
 | 214 |     appendParameter(new Parameter<string>(ParamNames[doccParam], std::string("()")));
 | 
|---|
 | 215 |     appendParameter(new Parameter<string>(ParamNames[subgroupParam], std::string("")));
 | 
|---|
| [1bef07] | 216 |  }
 | 
|---|
 | 217 | }
 | 
|---|
 | 218 | 
 | 
|---|
 | 219 | Psi3Parser_Parameters::~Psi3Parser_Parameters()
 | 
|---|
 | 220 | {}
 | 
|---|
 | 221 | 
 | 
|---|
 | 222 | /** Getter for a specific Parameter.
 | 
|---|
 | 223 |  *
 | 
|---|
 | 224 |  * @param param index among enum Parameters
 | 
|---|
 | 225 |  * @return value of the desired Parameters
 | 
|---|
 | 226 |  */
 | 
|---|
 | 227 | const std::string Psi3Parser_Parameters::getParameter(const enum Parameters param) const
 | 
|---|
 | 228 | {
 | 
|---|
| [118f1e] | 229 |   return FormatParser_Parameters::getParameter(ParamNames[param])->getAsString();
 | 
|---|
| [1bef07] | 230 | }
 | 
|---|
 | 231 | 
 | 
|---|
 | 232 | /** Setter for a specific Parameter.
 | 
|---|
 | 233 |  *
 | 
|---|
 | 234 |  * @param param index among enum Parameters
 | 
|---|
 | 235 |  * @param _value value to set desired Parameter to
 | 
|---|
 | 236 |  */
 | 
|---|
 | 237 | void Psi3Parser_Parameters::setParameter(const enum Parameters param, const std::string &_value)
 | 
|---|
 | 238 | {
 | 
|---|
 | 239 |   const std::string &name = getParameterName(param);
 | 
|---|
| [118f1e] | 240 |   FormatParser_Parameters::getParameter(name)->setAsString(_value);
 | 
|---|
| [1bef07] | 241 | }
 | 
|---|
 | 242 | 
 | 
|---|
 | 243 | /** Getter for name of a specific Parameter.
 | 
|---|
 | 244 |  *
 | 
|---|
 | 245 |  * @param param index among enum Parameters
 | 
|---|
 | 246 |  * @return name of the desired Parameter
 | 
|---|
 | 247 |  */
 | 
|---|
 | 248 | const std::string &Psi3Parser_Parameters::getParameterName(const enum Parameters param) const
 | 
|---|
 | 249 | {
 | 
|---|
 | 250 |   return ParamNames[param];
 | 
|---|
 | 251 | }
 | 
|---|
 | 252 | 
 | 
|---|
| [c17091] | 253 | /** Getter for name of a specific Reference.
 | 
|---|
 | 254 |  *
 | 
|---|
 | 255 |  * @param reference index among enum Reference
 | 
|---|
 | 256 |  * @return name of the desired Reference
 | 
|---|
 | 257 |  */
 | 
|---|
 | 258 | const std::string &Psi3Parser_Parameters::getReferenceName(const enum Reference reference) const
 | 
|---|
 | 259 | {
 | 
|---|
 | 260 |   return ValidReference[reference];
 | 
|---|
 | 261 | }
 | 
|---|
 | 262 | 
 | 
|---|
| [1bef07] | 263 | /** Checks whether all elements in the world also have parameters in the basis.
 | 
|---|
 | 264 |  *
 | 
|---|
 | 265 |  * @return true - all elements parametrized, false - at least one element is missing.
 | 
|---|
 | 266 |  */
 | 
|---|
 | 267 | bool Psi3Parser_Parameters::checkWorldElementsAgainstCurrentBasis() const
 | 
|---|
 | 268 | {
 | 
|---|
| [47d041] | 269 |   ELOG(0, "Psi3Parser_Parameters::checkWorldElementsAgainstCurrentBasis() - not implemented yet.");
 | 
|---|
| [1bef07] | 270 | 
 | 
|---|
 | 271 |   return false;
 | 
|---|
 | 272 | }
 | 
|---|
 | 273 | 
 | 
|---|