MADNESS  0.10.1
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
madness::QCCalculationParametersBase Class Reference

class for holding the parameters for calculation More...

#include <QCCalculationParametersBase.h>

Inheritance diagram for madness::QCCalculationParametersBase:
Inheritance graph
[legend]

Public Member Functions

bool file_exists (World &world, std::string filename) const
 
void from_json (const json &j)
 
template<typename T >
T get (const std::string key) const
 
ParameterContainerT get_all_parameters () const
 
QCParameterget_parameter (const std::string key)
 
hashT hash () const
 
bool is_user_defined (std::string key) const
 
bool operator== (const QCCalculationParametersBase &other) const
 
bool parameter_exists (const std::string &key) const
 
void print (const std::string header="", const std::string footer="") const
 print all parameters More...
 
std::string print_to_string (bool non_defaults_only=false) const
 
virtual void read_internal (World &world, std::string &filecontents, std::string tag)
 read the stream, starting from tag More...
 
template<typename Archive >
void serialize (Archive &ar)
 
template<typename T >
void set_derived_value (const std::string &key, const T &value)
 
template<typename T >
void set_user_defined_value (const std::string &key, const T &value)
 
json to_json () const
 
void to_json (json &j) const
 

Static Public Member Functions

static std::string add_quotes (const std::string arg)
 
template<typename T >
static bool check_type (const std::string key, const QCParameter &parameter)
 
template<typename T >
static bool check_type_silent (const QCParameter &parameter)
 
template<typename T >
static std::enable_if<!std::is_same< T, bool >::value, T >::type fromstring (const std::string &arg)
 
template<typename T >
static std::enable_if< std::is_same< T, bool >::value, T >::type fromstring (const std::string &arg)
 
template<typename T >
static std::enable_if< std::is_floating_point< T >::value, void >::type overwrite_if_inf (std::string &str, const T &arg)
 
template<typename T >
static std::enable_if<!std::is_floating_point< T >::value, void >::type overwrite_if_inf (std::string &str, const T &arg)
 
template<typename T >
static std::enable_if< std::is_same< T, std::string >::value, T >::type read_quotes (std::stringstream &ssvalue)
 
template<typename T >
static std::enable_if<!std::is_same< T, std::string >::value, T >::type read_quotes (std::stringstream &ssvalue)
 
static std::string tostring (const bool &arg)
 
template<typename T >
static std::string tostring (const T &arg)
 
static std::string trim_blanks (const std::string arg)
 
static std::string trim_quotes (const std::string arg)
 

Protected Types

typedef std::map< std::string, QCParameterParameterContainerT
 

Protected Member Functions

 QCCalculationParametersBase ()
 ctor for testing More...
 
 QCCalculationParametersBase (const QCCalculationParametersBase &other)
 copy ctor More...
 
virtual ~QCCalculationParametersBase ()
 destructor More...
 
const QCParameterget_parameter (const std::string key) const
 
template<typename T >
void initialize (const std::string &key, const T &value, const std::string comment="", const std::vector< T > allowed_values={})
 
virtual void read_input_and_commandline_options (World &world, const commandlineparser &parser, const std::string tag)
 
template<typename T >
bool try_setting_user_defined_value (const std::string &key, const std::string &val)
 

Protected Attributes

bool ignore_unknown_keys =true
 
bool ignore_unknown_keys_silently =false
 
ParameterContainerT parameters
 
bool print_debug =false
 
bool throw_if_datagroup_not_found =true
 

Private Member Functions

void read_commandline_options (World &world, const commandlineparser &parser, const std::string tag)
 read the parameters from the command line and broadcast More...
 
void read_input (World &world, const std::string filename, const std::string tag)
 read the parameters from file More...
 

Detailed Description

class for holding the parameters for calculation

Actual parameter classes will be derived from this class with a simple constructor (see test_QCCalculationParametersBase.cc for an example) and convenience getters for the parameters of each parameter class. Having the base class will allow consistent parameter input/output handling for all madness programs and reuse of the parsing methods. Even if the same parameter is used in different programs, default might differ (i.e. econv for 3D/6D calculations). The parameter class will effectively serve as a factory for the calculation classes (SCF, nemo, mp2, etc)

parameters are kept in a map with key (string) and value (QCParameter), types are converted whenever a parameter is accessed (i.e. should not be done too frequently in an inner loop)

Member Typedef Documentation

◆ ParameterContainerT

Constructor & Destructor Documentation

◆ QCCalculationParametersBase() [1/2]

madness::QCCalculationParametersBase::QCCalculationParametersBase ( )
inlineprotected

ctor for testing

◆ QCCalculationParametersBase() [2/2]

madness::QCCalculationParametersBase::QCCalculationParametersBase ( const QCCalculationParametersBase other)
inlineprotected

copy ctor

◆ ~QCCalculationParametersBase()

virtual madness::QCCalculationParametersBase::~QCCalculationParametersBase ( )
inlineprotectedvirtual

destructor

Member Function Documentation

◆ add_quotes()

static std::string madness::QCCalculationParametersBase::add_quotes ( const std::string  arg)
inlinestatic

References madness::arg().

Referenced by get().

◆ check_type()

template<typename T >
static bool madness::QCCalculationParametersBase::check_type ( const std::string  key,
const QCParameter parameter 
)
inlinestatic

◆ check_type_silent()

template<typename T >
static bool madness::QCCalculationParametersBase::check_type_silent ( const QCParameter parameter)
inlinestatic

◆ file_exists()

bool madness::QCCalculationParametersBase::file_exists ( World world,
std::string  filename 
) const

◆ from_json()

void madness::QCCalculationParametersBase::from_json ( const json j)
inline

◆ fromstring() [1/2]

template<typename T >
static std::enable_if<!std::is_same<T,bool>::value, T>::type madness::QCCalculationParametersBase::fromstring ( const std::string &  arg)
inlinestatic

References madness::arg(), errmsg(), T(), and tostring().

◆ fromstring() [2/2]

template<typename T >
static std::enable_if<std::is_same<T,bool>::value, T>::type madness::QCCalculationParametersBase::fromstring ( const std::string &  arg)
inlinestatic

References madness::arg(), errmsg(), T(), and transform().

◆ get()

template<typename T >
T madness::QCCalculationParametersBase::get ( const std::string  key) const
inline

◆ get_all_parameters()

ParameterContainerT madness::QCCalculationParametersBase::get_all_parameters ( ) const
inline

References parameters.

Referenced by madness::Molecule::read().

◆ get_parameter() [1/2]

QCParameter& madness::QCCalculationParametersBase::get_parameter ( const std::string  key)
inline

◆ get_parameter() [2/2]

const QCParameter& madness::QCCalculationParametersBase::get_parameter ( const std::string  key) const
inlineprotected

◆ hash()

hashT madness::QCCalculationParametersBase::hash ( ) const
inline

◆ initialize()

template<typename T >
void madness::QCCalculationParametersBase::initialize ( const std::string &  key,
const T value,
const std::string  comment = "",
const std::vector< T allowed_values = {} 
)
inlineprotected

◆ is_user_defined()

bool madness::QCCalculationParametersBase::is_user_defined ( std::string  key) const
inline

◆ operator==()

bool madness::QCCalculationParametersBase::operator== ( const QCCalculationParametersBase other) const
inline

References get(), p(), and parameters.

◆ overwrite_if_inf() [1/2]

template<typename T >
static std::enable_if<std::is_floating_point<T>::value, void>::type madness::QCCalculationParametersBase::overwrite_if_inf ( std::string &  str,
const T arg 
)
inlinestatic

References madness::arg().

Referenced by tostring().

◆ overwrite_if_inf() [2/2]

template<typename T >
static std::enable_if<!std::is_floating_point<T>::value, void>::type madness::QCCalculationParametersBase::overwrite_if_inf ( std::string &  str,
const T arg 
)
inlinestatic

◆ parameter_exists()

bool madness::QCCalculationParametersBase::parameter_exists ( const std::string &  key) const
inline

References parameters.

Referenced by get_parameter(), and read_internal().

◆ print()

void madness::QCCalculationParametersBase::print ( const std::string  header = "",
const std::string  footer = "" 
) const

◆ print_to_string()

std::string madness::QCCalculationParametersBase::print_to_string ( bool  non_defaults_only = false) const

◆ read_commandline_options()

void madness::QCCalculationParametersBase::read_commandline_options ( World world,
const commandlineparser parser,
const std::string  tag 
)
private

read the parameters from the command line and broadcast

syntax is: qcprogram –mp2='maxiter 10; freeze 1' –dft:maxiter=20 –Xmpi:debug=true the argument in quotes is the value of the parser keys

References madness::WorldGopInterface::broadcast_serializable(), madness::World::gop, madness::commandlineparser::key_exists(), q(), madness::World::rank(), read_internal(), and madness::commandlineparser::value().

Referenced by read_input_and_commandline_options().

◆ read_input()

void madness::QCCalculationParametersBase::read_input ( World world,
const std::string  filename,
const std::string  tag 
)
private

read the parameters from file

read the parameters from file and broadcast

only world.rank()==0 reads the input file and broadcasts to all other nodes, so we don't need to serialize the ParameterMap

References madness::WorldGopInterface::broadcast_serializable(), e(), errmsg(), madness::f, madness::filename, madness::World::gop, madness::World::rank(), and read_internal().

Referenced by read_input_and_commandline_options().

◆ read_input_and_commandline_options()

virtual void madness::QCCalculationParametersBase::read_input_and_commandline_options ( World world,
const commandlineparser parser,
const std::string  tag 
)
inlineprotectedvirtual

◆ read_internal()

void madness::QCCalculationParametersBase::read_internal ( World world,
std::string &  filecontents,
std::string  tag 
)
virtual

read the stream, starting from tag

only parameters that are defined in the constructor will be processed, all others will be discarded.

References e(), errmsg(), madness::f, get_parameter(), madness::QCParameter::get_type(), ignore_unknown_keys, ignore_unknown_keys_silently, parameter_exists(), madness::position_stream_to_word(), madness::print(), print(), print_debug, madness::World::rank(), and transform().

Referenced by read_commandline_options(), and read_input().

◆ read_quotes() [1/2]

template<typename T >
static std::enable_if<std::is_same<T,std::string>::value, T>::type madness::QCCalculationParametersBase::read_quotes ( std::stringstream &  ssvalue)
inlinestatic

◆ read_quotes() [2/2]

template<typename T >
static std::enable_if<!std::is_same<T,std::string>::value, T>::type madness::QCCalculationParametersBase::read_quotes ( std::stringstream &  ssvalue)
inlinestatic

References T().

◆ serialize()

template<typename Archive >
void madness::QCCalculationParametersBase::serialize ( Archive &  ar)
inline

References parameters, and print_debug.

◆ set_derived_value()

template<typename T >
void madness::QCCalculationParametersBase::set_derived_value ( const std::string &  key,
const T value 
)
inline

◆ set_user_defined_value()

template<typename T >
void madness::QCCalculationParametersBase::set_user_defined_value ( const std::string &  key,
const T value 
)
inline

◆ to_json() [1/2]

json madness::QCCalculationParametersBase::to_json ( ) const
inline

References p(), and parameters.

Referenced by madness::operator==(), and TEST_CASE().

◆ to_json() [2/2]

void madness::QCCalculationParametersBase::to_json ( json j) const
inline

Adds the response parameters to an existing json under key "parameters"

Parameters
j

References p(), and parameters.

◆ tostring() [1/2]

static std::string madness::QCCalculationParametersBase::tostring ( const bool &  arg)
inlinestatic

◆ tostring() [2/2]

template<typename T >
static std::string madness::QCCalculationParametersBase::tostring ( const T arg)
inlinestatic

◆ trim_blanks()

static std::string madness::QCCalculationParametersBase::trim_blanks ( const std::string  arg)
inlinestatic

References madness::arg().

Referenced by read_quotes().

◆ trim_quotes()

static std::string madness::QCCalculationParametersBase::trim_quotes ( const std::string  arg)
inlinestatic

References madness::arg().

Referenced by read_quotes().

◆ try_setting_user_defined_value()

template<typename T >
bool madness::QCCalculationParametersBase::try_setting_user_defined_value ( const std::string &  key,
const std::string &  val 
)
inlineprotected

Member Data Documentation

◆ ignore_unknown_keys

bool madness::QCCalculationParametersBase::ignore_unknown_keys =true
protected

◆ ignore_unknown_keys_silently

bool madness::QCCalculationParametersBase::ignore_unknown_keys_silently =false
protected

◆ parameters

ParameterContainerT madness::QCCalculationParametersBase::parameters
protected

◆ print_debug

bool madness::QCCalculationParametersBase::print_debug =false
protected

◆ throw_if_datagroup_not_found

bool madness::QCCalculationParametersBase::throw_if_datagroup_not_found =true
protected

The documentation for this class was generated from the following files: