|
8 | 8 | #include "classes/coreData.h" |
9 | 9 | #include "classes/pairPotential.h" |
10 | 10 | #include "classes/species.h" |
11 | | -#include "kernels/potentials/producer.h" |
12 | 11 | #include <algorithm> |
13 | 12 |
|
14 | 13 | // Write through specified LineParser |
@@ -62,24 +61,6 @@ bool Configuration::serialise(LineParser &parser) const |
62 | 61 | return false; |
63 | 62 | } |
64 | 63 |
|
65 | | - // If there are no defined external potentials we are done |
66 | | - if (globalPotentials_.empty() && targetedPotentials_.empty()) |
67 | | - return true; |
68 | | - |
69 | | - // Write global potentials |
70 | | - if (!parser.writeLineF("{} # nGlobalPotentials\n", globalPotentials_.size())) |
71 | | - return false; |
72 | | - for (auto &pot : globalPotentials_) |
73 | | - if (!pot->serialise(parser, "")) |
74 | | - return false; |
75 | | - |
76 | | - // Write targeted potentials |
77 | | - if (!parser.writeLineF("{} # nTargetedPotentials\n", targetedPotentials_.size())) |
78 | | - return false; |
79 | | - for (auto &pot : targetedPotentials_) |
80 | | - if (!pot->serialise(parser, "")) |
81 | | - return false; |
82 | | - |
83 | 64 | return true; |
84 | 65 | } |
85 | 66 |
|
@@ -168,77 +149,5 @@ bool Configuration::deserialise(LineParser &parser, const CoreData &coreData, bo |
168 | 149 | if (!hasPotentials) |
169 | 150 | return true; |
170 | 151 |
|
171 | | - // Read in global potentials |
172 | | - if (parser.getArgsDelim(LineParser::Defaults) != LineParser::Success) |
173 | | - return false; |
174 | | - globalPotentials_.resize(parser.argi(0)); |
175 | | - for (auto &pot : globalPotentials_) |
176 | | - { |
177 | | - // First line contains potential type |
178 | | - if (parser.getArgsDelim(LineParser::Defaults) != LineParser::Success) |
179 | | - return false; |
180 | | - auto potentialType = ExternalPotentialTypes::isType(parser.argsv(0)); |
181 | | - if (!potentialType) |
182 | | - return Messenger::error("Unrecognised external potential type '{}' found in Configuration '{}' in restart file.\n", |
183 | | - parser.argsv(0), name()); |
184 | | - |
185 | | - // Create new external potential |
186 | | - pot = ExternalPotentialProducer::create(*potentialType); |
187 | | - if (!pot->deserialise(parser, coreData)) |
188 | | - return false; |
189 | | - } |
190 | | - |
191 | | - // Get atom types present in configuration |
192 | | - auto atomTypes = atomTypeVector(); |
193 | | - |
194 | | - // Read in targeted potentials |
195 | | - if (parser.getArgsDelim(LineParser::Defaults) != LineParser::Success) |
196 | | - return false; |
197 | | - targetedPotentials_.resize(parser.argi(0)); |
198 | | - for (auto &pot : targetedPotentials_) |
199 | | - { |
200 | | - // First line contains potential type |
201 | | - if (parser.getArgsDelim(LineParser::Defaults) != LineParser::Success) |
202 | | - return false; |
203 | | - auto potentialType = ExternalPotentialTypes::isType(parser.argsv(0)); |
204 | | - if (!potentialType) |
205 | | - return Messenger::error("Unrecognised external potential type '{}' found in Configuration '{}' in restart file.\n", |
206 | | - parser.argsv(0), name()); |
207 | | - |
208 | | - // Create new external potential |
209 | | - pot = ExternalPotentialProducer::create(*potentialType); |
210 | | - |
211 | | - // Additional arguments after the potential type correspond to targets for the potential |
212 | | - for (auto n = 1; n < parser.nArgs(); ++n) |
213 | | - { |
214 | | - // Plain number - corresponds to a specific atom in the configuration |
215 | | - if (DissolveSys::isNumber(parser.args(n))) |
216 | | - { |
217 | | - auto i = parser.argi(n); |
218 | | - if (i < 0 || i >= atoms_.size()) |
219 | | - Messenger::exception("Atom index {} for targeted potential is out of range.\n", i); |
220 | | - pot->addTargetAtomIndex(i); |
221 | | - } |
222 | | - else if (std::ranges::find_if(atomTypes, [&](const auto at) |
223 | | - { return DissolveSys::sameString(at->name(), parser.args(n)); }) != atomTypes.end()) |
224 | | - { |
225 | | - auto it = std::ranges::find_if(atomTypes, [&](const auto at) |
226 | | - { return DissolveSys::sameString(at->name(), parser.args(n)); }); |
227 | | - pot->addTargetAtomType(*it); |
228 | | - } |
229 | | - else if (coreData.findSpecies(DissolveSys::niceName(parser.args(n)))) |
230 | | - pot->addTargetSpecies(coreData.findSpecies(DissolveSys::niceName(parser.args(n)))); |
231 | | - else |
232 | | - Messenger::exception("Unrecognised target '{}' for potential.\n", parser.args(n)); |
233 | | - } |
234 | | - |
235 | | - // Read in the rest of the potential |
236 | | - if (!pot->deserialise(parser, coreData)) |
237 | | - return false; |
238 | | - } |
239 | | - |
240 | | - // Link targeted potentials to atoms |
241 | | - linkTargetedPotentials(); |
242 | | - |
243 | 152 | return true; |
244 | 153 | } |
0 commit comments