MADNESS 0.10.1
ESInterface.h
Go to the documentation of this file.
1/* This file is a part of Slymer, which is distributed under the Creative
2 Commons Attribution-NonCommercial 4.0 International Public License.
3
4 (c) 2017 Stony Brook University. */
5
6/**
7 * \file ESInterface/ESInterface.h
8 * \brief API and helper routines for interfacing with electronic structure codes.
9 *
10 * Provides a common (abstract) framework for extracting information from
11 * external electronic structure calculations.
12 */
13
14#ifndef __ESInterface_ESInterface_h__
15#define __ESInterface_ESInterface_h__
16
17#include <madness/mra/mra.h>
18#include <array>
19#include <bitset>
20#include <functional>
21#include <ostream>
22#include <string>
24
25namespace slymer {
26
27/// An atom (symbol and position).
28struct Atom {
29 std::string symbol; ///< The atom's symbol.
30 std::array<double, 3> position; ///< The atom's location, in angstroms.
31};
32
33/// A set of atoms.
34using Atoms = std::vector<Atom>;
35
36namespace Properties {
37 /**
38 * \brief Different properties that can be read from electronic structure codes.
39 *
40 * C-style bitflags via (\c std::bitset) are used for specifying the properties.
41 *
42 * Some properties might require reading others, and this framework is designed
43 * to facilitate reading multiple properties in one go through the output file(s).
44 */
45 using Properties = std::bitset<5>;
46
47 constexpr Properties None = 0; ///< No properties.
48 constexpr Properties Basis = 1 << 0; ///< The basis set.
49 constexpr Properties Atoms = 1 << 1; ///< The atoms & positions.
50 constexpr Properties Energies = 1 << 2; ///< The MO energies.
51 constexpr Properties MOs = 1 << 3; ///< The MO vector coefficients.
52 constexpr Properties Occupancies = 1 << 4; ///< MO occupancies.
53} // namespace Properties
54
55/// Abstract base class for interfacing with electronic structure codes.
57protected:
58 Properties::Properties my_properties; ///< The properties that have been read.
59 BasisSet my_basis_set; ///< The basis set.
60 Atoms my_atoms; ///< The atoms (symbols and positions, in angstroms).
61 unsigned int my_lineardeps; ///< Number of linear dependencies in the basis
62 madness::Tensor<double> my_energies; ///< Alpha molecular orbital energies
63 madness::Tensor<double> my_MOs; ///< Alpha molecular orbital expansions coefficients. Column is the MO, row is the basis function.
64 madness::Tensor<double> my_occupancies; ///< Alpha molecular orbital occupancies.
65 madness::Tensor<double> my_beta_energies; ///< Beta molecular orbital energies
66 madness::Tensor<double> my_beta_MOs; ///< Beta molecular orbital expansions coefficients. Column is the MO, row is the basis function.
67 madness::Tensor<double> my_beta_occupancies; ///< Beta molecular orbital occupancies.
68
69public:
70 std::reference_wrapper<std::ostream> err; ///< Output stream for messages.
71 const Properties::Properties &properties; ///< Publically accessible list of read properties.
72 const BasisSet &basis_set; ///< Publicly accessible basis set.
73 const Atoms &atoms; ///< Publically accessible list of atoms.
74 const unsigned int &lineardeps; ///< Publically accessible number of linear dependencies
75 const madness::Tensor<double> &energies; ///< Publically accessible list of alpha MO energies.
76 const madness::Tensor<double> &MOs; ///< Publically accessible alpha MO expansions coefficients. Column is the MO, row is the basis function.
77 const madness::Tensor<double> &occupancies; ///< Publically accessible list of alpha MO occupancies (in eV).
78 const madness::Tensor<double> &beta_energies; ///< Publically accessible list of beta MO energies (in eV).
79 const madness::Tensor<double> &beta_MOs; ///< Publically accessible beta MO expansions coefficients. Column is the MO, row is the basis function.
80 const madness::Tensor<double> &beta_occupancies; ///< Publically accessible list of beta MO occupancies (in eV).
81
82
83 /// No default constructor.
84 ES_Interface() = delete;
85
86 /**
87 * \brief Move constructor.
88 *
89 * \param[in] es The existing interface to move.
90 */
99
100 /**
101 * \brief Copy constructor.
102 *
103 * \param[in] es The existing interface to copy.
104 */
113
114 /**
115 * \brief Constructor that sets the error/warning stream and the references.
116 *
117 * \param[in,out] err_ Output stream for messages. This can be updated later.
118 */
126
127 virtual ~ES_Interface() = default;
128
129protected:
130 /// Reset the interface.
131 void reset() {
133 my_basis_set.clear();
134 my_atoms.clear();
135 my_lineardeps = 0;
137 my_MOs.reshape(1, 1);
140 my_beta_MOs.reshape(1, 1);
142 }
143
144public:
145 /**
146 * \brief Read the specified properties and store them in the member variables.
147 *
148 * \param[in] props The properties to be read, using a bit flag combination.
149 */
150 virtual void read(Properties::Properties props) = 0;
151
152};
153
154} // namespace slymer
155
156#endif
A tensor is a multidimension array.
Definition tensor.h:317
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition tensor.h:1384
Abstract base class for interfacing with electronic structure codes.
Definition ESInterface.h:56
madness::Tensor< double > my_beta_MOs
Beta molecular orbital expansions coefficients. Column is the MO, row is the basis function.
Definition ESInterface.h:66
ES_Interface(ES_Interface &&es)
Move constructor.
Definition ESInterface.h:91
madness::Tensor< double > my_occupancies
Alpha molecular orbital occupancies.
Definition ESInterface.h:64
ES_Interface(std::ostream &err_)
Constructor that sets the error/warning stream and the references.
Definition ESInterface.h:119
Properties::Properties my_properties
The properties that have been read.
Definition ESInterface.h:58
const madness::Tensor< double > & MOs
Publically accessible alpha MO expansions coefficients. Column is the MO, row is the basis function.
Definition ESInterface.h:76
madness::Tensor< double > my_beta_energies
Beta molecular orbital energies.
Definition ESInterface.h:65
const madness::Tensor< double > & beta_occupancies
Publically accessible list of beta MO occupancies (in eV).
Definition ESInterface.h:80
const madness::Tensor< double > & beta_energies
Publically accessible list of beta MO energies (in eV).
Definition ESInterface.h:78
const madness::Tensor< double > & energies
Publically accessible list of alpha MO energies.
Definition ESInterface.h:75
const Properties::Properties & properties
Publically accessible list of read properties.
Definition ESInterface.h:71
const Atoms & atoms
Publically accessible list of atoms.
Definition ESInterface.h:73
const unsigned int & lineardeps
Publically accessible number of linear dependencies.
Definition ESInterface.h:74
virtual void read(Properties::Properties props)=0
Read the specified properties and store them in the member variables.
madness::Tensor< double > my_energies
Alpha molecular orbital energies.
Definition ESInterface.h:62
ES_Interface()=delete
No default constructor.
void reset()
Reset the interface.
Definition ESInterface.h:131
const madness::Tensor< double > & beta_MOs
Publically accessible beta MO expansions coefficients. Column is the MO, row is the basis function.
Definition ESInterface.h:79
Atoms my_atoms
The atoms (symbols and positions, in angstroms).
Definition ESInterface.h:60
unsigned int my_lineardeps
Number of linear dependencies in the basis.
Definition ESInterface.h:61
const BasisSet & basis_set
Publicly accessible basis set.
Definition ESInterface.h:72
std::reference_wrapper< std::ostream > err
Output stream for messages.
Definition ESInterface.h:70
madness::Tensor< double > my_beta_occupancies
Beta molecular orbital occupancies.
Definition ESInterface.h:67
const madness::Tensor< double > & occupancies
Publically accessible list of alpha MO occupancies (in eV).
Definition ESInterface.h:77
ES_Interface(const ES_Interface &es)
Copy constructor.
Definition ESInterface.h:105
BasisSet my_basis_set
The basis set.
Definition ESInterface.h:59
virtual ~ES_Interface()=default
madness::Tensor< double > my_MOs
Alpha molecular orbital expansions coefficients. Column is the MO, row is the basis function.
Definition ESInterface.h:63
Main include file for MADNESS and defines Function interface.
constexpr Properties Occupancies
MO occupancies.
Definition ESInterface.h:52
constexpr Properties MOs
The MO vector coefficients.
Definition ESInterface.h:51
constexpr Properties None
No properties.
Definition ESInterface.h:47
std::bitset< 5 > Properties
Different properties that can be read from electronic structure codes.
Definition ESInterface.h:45
constexpr Properties Energies
The MO energies.
Definition ESInterface.h:50
constexpr Properties Basis
The basis set.
Definition ESInterface.h:48
Definition basis.h:22
std::vector< std::reference_wrapper< BasisFunction > > BasisSet
Type for a basis set (collection of basis functions).
Definition basis.h:40
std::vector< Atom > Atoms
A set of atoms.
Definition ESInterface.h:34
Definition mraimpl.h:50
An atom (symbol and position).
Definition ESInterface.h:28
std::string symbol
The atom's symbol.
Definition ESInterface.h:29
std::array< double, 3 > position
The atom's location, in angstroms.
Definition ESInterface.h:30