- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/MpqcParser_Parameters.hpp
rc1db05 r7f570c 14 14 #endif 15 15 16 #include <iosfwd>17 16 #include <list> 18 #include < typeinfo>17 #include <map> 19 18 #include <vector> 20 19 21 20 #include "CodePatterns/Clone.hpp" 22 21 #include "CodePatterns/Log.hpp" 23 #include "CodePatterns/Verbose.hpp"24 25 #include <boost/any.hpp>26 22 27 23 #include "Parser/FormatParser_Parameters.hpp" 24 25 #include "Parser/Parameters/ContinuousParameter.hpp" 26 27 // specialization for bool (we want "yes/no" not "1/0") 28 template <> const std::string ContinuousValue<bool>::get() const; 29 template <> void ContinuousValue<bool>::set(const std::string _value); 28 30 29 31 class MpqcParser; … … 42 44 MpqcParser_Parameters(); 43 45 44 /** Copy Constructor of MpqcParser_Parameters.45 *46 * @param state ref to instance to copy47 */48 MpqcParser_Parameters(const MpqcParser_Parameters & state);49 50 46 /** Destructor of MpqcParser_Parameters. 51 47 * 52 48 */ 53 49 virtual ~MpqcParser_Parameters(); 50 51 /** Enumeration of all known Parameters to allow placing them in vectors, maps. 52 * 53 */ 54 enum Parameters { 55 hessianParam, //!< HessianParam, whether hessian should be calculated or not 56 savestateParam, //!< savestateParam, whether intermediate/final states (wave function) should be stored 57 do_gradientParam,//!< do_gradientParam, whether a gradient should be calculated 58 maxiterParam, //!< maxiterParam, number of maximum iterations for CG 59 memoryParam, //!< memoryParam, maximum amount of memory to use 60 stdapproxParam, //!< stdapproxParam, standard approximation in MBPT2 R12 61 nfzcParam, //!< nfzcParam, nfzc parameter in MBPT2 R12 62 basisParam, //!< basisParam, basis set to use 63 aux_basisParam, //!< aux_basisParam, auxiliary baseis set to use in MBPT2 R12 64 integrationParam,//!< integrationParam, integration method to use in MBPT2 R12 65 theoryParam, //!< theoryParam, level of theory to use 66 unknownParam}; //!< unknownParam, designates an unknown parameter 54 67 55 68 /** Enumeration of all known theories. … … 72 85 }; 73 86 74 /** Enumeration of all known Parameters to allow placing them in vectors, maps. 75 * 76 */ 77 enum Parameters { 78 hessianParam, //!< HessianParam, whether hessian should be calculated or not 79 savestateParam, //!< savestateParam, whether intermediate/final states (wave function) should be stored 80 do_gradientParam,//!< do_gradientParam, whether a gradient should be calculated 81 maxiterParam, //!< maxiterParam, number of maximum iterations for CG 82 memoryParam, //!< memoryParam, maximum amount of memory to use 83 stdapproxParam, //!< stdapproxParam, standard approximation in MBPT2 R12 84 nfzcParam, //!< nfzcParam, nfzc parameter in MBPT2 R12 85 basisParam, //!< basisParam, basis set to use 86 aux_basisParam, //!< aux_basisParam, auxiliary baseis set to use in MBPT2 R12 87 integrationParam,//!< integrationParam, integration method to use in MBPT2 R12 88 theoryParam, //!< theoryParam, level of theory to use 89 unknownParam}; //!< unknownParam, designates an unknown parameter 87 // enum to string getters 88 const std::string getParameter(const enum Parameters param) const; 89 void setParameter(const enum Parameters param, const std::string &); 90 const std::string &getParameterName(const enum Parameters param) const; 91 const std::string &getTheoryName(const enum Theory theory) const; 92 const std::string &getIntegrationMethodName(const enum IntegrationMethod integration) const; 93 94 private: 95 96 97 //!> vector with all available theories in same order as enum Theory. 98 std::vector<std::string> ValidTheories; 99 100 //!> vector with all available integration methods in same order as enum IntegrationMethod. 101 std::vector<std::string> ValidIntegrationMethods; 90 102 91 103 bool checkWorldElementsAgainstCurrentBasis() const; 92 104 93 /** Sets the desired level of solving theory to use.94 *95 * \param _theory shorthand of the theory96 */97 void setTheory(enum Theory _theory);98 99 /** Sets the desired level of solving integration to use.100 *101 * \param _integration shorthand of the integration102 */103 void setIntegration(enum IntegrationMethod _integration);104 105 /** Getter for integration method in params.106 *107 * @return enumeration index of IntegrationMethod.108 */109 enum IntegrationMethod getIntegration() const;110 111 /** Getter for current Theory in params.112 *113 * @return enumeration index of Theory114 */115 enum Theory getTheory() const;116 117 /** Getter for a parameter in params as a string.118 *119 * @param _param enumeration index of desired Parameter120 * @return string value121 */122 std::string getString(enum Parameters _param) const;123 124 /** Getter for integer value of desired Parameter in params.125 *126 * Only if type in params matches int!127 *128 * @param _param enumeration index in Parameter129 * @return integer value of parameter130 */131 int getInt(enum Parameters _param) const;132 133 /** Getter for double value of desired Parameter in params.134 *135 * Only if type in params matches double!136 *137 * @param _param enumeration index in Parameter138 * @return double value of parameter139 */140 double getDouble(enum Parameters _param) const;141 142 /** Getter for bool value of desired Parameter in params.143 *144 * Only if type in params matches bool!145 *146 * @param _param enumeration index in Parameter147 * @return bool value of parameter148 */149 bool getBool(enum Parameters _param) const;150 151 /** Setter for a desired value of its type is known.152 *153 * We check whether given type matches present type in params.154 *155 * @param _param enumeration index of Parameter156 * @param _desired desired value to set to157 * @return true - type match, value set, false - type mismatch158 */159 template <class T> bool setter(enum Parameters _param, T _desired) {160 if (typeid(T) == params[_param].type()) {161 params[_param] = _desired;162 return true;163 } else164 return false;165 }166 167 /** Sets a desired value in the params from a string.168 *169 * This is due to strict typing of C++ very ugly and boost::any does not make170 * it any better because it offers to functions to use values directly from171 * stringstream. Probably, because value is unknown to is as well and hence172 * the author could not implement it beautifully, so he dropped it altogether.173 * Grrr ....174 *175 * @param _param param to set176 * @param _desired stringstream containing value as next argument177 * @return true - type ok, false - unknown type in params.178 */179 bool setter(enum Parameters _param, std::stringstream& _desired);180 181 /** Grants access to ParamLookup.182 *183 * Does not check for unknown parameter.184 *185 * @param _name name of parameter186 * @return enumeration index of Parameters187 */188 enum Parameters getParam(std::string _name) const;189 190 /** Checker whether parameter with name is known.191 *192 * @param _name193 * @return true - parameter known, false - parameter unknown194 */195 bool haveParam(std::string _name) const;196 197 /** Creates a clone of the class.198 *199 * @return200 */201 FormatParser_Parameters* clone() const;202 203 /** Applies a before returned undo state.204 *205 * @param undo state to set206 */207 void makeClone(const FormatParser_Parameters & _state);208 209 /** Set the internal parameters to the one's from the given \a state.210 *211 * @param state set of parameters212 */213 void copyParameters(const MpqcParser_Parameters & state);214 215 private:216 105 /** Global initialization in cstor. 217 106 * … … 224 113 void initBasis(); 225 114 226 /** Initializes params. 227 * Sets the type and the associated enumeration index. 228 */ 229 void initParameters(); 115 //!> vector with all parameter names in same order as enum Parameters 116 std::vector<std::string> ParamNames; 230 117 231 /** Internal function used by initParameters() to add parameters to params. 232 * 233 * @param _enum enumeration index to set 234 * @param _p (default) value to set with certain type 235 */ 236 template <class T> void appendParameter(enum Parameters _enum, T _p) { 237 boost::any _p_value = _p; 238 params[_enum] = _p_value; 239 } 118 //!> typedef for the list of all available basis sets 119 typedef std::map<std::string, std::list<std::string> > BasisMapType; 240 120 241 // all internal typedefs for lists below 242 typedef std::map<std::string, std::list<std::string> > BasisMapType; 243 typedef std::map<enum Theory, std::string> TheoryNamesType; 244 typedef std::map<std::string, enum Theory> TheoryLookupType; 245 typedef std::map<enum IntegrationMethod, std::string> IntegrationNamesType; 246 typedef std::map<std::string, enum IntegrationMethod> IntegrationLookupType; 247 typedef std::map<enum Parameters, std::string> ParamNamesType; 248 typedef std::map<std::string, enum Parameters> ParamLookupType; 249 typedef std::map<enum Parameters, boost::any> parameterlist; 250 251 //!> boost::any container for all the parameters 252 parameterlist params; 253 254 // maps from names to enumerations 255 256 //!> contains basis and all elements the basis knows about 121 //!> list of all basis along with their present element parametrization 257 122 BasisMapType BasisList; 258 //!> contains the name of a theory as string259 TheoryNamesType TheoryNames;260 //!> contains a lookup from theory name to enumeration index261 TheoryLookupType TheoryLookup;262 //!> contains the name of an integration method as string263 IntegrationNamesType IntegrationNames;264 //!> contains a lookup from integration method name to enumeration index265 IntegrationLookupType IntegrationLookup;266 //!> contains the name of a parameter267 ParamNamesType ParamNames;268 //!> contains a lookup from parameter name to enumeration index269 ParamLookupType ParamLookup;270 123 }; 271 124 272 /** Output operator for the contents of MpqcParser_Parameters::params.273 *274 * @param ost output stream275 * @param params reference to MpqcParser_Parameters containing params.276 * @return reference to output stream for concatenation277 */278 std::ostream & operator << (std::ostream& ost, const MpqcParser_Parameters ¶ms);279 280 /** Input operator for a list of parameters to place into \a params.281 *282 * @param ist input stream283 * @param params parameters to parse into284 * @return input stream for concatenation285 */286 std::istream & operator >> (std::istream& ist, MpqcParser_Parameters ¶ms);287 288 125 #endif /* MPQCPARSER_PARAMETERS_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.