Debian Codegraph @

avogadro/core/gaussiansettools.h

raw
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_GAUSSIANSETTOOLS_H
7 #define AVOGADRO_CORE_GAUSSIANSETTOOLS_H
8
9 #include "avogadrocoreexport.h"
10
11 #include "basisset.h"
12 #include "vector.h"
13
14 #include <vector>
15
16 namespace Avogadro::Core {
17
18 class Cube;
19 class GaussianSet;
20 class Molecule;
21
22 /**
23 * @class GaussianSetTools gaussiansettools.h <avogadro/core/gaussiansettools.h>
24 * @brief Provide tools to calculate molecular orbitals, electron densities and
25 * other derived data stored in a GaussianSet result.
26 * @author Marcus D. Hanwell
27 */
28
29 class AVOGADROCORE_EXPORT GaussianSetTools
30 {
31 public:
32 explicit GaussianSetTools(Molecule* mol = nullptr);
33 ~GaussianSetTools() = default;
34
35 /**
36 * @brief Set the electron type, must be called once MOs are available
37 * @param type The electron type - Alpha, Beta, or Paired (default).
38 */
39 void setElectronType(BasisSet::ElectronType type) { m_type = type; }
40
41 /**
42 * @brief Populate the cube with values for the molecular orbital.
43 * @param cube The cube to be populated with values.
44 * @param molecularOrbitalNumber The molecular orbital number.
45 * @return True on success, false on failure.
46 */
47 bool calculateMolecularOrbital(Cube& cube, int molecularOrbitalNumber) const;
48
49 /**
50 * @brief Calculate the value of the specified molecular orbital at the
51 * position specified.
52 * @param position The position in space to calculate the value.
53 * @param molecularOrbitalNumber The molecular orbital number.
54 * @return The value of the molecular orbital at the position specified.
55 */
56 double calculateMolecularOrbital(const Vector3& position,
57 int molecularOrbitalNumber) const;
58
59 /**
60 * @brief Populate the cube with values for the electron density.
61 * @param cube The cube to be populated with values.
62 * @return True on success, false on failure.
63 */
64 bool calculateElectronDensity(Cube& cube) const;
65
66 /**
67 * @brief Calculate the value of the electron density at the position
68 * specified.
69 * @param position The position in space to calculate the value.
70 * @return The value of the electron density at the position specified.
71 */
72 double calculateElectronDensity(const Vector3& position) const;
73
74 /**
75 * @brief Populate the cube with values for the spin density.
76 * @param cube The cube to be populated with values.
77 * @return True on success, false on failure.
78 */
79 bool calculateSpinDensity(Cube& cube) const;
80
81 /**
82 * @brief Calculate the value of the electron spin density at the position
83 * specified.
84 * @param position The position in space to calculate the value.
85 * @return The value of the spin density at the position specified.
86 */
87 double calculateSpinDensity(const Vector3& position) const;
88
89 /**
90 * @brief Check that the basis set is valid and can be used.
91 * @return True if valid, false otherwise.
92 */
93 bool isValid() const;
94
95 private:
96 Molecule* m_molecule;
97 GaussianSet* m_basis;
98 BasisSet::ElectronType m_type = BasisSet::Paired;
99 std::vector<double> m_cutoffDistances;
100 // Cached atom positions in Bohr as 3 x N matrix for vectorized operations
101 Eigen::Matrix<double, 3, Eigen::Dynamic> m_atomPositionsBohr;
102
103 bool isSmall(double value) const;
104
105 // get the cutoff distance for the given angular momentum
106 // .. and the current basis set (exponents)
107 void calculateCutoffs();
108
109 /**
110 * @brief Calculate the values at this position in space. The public calculate
111 * functions call this function to prepare values before multiplying by the
112 * molecular orbital or density matrix elements.
113 * @param position The position in space to calculate the value.
114 * @param values Output vector to store basis function values (will be resized
115 * and zeroed).
116 */
117 void calculateValues(const Vector3& position, Eigen::VectorXd& values) const;
118
119 void pointS(unsigned int index, double dr2, Eigen::VectorXd& values) const;
120 void pointP(unsigned int index, const Vector3& delta, double dr2,
121 Eigen::VectorXd& values) const;
122 void pointD(unsigned int index, const Vector3& delta, double dr2,
123 Eigen::VectorXd& values) const;
124 void pointD5(unsigned int index, const Vector3& delta, double dr2,
125 Eigen::VectorXd& values) const;
126 void pointF(unsigned int index, const Vector3& delta, double dr2,
127 Eigen::VectorXd& values) const;
128 void pointF7(unsigned int index, const Vector3& delta, double dr2,
129 Eigen::VectorXd& values) const;
130 void pointG(unsigned int index, const Vector3& delta, double dr2,
131 Eigen::VectorXd& values) const;
132 void pointG9(unsigned int index, const Vector3& delta, double dr2,
133 Eigen::VectorXd& values) const;
134
135 // map from symmetry to angular momentum
136 // S, SP, P, D, D5, F, F7, G, G9, etc.
137 const int symToL[13] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
138 };
139
140 } // namespace Avogadro::Core
141
142 #endif // AVOGADRO_CORE_GAUSSIANSETTOOLS_H