Documentation

UnitFactory produces Unit objects that refer to a particular system of fundamental constants. UnitFactory is a helper class to ensure that all unit conversions are consistent, i.e. refer to the same system of fundamental constants. Since fundamental constants are updated every few years, it is mandatory to use UnitFactory to produce Unit objects, rather than create them directly. Since typically only 1 UnitFactory needs to be used in the entire program, the UnitFactory should be used as a singleton:

int main() {
UnitFactory::set_default("CODATA2010"); // set the 2010 CODATA revision as default
...
auto angstrom = UnitFactory::get_default().make_unit("angstrom");
}

Public Member Functions

 UnitFactory (std::string system)
 
 ~UnitFactory ()
 
const std::string & system () const
 
std::shared_ptr< const detail::FundamentalConstants< double > > constants () const
 
const char * description () const
 
Unit make_unit (const std::string &unit_str) const
 

Static Public Member Functions

static std::shared_ptr< const UnitFactoryget_default ()
 
static void set_default (const std::string &system)
 

Constructor & Destructor Documentation

◆ UnitFactory()

mpqc::UnitFactory::UnitFactory ( std::string  system)

Creates a UnitFactory object corresponding to the given fundamental constants system.

Parameters
systemspecifies the fundamental constants system, the allowed values are:
  • "2018CODATA" : the 2018 revision of the fundamental constants
  • "2014CODATA" : the 2014 revision of the fundamental constants (see DOI 10.1103/RevModPhys.88.035009 )
  • "2010CODATA" : the 2010 revision of the fundamental constants (see DOI 10.1103/RevModPhys.84.1527 )
  • "2006CODATA" : the 2006 revision of the fundamental constants (see DOI 10.1103/RevModPhys.80.633 ) (the default of Gaussian09)
  • "MPQC2" : the values of constants used by MPQC version 2.3

The default is currently "2018CODATA", and may be revised in the future.

◆ ~UnitFactory()

mpqc::UnitFactory::~UnitFactory ( )
inline

Member Function Documentation

◆ constants()

std::shared_ptr<const detail::FundamentalConstants<double> > mpqc::UnitFactory::constants ( ) const
inline
Returns
a shared_ptr to the fundamental constants system object

◆ description()

const char* mpqc::UnitFactory::description ( ) const
inline
Returns
the description of the fundamental constants system

◆ get_default()

std::shared_ptr< const UnitFactory > mpqc::UnitFactory::get_default ( )
static
Returns
the singleton UnitFactory object (default initialized with 2018CODATA fundamental constants)

◆ make_unit()

Unit mpqc::UnitFactory::make_unit ( const std::string &  unit_str) const

makes a Unit object from a given string specification, using the system of fundamental constants specified by this factory.

Parameters
unit_strthe string specification of the desired Unit. See The Units Library section.
Returns
the Unit object

◆ set_default()

void mpqc::UnitFactory::set_default ( const std::string &  system)
static

sets the singleton UnitFactory object

Parameters
systemspecifies the fundamental constants system, must be acceptable as the input to UnitFactory::UnitFactory() ctor

◆ system()

const std::string& mpqc::UnitFactory::system ( ) const
inline
Returns
the name of the fundamental constants system

The documentation for this class was generated from the following files:
int main(int argc, char *argv[])
Definition: mpqc.cpp:305
static void set_default(const std::string &system)
Definition: units.cpp:146
static std::shared_ptr< const UnitFactory > get_default()
Definition: units.cpp:144