24#include <boost/algorithm/string.hpp>
25#include <boost/format.hpp>
26#include <boost/lexical_cast.hpp>
27#include <boost/regex.hpp>
36 std::string identifier =
"";
73 std::string identifier =
"";
76 identifier =
"singlet";
79 identifier =
"triplet";
82 identifier =
"pert-qparticle";
85 identifier =
"diag-qparticle";
88 identifier =
"Kohn-Sham-orbital";
91 identifier =
"groundstate";
97 identifier =
"electron";
100 identifier =
"localized-orbital";
103 identifier =
"uks-exciton";
110 std::string lower = boost::algorithm::to_lower_copy(statetypestring);
112 if (lower ==
"s" || lower ==
"singlet") {
114 }
else if (lower ==
"t" || lower ==
"triplet") {
116 }
else if (lower ==
"pqp" || lower ==
"pert-qparticle") {
118 }
else if (lower ==
"dqp" || lower ==
"diag-qparticle" || lower ==
"qpdiag") {
120 }
else if (lower ==
"ks" || lower ==
"kohn-sham-orbital") {
122 }
else if (lower ==
"n" || lower ==
"groundstate" || lower ==
"gs") {
124 }
else if (lower ==
"h" || lower ==
"hole") {
126 }
else if (lower ==
"e" || lower ==
"electron") {
128 }
else if (lower ==
"l" || lower ==
"localized-orbital") {
130 }
else if (lower ==
"xu" || lower ==
"uks-exciton" ||
131 lower ==
"exciton_uks") {
134 throw std::runtime_error(
"Statetype:" + statetypestring +
145 return type_.ToLongString();
148 type_.ToLongString() + (boost::format(
" %i") % index).str();
150 result =
"Groundstate to " + result;
161 return type_.ToString();
163 std::string result =
type_.ToString() + (boost::format(
"%i") % index).str();
165 result =
"n2" + result;
173 std::regex reg(
"[0-9]+");
175 bool found_integer = std::regex_search(statestring, search, reg);
176 if (!found_integer) {
182 throw std::runtime_error(
"Found no index in string: " + statestring);
184 if (search.size() > 1) {
185 throw std::runtime_error(
"Found more than 1 index in string: " +
189 Index index = boost::lexical_cast<Index>(search.str(0));
198 std::regex reg(
"[^0-9]+");
201 bool found_typestring = std::regex_search(statestring, search, reg);
202 if (!found_typestring) {
203 throw std::runtime_error(
"Found no type in string: " + statestring);
205 if (search.size() > 1) {
206 throw std::runtime_error(
"Found more than one type in string: " +
213 std::string lower = boost::algorithm::to_lower_copy(statestring);
216 if (boost::starts_with(lower,
"n2")) {
218 rest = lower.substr(2);
219 }
else if (boost::starts_with(lower,
"groundstate to")) {
221 rest = lower.substr(14);
230 throw std::runtime_error(
"Transition states only exist for singlets.");
std::string ToLongString() const
std::string ToString() const
void FromString(const std::string &statetypestring)
std::string ToLongString() const
void FromString(const std::string &statestring)
std::string ToString() const
QMStateType DetermineType(const std::string &statestring)
Index DetermineIndex(const std::string &statestring)
Charge transport classes.
Provides a means for comparing floating point numbers.