votca 2026-dev
Loading...
Searching...
No Matches
hirshfeldpartition.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2026 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// ===========================================================================
21// STATUS: new, in-progress home for Hirshfeld real-space partitioning, the
22// weight-function scheme chosen for CDFT charge (and, later, spin)
23// constraints -- see the design discussion this branch grew out of for why
24// Hirshfeld over Becke/SSW (Becke-family partitions are known to give
25// unphysical atomic charges when atoms differ significantly in size,
26// confirmed via CP2K's own move away from plain Becke for this purpose;
27// Hirshfeld's promolecular-density weighting avoids that).
28//
29// A Hirshfeld weight for atom i is w_i(r) = rho_i^free(r) / sum_j
30// rho_j^free(r), where rho_i^free is atom i's own ISOLATED, spherically-
31// averaged reference density (DFTEngine::ComputeHirshfeldReferenceDensities,
32// via RunAtomicDFT_unrestricted with use_hunds_rule_occupation=true) -- this
33// class never touches that atomic-SCF machinery itself (which stays private
34// to DFTEngine); it only ever receives the resulting densities as an
35// explicit argument, matching DFTGradient's own established pattern in this
36// branch: static methods, explicit arguments only, no reaching into
37// DFTEngine's private state.
38//
39// Deliberately NOT yet implemented: the sum-over-atoms denominator, the
40// full AO-basis weight matrix W_i (the projection actually needed for the
41// Lagrange-multiplier potential added to the Fock matrix), or anything
42// about the constraint/Lagrange-multiplier optimization itself. This
43// commit is only the first, single-atom building block: evaluating one
44// isolated reference density, at one real-space point, given that atom's
45// own (small, atom-only) basis re-centered on its real position in the
46// molecule -- no embedding into the full molecule's AO basis at all (that
47// question, and why it does not arise here, was worked out separately:
48// unlike DFTEngine::AtomicGuess's own SAD-guess construction, Hirshfeld
49// never needs a molecule-sized combined object).
50// ===========================================================================
51
52#pragma once
53#ifndef VOTCA_XTP_HIRSHFELDPARTITION_H
54#define VOTCA_XTP_HIRSHFELDPARTITION_H
55
56// Standard includes
57#include <map>
58#include <string>
59#include <vector>
60
61// Local VOTCA includes
62#include "aobasis.h"
63#include "qmmolecule.h"
64#include "vxc_grid.h"
65
66namespace votca {
67namespace xtp {
68
70 public:
79 Eigen::MatrixXd density;
80 };
81
90 static std::vector<AtomicReference> BuildAtomicReferences(
91 const QMMolecule& mol, const std::string& basisset_name,
92 const std::map<std::string, Eigen::MatrixXd>& reference_densities);
93
111 static double EvaluateAtomicDensity(const AOBasis& atom_basis,
112 const Eigen::MatrixXd& reference_density,
113 const Eigen::Vector3d& point);
114
130 static Eigen::Vector3d EvaluateAtomicDensityGradient(
131 const AOBasis& atom_basis, const Eigen::MatrixXd& reference_density,
132 const Eigen::Vector3d& point);
133
144 static double EvaluateWeight(const std::vector<AtomicReference>& atoms,
145 Index target_atom_index,
146 const Eigen::Vector3d& point);
147
164 static Eigen::Vector3d EvaluateWeightGradient(
165 const std::vector<AtomicReference>& atoms, Index target_atom_index,
166 Index differentiate_atom_index, const Eigen::Vector3d& point);
167
193 static Eigen::Vector3d EvaluatePointWeightGradient(
194 const std::vector<AtomicReference>& atoms, Index target_atom_index,
195 const Eigen::Vector3d& point);
196
226 static Eigen::MatrixXd GridWeightDerivativeContribution(
227 const std::vector<AtomicReference>& atoms, Index target_atom_index,
228 const Eigen::MatrixXd& density_matrix, const QMMolecule& mol,
229 const Vxc_Grid& grid);
230
251 static Eigen::MatrixXd PulayAndTranslationContribution(
252 const std::vector<AtomicReference>& atoms, Index target_atom_index,
253 const Eigen::MatrixXd& density_matrix, const AOBasis& full_dftbasis,
254 const Vxc_Grid& grid);
255
268 static Eigen::MatrixXd WeightFunctionDerivativeContribution(
269 const std::vector<AtomicReference>& atoms, Index target_atom_index,
270 const Eigen::MatrixXd& density_matrix, const AOBasis& full_dftbasis,
271 const Vxc_Grid& grid);
272
287 static Eigen::MatrixXd ComputeCDFTForceContribution(
288 const std::vector<AtomicReference>& atoms, Index target_atom_index,
289 const Eigen::MatrixXd& density_matrix, const QMMolecule& mol,
290 const AOBasis& full_dftbasis, const Vxc_Grid& grid);
291
310 static Eigen::MatrixXd BuildWeightMatrix(
311 const std::vector<AtomicReference>& atoms, Index target_atom_index,
312 const AOBasis& full_dftbasis, const Vxc_Grid& grid);
313
331 struct Constraint {
332 Eigen::MatrixXd weight_matrix;
334 double lambda = 0.0;
337 };
338};
339
340} // namespace xtp
341} // namespace votca
342
343#endif // VOTCA_XTP_HIRSHFELDPARTITION_H
Container to hold Basisfunctions for all atoms.
Definition aobasis.h:42
static std::vector< AtomicReference > BuildAtomicReferences(const QMMolecule &mol, const std::string &basisset_name, const std::map< std::string, Eigen::MatrixXd > &reference_densities)
static double EvaluateWeight(const std::vector< AtomicReference > &atoms, Index target_atom_index, const Eigen::Vector3d &point)
static double EvaluateAtomicDensity(const AOBasis &atom_basis, const Eigen::MatrixXd &reference_density, const Eigen::Vector3d &point)
static Eigen::MatrixXd WeightFunctionDerivativeContribution(const std::vector< AtomicReference > &atoms, Index target_atom_index, const Eigen::MatrixXd &density_matrix, const AOBasis &full_dftbasis, const Vxc_Grid &grid)
static Eigen::Vector3d EvaluatePointWeightGradient(const std::vector< AtomicReference > &atoms, Index target_atom_index, const Eigen::Vector3d &point)
static Eigen::Vector3d EvaluateWeightGradient(const std::vector< AtomicReference > &atoms, Index target_atom_index, Index differentiate_atom_index, const Eigen::Vector3d &point)
static Eigen::MatrixXd GridWeightDerivativeContribution(const std::vector< AtomicReference > &atoms, Index target_atom_index, const Eigen::MatrixXd &density_matrix, const QMMolecule &mol, const Vxc_Grid &grid)
static Eigen::Vector3d EvaluateAtomicDensityGradient(const AOBasis &atom_basis, const Eigen::MatrixXd &reference_density, const Eigen::Vector3d &point)
static Eigen::MatrixXd BuildWeightMatrix(const std::vector< AtomicReference > &atoms, Index target_atom_index, const AOBasis &full_dftbasis, const Vxc_Grid &grid)
static Eigen::MatrixXd PulayAndTranslationContribution(const std::vector< AtomicReference > &atoms, Index target_atom_index, const Eigen::MatrixXd &density_matrix, const AOBasis &full_dftbasis, const Vxc_Grid &grid)
static Eigen::MatrixXd ComputeCDFTForceContribution(const std::vector< AtomicReference > &atoms, Index target_atom_index, const Eigen::MatrixXd &density_matrix, const QMMolecule &mol, const AOBasis &full_dftbasis, const Vxc_Grid &grid)
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26