MADNESS 0.10.1
RestartPlan.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2007,2010 Oak Ridge National Laboratory
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30*/
31
32/// \file RestartPlan.h
33/// \brief decide once, per geometry, where the initial orbitals come from
34
35#ifndef MADNESS_CHEM_RESTARTPLAN_H__INCLUDED
36#define MADNESS_CHEM_RESTARTPLAN_H__INCLUDED
37
40
41#include <optional>
42#include <string>
43#include <vector>
44
45namespace madness {
46
47/// what the user asked for with the `restart` keyval
48///
49/// `automatic` is spelled "auto" in input files -- `auto` is a C++ keyword.
50enum class RestartMode {
51 automatic, ///< look at what is on disk and choose (the default)
52 none, ///< ignore everything on disk, start from the initial guess
53 iterate, ///< read restartdata and keep iterating
54 read_only, ///< read restartdata and do not iterate, whatever its precision;
55 ///< requires the archive to be for the requested geometry
56 ao, ///< read the AO projections (restartaodata) and iterate
57 nwchem, ///< read an NWChem movecs file and iterate
58};
59
60/// the six spellings accepted by the `restart` keyval, for allowed_values
61inline std::vector<std::string> restart_mode_names() {
62 return {"auto", "none", "iterate", "read_only", "ao", "nwchem"};
63}
64
65inline std::string to_string(const RestartMode m) {
66 switch (m) {
67 case RestartMode::automatic: return "auto";
68 case RestartMode::none: return "none";
69 case RestartMode::iterate: return "iterate";
70 case RestartMode::read_only: return "read_only";
71 case RestartMode::ao: return "ao";
72 case RestartMode::nwchem: return "nwchem";
73 }
74 return "auto";
75}
76
77/// parse the `restart` keyval
78///
79/// Throws on an unknown spelling. The keyval carries allowed_values, so
80/// QCParameter normally rejects a bad string before this is ever reached; this
81/// check is the backstop for values set programmatically.
82inline RestartMode restart_mode_from_string(const std::string& s) {
83 if (s == "auto") return RestartMode::automatic;
84 if (s == "none") return RestartMode::none;
85 if (s == "iterate") return RestartMode::iterate;
86 if (s == "read_only") return RestartMode::read_only;
87 if (s == "ao") return RestartMode::ao;
88 if (s == "nwchem") return RestartMode::nwchem;
89 MADNESS_EXCEPTION("unknown restart mode", 1);
90}
91
92/// where the initial orbitals will come from
93enum class RestartSource : int {
94 initial_guess = 0, ///< atomic guess, i.e. no restart at all
95 restartdata = 1, ///< <prefix>.restartdata, MRA orbitals
96 restartao = 2, ///< <prefix>.restartaodata, AO expansion coefficients
97 nwchem = 3, ///< an NWChem movecs file
98};
99
100inline std::string to_string(const RestartSource s) {
101 switch (s) {
102 case RestartSource::restartdata: return "restartdata";
103 case RestartSource::restartao: return "restartaodata";
104 case RestartSource::nwchem: return "nwchem";
105 default: return "initial_guess";
106 }
107}
108
109/// what a look at the disk found -- pure disk facts, no engine opinion in here
110///
111/// Separated from the decision so that plan_restart() stays a pure function of
112/// its arguments and the whole decision table can be tested without touching a
113/// filesystem or constructing an MRA function.
115
116 /// <prefix>.restartdata.00000 exists
118
119 /// its header parsed. Set only when restartdata_present; a present file with
120 /// no metadata is a corrupt or future-version archive, which is worth saying
121 /// out loud rather than quietly recomputing.
122 std::optional<RestartMetadata> meta;
123
124 /// <prefix>.restartaodata exists
125 bool restartao_present = false;
126
127 /// an NWChem file was named in the input
128 bool nwfile_named = false;
129};
130
131/// which restart sources the asking engine can actually read
132///
133/// Not every engine can read every source, and pretending otherwise turns a
134/// clear "not implemented" into a confusing "file not found". moldft can read
135/// all of them; nemo can read neither the AO projections (`SCF::restart_aos` is
136/// reachable only from `SCF::get_initial_orbitals`, which nemo never calls, and
137/// the file holds <AO|psi> where nemo needs <AO|F>) nor NWChem movecs.
139 bool ao = false; ///< can read <prefix>.restartaodata
140 bool nwchem = false; ///< can read an NWChem movecs file
141
142 static RestartCapabilities all() { return {true, true}; }
143 static RestartCapabilities restartdata_only() { return {false, false}; }
144};
145
146/// how the requested geometry relates to the one in an archive
147enum class GeometryMatch {
148 same, ///< same atoms at the same places
149 displaced, ///< same atoms, moved -- e.g. a geometry optimization step
150 different_composition, ///< different atoms altogether
151};
152
153/// compare two molecules, atom by atom and in order
154///
155/// Order matters: the orbitals in an archive are expanded about the atoms in
156/// the order the archive's molecule lists them, so a permuted molecule is not
157/// the same molecule as far as restart is concerned.
159 const double tol = 1.e-8) {
160 if (archive.natom() != requested.natom()) return GeometryMatch::different_composition;
161 for (std::size_t i = 0; i < requested.natom(); ++i) {
162 if (archive.get_atomic_number(i) != requested.get_atomic_number(i))
164 }
165 for (std::size_t i = 0; i < requested.natom(); ++i) {
166 const Atom a = archive.get_atom(i);
167 const Atom b = requested.get_atom(i);
168 if (std::abs(a.x - b.x) > tol or std::abs(a.y - b.y) > tol or
169 std::abs(a.z - b.z) > tol)
171 }
172 return GeometryMatch::same;
173}
174
175/// the decision: one source, one starting rung, one reason
177
178 RestartMode mode = RestartMode::automatic; ///< what was asked for
180
181 /// false means "return what is on disk without solving anything"
182 bool iterate = true;
183
184 /// rung of `protocol()` to start at; rungs below it are already covered
185 std::size_t protocol_start = 0;
186
187 /// energy from the archive, meaningful only when iterate==false
188 double stale_energy = 1.e10;
189
190 /// true if this decision should be logged as a WARNING rather than as info
191 ///
192 /// Two cases: a file was there but could not be used (silently recomputing
193 /// would hide a disk fault or a wrong prefix), and read_only handing back an
194 /// energy that does not meet the requested precision.
195 bool warn = false;
196
197 /// one line, for the log and for the results json
198 std::string why;
199
200 /// true if orbitals have to be read from disk before anything else happens
202
203 std::string print_to_string() const {
204 return "restart " + madness::to_string(mode) + ": from " +
205 madness::to_string(source) + ", " +
206 (iterate ? "starting at protocol rung " + std::to_string(protocol_start)
207 : std::string("no iterations")) +
208 " -- " + why;
209 }
210
211 /// serialization, so the plan can be decided on one rank and broadcast
212 template <typename Archive>
213 void serialize(Archive& ar) {
214 int m = static_cast<int>(mode);
215 int s = static_cast<int>(source);
216 ar & m & s & iterate & protocol_start & stale_energy & warn & why;
217 mode = static_cast<RestartMode>(m);
218 source = static_cast<RestartSource>(s);
219 }
220};
221
222/// format a threshold compactly for a log line ("1e-06", not "0.000001")
223inline std::string format_thresh(const double t) {
224 std::stringstream ss;
225 ss << std::scientific << std::setprecision(0) << t;
226 return ss.str();
227}
228
229/// index of the first protocol rung that is tighter than an achieved precision
230///
231/// nullopt means the ladder holds nothing tighter, i.e. the archive already
232/// covers every rung. The 0.999 slack absorbs the round trip of a threshold
233/// through an archive; without it a run converged to 1e-6 can fail to recognize
234/// the 1e-6 rung as covered.
235inline std::optional<std::size_t>
236first_rung_tighter_than(const std::vector<double>& protocol, const double achieved) {
237 for (std::size_t i = 0; i < protocol.size(); ++i)
238 if (protocol[i] < achieved * 0.999) return i;
239 return std::nullopt;
240}
241
242/// decide where the initial orbitals come from -- the whole decision table
243///
244/// Pure: no filesystem, no MPI, no MRA. That is the point of the split, and it
245/// is what makes the table testable line by line (test_restart.cc).
246///
247/// @param[in] mode the user's `restart` keyval
248/// @param[in] disk what survey_restart_sources() found
249/// @param[in] can which sources the asking engine can read
250/// @param[in] protocol the precision ladder, `CalculationParameters::protocol()`
251/// @param[in] user_dconv the user's `dconv`
252/// @param[in] requested the geometry this calculation is for
253/// @param[in] wanted the representation the asking engine stores (mo/nemo/znemo)
254/// @param[in] eprec the requested molecular smoothing parameter; 0 skips the
255/// check, which is what a caller that does not know it passes
256/// @param[in] xc the requested exchange-correlation functional; an empty
257/// string skips the check
258/// @param[in] ncf the requested nuclear correlation factor, e.g. "slater:2.0";
259/// empty for an engine that has none, and skips the check
262 const std::vector<double>& protocol,
263 const double user_dconv, const Molecule& requested,
265 const double eprec = 0.0,
266 const std::string& xc = "",
267 const std::string& ncf = "") {
268
269 MADNESS_CHECK_THROW(not protocol.empty(), "empty protocol in plan_restart");
270 const std::size_t last = protocol.size() - 1;
271
272 const bool ao_available = disk.restartao_present and can.ao;
273 const bool nwchem_available = disk.nwfile_named and can.nwchem;
274
275 // the precision this run has to reach. dconv cannot be demanded tighter
276 // than the final rung represents, which is what SCFProtocol also does.
277 const double target_thresh = protocol.back();
278 const double target_dconv = std::max(target_thresh, user_dconv);
279
281 plan.mode = mode;
282
283 // does the archive solve the same Hamiltonian this run is asking about?
284 //
285 // eprec, xc and the nuclear correlation factor all change the operator, not
286 // just its representation: orbitals from a different one are a perfectly good
287 // guess, but their convergence claim is about another problem, and -- unlike a
288 // k or thresh mismatch -- that cannot be repaired by reprojecting. An unset
289 // value on either side (0.0 / "") means "not recorded" -- v4 archives, the
290 // seeding tools, and engines that have no ncf -- which is not evidence of a
291 // mismatch. Returns an empty string when the Hamiltonians agree, otherwise the
292 // phrase that goes into `why`.
293 auto hamiltonian_mismatch = [&](const RestartMetadata& meta) {
294 if (meta.eprec != 0.0 and eprec != 0.0 and
295 std::abs(meta.eprec / eprec - 1.0) > 1.e-10)
296 return "archive was written at eprec " + format_thresh(meta.eprec) +
297 ", this run uses " + format_thresh(eprec);
298 if (not meta.xc.empty() and not xc.empty() and meta.xc != xc)
299 return "archive was written with xc '" + meta.xc + "', this run uses '" +
300 xc + "'";
301 if (not meta.ncf.empty() and not ncf.empty() and meta.ncf != ncf)
302 return "archive was written with the nuclear correlation factor '" +
303 meta.ncf + "', this run uses '" + ncf + "'";
304 return std::string();
305 };
306
307 // ---- fall back to the initial guess, recording why ---------------------
308 auto give_up = [&](const std::string& why) {
310 plan.iterate = true;
311 plan.protocol_start = 0;
312 plan.why = why;
313 return plan;
314 };
315
316 // ---- use restartdata, iterating from wherever it left off --------------
317 auto continue_from_archive = [&](const RestartMetadata& meta, const std::string& why) {
319 plan.stale_energy = meta.current_energy;
320 const auto rung = first_rung_tighter_than(protocol, meta.converged_for_thresh);
321 plan.iterate = true;
322 plan.protocol_start = rung.value_or(last);
323 plan.why = why;
324 return plan;
325 };
326
327 if (mode == RestartMode::none) {
328 // Contradictory input, and worth saying so here: with `nwfile` set, the AO
329 // basis itself is read from the NWChem file (SCF's ctor), so there is no
330 // atomic guess left to fall back to and SCF::initial_guess asserts with a
331 // message that explains nothing.
333 "restart none together with `nwfile`: the AO basis is read from the "
334 "nwchem file, so there is no atomic guess to fall back to. Use "
335 "restart=nwchem, or drop the `nwfile` keyval.");
336 return give_up("restart none: ignoring anything on disk");
337 }
338
339 // ---- explicitly requested sources: never fall back silently ------------
340 //
341 // A silent fallback here burns hours: the user asked to resume a long run
342 // and would get a fresh one instead, indistinguishable from the outside
343 // until the wall clock says so.
344 if (mode == RestartMode::nwchem) {
346 "restart nwchem: this calculation cannot read NWChem orbitals");
347 MADNESS_CHECK_THROW(disk.nwfile_named,
348 "restart nwchem: no nwchem file given -- set the `nwfile` keyval");
350 plan.iterate = true;
351 plan.protocol_start = 0;
352 plan.why = "restart nwchem: as requested";
353 return plan;
354 }
355
356 if (mode == RestartMode::ao) {
358 "restart ao: this calculation cannot read AO projections");
359 MADNESS_CHECK_THROW(disk.restartao_present,
360 "restart ao: no restartaodata file found");
362 plan.iterate = true;
363 plan.protocol_start = 0;
364 plan.why = "restart ao: as requested";
365 return plan;
366 }
367
368 if (mode == RestartMode::iterate or mode == RestartMode::read_only) {
369 MADNESS_CHECK_THROW(disk.restartdata_present,
370 "restart iterate/read_only: no restartdata archive found");
371 MADNESS_CHECK_THROW(disk.meta.has_value(),
372 "restart iterate/read_only: the restartdata archive could not be read");
373 const RestartMetadata& meta = disk.meta.value();
375 "restart iterate/read_only: the restartdata archive holds a different "
376 "kind of orbital than this calculation uses");
377
378 if (mode == RestartMode::read_only) {
379 // Precision is the user's call to make; the geometry is not. read_only
380 // hands back meta.current_energy without solving anything, so at a
381 // displaced geometry it would report an energy for a molecule nobody
382 // asked about -- and unlike a loose threshold, that cannot be what the
383 // user meant. `iterate` needs no such check: there the orbitals are
384 // only a starting guess and the SCF runs at the requested geometry.
387 "restart read_only: archive geometry does not match the requested geometry");
388 // The user asserted these orbitals are the answer. Respect that even
389 // when they are not converged to the requested precision -- warn and
390 // hand back the stale energy rather than second-guessing.
392 plan.iterate = false;
393 plan.protocol_start = last;
394 plan.stale_energy = meta.current_energy;
395 const std::string other = hamiltonian_mismatch(meta);
396 if (not other.empty()) {
397 // Not overridden -- the user asked for these orbitals and gets
398 // them -- but handing back an energy for a different Hamiltonian
399 // without saying so is how a wrong number ends up in a table.
400 plan.warn = true;
401 plan.why = "restart read_only: " + other +
402 " -- returning the archive's energy for a DIFFERENT "
403 "Hamiltonian, as requested";
404 return plan;
405 }
407 plan.warn = not good;
408 plan.why = good
409 ? "restart read_only: archive is converged to the requested precision"
410 : "restart read_only: archive is converged only to thresh " +
411 format_thresh(meta.converged_for_thresh) + " dconv " +
412 format_thresh(meta.converged_for_dconv) + ", NOT to the requested " +
414 " -- returning its energy anyway, as requested";
415 return plan;
416 }
417 // iterate: honour the request even if the archive already looks converged,
418 // and in that case re-verify at the final rung rather than doing nothing.
419 return continue_from_archive(meta, "restart iterate: as requested");
420 }
421
422 // ---- automatic ---------------------------------------------------------
424
425 if (not disk.restartdata_present) {
426 // nwchem before the AO projections, which reverses the order the old
427 // precedence ladder used (SCF::get_initial_orbitals: restartdata, ao,
428 // NWChem, guess). Naming a file in the input is a statement of intent; a
429 // leftover restartaodata is not. In practice the two rarely coexist --
430 // save_mos deliberately writes no restartaodata when nwfile is set,
431 // because the AO basis then comes from the nwchem file.
432 if (nwchem_available) {
434 plan.why = "restart auto: no restartdata, but an nwchem file was given";
435 return plan;
436 }
437 if (ao_available) {
439 plan.why = "restart auto: no restartdata, using the AO projections";
440 return plan;
441 }
442 return give_up("restart auto: nothing on disk");
443 }
444
445 // a file is there. Anything below this point that rejects it is a surprise
446 // and must be reported, not swallowed.
447 auto reject_archive = [&](const std::string& why) {
448 plan.warn = true;
449 if (ao_available) {
451 plan.iterate = true;
452 plan.protocol_start = 0;
453 plan.why = why + "; using the AO projections instead";
454 return plan;
455 }
456 return give_up(why + "; starting from the initial guess instead");
457 };
458
459 if (not disk.meta.has_value())
460 return reject_archive("restart auto: restartdata exists but its header could "
461 "not be read (truncated, or written by a newer MADNESS)");
462
463 const RestartMetadata& meta = disk.meta.value();
464
466 return reject_archive("restart auto: restartdata holds '" +
468 "' orbitals, this calculation wants '" +
470
473 // Not a fault: a different molecule in the same directory. The AO file
474 // is indexed by the same atoms, so it is no better.
475 plan.warn = false;
476 return give_up("restart auto: restartdata is for a different molecule");
477 }
479 // A geometry optimization step. MRA orbitals at the old geometry are
480 // wrong where it matters most -- at the nuclei -- so go through the AO
481 // expansion, which is re-centred on the new positions.
482 if (ao_available) {
484 plan.iterate = true;
485 plan.protocol_start = 0;
486 plan.why = "restart auto: geometry moved, using the AO projections";
487 return plan;
488 }
489 return give_up("restart auto: geometry moved and no AO projections available");
490 }
491
492 // A different eprec, functional or nuclear correlation factor is a different
493 // Hamiltonian: keep the orbitals as a guess, but throw away the archive's
494 // convergence claim, which is about another problem. Without this an
495 // `xc=lda` run in a directory holding a converged `xc=hf` archive skips the
496 // SCF entirely and reports the HF energy.
497 const std::string other = hamiltonian_mismatch(meta);
498 if (not other.empty())
499 return continue_from_archive(meta, "restart auto: " + other +
500 " -- a different Hamiltonian, so re-converging");
501
504 plan.iterate = false;
505 plan.protocol_start = last;
506 plan.stale_energy = meta.current_energy;
507 plan.why = "restart auto: archive is converged to thresh " +
508 format_thresh(target_thresh) + " and dconv " +
510 return plan;
511 }
512
513 return continue_from_archive(meta, "restart auto: archive converged only to thresh " +
515 " dconv " + format_thresh(meta.converged_for_dconv) +
516 ", continuing");
517}
518
519/// look at the disk: what restart data is there?
520///
521/// The existence tests run on rank 0 and are broadcast, so ranks cannot diverge
522/// on them. peek_restartdata() is collective by construction (the parallel
523/// archive broadcasts what it reads), so every rank passes through it together
524/// or none does.
525inline RestartSources survey_restart_sources(World& world, const std::string& prefix,
526 const bool nwfile_named) {
528 disk.nwfile_named = nwfile_named;
529
530 int flags[2] = {0, 0};
531 if (world.rank() == 0) {
532 flags[0] = restartdata_exists(prefix + ".restartdata") ? 1 : 0;
533 flags[1] = std::filesystem::exists(prefix + ".restartaodata") ? 1 : 0;
534 }
535 world.gop.broadcast(flags, 2, 0);
536 disk.restartdata_present = (flags[0] == 1);
537 disk.restartao_present = (flags[1] == 1);
538
539 if (disk.restartdata_present) disk.meta = peek_restartdata(world, prefix + ".restartdata");
540 return disk;
541}
542
543/// survey the disk and decide, identically on every rank
544///
545/// Agreement between ranks is the point. Ranks that disagree about where the
546/// orbitals come from diverge on collective Function construction and hang -- a
547/// hang is a far worse failure than a wrong answer, because it leaves nothing to
548/// debug. Two things secure it:
549///
550/// * every input to plan_restart() is already rank-invariant -- the existence
551/// tests are broadcast by survey_restart_sources(), the header is broadcast by
552/// the parallel archive, and the parameters and molecule are replicated -- so
553/// all ranks run the decision and any throw from an explicitly requested but
554/// missing source is collective rather than a rank-0 abort into a hang;
555/// * the result is then broadcast anyway, so the "identical inputs, identical
556/// output" argument does not have to stay true for correctness.
557///
558/// @param[in] can which sources the asking engine can read; see RestartCapabilities
559/// @param[in] ncf the nuclear correlation factor this run uses (SCF::restart_ncf);
560/// empty for an engine that has none
563 const Molecule& requested,
566 const std::string& ncf = "") {
567
568 const RestartSources disk =
569 survey_restart_sources(world, param.prefix(), param.nwfile() != "none");
570
571 RestartPlan plan = plan_restart(mode, disk, can, param.protocol(), param.dconv(),
572 requested, wanted, requested.parameters.eprec(),
573 param.xc(), ncf);
575
576 if (world.rank() == 0 and param.print_level() > 1) {
577 if (plan.warn) print("WARNING:", plan.why);
578 else print(plan.print_to_string());
579 if (disk.meta.has_value() and param.print_level() > 2)
580 print(" archive:", disk.meta.value().print_to_string());
581 }
582 return plan;
583}
584
585} // namespace madness
586
587#endif // MADNESS_CHEM_RESTARTPLAN_H__INCLUDED
the header of a restartdata archive, in one place
Definition molecule.h:60
Definition molecule.h:129
const Atom & get_atom(unsigned int i) const
Definition molecule.cc:502
size_t natom() const
Definition molecule.h:457
unsigned int get_atomic_number(unsigned int i) const
Definition molecule.cc:430
void broadcast_serializable(objT &obj, ProcessID root)
Broadcast a serializable object.
Definition worldgop.h:774
void broadcast(void *buf, size_t nbyte, ProcessID root, bool dowork=true, Tag bcast_tag=-1)
Broadcasts bytes from process root while still processing AM & tasks.
Definition worldgop.cc:188
A parallel world class.
Definition world.h:134
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
WorldGopInterface & gop
Global operations.
Definition world.h:216
static const double eprec
Definition hatom_sf_dirac.cc:18
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
GeometryMatch compare_geometry(const Molecule &archive, const Molecule &requested, const double tol=1.e-8)
Definition RestartPlan.h:158
std::string to_string(const Representation r)
Definition Restart.h:64
std::optional< std::size_t > first_rung_tighter_than(const std::vector< double > &protocol, const double achieved)
Definition RestartPlan.h:236
std::string format_thresh(const double t)
format a threshold compactly for a log line ("1e-06", not "0.000001")
Definition RestartPlan.h:223
bool restartdata_exists(const std::string &filename)
Definition Restart.h:298
RestartMode
Definition RestartPlan.h:50
@ automatic
look at what is on disk and choose (the default)
@ none
ignore everything on disk, start from the initial guess
@ iterate
read restartdata and keep iterating
@ ao
read the AO projections (restartaodata) and iterate
@ nwchem
read an NWChem movecs file and iterate
RestartMode restart_mode_from_string(const std::string &s)
Definition RestartPlan.h:82
RestartPlan make_restart_plan(World &world, const RestartMode mode, const CalculationParameters &param, const Molecule &requested, const Representation wanted, const RestartCapabilities &can, const std::string &ncf="")
Definition RestartPlan.h:561
RestartSources survey_restart_sources(World &world, const std::string &prefix, const bool nwfile_named)
Definition RestartPlan.h:525
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:227
std::optional< RestartMetadata > peek_restartdata(World &world, const std::string &filename)
Definition Restart.h:223
RestartSource
where the initial orbitals will come from
Definition RestartPlan.h:93
@ initial_guess
atomic guess, i.e. no restart at all
@ restartdata
<prefix>.restartdata, MRA orbitals
@ restartao
<prefix>.restartaodata, AO expansion coefficients
@ nwchem
an NWChem movecs file
GeometryMatch
how the requested geometry relates to the one in an archive
Definition RestartPlan.h:147
@ different_composition
different atoms altogether
@ same
same atoms at the same places
@ displaced
same atoms, moved – e.g. a geometry optimization step
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
RestartPlan plan_restart(const RestartMode mode, const RestartSources &disk, const RestartCapabilities &can, const std::vector< double > &protocol, const double user_dconv, const Molecule &requested, const Representation wanted, const double eprec=0.0, const std::string &xc="", const std::string &ncf="")
Definition RestartPlan.h:260
Representation
Definition Restart.h:57
std::vector< std::string > restart_mode_names()
the six spellings accepted by the restart keyval, for allowed_values
Definition RestartPlan.h:61
static long abs(long a)
Definition tensor.h:219
XCfunctional xc
Definition newsolver_lda.cc:53
static const double b
Definition nonlinschro.cc:119
static const double a
Definition nonlinschro.cc:118
static const double m
Definition relops.cc:9
std::string prefix
Definition tdse.cc:71
Definition CalculationParameters.h:51
Definition RestartPlan.h:138
static RestartCapabilities restartdata_only()
Definition RestartPlan.h:143
bool nwchem
can read an NWChem movecs file
Definition RestartPlan.h:140
static RestartCapabilities all()
Definition RestartPlan.h:142
bool ao
can read <prefix>.restartaodata
Definition RestartPlan.h:139
Definition Restart.h:105
bool is_converged_to(const double thresh, const double dconv) const
true if these orbitals are at least as converged as the request
Definition Restart.h:186
double converged_for_dconv
Definition Restart.h:127
bool representation_matches(const Representation wanted) const
Definition Restart.h:195
Molecule molecule
Definition Restart.h:117
double converged_for_thresh
Definition Restart.h:120
Representation representation
what the stored functions are; see Representation
Definition Restart.h:130
double current_energy
Definition Restart.h:113
the decision: one source, one starting rung, one reason
Definition RestartPlan.h:176
RestartSource source
Definition RestartPlan.h:179
bool warn
Definition RestartPlan.h:195
bool needs_load() const
true if orbitals have to be read from disk before anything else happens
Definition RestartPlan.h:201
std::size_t protocol_start
rung of protocol() to start at; rungs below it are already covered
Definition RestartPlan.h:185
bool iterate
false means "return what is on disk without solving anything"
Definition RestartPlan.h:182
double stale_energy
energy from the archive, meaningful only when iterate==false
Definition RestartPlan.h:188
std::string why
one line, for the log and for the results json
Definition RestartPlan.h:198
RestartMode mode
what was asked for
Definition RestartPlan.h:178
std::string print_to_string() const
Definition RestartPlan.h:203
void serialize(Archive &ar)
serialization, so the plan can be decided on one rank and broadcast
Definition RestartPlan.h:213
Definition RestartPlan.h:114
bool restartao_present
<prefix>.restartaodata exists
Definition RestartPlan.h:125
bool restartdata_present
<prefix>.restartdata.00000 exists
Definition RestartPlan.h:117
bool nwfile_named
an NWChem file was named in the input
Definition RestartPlan.h:128
std::optional< RestartMetadata > meta
Definition RestartPlan.h:122
Definition dirac-hatom.cc:112
ncf(double gamma, double a, double Z)
Definition dirac-hatom.cc:116
InputParameters param
Definition tdse.cc:203