votca 2026-dev
Loading...
Searching...
No Matches
bulksimulation.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_BULKSIMULATION_H
22#define VOTCA_XTP_BULKSIMULATION_H
23
24// Standard includes
25#include <cstdint>
26#include <memory>
27#include <string>
28#include <vector>
29
30// Local VOTCA includes
31#include "eigen.h"
32#include "kmcengine.h"
33#include "kmcrates.h"
34#include "kmcwaitingtime.h"
35#include "tofgraph.h"
36
37namespace votca {
38namespace xtp {
39
66 public:
67 struct Settings {
68 std::uint64_t seed = 1;
72 double equilibration = 0.0; // s
76 double sample_interval = 0.0;
78 };
79
81 struct Sample {
82 double time = 0.0;
85 std::vector<Eigen::Vector3d> positions;
87 double energy = 0.0;
88 };
89
90 struct RunData {
93 double start = 0.0;
94 double end = 0.0;
95 Eigen::Vector3d velocity = Eigen::Vector3d::Zero();
96 Eigen::Matrix3d diffusion = Eigen::Matrix3d::Zero();
98 Eigen::Matrix3d velocity_covariance = Eigen::Matrix3d::Zero();
100 double block_length = 0.0;
102 std::vector<Eigen::Vector3d> displacement;
103 };
104
105 struct Result {
106 std::vector<RunData> runs;
107 Eigen::Vector3d velocity = Eigen::Vector3d::Zero();
108 Eigen::Vector3d velocity_error = Eigen::Vector3d::Zero();
109 Eigen::Matrix3d diffusion = Eigen::Matrix3d::Zero();
111 Eigen::Matrix3d diffusion_error = Eigen::Matrix3d::Zero();
113 Eigen::VectorXd occupation;
114 std::vector<Sample> trajectory;
118 };
119
127 struct ExactResult {
128 bool available = false;
129 std::string message;
130 Index sites = 0; // in the closed class
131 Eigen::Vector3d velocity = Eigen::Vector3d::Zero();
132 Eigen::Matrix3d diffusion = Eigen::Matrix3d::Zero();
133 Eigen::VectorXd occupation; // pi, zero outside the closed class
134 std::string solver;
135 double backward_error = 0.0;
136 bool converged = false;
137 };
138
139 static ExactResult Exact(const ToFGraph& graph, Index direct_limit = 20000,
140 double tolerance = 1e-12);
141
144 BulkSimulation(const ToFGraph& graph, const Settings& settings);
145 BulkSimulation(const ToFGraph& graph, const Settings& settings,
146 const TimeDependentRates& rates,
147 WaitingTimeStrategy& strategy);
148
149 Result Simulate() const;
150
151 private:
154 std::unique_ptr<TimeDependentRates> own_rates_;
155 std::unique_ptr<WaitingTimeStrategy> own_strategy_;
156 std::unique_ptr<KMCEngine> engine_;
157
158 void Check() const;
159 RunData SingleRun(Index run, Eigen::VectorXd& occupation,
160 std::vector<Sample>* trajectory) const;
161};
162
163} // namespace xtp
164} // namespace votca
165
166#endif // VOTCA_XTP_BULKSIMULATION_H
std::unique_ptr< WaitingTimeStrategy > own_strategy_
static ExactResult Exact(const ToFGraph &graph, Index direct_limit=20000, double tolerance=1e-12)
direct sparse LU up to direct_limit sites, BiCGSTAB with ILUT above
std::unique_ptr< KMCEngine > engine_
RunData SingleRun(Index run, Eigen::VectorXd &occupation, std::vector< Sample > *trajectory) const
BulkSimulation(const ToFGraph &graph, const Settings &settings)
std::unique_ptr< TimeDependentRates > own_rates_
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...
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
Eigen::Matrix3d diffusion_error
standard error over runs, zero for one run
Eigen::VectorXd occupation
occupation probability per site, averaged over runs
Eigen::Matrix3d velocity_covariance
covariance of the block increments of the velocity estimate
double start
observation window [start, end]
std::vector< Eigen::Vector3d > displacement
displacement of each carrier over the window
state of run 0 at a sampling time
double energy
mean site energy of the carriers
std::vector< Eigen::Vector3d > positions
unwrapped positions of the carriers