source: src/Parser/MpqcParser_Parameters.cpp@ e45c1d

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since e45c1d was e45c1d, checked in by Frederik Heber <heber@…>, 13 years ago

Added ParameterExceptions, is caught by Dialog::checkAll() for the moment.

  • Property mode set to 100644
File size: 5.2 KB
Line 
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 * 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
22#include <string>
23
24#include "CodePatterns/Log.hpp"
25
26#include "MpqcParser.hpp"
27#include "MpqcParser_Parameters.hpp"
28
29#include "Parameters/Parameter.hpp"
30
31template <>
32const std::string Value<bool>::getAsString() const throw(ParameterValueException)
33{
34 if(!ValueSet)
35 throw ParameterValueException();
36 if (value)
37 return std::string("yes");
38 else
39 return std::string("no");
40}
41
42template <>
43void Value<bool>::setAsString(const std::string _value) throw(ParameterException)
44{
45 if (_value == std::string("yes")) {
46 set(true);
47 } else if (_value == std::string("no")) {
48 set(false);
49 } else {
50 throw ParameterValueException();
51 }
52}
53
54
55MpqcParser_Parameters::MpqcParser_Parameters()
56{
57 Init();
58}
59
60void MpqcParser_Parameters::Init()
61{
62 // add all known basis
63 initBasis();
64
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 }
81
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(
91 new Parameter<std::string>(
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(
104 new Parameter<std::string>(
105 ParamNames[integrationParam],
106 ValidIntegrationMethods,
107 ValidIntegrationMethods[IntegralCints]));
108 }
109
110 // add all continuous parameters
111 {
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"));
121 }
122}
123
124MpqcParser_Parameters::~MpqcParser_Parameters()
125{}
126
127/** Getter for a specific Parameter.
128 *
129 * @param param index among enum Parameters
130 * @return value of the desired Parameters
131 */
132const std::string MpqcParser_Parameters::getParameter(const enum Parameters param) const
133{
134 return FormatParser_Parameters::getParameter(ParamNames[param])->getAsString();
135}
136
137/** Setter for a specific Parameter.
138 *
139 * @param param index among enum Parameters
140 * @param _value value to set desired Parameter to
141 */
142void MpqcParser_Parameters::setParameter(const enum Parameters param, const std::string &_value)
143{
144 const std::string &name = getParameterName(param);
145 FormatParser_Parameters::getParameter(name)->setAsString(_value);
146}
147
148/** Getter for name of a specific Parameter.
149 *
150 * @param param index among enum Parameters
151 * @return name of the desired Parameter
152 */
153const std::string &MpqcParser_Parameters::getParameterName(const enum Parameters param) const
154{
155 return ParamNames[param];
156}
157
158/** Getter for name of a specific Parameter.
159 *
160 * @param param index among enum Theory
161 * @return name of the desired Theory
162 */
163const std::string &MpqcParser_Parameters::getTheoryName(const enum Theory theory) const
164{
165 return ValidTheories[theory];
166}
167
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 */
173const std::string &MpqcParser_Parameters::getIntegrationMethodName(const enum IntegrationMethod integration) const
174{
175 return ValidIntegrationMethods[integration];
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 */
182bool MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() const
183{
184 ELOG(0, "MpqcParser_Parameters::checkWorldElementsAgainstCurrentBasis() - not implemented yet.");
185
186 return false;
187}
188
Note: See TracBrowser for help on using the repository browser.