votca 2026-dev
Loading...
Searching...
No Matches
kmcwaitingtime.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_KMCWAITINGTIME_H
22#define VOTCA_XTP_KMCWAITINGTIME_H
23
24// Standard includes
25#include <memory>
26#include <string>
27#include <vector>
28
29// Local VOTCA includes
30#include "kmcrandom.h"
31#include "kmcrates.h"
32
33namespace votca {
34namespace xtp {
35
70 public:
71 virtual ~WaitingTimeStrategy() = default;
72 virtual std::string Name() const = 0;
73 virtual void Prepare(const TimeDependentRates& rates) = 0;
74 virtual double NextTime(Index site, double t, KMCRandom& random) const = 0;
75 virtual Index ChooseHop(Index site, double t, KMCRandom& random) const = 0;
76};
77
83 public:
84 std::string Name() const override { return "exponential"; }
85 void Prepare(const TimeDependentRates& rates) override;
86 double NextTime(Index site, double t, KMCRandom& random) const override;
87 Index ChooseHop(Index site, double t, KMCRandom& random) const override;
88
89 private:
90 const ToFGraph* graph_ = nullptr;
91 std::vector<double> escape_;
92 std::vector<double> cumulative_; // per edge, cumulative within its site
93};
94
103 public:
104 std::string Name() const override { return "thinning"; }
105 void Prepare(const TimeDependentRates& rates) override;
106 double NextTime(Index site, double t, KMCRandom& random) const override;
107 Index ChooseHop(Index site, double t, KMCRandom& random) const override;
108
109 private:
110 const TimeDependentRates* rates_ = nullptr;
111 std::vector<double> bound_escape_;
112 std::vector<double> cumulative_; // of the bounds
113};
114
150 public:
151 struct Settings {
152 Index quadrature_points = 1000; // per period, for Lambda_i
154 double tolerance = 1e-14; // relative, root search
155 };
156 explicit IntegratedRateInversion(const Settings& settings)
157 : settings_(settings) {}
158 std::string Name() const override { return "integrated-rate inversion"; }
159 void Prepare(const TimeDependentRates& rates) override;
160 double NextTime(Index site, double t, KMCRandom& random) const override;
161 Index ChooseHop(Index site, double t, KMCRandom& random) const override;
162
163 private:
165 const TimeDependentRates* rates_ = nullptr;
166};
167
169std::unique_ptr<WaitingTimeStrategy> MakeWaitingTimeStrategy(
170 const std::string& name);
171
172} // namespace xtp
173} // namespace votca
174
175#endif // VOTCA_XTP_KMCWAITINGTIME_H
Time-homogeneous KMC: waiting time Exp(escape rate), destination with probability w_e / escape rate....
Index ChooseHop(Index site, double t, KMCRandom &random) const override
std::string Name() const override
std::vector< double > cumulative_
double NextTime(Index site, double t, KMCRandom &random) const override
void Prepare(const TimeDependentRates &rates) override
const TimeDependentRates * rates_
double NextTime(Index site, double t, KMCRandom &random) const override
IntegratedRateInversion(const Settings &settings)
Index ChooseHop(Index site, double t, KMCRandom &random) const override
std::string Name() const override
void Prepare(const TimeDependentRates &rates) override
Random numbers for kinetic Monte Carlo: one independent stream per (seed, stream) pair....
Definition kmcrandom.h:42
Thinning (Lewis-Shedler) for any rates with time-independent upper bounds B_e >= w_e(t): candidate ev...
std::vector< double > bound_escape_
std::string Name() const override
const TimeDependentRates * rates_
std::vector< double > cumulative_
double NextTime(Index site, double t, KMCRandom &random) const override
Index ChooseHop(Index site, double t, KMCRandom &random) const override
void Prepare(const TimeDependentRates &rates) override
Hop rates of the edges of a ToFGraph as functions of time.
Definition kmcrates.h:52
Hopping graph for time-of-flight (ToF) transport.
Definition tofgraph.h:77
How a carrier's next hop is drawn: the waiting time and the destination. The pluggable part of the KM...
virtual double NextTime(Index site, double t, KMCRandom &random) const =0
virtual Index ChooseHop(Index site, double t, KMCRandom &random) const =0
virtual std::string Name() const =0
virtual ~WaitingTimeStrategy()=default
virtual void Prepare(const TimeDependentRates &rates)=0
std::unique_ptr< WaitingTimeStrategy > MakeWaitingTimeStrategy(const std::string &name)
strategy by name: exponential, thinning, inversion
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26