Loading...
Searching...
No Matches
PotentialWrapper.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5//
6// PotentialWrapper.h
7// gpr_dimer
8//
9// Type-erased wrapper for potential energy surfaces.
10//
11
12#ifndef PotentialWrapper_h
13#define PotentialWrapper_h
14
15#include <algorithm>
16#include <array>
17#include <cmath>
18#include <functional>
19#include <memory>
20#include <stdexcept>
21#include <tuple>
22#include <type_traits>
23#include <utility>
24#include <vector>
25
26#include "rgpot/ForceStructs.hpp"
27#include "rgpot/types/AtomMatrix.hpp"
28
29namespace rgpot {
30class PotentialBase;
31}
32
33namespace pot {
34
38inline constexpr double kEnergyVarianceNegativeRtol = 1.0e-8;
39
45inline bool energyVarianceAccepted(const double variance) noexcept
46{
47 return std::isfinite(variance) && variance >= -kEnergyVarianceNegativeRtol;
48}
49
54inline double energyVarianceToRms(const double variance)
55{
56 if (!energyVarianceAccepted(variance))
57 throw std::domain_error(
58 "PotentialWrapper: rgpot energy variance must be finite and "
59 "non-negative");
60 if (variance < 0.0) return 0.0;
61 return std::sqrt(variance);
62}
63
68void resetOracleEvaluations() noexcept;
69[[nodiscard]] long oracleEvaluations() noexcept;
70void pushOracleEvaluations(long evaluations) noexcept;
71void popOracleEvaluations() noexcept;
72
85
95 struct RichForceTag { };
96
97public:
102 using ForceFn = std::function<void(
103 long N, const double* R, const int* atomicNrs, double* F, double* U,
104 double* energy_noise_rms, const double* box)>;
105 using ForceWithUncertaintyFn = std::function<void(
106 long N, const double* R, const int* atomicNrs, double* F, double* U,
107 double* energy_noise_rms, double* force_noise_rms, const double* box)>;
110 using ForceBatchFn = std::function<void(
111 long N, std::size_t B, const double* R, const int* atomicNrs, double* F,
112 double* U, const double* box)>;
114 using ForceBatchWithForceNoiseFn = std::function<void(
115 long N, std::size_t B, const double* R, const int* atomicNrs, double* F,
116 double* U, double* V, const double* box)>;
118 using ForceBatchWithUncertaintyFn = std::function<void(
119 long N, std::size_t B, const double* R, const int* atomicNrs, double* F,
120 double* U, double* energy_noise_rms, double* force_noise_rms,
121 const double* box)>;
122
124 {
125 if (!fn) {
126 throw std::invalid_argument(
127 "PotentialWrapper: force function must not be null");
128 }
129 m_force_with_uncertainty =
130 [fn = std::move(fn)](long N, const double* R, const int* atomicNrs,
131 double* F, double* U, double* energy_noise_rms,
132 double* force_noise_rms,
133 const double* box) mutable {
134 fn(N, R, atomicNrs, F, U, energy_noise_rms, box);
135 // This adapter has no force-noise channel. Publish the
136 // zero only after fn returns, so a throw leaves the
137 // caller buffer untouched.
138 if (force_noise_rms) *force_noise_rms = 0.0;
139 };
140 }
141
145 void force(long N, const double* R, const int* atomicNrs, double* F,
146 double* U, double* energy_noise_rms, const double* box)
147 {
148 forceWithUncertainty(N, R, atomicNrs, F, U, energy_noise_rms, nullptr,
149 box);
150 }
151
152 void forceWithUncertainty(long N, const double* R, const int* atomicNrs,
153 double* F, double* U, double* energy_noise_rms,
154 double* force_noise_rms, const double* box)
155 {
156 const OracleEvaluationScope scope(1);
157 m_force_with_uncertainty(N, R, atomicNrs, F, U, energy_noise_rms,
158 force_noise_rms, box);
159 }
160
163 {
164 return PotentialWrapper(std::move(fn), RichForceTag{});
165 }
166
169 [[nodiscard]] bool hasForceBatch() const noexcept
170 {
171 return static_cast<bool>(m_force_batch) ||
173 }
174
175 [[nodiscard]] bool hasForceBatchWithUncertainty() const noexcept
176 {
177 return static_cast<bool>(m_force_batch_with_uncertainty);
178 }
179
181 {
182 m_force_batch = std::move(fn);
183 m_force_batch_with_uncertainty = {};
184 }
185
186 void setForceBatch(std::nullptr_t)
187 {
189 }
190
192 {
193 if (!fn) {
195 return;
196 }
198 [fn = std::move(fn)](long N, std::size_t B, const double* R,
199 const int* atomicNrs, double* F, double* U,
200 double* energy_noise, double* force_noise,
201 const double* box) {
202 fn(N, B, R, atomicNrs, F, U, force_noise, box);
203 // This adapter has no energy-noise channel. Zero it only
204 // after the batch returns so a throw leaves the caller
205 // buffer untouched.
206 if (energy_noise) std::fill_n(energy_noise, B, 0.0);
207 });
208 }
209
211 {
212 m_force_batch_with_uncertainty = std::move(fn);
213 m_force_batch = {};
214 }
215
217 void forceBatch(long N, std::size_t B, const double* R,
218 const int* atomicNrs, double* F, double* U,
219 const double* box)
220 {
221 const OracleEvaluationScope scope(static_cast<long>(B));
222 if (m_force_batch_with_uncertainty) {
223 m_force_batch_with_uncertainty(N, B, R, atomicNrs, F, U, nullptr,
224 nullptr, box);
225 } else if (m_force_batch) {
226 m_force_batch(N, B, R, atomicNrs, F, U, box);
227 } else {
228 throw std::logic_error(
229 "PotentialWrapper: no batch surface on this potential");
230 }
231 }
232
234 void forceBatch(long N, std::size_t B, const double* R,
235 const int* atomicNrs, double* F, double* U, double* V,
236 const double* box)
237 {
238 if (!V) {
239 forceBatch(N, B, R, atomicNrs, F, U, box);
240 return;
241 }
242 forceBatchWithUncertainty(N, B, R, atomicNrs, F, U, nullptr, V, box);
243 }
244
247 void forceBatchWithUncertainty(long N, std::size_t B, const double* R,
248 const int* atomicNrs, double* F, double* U,
249 double* energy_noise, double* force_noise,
250 const double* box)
251 {
252 const OracleEvaluationScope scope(static_cast<long>(B));
253 if (m_force_batch_with_uncertainty) {
254 m_force_batch_with_uncertainty(N, B, R, atomicNrs, F, U,
255 energy_noise, force_noise, box);
256 return;
257 }
258 // No uncertainty batch: each image is its own call. Hold every
259 // image until the last call returns, so a failed check on a
260 // later image leaves the caller buffers untouched. A negative
261 // count casts 3*N to a huge size_t; reject it before any image
262 // is evaluated, as the native batch does.
263 if (N <= 0) {
264 throw std::invalid_argument(
265 "PotentialWrapper: n_atoms must be positive");
266 }
267 const auto stride = static_cast<std::size_t>(N) * 3;
268 const bool write_forces = F != nullptr && stride > 0;
269 const bool write_energy = U != nullptr;
270 const bool write_energy_noise = energy_noise != nullptr;
271 const bool write_force_noise = force_noise != nullptr;
272 std::vector<double> scratch_forces(write_forces ? B * stride : 0);
273 std::vector<double> scratch_energy(write_energy ? B : 0);
274 std::vector<double> scratch_energy_noise(write_energy_noise ? B : 0);
275 std::vector<double> scratch_force_noise(write_force_noise ? B : 0);
276 for (std::size_t b = 0; b < B; ++b) {
278 N, R + b * stride, atomicNrs,
279 write_forces ? scratch_forces.data() + b * stride : nullptr,
280 write_energy ? scratch_energy.data() + b : nullptr,
281 write_energy_noise ? scratch_energy_noise.data() + b : nullptr,
282 write_force_noise ? scratch_force_noise.data() + b : nullptr,
283 box);
284 }
285 if (write_forces && B > 0)
286 std::copy_n(scratch_forces.data(), scratch_forces.size(), F);
287 if (write_energy && B > 0) std::copy_n(scratch_energy.data(), B, U);
288 if (write_energy_noise && B > 0)
289 std::copy_n(scratch_energy_noise.data(), B, energy_noise);
290 if (write_force_noise && B > 0)
291 std::copy_n(scratch_force_noise.data(), B, force_noise);
292 }
293
304 PotentialWrapper geometry, PotentialWrapper uncertainty)
305 {
307 [geometry = std::move(geometry),
308 uncertainty = std::move(uncertainty)](
309 long N, const double* R, const int* atomicNrs, double* F,
310 double* U, double* energy_noise_rms, double* force_noise_rms,
311 const double* box) mutable {
312 // Geometry may report its own energy noise. Keep that off
313 // the caller pointer until the uncertainty source accepts
314 // its variance; a throw there must leave this channel.
315 double geometry_energy_noise = 0.0;
316 geometry.forceWithUncertainty(N, R, atomicNrs, F, U,
317 energy_noise_rms != nullptr
318 ? &geometry_energy_noise
319 : nullptr,
320 force_noise_rms, box);
321 if (!energy_noise_rms) return;
322
323 const std::size_t n_components =
324 N > 0 ? static_cast<std::size_t>(N) * 3 : 0;
325 std::vector<double> discarded_forces(n_components);
326 double discarded_energy = 0.0;
327 double source_energy_noise_rms = 0.0;
328 double discarded_force_noise_rms = 0.0;
329 uncertainty.forceWithUncertainty(
330 N, R, atomicNrs, discarded_forces.data(), &discarded_energy,
331 &source_energy_noise_rms, &discarded_force_noise_rms, box);
332 *energy_noise_rms = source_energy_noise_rms;
333 });
334 }
335
343 PotentialWrapper source)
344 {
346 [source = std::move(source)](
347 long N, const double* R, const int* atomicNrs, double* F,
348 double* U, double* energy_noise_rms, double* force_noise_rms,
349 const double* box) mutable {
350 double routed_force_noise_rms = 0.0;
351 double discarded_force_noise_rms = 0.0;
352 source.forceWithUncertainty(N, R, atomicNrs, F, U,
353 &routed_force_noise_rms,
354 &discarded_force_noise_rms, box);
355 if (energy_noise_rms) *energy_noise_rms = 0.0;
356 if (force_noise_rms) *force_noise_rms = routed_force_noise_rms;
357 });
358 }
359
366 template <typename RgPot>
368 {
369 return from_rgpot_caller(
370 [&pot](const rgpot::types::AtomMatrix& positions,
371 const std::vector<int>& atmtypes,
372 const std::array<std::array<double, 3>, 3>& cell) {
373 return pot(positions, atmtypes, cell);
374 });
375 }
376
383 template <typename RgPot>
384 static PotentialWrapper from_rgpot(std::shared_ptr<RgPot> pot)
385 {
386 if (!pot) {
387 throw std::invalid_argument(
388 "PotentialWrapper: rgpot shared pointer must not be null");
389 }
390 auto wrapper = from_rgpot_caller(
391 [pot](const rgpot::types::AtomMatrix& positions,
392 const std::vector<int>& atmtypes,
393 const std::array<std::array<double, 3>, 3>& cell) {
394 return (*pot)(positions, atmtypes, cell);
395 });
396 // Batch surface. An rgpot CRTP potential carries forceBatch (a
397 // per-system fallback in the base, a one-call kernel where the
398 // backend implements forceBatchImpl, e.g. the UMA band graph).
399 // Not everything reaching this template is one: the Python
400 // trampoline is a plain callable with the operator() signature
401 // and nothing else, so the member is checked rather than assumed.
402 if constexpr (requires(RgPot& p, rgpot::ForceBatch& b) {
403 p.forceBatch(b);
404 }) {
405 using Result = std::invoke_result_t<
406 RgPot&, const rgpot::types::AtomMatrix&,
407 const std::vector<int>&,
408 const std::array<std::array<double, 3>, 3>&>;
409 constexpr auto arity = std::tuple_size<std::decay_t<Result>>::value;
410 ForceBatchWithUncertaintyFn native_batch =
411 [pot = std::move(pot)](long N, std::size_t B, const double* R,
412 const int* atomicNrs, double* F,
413 double* U, double* energy_noise,
414 double* force_noise, const double* box) {
415 // A non-positive count would hand the caller force
416 // pointer to the backend, and a negative count casts
417 // to a huge size_t. Reject it before any call.
418 if (N <= 0) {
419 throw std::invalid_argument(
420 "PotentialWrapper: n_atoms must be positive");
421 }
422 // ForceInput carries const members: build in place.
423 // rgpot writes forces through ForceOut::F. Keep forces,
424 // energies, and both noise channels in scratch until
425 // every system's variance validates.
426 const std::size_t stride = static_cast<std::size_t>(N) * 3;
427 std::vector<double> scratch_forces(B * stride);
428 std::vector<rgpot::ForceInput> in;
429 std::vector<rgpot::ForceOut> out;
430 in.reserve(B);
431 out.reserve(B);
432 for (std::size_t b = 0; b < B; ++b) {
433 in.push_back(
434 rgpot::ForceInput{static_cast<std::size_t>(N),
435 R + b * 3 * N, atomicNrs, box});
436 out.emplace_back();
437 out.back().F = scratch_forces.data() + b * stride;
438 }
439 rgpot::ForceBatch batch{B, in.data(), out.data()};
440 pot->forceBatch(batch);
441 std::vector<double> energy_rms;
442 if (energy_noise != nullptr) {
443 energy_rms.resize(B);
444 for (std::size_t b = 0; b < B; ++b) {
445 if constexpr (arity >= 3)
446 energy_rms[b] =
447 energyVarianceToRms(out[b].variance);
448 else
449 energy_rms[b] = 0.0;
450 }
451 }
452 if (F != nullptr) {
453 std::copy_n(scratch_forces.data(),
454 scratch_forces.size(), F);
455 }
456 // A null energy pointer is left untouched, as the
457 // means-only fallback does.
458 if (U != nullptr) {
459 for (std::size_t b = 0; b < B; ++b)
460 U[b] = out[b].energy;
461 }
462 if (energy_noise != nullptr)
463 std::copy_n(energy_rms.data(), B, energy_noise);
464 if (force_noise != nullptr)
465 std::fill_n(force_noise, B, 0.0);
466 };
467 if constexpr (arity <= 3) {
468 // rgpot's third tuple value is ForceOut::variance, which
469 // the single-call adapter carries as energy noise.
470 wrapper.setForceBatchWithUncertainty(std::move(native_batch));
471 } else {
472 // One variance slot cannot represent two noise channels.
473 wrapper.setForceBatch([native_batch = std::move(native_batch)](
474 long N, std::size_t B,
475 const double* R, const int* atomicNrs,
476 double* F, double* U,
477 const double* box) {
478 native_batch(N, B, R, atomicNrs, F, U, nullptr, nullptr,
479 box);
480 });
481 }
482 } else {
483 // Walk the systems so the surface still answers. Leaving it
484 // unset would be legal -- hasForceBatch() models absence --
485 // but it would silently drop band batching for every
486 // Python-defined potential, and the caller wants the answer
487 // rather than a promise about how many calls produced it.
488 wrapper.m_force_batch = [pot = std::move(pot)](
489 long N, std::size_t B, const double* R,
490 const int* atomicNrs, double* F,
491 double* U, const double* box) {
492 // A negative count casts to a huge size_t and builds a
493 // bogus type range. Reject it before any call, as the
494 // native batch does.
495 if (N <= 0) {
496 throw std::invalid_argument(
497 "PotentialWrapper: n_atoms must be positive");
498 }
499 const auto n = static_cast<std::size_t>(N);
500 std::array<std::array<double, 3>, 3> cell{};
501 if (box != nullptr) {
502 for (std::size_t r = 0; r < 3; ++r)
503 for (std::size_t c = 0; c < 3; ++c)
504 cell[r][c] = box[r * 3 + c];
505 }
506 const std::vector<int> types(atomicNrs, atomicNrs + n);
507 // Compute every image before writing. A throw on a later
508 // image must leave the caller buffers untouched.
509 const std::size_t stride = 3 * n;
510 std::vector<double> scratch_energies(B);
511 std::vector<double> scratch_forces(B * stride);
512 for (std::size_t b = 0; b < B; ++b) {
513 rgpot::types::AtomMatrix pos(n, 3);
514 for (std::size_t a = 0; a < n; ++a)
515 for (std::size_t d = 0; d < 3; ++d)
516 pos(a, d) = R[b * 3 * n + a * 3 + d];
517 // std::get rather than a structured binding: the
518 // trampoline returns a wider tuple than
519 // PotentialBase does, and only the first two
520 // elements are wanted either way.
521 const auto result = (*pot)(pos, types, cell);
522 scratch_energies[b] = std::get<0>(result);
523 const auto& forces = std::get<1>(result);
524 if (stride == 0) continue;
525 for (std::size_t a = 0; a < n; ++a)
526 for (std::size_t d = 0; d < 3; ++d)
527 scratch_forces[b * stride + a * 3 + d] =
528 forces(a, d);
529 }
530 if (B > 0) {
531 // A null energy or force pointer is left untouched,
532 // as the native batch does.
533 if (U != nullptr)
534 std::copy_n(scratch_energies.data(), B, U);
535 if (F != nullptr && stride > 0)
536 std::copy_n(scratch_forces.data(),
537 scratch_forces.size(), F);
538 }
539 };
540 }
541 return wrapper;
542 }
543
554 std::shared_ptr<rgpot::PotentialBase> pot);
555
556private:
557 ForceBatchFn m_force_batch;
558 ForceBatchWithUncertaintyFn m_force_batch_with_uncertainty;
559
560 template <typename T>
561 struct dependent_false : std::false_type { };
562
563 template <typename Result>
564 static std::tuple<double, rgpot::types::AtomMatrix, double, double>
565 normalize_rgpot_result(Result&& result)
566 {
567 using Decayed = std::decay_t<Result>;
568 constexpr std::size_t arity = std::tuple_size<Decayed>::value;
569 if constexpr (arity == 2) {
570 auto [energy, forces] = std::forward<Result>(result);
571 return {energy, std::move(forces), 0.0, 0.0};
572 } else if constexpr (arity == 3) {
573 auto [energy, forces, energy_variance] =
574 std::forward<Result>(result);
575 return {energy, std::move(forces), energy_variance, 0.0};
576 } else if constexpr (arity == 4) {
577 auto [energy, forces, energy_variance, force_noise_rms] =
578 std::forward<Result>(result);
579 return {energy, std::move(forces), energy_variance,
580 force_noise_rms};
581 } else {
582 static_assert(dependent_false<Decayed>::value,
583 "rgpot potential must return (energy, forces) or "
584 "(energy, forces, energy_variance) or "
585 "(energy, forces, energy_variance, "
586 "force_noise_rms)");
587 }
588 }
589
590 template <typename Caller>
591 static PotentialWrapper from_rgpot_caller(Caller caller)
592 {
594 [caller = std::move(caller)](
595 long N, const double* R, const int* atomicNrs, double* F,
596 double* U, double* energy_noise_rms, double* force_noise_rms,
597 const double* box) mutable {
598 // Build AtomMatrix from flat array (row-major, N x 3)
599 rgpot::types::AtomMatrix positions(static_cast<size_t>(N), 3);
600 for (long i = 0; i < N; ++i) {
601 positions(static_cast<size_t>(i), 0) = R[3 * i];
602 positions(static_cast<size_t>(i), 1) = R[3 * i + 1];
603 positions(static_cast<size_t>(i), 2) = R[3 * i + 2];
604 }
605
606 // Build atmtypes vector
607 std::vector<int> atmtypes(atomicNrs, atomicNrs + N);
608
609 // Build box array
610 std::array<std::array<double, 3>, 3> cell;
611 for (int r = 0; r < 3; ++r) {
612 for (int c = 0; c < 3; ++c) {
613 cell[static_cast<size_t>(r)][static_cast<size_t>(c)] =
614 box[r * 3 + c];
615 }
616 }
617
618 // Call the rgpot potential and normalize optional variance.
619 auto [energy, forces, pot_energy_variance,
620 pot_force_noise_rms] =
621 normalize_rgpot_result(caller(positions, atmtypes, cell));
622
623 // Validate before publishing. A bad variance throws and
624 // must leave energy, forces, and both noise channels as
625 // the caller passed them.
626 const bool publish_energy_noise = energy_noise_rms != nullptr;
627 const double energy_rms =
628 publish_energy_noise
629 ? energyVarianceToRms(pot_energy_variance)
630 : 0.0;
631 // A non-finite or negative force RMS is the same class of
632 // failure as a rejected energy variance: publish nothing.
633 if (force_noise_rms != nullptr &&
634 (!std::isfinite(pot_force_noise_rms) ||
635 pot_force_noise_rms < 0.0))
636 throw std::domain_error(
637 "PotentialWrapper: rgpot force noise RMS must be "
638 "finite and non-negative");
639
640 if (U) *U = energy;
641
642 // Write back forces (row-major N x 3)
643 if (F) {
644 for (long i = 0; i < N; ++i) {
645 F[3 * i] = forces(static_cast<size_t>(i), 0);
646 F[3 * i + 1] = forces(static_cast<size_t>(i), 1);
647 F[3 * i + 2] = forces(static_cast<size_t>(i), 2);
648 }
649 }
650 if (publish_energy_noise) *energy_noise_rms = energy_rms;
651 if (force_noise_rms) *force_noise_rms = pot_force_noise_rms;
652 });
653 }
654
655 explicit PotentialWrapper(ForceWithUncertaintyFn fn, RichForceTag)
656 : m_force_with_uncertainty(std::move(fn))
657 {
658 if (!m_force_with_uncertainty) {
659 throw std::invalid_argument(
660 "PotentialWrapper: force function must not be null");
661 }
662 }
663
664 ForceWithUncertaintyFn m_force_with_uncertainty;
665};
666
667} /* End namespace pot */
668
669#endif /* PotentialWrapper_h */
Type-erased wrapper around any potential that provides a force() interface.
void forceBatchWithUncertainty(long N, std::size_t B, const double *R, const int *atomicNrs, double *F, double *U, double *energy_noise, double *force_noise, const double *box)
std::function< void( long N, std::size_t B, const double *R, const int *atomicNrs, double *F, double *U, double *energy_noise_rms, double *force_noise_rms, const double *box)> ForceBatchWithUncertaintyFn
Both optional noise arrays use the single-call RMS conventions.
void setForceBatch(ForceBatchWithForceNoiseFn fn)
static PotentialWrapper composeGeometryAndEnergyUncertainty(PotentialWrapper geometry, PotentialWrapper uncertainty)
Compose geometry output with an independent energy-uncertainty source.
std::function< void( long N, std::size_t B, const double *R, const int *atomicNrs, double *F, double *U, const double *box)> ForceBatchFn
void forceBatch(long N, std::size_t B, const double *R, const int *atomicNrs, double *F, double *U, double *V, const double *box)
Batched evaluation with optional force noise.
std::function< void( long N, const double *R, const int *atomicNrs, double *F, double *U, double *energy_noise_rms, double *force_noise_rms, const double *box)> ForceWithUncertaintyFn
void forceBatch(long N, std::size_t B, const double *R, const int *atomicNrs, double *F, double *U, const double *box)
Batched means; requires hasForceBatch().
std::function< void( long N, std::size_t B, const double *R, const int *atomicNrs, double *F, double *U, double *V, const double *box)> ForceBatchWithForceNoiseFn
A batch with force noise and zero energy noise.
bool hasForceBatchWithUncertainty() const noexcept
std::function< void( long N, const double *R, const int *atomicNrs, double *F, double *U, double *energy_noise_rms, const double *box)> ForceFn
static PotentialWrapper from_force_with_uncertainty(ForceWithUncertaintyFn fn)
static PotentialWrapper routeEnergyUncertaintyToForceChannel(PotentialWrapper source)
Route a legacy scalar uncertainty into the force-noise channel.
bool hasForceBatch() const noexcept
void forceWithUncertainty(long N, const double *R, const int *atomicNrs, double *F, double *U, double *energy_noise_rms, double *force_noise_rms, const double *box)
void setForceBatchWithUncertainty(ForceBatchWithUncertaintyFn fn)
static PotentialWrapper from_rgpot(std::shared_ptr< RgPot > pot)
Factory: adapt and own an rgpot PotentialBase subclass.
static PotentialWrapper from_rgpot(RgPot &pot)
Factory: adapt an rgpot PotentialBase subclass.
void setForceBatch(ForceBatchFn fn)
void setForceBatch(std::nullptr_t)
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *energy_noise_rms, const double *box)
Invoke the wrapped potential.
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
Potential wrappers and the batched oracle interface.
void resetOracleEvaluations() noexcept
long oracleEvaluations() noexcept
bool energyVarianceAccepted(const double variance) noexcept
double energyVarianceToRms(const double variance)
constexpr double kEnergyVarianceNegativeRtol
void pushOracleEvaluations(long evaluations) noexcept
void popOracleEvaluations() noexcept
OracleEvaluationScope & operator=(const OracleEvaluationScope &)=delete
OracleEvaluationScope(long evaluations)
OracleEvaluationScope(const OracleEvaluationScope &)=delete