22#include <boost/format.hpp>
60 std::vector<Segment>& segs = top.
Segments();
62 if (segs.size() < 1) {
63 throw std::runtime_error(
"Your state file contains no segments!");
65 nodes_.reserve(segs.size());
67 bool injectable =
false;
75 if (nblist.
size() < 1) {
76 throw std::runtime_error(
"neighborlist contains no pairs!");
79 throw std::runtime_error(
80 "Your Temperature is negative or zero, please specify the temperature "
90 for (
const QMPair* pair : nblist) {
92 nodes_[pair->Seg1()->getId()].AddEventfromQmPair(*pair,
nodes_,
94 nodes_[pair->Seg2()->getId()].AddEventfromQmPair(*pair,
nodes_,
99 <<
" sites are computed." << std::flush;
103 Index max = std::numeric_limits<Index>::min();
104 Index min = std::numeric_limits<Index>::max();
105 double minlength = std::numeric_limits<double>::max();
106 double maxlength = 0;
107 for (
const auto& node :
nodes_) {
110 for (
const auto& event : node.Events()) {
111 if (event.isDecayEvent()) {
114 double dist =
event.getDeltaR().norm();
115 if (dist > maxlength) {
117 }
else if (dist < minlength) {
125 <<
"Node " << node.getId() <<
" has 0 jumps" << std::flush;
126 }
else if (size < min) {
128 }
else if (size > max) {
132 double avg = double(events) / double(
nodes_.size());
133 double deviation = 0.0;
134 for (
const auto& node :
nodes_) {
135 double size = double(node.Events().size());
136 deviation += (size - avg) * (size - avg);
138 deviation = std::sqrt(deviation /
double(
nodes_.size()));
141 <<
"Nblist has " << nblist.
size() <<
" pairs. Nodes contain " << events
143 <<
"with avg=" << avg <<
" std=" << deviation <<
" max=" << max
144 <<
" min=" << min <<
" jumps per site\n"
150 <<
"spatial carrier density: "
155 std::vector<std::string> ignored_segtypes = toignore.
ToVector();
157 for (
auto& node :
nodes_) {
158 std::string this_segtype = segs[node.getId()].getType();
159 if (std::find(ignored_segtypes.begin(), ignored_segtypes.end(),
160 this_segtype) == ignored_segtypes.end()) {
161 node.InitEscapeRate();
169 std::vector<GNode*>& forbiddenlist)
const {
170 forbiddenlist.clear();
175 GNode& node, std::vector<GNode*>& forbiddenlist)
const {
176 forbiddenlist.push_back(&node);
181 const GNode& node,
const std::vector<GNode*>& forbiddenlist)
const {
182 bool forbidden =
false;
183 for (
const GNode* fnode : forbiddenlist) {
184 if (&node == fnode) {
193 const GNode& node,
const std::vector<GNode*>& forbiddendests)
const {
194 bool surrounded =
true;
195 for (
const auto& event : node.
Events()) {
196 bool thisevent_possible =
true;
197 for (
const GNode* fnode : forbiddendests) {
198 if (event.getDestination() == fnode) {
199 thisevent_possible =
false;
203 if (thisevent_possible ==
true) {
219 <<
"starting position for charge " << i <<
": segment "
227 Index nodeId_guess = -1;
230 }
while (
nodes_[nodeId_guess].isOccupied() ||
231 nodes_[nodeId_guess].isInjectable() ==
244 dt = -1 / cumulated_rate * std::log(rand_u);
260 u -=
carriers_[i].getCurrentEscapeRate() / cumulated_rate;
271 <<
"\nRates are written to " << filename << std::flush;
273 ratefs.open(filename, fstream::out);
274 ratefs <<
"#PairID,SiteID1,SiteID2, ,rate12[1/s],rate21[1/s] at "
279 for (
const QMPair* pair : nblist) {
281 ratefs << pair->getId() <<
" " << pair->Seg1()->getId() <<
" "
282 << pair->Seg2()->getId() <<
" " << rates.
rate12 <<
" "
285 ratefs << std::flush;
290 std::string filename) {
292 <<
"\nOccupations are written to " << filename << std::flush;
294 probs.open(filename, fstream::out);
295 probs <<
"#SiteID, Occupation prob at "
299 double occupationprobability = node.OccupationTime() / simtime;
300 probs << node.getId() <<
"\t" << occupationprobability << endl;
Index getCurrentNodeId() const
const std::vector< GLink > & Events() const
GLink * findHoppingDestination(double p) const
void ResetForbiddenlist(std::vector< GNode * > &forbiddenid) const
void LoadGraph(Topology &top)
std::vector< Chargecarrier > carriers_
void WriteRatestoFile(std::string filename, const QMNBList &nblist)
double Promotetime(double cumulated_rate)
Chargecarrier * ChooseAffectedCarrier(double cumulated_rate)
std::string ignoresegments_
const GLink & ChooseHoppingDest(const GNode &node)
void AddtoForbiddenlist(GNode &node, std::vector< GNode * > &forbiddenid) const
void RandomlyAssignCarriertoSite(Chargecarrier &Charge)
void RandomlyCreateCharges()
std::string trajectoryfile_
void ParseCommonOptions(const tools::Property &options)
bool CheckSurrounded(const GNode &node, const std::vector< GNode * > &forbiddendests) const
std::string injectionmethod_
tools::Random RandomVariable_
std::vector< GNode > nodes_
void WriteOccupationtoFile(double simtime, std::string filename)
bool CheckForbidden(const GNode &node, const std::vector< GNode * > &forbiddenlist) const
std::string injection_name_
std::string ToLongString() const
std::string ToString() const
PairRates Rate(const QMPair &pair, QMStateType carriertype) const
Container for segments and box and atoms.
std::vector< Segment > & Segments()
#define XTP_LOG(level, log)
base class for all analysis tools