votca 2024.2-dev
Loading...
Searching...
No Matches
Localisation_filter.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// Local VOTCA includes
22
23// Local private VOTCA includes
24#include "Localisation_filter.h"
25
26namespace votca {
27namespace xtp {
28
30 std::string indices = options.get("fragment").as<std::string>();
31 fragment_ = QMFragment<double>(0, indices);
32 fragment_.value() = options.get("threshold").as<double>();
33}
34
36 XTP_LOG(Log::error, log) << "Using localisation tracker for fragment "
37 << fragment_ << std::flush;
38}
39
41
42std::vector<Index> Localisation_filter::CalcIndeces(const Orbitals& orb,
43 QMStateType type) const {
44
45 if (!type.isExciton()) {
46 throw std::runtime_error("Localisation filter only works for excitons.");
47 }
48 std::vector<Index> indexes;
49 Lowdin low;
52 std::vector<QMFragment<BSE_Population> > loc = {frag};
53 low.CalcChargeperFragment(loc, orb, type);
54 const Eigen::VectorXd& popE = loc[0].value().E;
55 const Eigen::VectorXd& popH = loc[0].value().H;
56 for (Index i = 0; i < popE.size(); i++) {
57 if (std::abs(popE[i]) > fragment_.value() &&
58 std::abs(popH[i]) > fragment_.value()) {
59 indexes.push_back(i);
60 }
61 }
62 return indexes;
63}
64
68
72
73} // namespace xtp
74} // namespace votca
class to manage program options with xml serialization functionality
Definition property.h:55
Property & get(const std::string &key)
get existing property
Definition property.cc:79
T as() const
return value as type
Definition property.h:283
void UpdateHist(const Orbitals &orb, QMState state) final
std::vector< Index > CalcIndeces(const Orbitals &orb, QMStateType type) const final
void Info(Logger &log) const final
void ReadFromCpt(CheckpointReader &r) final
void WriteToCpt(CheckpointWriter &w) final
void Initialize(const tools::Property &options) final
Logger is used for thread-safe output of messages.
Definition logger.h:164
container for molecular orbitals
Definition orbitals.h:46
void CalcChargeperFragment(std::vector< QMFragment< BSE_Population > > &frags, const Orbitals &orbitals, QMStateType type) const
void ReadFromCpt(CheckpointReader &r)
Definition qmfragment.h:99
void WriteToCpt(CheckpointWriter &w) const
Definition qmfragment.h:93
void copy_withoutvalue(const QMFragment< T2 > &frag)
Definition qmfragment.h:50
const T & value() const
Definition qmfragment.h:59
bool isExciton() const
Definition qmstate.h:71
Identifier for QMstates. Strings like S1 are converted into enum +zero indexed int.
Definition qmstate.h:132
#define XTP_LOG(level, log)
Definition logger.h:40
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26