votca 2026-dev
Loading...
Searching...
No Matches
bse_operator.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_BSE_OPERATOR_H
22#define VOTCA_XTP_BSE_OPERATOR_H
23
24// Standard includes
25#include <memory>
26
27// Local VOTCA includes
28#include "eigen.h"
29#include "matrixfreeoperator.h"
30#include "symmetric_tiles.h"
31#include "threecenter.h"
32
33namespace votca {
34namespace xtp {
35
43
44template <Index cqp, Index cx, Index cd, Index cd2>
45class BSE_OPERATOR final : public MatrixFreeOperator {
46
47 public:
48 BSE_OPERATOR(const Eigen::VectorXd& Hd_operator, const TCMatrix_gwbse& Mmn,
49 const Eigen::MatrixXd& Hqp)
50 : epsilon_0_inv_(Hd_operator), Mmn_(Mmn), Hqp_(Hqp) {};
51
53
54 // This method sets up the diagonal of the hermitian BSE hamiltonian.
55 // Otherwise see the matmul function
56 Eigen::VectorXd diagonal() const;
57 /*
58 * This is the main routine for setting up the hermitian parts of the BSE
59 * For the non-hermitian case look at bseoperator_btda.h which combines
60 * the bse_operators. The operator is never set up explicitly, instead only
61 * the product of it with an input matrix is computed. using the template
62 * arguements Different parts of the hamiltonian can be constructed. In
63 * general it is inefficient to set them up independently (unless you need it
64 * for analysis) thus the function combines all parts.
65 */
66 Eigen::MatrixXd matmul(const Eigen::MatrixXd& input) const;
67
72 void set_direct_cache(std::shared_ptr<SymmetricTiles> cache) {
73 direct_cache_ = std::move(cache);
74 }
75 bool direct_term_cached() const {
76 return direct_cache_ != nullptr && direct_cache_->built();
77 }
78
79 static constexpr Index DirectKind() {
80 return (cd != 0) ? 1 : ((cd2 != 0) ? 2 : 0);
81 }
82
86
87 private:
88 // the screened direct term (cd or cd2 part, unit prefactor) as the lower
89 // triangle of a symmetric matrix
90 void BuildDirectMatrix() const;
91 // the screened direct term applied block by block (see use_row_kernel)
92 Eigen::MatrixXd ApplyDirectBlocks(const Eigen::MatrixXd& input) const;
93 Eigen::MatrixXd ApplyDirectRows(const Eigen::MatrixXd& input) const;
94
95 std::shared_ptr<SymmetricTiles> direct_cache_;
96 bool row_kernel_ = false;
97 // stacked slices for the block kernel: for cd the vv blocks of the
98 // occupied slices (row v1*n_v + v2), for cd2 the cv blocks of the virtual
99 // slices (row c1*n_v + v2)
100 mutable Eigen::MatrixXd stacked_;
106
107 const Eigen::VectorXd& epsilon_0_inv_;
109 const Eigen::MatrixXd& Hqp_;
110};
111
112// type defs for the different operators
115
117
122
123} // namespace xtp
124} // namespace votca
125
126#endif // VOTCA_XTP_BSE_OPERATOR_H
std::shared_ptr< SymmetricTiles > direct_cache_
Eigen::MatrixXd ApplyDirectRows(const Eigen::MatrixXd &input) const
BSE_OPERATOR(const Eigen::VectorXd &Hd_operator, const TCMatrix_gwbse &Mmn, const Eigen::MatrixXd &Hqp)
const Eigen::VectorXd & epsilon_0_inv_
void set_direct_cache(std::shared_ptr< SymmetricTiles > cache)
static constexpr Index DirectKind()
Tag of the direct term an operator caches: 1 for Hd, 2 for Hd2.
void configure(BSEOperator_Options opt)
Eigen::MatrixXd matmul(const Eigen::MatrixXd &input) const
Eigen::MatrixXd ApplyDirectBlocks(const Eigen::MatrixXd &input) const
void use_row_kernel(bool rows)
Eigen::VectorXd diagonal() const
bool direct_term_cached() const
BSE_OPERATOR< 1, 0, 0, 0 > HqpOperator
BSE_OPERATOR< 0, 0, 1, 0 > HdOperator
BSE_OPERATOR< 0, 0, 0, 1 > Hd2Operator
BSE_OPERATOR< 1, 2, 1, 0 > SingletOperator_TDA
Definition bse.h:40
BSE_OPERATOR< 1, 0, 1, 0 > TripletOperator_TDA
Definition bse.h:41
BSE_OPERATOR< 0, 2, 0, 1 > SingletOperator_BTDA_B
BSE_OPERATOR< 0, 1, 0, 0 > HxOperator
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26