votca 2026-dev
Loading...
Searching...
No Matches
tofgraph.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#pragma once
21#ifndef VOTCA_XTP_TOFGRAPH_H
22#define VOTCA_XTP_TOFGRAPH_H
23
24// Standard includes
25#include <string>
26#include <vector>
27
28// Local VOTCA includes
29#include "eigen.h"
30#include "qmstate.h"
31#include "topology.h"
32
33namespace votca {
34namespace tools {
35class Property;
36}
37} // namespace votca
38
39namespace votca {
40namespace xtp {
41
77class ToFGraph {
78 public:
79 struct Options {
84 double source_thickness = 0.0;
85 double sink_thickness = 0.0;
88 std::string source_pattern = "";
89 std::string sink_pattern = "";
92 bool bulk = false;
94 std::vector<std::string> ignore_types;
95 };
96
100 static Options BulkOptions(const std::string& injection_pattern,
101 const std::string& ignore_types);
102
105
106 enum class Role { Bulk, Source, Sink };
107
108 struct Site {
111 Eigen::Vector3d pos = Eigen::Vector3d::Zero();
113 double x = 0.0;
116 bool reaches_sink = false;
118 double energy = 0.0;
120 double potential = 0.0;
122 bool ignored = false;
123 };
124
125 struct Edge {
126 Index to = -1;
127 double rate = 0.0;
128 Eigen::Vector3d dR = Eigen::Vector3d::Zero(); // pos(to) - pos(from)
129 Index pair = -1; // id in the neighbour list
130 };
131
133 class EdgeRange {
134 public:
135 EdgeRange(const Edge* b, const Edge* e) : begin_(b), end_(e) {}
136 const Edge* begin() const { return begin_; }
137 const Edge* end() const { return end_; }
138 Index size() const { return Index(end_ - begin_); }
139
140 private:
141 const Edge* begin_;
142 const Edge* end_;
143 };
144
146 ToFGraph(const Topology& top, const Options& opt, QMStateType carrier,
147 double temperature, const Eigen::Vector3d& field);
148
149 Index NumberOfSites() const { return Index(sites_.size()); }
150 const std::vector<Site>& Sites() const { return sites_; }
151 const Site& getSite(Index i) const { return sites_[i]; }
152
154 return EdgeRange(edges_.data() + offsets_[i],
155 edges_.data() + offsets_[i + 1]);
156 }
157 Index NumberOfEdges() const { return Index(edges_.size()); }
160 Index EdgeOffset(Index i) const { return offsets_[i]; }
161 const Edge& getEdge(Index e) const { return edges_[e]; }
163 double EscapeRate(Index i) const { return escape_rates_[i]; }
164
166 const std::vector<Index>& SourceSites() const { return sources_; }
168 const std::vector<Index>& DisconnectedSources() const {
170 }
171 const std::vector<Index>& SinkSites() const { return sinks_; }
172
176 bool isBulk() const { return opt_.bulk; }
177
179 const Eigen::Vector3d& Normal() const { return normal_; }
181 double Thickness() const { return thickness_; }
184 double Length() const { return length_; }
185
191 bool isReversible() const { return reversible_; }
193 double DetailedBalanceDeviation() const { return db_deviation_; }
194
195 QMStateType CarrierType() const { return carrier_; }
196 double Temperature() const { return temperature_; }
197 const Eigen::Vector3d& Field() const { return field_; }
198
200 std::string Summary() const;
201
202 private:
206 Eigen::Vector3d field_;
207
208 std::vector<Site> sites_;
209 std::vector<Edge> edges_;
210 std::vector<Index> offsets_;
211 std::vector<double> escape_rates_;
212 std::vector<Index> sources_;
213 std::vector<Index> disconnected_sources_;
214 std::vector<Index> sinks_;
218 Eigen::Vector3d normal_ = Eigen::Vector3d::Zero();
219 double thickness_ = 0.0;
220 double length_ = 0.0;
221 bool reversible_ = false;
222 double db_deviation_ = 0.0;
223
224 void SetupSites(const Topology& top);
225 void SetupEdges(const Topology& top);
226 void FindReachability();
227 void SetupBulkSources();
228};
229
230} // namespace xtp
231} // namespace votca
232
233#endif // VOTCA_XTP_TOFGRAPH_H
class to manage program options with xml serialization functionality
Definition property.h:55
[begin, end) of the out-edges of one site
Definition tofgraph.h:133
const Edge * begin() const
Definition tofgraph.h:136
EdgeRange(const Edge *b, const Edge *e)
Definition tofgraph.h:135
const Edge * end() const
Definition tofgraph.h:137
void SetupSites(const Topology &top)
Definition tofgraph.cc:134
QMStateType CarrierType() const
Definition tofgraph.h:195
Eigen::Vector3d normal_
Definition tofgraph.h:218
QMStateType carrier_
Definition tofgraph.h:204
Eigen::Vector3d field_
Definition tofgraph.h:206
const Eigen::Vector3d & Field() const
Definition tofgraph.h:197
Index NumberOfIgnoredSites() const
sites of ignored segment types
Definition tofgraph.h:175
const Site & getSite(Index i) const
Definition tofgraph.h:151
std::vector< double > escape_rates_
Definition tofgraph.h:211
std::vector< Index > disconnected_sources_
Definition tofgraph.h:213
double DetailedBalanceDeviation() const
largest |ln(w_ij/w_ji) - (U_i - U_j)/kT| over all pairs
Definition tofgraph.h:193
const std::vector< Index > & SourceSites() const
source sites from which a sink can be reached
Definition tofgraph.h:166
std::vector< Site > sites_
Definition tofgraph.h:208
Index NumberOfSites() const
Definition tofgraph.h:149
const Edge & getEdge(Index e) const
Definition tofgraph.h:161
const std::vector< Index > & DisconnectedSources() const
source sites from which no sink can be reached (excluded above)
Definition tofgraph.h:168
std::vector< Index > offsets_
Definition tofgraph.h:210
const std::vector< Index > & SinkSites() const
Definition tofgraph.h:171
Index NumberOfCutPairs() const
Definition tofgraph.h:173
std::vector< Index > sources_
Definition tofgraph.h:212
std::vector< Edge > edges_
Definition tofgraph.h:209
ToFGraph(const Topology &top, const Options &opt, QMStateType carrier, double temperature, const Eigen::Vector3d &field)
temperature as kT in Hartree, field in Hartree/bohr (as Rate_Engine)
Definition tofgraph.cc:96
double Temperature() const
Definition tofgraph.h:196
static Options BulkOptions(const std::string &injection_pattern, const std::string &ignore_types)
Definition tofgraph.cc:61
bool isBulk() const
Definition tofgraph.h:176
Index NumberOfEdges() const
Definition tofgraph.h:157
EdgeRange OutEdges(Index i) const
Definition tofgraph.h:153
const std::vector< Site > & Sites() const
Definition tofgraph.h:150
double Length() const
Definition tofgraph.h:184
double Thickness() const
thickness of the box along the normal
Definition tofgraph.h:181
bool isReversible() const
Definition tofgraph.h:191
std::vector< Index > sinks_
Definition tofgraph.h:214
const Eigen::Vector3d & Normal() const
unit normal of the cut face, pointing from source to sink side
Definition tofgraph.h:179
static Options OptionsFromProperty(const tools::Property &tof)
Options from the "tof" subpackage (subpackages/tof.xml), lengths in nm.
Definition tofgraph.cc:73
void SetupEdges(const Topology &top)
Definition tofgraph.cc:216
Index EdgeOffset(Index i) const
Definition tofgraph.h:160
double EscapeRate(Index i) const
sum of the rates of all out-edges
Definition tofgraph.h:163
std::string Summary() const
human readable summary
Definition tofgraph.cc:360
Container for segments and box and atoms.
Definition topology.h:41
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
std::vector< std::string > ignore_types
segment type wildcards of segments without edges
Definition tofgraph.h:94
Index axis
box vector across which the periodicity is cut (0: a, 1: b, 2: c)
Definition tofgraph.h:81
double potential
energy + field term, U = E - q F.r: hops release U_i - U_j
Definition tofgraph.h:120
bool reaches_sink
a sink can be reached from this site (always true for sinks)
Definition tofgraph.h:116
double energy
site energy of the carrier
Definition tofgraph.h:118
bool ignored
segment type in Options::ignore_types, no edges
Definition tofgraph.h:122
double x
coordinate along the transport normal, in [0, thickness)
Definition tofgraph.h:113
Eigen::Vector3d pos
position with the fractional coordinates wrapped into [0,1)
Definition tofgraph.h:111