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