votca 2024.2-dev
Loading...
Searching...
No Matches
activedensitymatrix.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2023 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 * References- (1) A fast intrinsic localization procedure applicable for ab
22 *initio and semiempirical linear combination of atomic orbital wave functions.
23 *Janos Pipek and Paul G. Mezey. J. Chem. Phys. 90, 4916 (1989);
24 *https://doi.org/10.1063/1.456588
25 *(2) A Simple, Exact Density-Functional-Theory
26 *Embedding Scheme. Frederick R. Manby, Martina Stella, Jason D. Goodpaster, and
27 *Thomas F. Miller Journal of Chemical Theory and Computation 2012 8 (8),
28 *2564-2568 DOI: 10.1021/ct300544e
29 *(3) Projection-Based Wavefunction-in-DFT Embedding
30 *Sebastian J. R. Lee, Matthew Welborn, Frederick R. Manby, and Thomas F. Miller
31 *III Accounts of Chemical Research 2019 52 (5), 1359-1368
32 *DOI: 10.1021/acs.accounts.8b00672
33 */
35#include "votca/xtp/aomatrix.h"
36namespace votca {
37namespace xtp {
38
39std::array<Eigen::MatrixXd, 3> ActiveDensityMatrix::compute_Dmat_A() {
40 Eigen::MatrixXd localized_mo_coeff = orbitals_.getLMOs();
41 return activedensitymatrix(localized_mo_coeff);
42}
43
44std::array<Eigen::MatrixXd, 3> ActiveDensityMatrix::activedensitymatrix(
45 const Eigen::MatrixXd &localized_mo_coeff) {
46 AOBasis aobasis = orbitals_.getDftBasis();
47 AOOverlap overlap;
48 overlap.Fill(aobasis);
49 Index numOfActiveOrbs = 0;
50 Index numOfInactiveOrbs = 0;
51 std::vector<Index> numfuncpatom = aobasis.getFuncPerAtom();
52 Eigen::MatrixXd active_mo_coeff;
53 Eigen::MatrixXd inactive_mo_coeff;
54
55 for (Index LocMoCoeff_col_i = 0; LocMoCoeff_col_i < localized_mo_coeff.cols();
56 LocMoCoeff_col_i++) {
57 // Calculate orbital wise Mulliken population
58 const Eigen::MatrixXd orbital_wise_population =
59 localized_mo_coeff.col(LocMoCoeff_col_i).transpose() *
60 overlap.Matrix() *
61 localized_mo_coeff.col(LocMoCoeff_col_i).asDiagonal();
62 const Eigen::RowVectorXd MullikenPop_per_basisfunc =
63 orbital_wise_population.colwise().sum();
64 Index start = 0;
65 bool inactive = true;
66 for (Index atom_id = 0; atom_id < Index(numfuncpatom.size()); atom_id++) {
67 const double MullikenPop_per_atom =
68 MullikenPop_per_basisfunc.segment(start, numfuncpatom[atom_id]).sum();
69 if ((std::find(activeatoms_.begin(), activeatoms_.end(), atom_id) !=
70 activeatoms_.end()) &&
71 MullikenPop_per_atom > threshold_) {
72 active_mo_coeff.conservativeResize(localized_mo_coeff.rows(),
73 numOfActiveOrbs + 1);
74 active_mo_coeff.col(numOfActiveOrbs) =
75 localized_mo_coeff.col(LocMoCoeff_col_i);
76 numOfActiveOrbs++;
77 inactive = false;
78 break;
79 }
80 start += numfuncpatom[atom_id];
81 }
82 if (inactive) {
83 inactive_mo_coeff.conservativeResize(localized_mo_coeff.rows(),
84 numOfInactiveOrbs + 1);
85 inactive_mo_coeff.col(numOfInactiveOrbs) =
86 localized_mo_coeff.col(LocMoCoeff_col_i);
87 numOfInactiveOrbs++;
88 }
89 }
90 const Eigen::MatrixXd dmat_active =
91 2 * active_mo_coeff * active_mo_coeff.transpose();
92 std::array<Eigen::MatrixXd, 3> result;
93 result[0] = dmat_active;
94 result[1] = active_mo_coeff;
95 result[2] = inactive_mo_coeff;
96 return result;
97}
98} // namespace xtp
99} // namespace votca
Container to hold Basisfunctions for all atoms.
Definition aobasis.h:42
const std::vector< Index > & getFuncPerAtom() const
Definition aobasis.h:72
void Fill(const AOBasis &aobasis) final
const Eigen::MatrixXd & Matrix() const
Definition aomatrix.h:52
std::array< Eigen::MatrixXd, 3 > activedensitymatrix(const Eigen::MatrixXd &localized_mo_coeff)
std::array< Eigen::MatrixXd, 3 > compute_Dmat_A()
const Eigen::MatrixXd & getLMOs() const
Definition orbitals.h:411
const AOBasis & getDftBasis() const
Definition orbitals.h:208
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26