votca 2026-dev
Loading...
Searching...
No Matches
ppm.cc
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// Standard includes
21#include <iostream>
22
23#include "votca/xtp/ppm.h"
24#include "votca/xtp/rpa_uks.h"
25
26namespace votca {
27namespace xtp {
28
29namespace {
30template <typename RPAType>
31void ConstructPPMParametersImpl(const RPAType& rpa, Eigen::MatrixXd& ppm_phi,
32 Eigen::VectorXd& ppm_weight,
33 Eigen::VectorXd& ppm_freq, double screening_r,
34 double screening_i) {
35 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> es(
36 rpa.calculate_epsilon_r(screening_r));
37 ppm_phi = es.eigenvectors();
38
39 ppm_weight = 1 - es.eigenvalues().array().inverse();
40
41 Eigen::MatrixXd ortho =
42 ppm_phi.transpose() * rpa.calculate_epsilon_i(screening_i) * ppm_phi;
43 Eigen::MatrixXd epsilon_1_inv = ortho.inverse();
44
45 ppm_freq.resize(es.eigenvalues().size());
46#pragma omp parallel for
47 for (Index i = 0; i < es.eigenvalues().size(); i++) {
48 if (ppm_weight(i) < 1.e-5) {
49 ppm_weight(i) = 0.0;
50 ppm_freq(i) = 0.5;
51 continue;
52 } else {
53 double nom = epsilon_1_inv(i, i) - 1.0;
54 double frac =
55 -1.0 * nom / (nom + ppm_weight(i)) * screening_i * screening_i;
56 ppm_freq(i) = std::sqrt(std::abs(frac));
57 }
58 }
59}
60} // namespace
61
63 ConstructPPMParametersImpl(rpa, ppm_phi_, ppm_weight_, ppm_freq_, screening_r,
65}
66
68 ConstructPPMParametersImpl(rpa, ppm_phi_, ppm_weight_, ppm_freq_, screening_r,
70}
71
72} // namespace xtp
73} // namespace votca
Eigen::VectorXd ppm_freq_
Definition ppm.h:50
Eigen::VectorXd ppm_weight_
Definition ppm.h:51
void PPM_construct_parameters(const RPA &rpa)
Definition ppm.cc:62
Eigen::MatrixXd ppm_phi_
Definition ppm.h:49
double screening_i
Definition ppm.h:47
double screening_r
Definition ppm.h:46
Unrestricted RPA helper for spin-resolved GW screening.
Definition rpa_uks.h:68
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26