GQCP
Loading...
Searching...
No Matches
ScalarBasis.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
25#include "Molecule/Molecule.hpp"
28
29#include <functional>
30
31
32namespace GQCP {
33
34
40template <typename _Shell>
42public:
43 // The type of shell that this scalar basis contains.
44 using Shell = _Shell;
45
46 // The type of the primitive functions that underlie this scalar basis.
47 using Primitive = typename Shell::Primitive;
48
49 // The type of basis functions that this scalar basis consists of.
50 using BasisFunction = typename Shell::BasisFunction;
51
52private:
53 // A collection of shells that represents this scalar basis.
54 ShellSet<Shell> shell_set;
55
56
57public:
58 /*
59 * MARK: Constructors
60 */
61
65 ScalarBasis(const ShellSet<Shell>& shell_set) :
66 shell_set {shell_set} {}
67
68
77 template <typename Z = Shell>
78 ScalarBasis(const NuclearFramework& nuclear_framework, const std::string& basisset_name,
79 typename std::enable_if<std::is_same<Z, GTOShell>::value>::type* = 0) :
80 ScalarBasis(GTOBasisSet(basisset_name).generate(nuclear_framework)) {
81
83 }
84
85
94 template <typename Z = Shell>
95 ScalarBasis(const Molecule& molecule, const std::string& basisset_name,
96 typename std::enable_if<std::is_same<Z, GTOShell>::value>::type* = 0) :
97 ScalarBasis(molecule.nuclearFramework(), basisset_name) {}
98
99
109 template <typename Z = Shell>
110 ScalarBasis(const NuclearFramework& nuclear_framework, const std::string& basisset_name, const HomogeneousMagneticField& B,
111 typename std::enable_if<std::is_same<Z, LondonGTOShell>::value>::type* = 0) :
112 ScalarBasis(GTOBasisSet(basisset_name).generate(nuclear_framework).applyLondonModification(B)) {
113
115 }
116
117
127 template <typename Z = Shell>
128 ScalarBasis(const Molecule& molecule, const std::string& basisset_name, const HomogeneousMagneticField& B,
129 typename std::enable_if<std::is_same<Z, LondonGTOShell>::value>::type* = 0) :
130 ScalarBasis(molecule.nuclearFramework(), basisset_name, B) {}
131
132
133 /*
134 * MARK: Shell set
135 */
136
140 const ShellSet<Shell>& shellSet() const { return this->shell_set; }
141
142
143 /*
144 * MARK: Basis functions
145 */
146
150 std::vector<BasisFunction> basisFunctions() const { return this->shell_set.basisFunctions(); }
151
155 size_t numberOfBasisFunctions() const { return this->shell_set.numberOfBasisFunctions(); }
156
164 std::vector<size_t> basisFunctionIndices(const std::function<bool(const Shell&)>& selector) const {
165
166 const auto shells = this->shellSet().asVector();
167
168 // Find the indices of those basis functions for which the shell selector returns true.
169 std::vector<size_t> ao_indices;
170 size_t bf_index = 0;
171 for (size_t shell_index = 0; shell_index < shells.size(); shell_index++) {
172 const auto& shell = shells[shell_index];
173
174 // If a shell has to be included, include all indices of the basis functions in it.
175 const auto number_of_bf_in_shell = shell.numberOfBasisFunctions();
176 if (selector(shell)) {
177 for (size_t i = 0; i < number_of_bf_in_shell; i++) {
178 ao_indices.push_back(bf_index);
179 bf_index++;
180 }
181 } else {
182 // Increase the current BF index to accommodate to the next shell.
183 bf_index += number_of_bf_in_shell;
184 }
185 }
186
187 return ao_indices;
188 }
189
190
198 std::vector<size_t> basisFunctionIndices(const std::function<bool(const BasisFunction&)>& selector) const {
199
200 const auto basis_functions = this->basisFunctions();
201
202 // Find the indices of those basis functions for which the selector returns true.
203 std::vector<size_t> ao_indices;
204 for (size_t i = 0; i < basis_functions.size(); i++) {
205 const auto& basis_function = basis_functions[i];
206
207 if (selector(basis_function)) {
208 ao_indices.push_back(i);
209 }
210 }
211
212 return ao_indices;
213 }
214};
215
216
217} // namespace GQCP
Definition: GTOBasisSet.hpp:35
Definition: HomogeneousMagneticField.hpp:30
Definition: Molecule.hpp:34
Definition: NuclearFramework.hpp:35
Definition: ScalarBasis.hpp:41
std::vector< BasisFunction > basisFunctions() const
Definition: ScalarBasis.hpp:150
ScalarBasis(const Molecule &molecule, const std::string &basisset_name, typename std::enable_if< std::is_same< Z, GTOShell >::value >::type *=0)
Definition: ScalarBasis.hpp:95
ScalarBasis(const ShellSet< Shell > &shell_set)
Definition: ScalarBasis.hpp:65
_Shell Shell
Definition: ScalarBasis.hpp:44
size_t numberOfBasisFunctions() const
Definition: ScalarBasis.hpp:155
ScalarBasis(const Molecule &molecule, const std::string &basisset_name, const HomogeneousMagneticField &B, typename std::enable_if< std::is_same< Z, LondonGTOShell >::value >::type *=0)
Definition: ScalarBasis.hpp:128
typename Shell::Primitive Primitive
Definition: ScalarBasis.hpp:47
std::vector< size_t > basisFunctionIndices(const std::function< bool(const Shell &)> &selector) const
Definition: ScalarBasis.hpp:164
ScalarBasis(const NuclearFramework &nuclear_framework, const std::string &basisset_name, typename std::enable_if< std::is_same< Z, GTOShell >::value >::type *=0)
Definition: ScalarBasis.hpp:78
const ShellSet< Shell > & shellSet() const
Definition: ScalarBasis.hpp:140
std::vector< size_t > basisFunctionIndices(const std::function< bool(const BasisFunction &)> &selector) const
Definition: ScalarBasis.hpp:198
typename Shell::BasisFunction BasisFunction
Definition: ScalarBasis.hpp:50
ScalarBasis(const NuclearFramework &nuclear_framework, const std::string &basisset_name, const HomogeneousMagneticField &B, typename std::enable_if< std::is_same< Z, LondonGTOShell >::value >::type *=0)
Definition: ScalarBasis.hpp:110
Definition: ShellSet.hpp:41
const std::vector< Shell > & asVector() const
Definition: ShellSet.hpp:180
std::vector< BasisFunction > basisFunctions() const
Definition: ShellSet.hpp:141
size_t numberOfBasisFunctions() const
Definition: ShellSet.hpp:127
void embedNormalizationFactorsOfPrimitives()
Definition: ShellSet.hpp:99
Definition: BaseOneElectronIntegralBuffer.hpp:25