source: src/Parser/MpqcParser_Parameters.hpp@ 963321a

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 963321a was 44fce5, checked in by Frederik Heber <heber@…>, 14 years ago

Extended MpqcParser_Parameters, can set and get all values.

  • Property mode set to 100644
File size: 8.0 KB
Line 
1/*
2 * MpqcParser_Parameters.hpp
3 *
4 * Created on: Feb 3, 2011
5 * Author: heber
6 */
7
8#ifndef MPQCPARSER_PARAMETERS_HPP_
9#define MPQCPARSER_PARAMETERS_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <iosfwd>
17#include <list>
18#include <typeinfo>
19#include <vector>
20
21#include "CodePatterns/Log.hpp"
22#include "CodePatterns/Verbose.hpp"
23
24#include <boost/any.hpp>
25
26
27class MpqcParser;
28
29class MpqcParser_Parameters
30{
31 // MpqcParser should be friend to access params directly for types.
32 friend class MpqcParser;
33 // ParserMpqcUnitTest needs to be friend to check types contained in params.
34 friend class ParserMpqcUnitTest;
35
36public:
37 /** Constructor of MpqcParser_Parameters.
38 *
39 */
40 MpqcParser_Parameters();
41
42 /** Destructor of MpqcParser_Parameters.
43 *
44 */
45 ~MpqcParser_Parameters();
46
47 /** Enumeration of all known theories.
48 *
49 */
50 enum Theory {
51 CLHF, //!< Closed Shell Hartree-Fock equations
52 CLKS, //!< Closed Shell Kohn-Sham equations
53 MBPT2, //!< Moeller Plesset Perturbation Theory second order
54 MBPT2_R12, //!< Moeller Plesset Perturbation Theory second order with R12 integral
55 unknownTheory //!< designates an unknown theory
56 };
57
58 /** Enumeration of all known integration methods
59 *
60 */
61 enum IntegrationMethod {
62 IntegralCints, //!< Integration method Cints in MBPT2 R12?
63 unknownIntegration //!< designates unknown integration method
64 };
65
66 /** Enumeration of all known Parameters to allow placing them in vectors, maps.
67 *
68 */
69 enum Parameters {
70 hessianParam, //!< HessianParam, whether hessian should be calculated or not
71 savestateParam, //!< savestateParam, whether intermediate/final states (wave function) should be stored
72 do_gradientParam,//!< do_gradientParam, whether a gradient should be calculated
73 maxiterParam, //!< maxiterParam, number of maximum iterations for CG
74 memoryParam, //!< memoryParam, maximum amount of memory to use
75 stdapproxParam, //!< stdapproxParam, standard approximation in MBPT2 R12
76 nfzcParam, //!< nfzcParam, nfzc parameter in MBPT2 R12
77 basisParam, //!< basisParam, basis set to use
78 aux_basisParam, //!< aux_basisParam, auxiliary baseis set to use in MBPT2 R12
79 integrationParam,//!< integrationParam, integration method to use in MBPT2 R12
80 theoryParam, //!< theoryParam, level of theory to use
81 unknownParam}; //!< unknownParam, designates an unknown parameter
82
83 bool checkWorldElementsAgainstCurrentBasis() const;
84
85 /** Sets the desired level of solving theory to use.
86 *
87 * \param _theory shorthand of the theory
88 */
89 void setTheory(enum Theory _theory);
90
91 /** Sets the desired level of solving integration to use.
92 *
93 * \param _integration shorthand of the integration
94 */
95 void setIntegration(enum IntegrationMethod _integration);
96
97 /** Getter for integration method in params.
98 *
99 * @return enumeration index of IntegrationMethod.
100 */
101 enum IntegrationMethod getIntegration();
102
103 /** Getter for current Theory in params.
104 *
105 * @return enumeration index of Theory
106 */
107 enum Theory getTheory();
108
109 /** Getter for a parameter in params as a string.
110 *
111 * @param _param enumeration index of desired Parameter
112 * @return string value
113 */
114 std::string getString(enum Parameters _param);
115
116 /** Getter for integer value of desired Parameter in params.
117 *
118 * Only if type in params matches int!
119 *
120 * @param _param enumeration index in Parameter
121 * @return integer value of parameter
122 */
123 int getInt(enum Parameters _param);
124
125 /** Getter for double value of desired Parameter in params.
126 *
127 * Only if type in params matches double!
128 *
129 * @param _param enumeration index in Parameter
130 * @return double value of parameter
131 */
132 double getDouble(enum Parameters _param);
133
134 /** Getter for bool value of desired Parameter in params.
135 *
136 * Only if type in params matches bool!
137 *
138 * @param _param enumeration index in Parameter
139 * @return bool value of parameter
140 */
141 bool getBool(enum Parameters _param);
142
143 /** Setter for a desired value of its type is known.
144 *
145 * We check whether given type matches present type in params.
146 *
147 * @param _param enumeration index of Parameter
148 * @param _desired desired value to set to
149 * @return true - type match, value set, false - type mismatch
150 */
151 template <class T> bool setter(enum Parameters _param, T _desired) {
152 if (typeid(T) == params[_param].type()) {
153 params[_param] = _desired;
154 return true;
155 } else
156 return false;
157 }
158
159 /** Sets a desired value in the params from a string.
160 *
161 * This is due to strict typing of C++ very ugly and boost::any does not make
162 * it any better because it offers to functions to use values directly from
163 * stringstream. Probably, because value is unknown to is as well and hence
164 * the author could not implement it beautifully, so he dropped it altogether.
165 * Grrr ....
166 *
167 * @param _param param to set
168 * @param _desired stringstream containing value as next argument
169 * @return true - type ok, false - unknown type in params.
170 */
171 bool setter(enum Parameters _param, std::stringstream& _desired);
172
173 /** Grants access to ParamLookup.
174 *
175 * Does not check for unknown parameter.
176 *
177 * @param _name name of parameter
178 * @return enumeration index of Parameters
179 */
180 enum Parameters getParam(std::string _name);
181
182 /** Checker whether parameter with name is known.
183 *
184 * @param _name
185 * @return true - parameter known, false - parameter unknown
186 */
187 bool haveParam(std::string _name) const;
188
189private:
190 /** Initializes BasisList.
191 *
192 */
193 void initBasis();
194
195 /** Initializes params.
196 * Sets the type and the associated enumeration index.
197 */
198 void initParameters();
199
200 /** Internal function used by initParameters() to add parameters to params.
201 *
202 * @param _enum enumeration index to set
203 * @param _p (default) value to set with certain type
204 */
205 template <class T> void appendParameter(enum Parameters _enum, T _p) {
206 boost::any _p_value = _p;
207 params[_enum] = _p_value;
208 }
209
210 // all internal typedefs for lists below
211 typedef std::map<std::string, std::list<std::string> > BasisMapType;
212 typedef std::map<enum Theory, std::string> TheoryNamesType;
213 typedef std::map<std::string, enum Theory> TheoryLookupType;
214 typedef std::map<enum IntegrationMethod, std::string> IntegrationNamesType;
215 typedef std::map<std::string, enum IntegrationMethod> IntegrationLookupType;
216 typedef std::map<enum Parameters, std::string> ParamNamesType;
217 typedef std::map<std::string, enum Parameters> ParamLookupType;
218 typedef std::map<enum Parameters, boost::any> parameterlist;
219
220 //!> boost::any container for all the parameters
221 parameterlist params;
222
223 // maps from names to enumerations
224
225 //!> contains basis and all elements the basis knows about
226 BasisMapType BasisList;
227 //!> contains the name of a theory as string
228 TheoryNamesType TheoryNames;
229 //!> contains a lookup from theory name to enumeration index
230 TheoryLookupType TheoryLookup;
231 //!> contains the name of an integration method as string
232 IntegrationNamesType IntegrationNames;
233 //!> contains a lookup from integration method name to enumeration index
234 IntegrationLookupType IntegrationLookup;
235 //!> contains the name of a parameter
236 ParamNamesType ParamNames;
237 //!> contains a lookup from parameter name to enumeration index
238 ParamLookupType ParamLookup;
239};
240
241/** Output operator for the contents of MpqcParser_Parameters::params.
242 *
243 * @param ost output stream
244 * @param params reference to MpqcParser_Parameters containing params.
245 * @return reference to output stream for concatenation
246 */
247std::ostream & operator << (std::ostream& ost, const MpqcParser_Parameters &params);
248
249/** Input operator for a list of parameters to place into \a params.
250 *
251 * @param ist input stream
252 * @param params parameters to parse into
253 * @return input stream for concatenation
254 */
255std::istream & operator >> (std::istream& ist, MpqcParser_Parameters &params);
256
257#endif /* MPQCPARSER_PARAMETERS_HPP_ */
Note: See TracBrowser for help on using the repository browser.