votca 2026-dev
Loading...
Searching...
No Matches
tofsimulation.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_TOFSIMULATION_H
22#define VOTCA_XTP_TOFSIMULATION_H
23
24// Standard includes
25#include <cstdint>
26#include <memory>
27#include <string>
28#include <vector>
29
30// Local VOTCA includes
31#include "kmcengine.h"
32#include "kmcrates.h"
33#include "kmcwaitingtime.h"
34#include "tofgraph.h"
35
36namespace votca {
37namespace xtp {
38
61 public:
62 struct Settings {
63 std::uint64_t seed = 1;
64 Index runs = 1000;
65 std::vector<KMCEngine::Pulse> pulses = {KMCEngine::Pulse{}};
67 double tmin = 1e-15; // s, current/collection time axis
68 double tmax = 1.0;
70 };
71
72 struct RunData {
74 double first_arrival = 0.0; // valid if status.absorbed > 0
75 double mean_transit = 0.0; // valid if status.absorbed > 0
76 };
77
78 struct Statistic {
80 double mean = 0.0;
81 double standard_error = 0.0;
82 double standard_deviation = 0.0;
84 double top_percent_share = 0.0;
85 };
86
87 struct Result {
88 std::vector<RunData> runs;
94 Statistic first; // over uncensored runs
95 Statistic transit; // over uncensored runs
96 std::vector<double> bin_edges; // s, size bins + 1
97 std::vector<double> current; // 1/s, per bin
98 std::vector<double> collected; // fraction absorbed by the bin end
102 double displacement_after = 0.0;
103 };
104
106 ToFSimulation(const ToFGraph& graph, const Settings& settings);
107
110 ToFSimulation(const ToFGraph& graph, const Settings& settings,
111 const TimeDependentRates& rates, WaitingTimeStrategy& strategy);
112
113 const std::string& StrategyName() const { return strategy_name_; }
114
115 Result Simulate() const;
116
117 static Statistic Analyze(std::vector<double> samples);
118
119 private:
120 RunData SingleRun(Index run, std::vector<double>& current,
121 std::vector<double>& arrivals, double& before,
122 double& after) const;
123 Index Bin(double t) const;
124
125 void Setup();
126
129 std::unique_ptr<StaticRates> own_rates_;
130 std::unique_ptr<WaitingTimeStrategy> own_strategy_;
131 std::unique_ptr<KMCEngine> engine_;
132 std::string strategy_name_;
133 std::vector<double> edges_;
134};
135
136} // namespace xtp
137} // namespace votca
138
139#endif // VOTCA_XTP_TOFSIMULATION_H
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
Index Bin(double t) const
std::unique_ptr< WaitingTimeStrategy > own_strategy_
const std::string & StrategyName() const
std::vector< double > edges_
std::unique_ptr< StaticRates > own_rates_
std::unique_ptr< KMCEngine > engine_
ToFSimulation(const ToFGraph &graph, const Settings &settings)
static rates of the graph, exponential waiting times
RunData SingleRun(Index run, std::vector< double > &current, std::vector< double > &arrivals, double &before, double &after) const
static Statistic Analyze(std::vector< double > samples)
How a carrier's next hop is drawn: the waiting time and the destination. The pluggable part of the KM...
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
std::vector< double > collected
std::vector< RunData > runs
std::vector< double > bin_edges
std::vector< double > current
std::vector< KMCEngine::Pulse > pulses
double top_percent_share
share of the sum contributed by the largest 1 % of the samples