44 throw std::runtime_error(
"EwaldRegistry: unknown EwaldChargeState");
48 if (tag ==
"neutral") {
52 if (tag ==
"electron") {
64 return std::to_string(
id) +
"_" + StateTag(state);
78 if (site.getRank() > 1) {
79 std::stringstream message;
80 message <<
"EwaldRegistry: segment " <<
id <<
", site " << site.getId()
81 <<
" (" << site.getElement() <<
") has rank " << site.getRank()
82 <<
". This Ewald implementation handles charges and dipoles "
83 "(rank <= 1) only -- higher multipoles would be read and "
84 "then ignored, giving a wrong energy with no symptom. Use "
85 "a rank 0 or rank 1 .mps.";
86 throw std::runtime_error(message.str());
93 store_.insert_or_assign(
Key(
id, state), std::move(segment));
103 std::stringstream message;
104 message <<
"EwaldRegistry: no entry for segment id " <<
id <<
" in state '"
105 << StateTag(state) <<
"'";
106 throw std::out_of_range(message.str());
114 std::stringstream message;
115 message <<
"EwaldRegistry: no entry for segment id " <<
id <<
" in state '"
116 << StateTag(state) <<
"'";
117 throw std::out_of_range(message.str());
127 std::vector<Index> ids;
128 for (
const auto& entry :
store_) {
129 Index id = entry.first.first;
130 if (ids.empty() || ids.back() !=
id) {
138 std::vector<EwaldChargeState> states;
139 for (
const auto& entry :
store_) {
140 if (entry.first.first ==
id) {
141 states.push_back(entry.first.second);
151 for (
const auto& entry :
store_) {
152 Index id = entry.first.first;
167 std::stringstream message;
168 message <<
"EwaldRegistry: size inconsistency reading checkpoint ("
169 << names.size() <<
" groups found, " <<
size <<
" expected)";
170 throw std::runtime_error(message.str());
172 for (
const std::string& name : names) {
175 std::size_t split = name.rfind(
'_');
176 if (split == std::string::npos) {
177 throw std::runtime_error(
178 "EwaldRegistry: malformed checkpoint group name '" + name +
"'");
180 Index id = std::stoi(name.substr(0, split));
181 std::string tag = name.substr(split + 1);
183 if (!TagToState(tag, state)) {
184 throw std::runtime_error(
"EwaldRegistry: unknown charge state tag '" +
185 tag +
"' in checkpoint group name '" + name +
virtual void WriteToCpt(CheckpointWriter &w) const
std::vector< std::string > getChildGroupNames() const
CheckpointReader openChild(const std::string &childName) const
CheckpointWriter openChild(const std::string &childName) const
std::map< Key, PolarSegment, KeyLess > store_
bool Has(Index id, EwaldChargeState state) const
std::pair< Index, EwaldChargeState > Key
std::vector< EwaldChargeState > StatesFor(Index id) const
std::vector< Index > AllIds() const
void WriteToCpt(CheckpointWriter &w) const
const PolarSegment & Get(Index id, EwaldChargeState state) const
void Erase(Index id, EwaldChargeState state)
void Register(Index id, EwaldChargeState state, PolarSegment segment)
void ReadFromCpt(CheckpointReader &r)
Class to represent Atom/Site in electrostatic+polarization.
Charge transport classes.
ClassicalSegment< PolarSite > PolarSegment
Provides a means for comparing floating point numbers.