votca 2026-dev
Loading...
Searching...
No Matches
qmstate.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 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_QMSTATE_H
22#define VOTCA_XTP_QMSTATE_H
23
24// Standard includes
25#include <cassert>
26#include <string>
27
28// VOTCA includes
29#include <votca/tools/types.h>
30
31namespace votca {
32namespace xtp {
33
35 public:
36 enum statetype { // never change the values
38 Hole = 1,
41 Gstate = 4,
47 };
48
49 QMStateType(const statetype& type) : type_(type) { ; }
51 QMStateType(const std::string& s) { FromString(s); }
52
53 statetype Type() const { return type_; }
54
55 void FromString(const std::string& statetypestring);
56
57 std::string ToString() const;
58
59 std::string ToLongString() const;
60
61 bool operator==(const QMStateType& rhs) const { return type_ == rhs.Type(); }
62
63 bool operator!=(const QMStateType& rhs) const { return type_ != rhs.Type(); }
64
65 bool operator==(const QMStateType::statetype& rhs) const {
66 return type_ == rhs;
67 }
68
69 bool operator!=(const QMStateType::statetype& rhs) const {
70 return type_ != rhs;
71 }
72
73 bool isExciton() const {
76 }
77
82
87
88 bool isGWState() const {
90 }
91
92 bool isKSState() const { return (type_ == statetype::KSstate); }
93
94 bool isPQPState() const { return (type_ == statetype::PQPstate); }
95
96 private:
98};
99
106
107template <class T>
109 public:
110 QMStateCarrierStorage() { content_ = {0, 0, 0, 0}; }
111
112 void setValue(T value, QMStateType t) {
113 assert(t.isKMCState() &&
114 "QMStateCarrierStorage QMStateType is not for KMC simulations");
115 content_[t.Type()] = value;
116 }
117
119 assert(t.isKMCState() &&
120 "QMStateCarrierStorage QMStateType is not for KMC simulations");
121 return content_[t.Type()];
122 }
123
124 private:
125 std::array<T, 4> content_;
126};
127
134
135class QMState {
136
137 public:
138 QMState(const QMStateType::statetype& type, Index index, bool transition)
139 : type_(QMStateType(type)), index_(index), transition_(transition) {
140 ;
141 }
142 QMState(const QMStateType& type, Index index, bool transition)
143 : type_(type), index_(index), transition_(transition) {
144 ;
145 }
146 QMState() { ; }
147 QMState(const std::string& statestring) { FromString(statestring); }
148 void FromString(const std::string& statestring);
149
150 std::string ToString() const;
151
152 std::string ToLongString() const;
153
154 const QMStateType& Type() const { return type_; }
155
156 bool isTransition() const { return transition_; }
157 Index StateIdx() const { return index_; }
158
159 bool operator==(const QMState& rhs) const {
160 return (type_ == rhs.Type() && index_ == rhs.StateIdx());
161 }
162
163 bool operator!=(const QMState& rhs) const {
164 return (type_ != rhs.Type() || index_ != rhs.StateIdx());
165 }
166
167 private:
168 Index DetermineIndex(const std::string& statestring);
169 QMStateType DetermineType(const std::string& statestring);
171
173
175};
176
177} // namespace xtp
178} // namespace votca
179
180#endif // VOTCA_XTP_QMSTATE_H
T getValue(QMStateType t) const
Definition qmstate.h:118
std::array< T, 4 > content_
Definition qmstate.h:125
void setValue(T value, QMStateType t)
Definition qmstate.h:112
statetype Type() const
Definition qmstate.h:53
std::string ToLongString() const
Definition qmstate.cc:72
bool operator!=(const QMStateType::statetype &rhs) const
Definition qmstate.h:69
bool isKSState() const
Definition qmstate.h:92
bool isPQPState() const
Definition qmstate.h:94
bool isGWState() const
Definition qmstate.h:88
QMStateType(const statetype &type)
Definition qmstate.h:49
bool isKMCState() const
Definition qmstate.h:78
bool operator==(const QMStateType::statetype &rhs) const
Definition qmstate.h:65
QMStateType(const std::string &s)
Definition qmstate.h:51
bool operator==(const QMStateType &rhs) const
Definition qmstate.h:61
bool isSingleParticleState() const
Definition qmstate.h:83
std::string ToString() const
Definition qmstate.cc:35
bool isExciton() const
Definition qmstate.h:73
void FromString(const std::string &statetypestring)
Definition qmstate.cc:109
bool operator!=(const QMStateType &rhs) const
Definition qmstate.h:63
bool operator==(const QMState &rhs) const
Definition qmstate.h:159
std::string ToLongString() const
Definition qmstate.cc:139
bool operator!=(const QMState &rhs) const
Definition qmstate.h:163
QMStateType type_
Definition qmstate.h:170
void FromString(const std::string &statestring)
Definition qmstate.cc:212
QMState(const std::string &statestring)
Definition qmstate.h:147
std::string ToString() const
Definition qmstate.cc:155
Index StateIdx() const
Definition qmstate.h:157
QMState(const QMStateType::statetype &type, Index index, bool transition)
Definition qmstate.h:138
bool isTransition() const
Definition qmstate.h:156
const QMStateType & Type() const
Definition qmstate.h:154
QMState(const QMStateType &type, Index index, bool transition)
Definition qmstate.h:142
QMStateType DetermineType(const std::string &statestring)
Definition qmstate.cc:197
Index DetermineIndex(const std::string &statestring)
Definition qmstate.cc:170
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26