| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef AVOGADRO_CORE_SLATERSET_H |
| 7 |
#define AVOGADRO_CORE_SLATERSET_H |
| 8 |
|
| 9 |
#include "basisset.h" |
| 10 |
|
| 11 |
#include <avogadro/core/matrix.h> |
| 12 |
#include <avogadro/core/vector.h> |
| 13 |
|
| 14 |
#include <vector> |
| 15 |
|
| 16 |
namespace Avogadro::Core { |
| 17 |
|
| 18 |
/** |
| 19 |
* @class SlaterSet slaterset.h |
| 20 |
* @brief SlaterSet Class |
| 21 |
* @author Marcus D. Hanwell |
| 22 |
* |
| 23 |
* The SlaterSet class has a transparent data structure for storing the basis |
| 24 |
* sets output by many quantum mechanical codes. It has a certain hierarchy |
| 25 |
* where shells are built up from n primitives, in this case Slater Type |
| 26 |
* Orbitals (STOs). Each shell has a type (S, P, D, F, etc) and is composed of |
| 27 |
* one or more STOs. Each STO has a contraction coefficient, c, and an exponent, |
| 28 |
* a. |
| 29 |
* |
| 30 |
* When calculating Molecular Orbitals (MOs) each orthogonal shell has an |
| 31 |
* independent coefficient. That is the S type orbitals have one coefficient, |
| 32 |
* the P type orbitals have three coefficients (Px, Py and Pz), the D type |
| 33 |
* orbitals have five (or six if cartesian types) coefficients, and so on. |
| 34 |
*/ |
| 35 |
|
| 36 |
struct SlaterShell; |
| 37 |
|
| 38 |
class AVOGADROCORE_EXPORT SlaterSet : public BasisSet |
| 39 |
{ |
| 40 |
public: |
| 41 |
/** |
| 42 |
* Constructor. |
| 43 |
*/ |
| 44 |
SlaterSet() = default; |
| 45 |
|
| 46 |
/** |
| 47 |
* Destructor. |
| 48 |
*/ |
| 49 |
~SlaterSet() override = default; |
| 50 |
|
| 51 |
/** |
| 52 |
* Clone. |
| 53 |
*/ |
| 54 |
SlaterSet* clone() const override { return new SlaterSet(*this); } |
| 55 |
|
| 56 |
/** |
| 57 |
* Enumeration of the Slater orbital types. |
| 58 |
*/ |
| 59 |
enum slater |
| 60 |
{ |
| 61 |
S, |
| 62 |
PX, |
| 63 |
PY, |
| 64 |
PZ, |
| 65 |
X2, |
| 66 |
XZ, |
| 67 |
Z2, |
| 68 |
YZ, |
| 69 |
XY, |
| 70 |
UU |
| 71 |
}; |
| 72 |
|
| 73 |
/** |
| 74 |
* Add a basis to the basis set. |
| 75 |
* @param i Index of the atom to add the Basis too. |
| 76 |
* @return The index of the added Basis. |
| 77 |
*/ |
| 78 |
bool addSlaterIndices(const std::vector<int>& i); |
| 79 |
|
| 80 |
/** |
| 81 |
* Add the symmetry types for the orbitals. |
| 82 |
* @param t Vector containing the types of symmetry using the slater enum. |
| 83 |
*/ |
| 84 |
bool addSlaterTypes(const std::vector<int>& t); |
| 85 |
|
| 86 |
/** |
| 87 |
* Add a STO to the supplied basis. |
| 88 |
* @param zetas The exponents of the STOs |
| 89 |
* @return True if successful. |
| 90 |
*/ |
| 91 |
bool addZetas(const std::vector<double>& zetas); |
| 92 |
|
| 93 |
/** |
| 94 |
* The PQNs for the orbitals. |
| 95 |
*/ |
| 96 |
bool addPQNs(const std::vector<int>& pqns); |
| 97 |
|
| 98 |
/** |
| 99 |
* The overlap matrix. |
| 100 |
* @param m Matrix containing the overlap matrix for the basis. |
| 101 |
*/ |
| 102 |
bool addOverlapMatrix(const Eigen::MatrixXd& m); |
| 103 |
|
| 104 |
/** |
| 105 |
* Add Eigen Vectors to the SlaterSet. |
| 106 |
* @param e Matrix of the eigen vectors for the SlaterSet. |
| 107 |
*/ |
| 108 |
bool addEigenVectors(const Eigen::MatrixXd& e); |
| 109 |
|
| 110 |
/** |
| 111 |
* Add the density matrix to the SlaterSet. |
| 112 |
* @param d Density matrix for the SlaterSet. |
| 113 |
*/ |
| 114 |
bool addDensityMatrix(const Eigen::MatrixXd& d); |
| 115 |
|
| 116 |
/** |
| 117 |
* @return The number of molecular orbitals in the BasisSet. |
| 118 |
*/ |
| 119 |
unsigned int molecularOrbitalCount(ElectronType type = Paired) const override; |
| 120 |
|
| 121 |
/** |
| 122 |
* @return True of the basis set is valid, false otherwise. |
| 123 |
* Default is true, if false then the basis set is likely unusable. |
| 124 |
*/ |
| 125 |
bool isValid() override { return true; } |
| 126 |
|
| 127 |
/** |
| 128 |
* Initialize the calculation, this must normally be done before anything. |
| 129 |
*/ |
| 130 |
void initCalculation(); |
| 131 |
|
| 132 |
/** |
| 133 |
* Accessors for the various properties of the SlaterSet. |
| 134 |
*/ |
| 135 |
std::vector<int>& slaterIndices() { return m_slaterIndices; } |
| 136 |
std::vector<int>& slaterTypes() { return m_slaterTypes; } |
| 137 |
std::vector<double>& zetas() { return m_zetas; } |
| 138 |
std::vector<double>& factors() { return m_factors; } |
| 139 |
std::vector<int>& PQNs() { return m_PQNs; } |
| 140 |
MatrixX& normalizedMatrix() { return m_normalized; } |
| 141 |
MatrixX& densityMatrix() { return m_density; } |
| 142 |
|
| 143 |
// Nonfunctional - Included for backwards compatibility |
| 144 |
void outputAll(); |
| 145 |
|
| 146 |
private: |
| 147 |
std::vector<int> m_slaterIndices; |
| 148 |
std::vector<int> m_slaterTypes; |
| 149 |
std::vector<double> m_zetas; |
| 150 |
std::vector<int> m_pqns, m_PQNs; |
| 151 |
|
| 152 |
std::vector<double> m_factors; |
| 153 |
MatrixX m_overlap; |
| 154 |
MatrixX m_eigenVectors; |
| 155 |
MatrixX m_density; |
| 156 |
MatrixX m_normalized; |
| 157 |
bool m_initialized = false; |
| 158 |
|
| 159 |
unsigned int factorial(unsigned int n); |
| 160 |
}; |
| 161 |
|
| 162 |
} // namespace Avogadro::Core |
| 163 |
|
| 164 |
#endif |