votca 2026-dev
Loading...
Searching...
No Matches
gridbox.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#pragma once
21#ifndef VOTCA_XTP_GRIDBOX_H
22#define VOTCA_XTP_GRIDBOX_H
23
24// Local VOTCA includes
25#include "aoshell.h"
26#include "grid_containers.h"
27
28namespace votca {
29namespace xtp {
30
35class GridBox {
36
37 public:
38 void FindSignificantShells(const AOBasis& basis);
39 AOShell::AOValues CalcAOValues(const Eigen::Vector3d& point) const;
40
45 void CalcAOValues(const Eigen::Vector3d& point, Eigen::MatrixXd& values,
46 Eigen::MatrixXd& derivatives, Index col) const;
47
48 // Added for GGA XC-gradient support -- same pattern as CalcAOValues
49 // above (loop over significant_shells, pack into box-local ranges via
50 // aoranges), calling AOShell::EvalAOspaceHessian instead of
51 // EvalAOspace.
53 const Eigen::Vector3d& point) const;
54
55 const std::vector<Eigen::Vector3d>& getGridPoints() const { return grid_pos; }
56
57 const std::vector<double>& getGridWeights() const { return weights; }
58 std::vector<double>& getPotentialValues() { return potential_values; }
59 const std::vector<double>& getPotentialValues() const {
60 return potential_values;
61 }
62
63 const std::vector<Index>& getOwnerAtoms() const { return owner_atoms; }
64
65 const std::vector<const AOShell*>& getShells() const {
66 return significant_shells;
67 }
68
69 const std::vector<GridboxRange>& getAOranges() const { return aoranges; }
70
71 Index size() const { return Index(grid_pos.size()); }
72
73 Index Shellsize() const { return Index(significant_shells.size()); }
74
75 Index Matrixsize() const { return matrix_size; }
76
77 void addGridBox(const GridBox& box) {
78 grid_pos.insert(grid_pos.end(), box.grid_pos.begin(), box.grid_pos.end());
79 weights.insert(weights.end(), box.weights.begin(), box.weights.end());
81 box.potential_values.begin(),
82 box.potential_values.end());
83 owner_atoms.insert(owner_atoms.end(), box.owner_atoms.begin(),
84 box.owner_atoms.end());
85 return;
86 }
87
89 grid_pos.push_back(point.grid_pos);
90 weights.push_back(point.grid_weight);
91 potential_values.push_back(0.0);
92 owner_atoms.push_back(point.owner_atom);
93 };
94
95 void addShell(const AOShell* shell) {
96 significant_shells.push_back(shell);
97 matrix_size += shell->getNumFunc();
98 };
99
101
102 Eigen::MatrixXd ReadFromBigMatrix(const Eigen::MatrixXd& bigmatrix) const;
103
104 Eigen::VectorXd ReadFromBigVector(const Eigen::VectorXd& bigvector) const;
105
106 void AddtoBigMatrix(Eigen::MatrixXd& bigmatrix,
107 const Eigen::MatrixXd& smallmatrix) const;
108
109 static bool compareGridboxes(GridBox& box1, GridBox& box2) {
110 if (box1.Matrixsize() != box2.Matrixsize()) {
111 return false;
112 }
113 if (box1.Shellsize() != box2.Shellsize()) {
114 return false;
115 }
116 for (Index i = 0; i < Index(box1.significant_shells.size()); ++i) {
117 if (box1.significant_shells[i] != box2.significant_shells[i]) {
118 return false;
119 }
120 }
121 return true;
122 }
123
124 private:
126 std::vector<GridboxRange> aoranges;
127 std::vector<GridboxRange> ranges;
128 std::vector<GridboxRange> inv_ranges;
129 std::vector<Eigen::Vector3d> grid_pos;
130 std::vector<const AOShell*> significant_shells;
131 std::vector<double> weights;
132 std::vector<double> potential_values;
133 // Parallel to grid_pos/weights: which atom each point's radial/angular
134 // quadrature was generated from. Added for the SSW grid-weight nuclear
135 // derivative (Vxc_Potential::GridWeightGradient); not used by any
136 // existing (deriv_order=0) code path.
137 std::vector<Index> owner_atoms;
138};
139
140} // namespace xtp
141} // namespace votca
142#endif // VOTCA_XTP_GRIDBOX_H
Container to hold Basisfunctions for all atoms.
Definition aobasis.h:42
Index getNumFunc() const
Definition aoshell.h:103
void PrepareForIntegration()
Definition gridbox.cc:121
const std::vector< Eigen::Vector3d > & getGridPoints() const
Definition gridbox.h:55
std::vector< Index > owner_atoms
Definition gridbox.h:137
Eigen::MatrixXd ReadFromBigMatrix(const Eigen::MatrixXd &bigmatrix) const
Definition gridbox.cc:97
void AddtoBigMatrix(Eigen::MatrixXd &bigmatrix, const Eigen::MatrixXd &smallmatrix) const
Definition gridbox.cc:84
void addShell(const AOShell *shell)
Definition gridbox.h:95
void addGridBox(const GridBox &box)
Definition gridbox.h:77
std::vector< GridboxRange > inv_ranges
Definition gridbox.h:128
std::vector< double > weights
Definition gridbox.h:131
const std::vector< const AOShell * > & getShells() const
Definition gridbox.h:65
const std::vector< GridboxRange > & getAOranges() const
Definition gridbox.h:69
const std::vector< double > & getGridWeights() const
Definition gridbox.h:57
const std::vector< Index > & getOwnerAtoms() const
Definition gridbox.h:63
std::vector< const AOShell * > significant_shells
Definition gridbox.h:130
AOShell::AOValuesHessian CalcAOValuesHessian(const Eigen::Vector3d &point) const
Definition gridbox.cc:68
std::vector< Eigen::Vector3d > grid_pos
Definition gridbox.h:129
Eigen::VectorXd ReadFromBigVector(const Eigen::VectorXd &bigvector) const
Definition gridbox.cc:111
static bool compareGridboxes(GridBox &box1, GridBox &box2)
Definition gridbox.h:109
AOShell::AOValues CalcAOValues(const Eigen::Vector3d &point) const
Definition gridbox.cc:44
Index size() const
Definition gridbox.h:71
std::vector< GridboxRange > aoranges
Definition gridbox.h:126
Index Matrixsize() const
Definition gridbox.h:75
std::vector< GridboxRange > ranges
Definition gridbox.h:127
void FindSignificantShells(const AOBasis &basis)
Definition gridbox.cc:27
std::vector< double > potential_values
Definition gridbox.h:132
Index Shellsize() const
Definition gridbox.h:73
void addGridPoint(const GridContainers::Cartesian_gridpoint &point)
Definition gridbox.h:88
const std::vector< double > & getPotentialValues() const
Definition gridbox.h:59
std::vector< double > & getPotentialValues()
Definition gridbox.h:58
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26