Loading...
Searching...
No Matches
RgpotPot.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include "eon/Potential.h"
15#include <memory>
16#include <string>
17
18class RGPotEngine;
19
25class RgpotPot final : public eonc::Potential {
26public:
27 explicit RgpotPot(const eonc::Parameters &p);
28 ~RgpotPot() override;
29
30 RgpotPot(const RgpotPot &) = delete;
31 RgpotPot &operator=(const RgpotPot &) = delete;
32
33 void force(long N, const double *R, const int *atomicNrs, double *F,
34 double *U, double *variance, const double *box) override;
35
36 [[nodiscard]] bool isThreadSafe() const noexcept override { return false; }
37
41 [[nodiscard]] bool supportsBatchEvaluation() const noexcept override;
42 void forceBatch(long nSystems, long nAtoms, const double *const *positions,
43 const int *const *atomicNrs, double *const *forces,
44 double *energies, double *variances,
45 const double *const *boxes) override;
49 void forceBatchOwned(long nSystems, long nAtoms,
50 const double *const *positions,
51 const int *const *atomicNrs, double *const *forces,
52 double *energies, double *variances,
53 const double *const *boxes, const long *owners) override;
55 [[nodiscard]] bool requiresIsolatedMoleculeLayout() const noexcept override {
56 return backend_ == "nwchemc";
57 }
58 [[nodiscard]] const std::string &backend() const noexcept { return backend_; }
59 [[nodiscard]] bool engineAvailable() const;
60
61private:
62 // Under mpirun (an MPI build of rgpot with cpmdc) only world rank 0 runs
63 // eOn. It broadcasts each force request; the other ranks serve requests
64 // from the constructor until the driver sends a stop, then exit.
65 [[noreturn]] void serveWorker();
66 void computeSingle(long N, const double *R, const int *atomicNrs, double *F,
67 double *U, const double *box);
68 void computeBatch(long nSystems, long nAtoms, const double *const *positions,
69 const int *const *atomicNrs, double *const *forces,
70 double *energies, const double *const *boxes,
71 const std::int64_t *owners);
72 void sendStop();
73 void stopAndDrop();
75
76 std::unique_ptr<RGPotEngine> impl_;
77 std::string backend_;
78 bool driver_{true};
79 bool stopped_{false};
80 bool dropped_{false};
81 bool acked_{false};
82};
Opaque rgpot-backed engine (nwchemc / cpmdc / metatomic / xtb).
Definition RGPotEngine.h:46
RgpotPot(const RgpotPot &)=delete
RgpotPot(const eonc::Parameters &p)
Definition RgpotPot.cpp:18
bool engineAvailable() const
Definition RgpotPot.cpp:135
bool requiresIsolatedMoleculeLayout() const noexcept override
NWChem molecular SCF does not support PBC; CPMD may be periodic.
Definition RgpotPot.h:55
std::string backend_
Definition RgpotPot.h:77
void computeSingle(long N, const double *R, const int *atomicNrs, double *F, double *U, const double *box)
Definition RgpotPot.cpp:214
std::unique_ptr< RGPotEngine > impl_
Definition RgpotPot.h:76
void forceBatchOwned(long nSystems, long nAtoms, const double *const *positions, const int *const *atomicNrs, double *const *forces, double *energies, double *variances, const double *const *boxes, const long *owners) override
System j runs on group owners[j] mod G when owners is given (an owner below zero falls back to j),...
Definition RgpotPot.cpp:349
void forceBatch(long nSystems, long nAtoms, const double *const *positions, const int *const *atomicNrs, double *const *forces, double *energies, double *variances, const double *const *boxes) override
Definition RgpotPot.cpp:340
bool stopped_
Definition RgpotPot.h:79
void computeBatch(long nSystems, long nAtoms, const double *const *positions, const int *const *atomicNrs, double *const *forces, double *energies, const double *const *boxes, const std::int64_t *owners)
Definition RgpotPot.cpp:225
bool dropped_
Definition RgpotPot.h:80
const std::string & backend() const noexcept
Definition RgpotPot.h:58
bool acked_
Definition RgpotPot.h:81
bool isThreadSafe() const noexcept override
Whether this potential's force() can be called from multiple threads on the SAME instance.
Definition RgpotPot.h:36
bool driver_
Definition RgpotPot.h:78
~RgpotPot() override
Definition RgpotPot.cpp:125
RgpotPot & operator=(const RgpotPot &)=delete
void stopAndDrop()
Definition RgpotPot.cpp:158
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box) override
Definition RgpotPot.cpp:317
void serveWorker()
Definition RgpotPot.cpp:264
bool supportsBatchEvaluation() const noexcept override
With cpmdc calculator groups ([RgpotPot] ranks_per_image), a batch is spread over the groups: system ...
Definition RgpotPot.cpp:336
void sendStop()
Definition RgpotPot.cpp:148
void releaseWorkersAtExit()
Definition RgpotPot.cpp:175