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 =
"";
70 std::string identifier =
"";
73 identifier =
"singlet";
76 identifier =
"triplet";
79 identifier =
"pert-qparticle";
82 identifier =
"diag-qparticle";
85 identifier =
"Kohn-Sham-orbital";
88 identifier =
"groundstate";
94 identifier =
"electron";
97 identifier =
"localized-orbital";
104 std::string lower = boost::algorithm::to_lower_copy(statetypestring);
106 if (lower ==
"s" || lower ==
"singlet") {
108 }
else if (lower ==
"t" || lower ==
"triplet") {
110 }
else if (lower ==
"pqp" || lower ==
"pert-qparticle") {
112 }
else if (lower ==
"dqp" || lower ==
"diag-qparticle" || lower ==
"qpdiag") {
114 }
else if (lower ==
"ks" || lower ==
"kohn-sham-orbital") {
116 }
else if (lower ==
"n" || lower ==
"groundstate" || lower ==
"gs") {
118 }
else if (lower ==
"h" || lower ==
"hole") {
120 }
else if (lower ==
"e" || lower ==
"electron") {
122 }
else if (lower ==
"l" || lower ==
"localized-orbital") {
125 throw std::runtime_error(
"Statetype:" + statetypestring +
141 result =
"Groundstate to " + result;
154 std::string result =
type_.
ToString() + (boost::format(
"%i") % index).str();
156 result =
"n2" + result;
164 std::regex reg(
"[0-9]+");
166 bool found_integer = std::regex_search(statestring, search, reg);
167 if (!found_integer) {
173 throw std::runtime_error(
"Found no index in string: " + statestring);
175 if (search.size() > 1) {
176 throw std::runtime_error(
"Found more than 1 index in string: " +
180 Index index = boost::lexical_cast<Index>(search.str(0));
189 std::regex reg(
"[^0-9]+");
192 bool found_typestring = std::regex_search(statestring, search, reg);
193 if (!found_typestring) {
194 throw std::runtime_error(
"Found no type in string: " + statestring);
196 if (search.size() > 1) {
197 throw std::runtime_error(
"Found more than one type in string: " +
204 std::string lower = boost::algorithm::to_lower_copy(statestring);
207 if (boost::starts_with(lower,
"n2")) {
209 rest = lower.substr(2);
210 }
else if (boost::starts_with(lower,
"groundstate to")) {
212 rest = lower.substr(14);
221 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)
base class for all analysis tools