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