Loading...
Searching...
No Matches
MPIPot Class Reference

#include <MPIPot.h>

Inheritance diagram for MPIPot:

Public Member Functions

 MPIPot (const Parameters &p)
 ~MPIPot ()
void initialize ()
void cleanMemory (void)
void force (long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box)
Public Member Functions inherited from eonc::Potential
 Potential (PotType a_ptype)
 Potential (PotType a_ptype, const Parameters &)
 Potential (const Parameters &a_params)
virtual ~Potential ()
std::tuple< double, AtomMatrixget_ef (const AtomMatrix &pos, const VectorXi &atmnrs, const Matrix3d &box)
PotType getType () const
virtual bool isSurrogate () const noexcept
 Whether this is a surrogate (GP) potential.
virtual bool requiresIsolatedMoleculeLayout () const noexcept
 True for molecular QM / non-PBC backends (NWChem socket, ASE ORCA/NWChem, …).
virtual bool isThreadSafe () const noexcept
 Whether this potential's force() can be called from multiple threads on the SAME instance.
virtual bool isSharedInstanceThreadSafe () const noexcept
 Conservative gate for sharing one Potential instance across threads.
virtual bool needsPerImageInstance () const noexcept
 Whether NEB should create separate Potential instances per image for true parallel force evaluation.
virtual bool supportsBatchEvaluation () const noexcept
 Whether this potential supports batched evaluation of N systems in a single call.
virtual 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)
 Evaluate forces for N systems in a single call.

Private Attributes

int potentialRank {0}
double poll_period {0.0}

Additional Inherited Members

Public Attributes inherited from eonc::Potential
std::atomic< size_t > forceCallCounter
Protected Attributes inherited from eonc::Potential
PotType ptype

Detailed Description

Definition at line 17 of file MPIPot.h.

Constructor & Destructor Documentation

◆ MPIPot()

MPIPot::MPIPot ( const Parameters & p)

Definition at line 21 of file MPIPot.cpp.

22 : Potential(p) {
25 return;
26}
double poll_period
Definition MPIPot.h:29
int potentialRank
Definition MPIPot.h:28
struct eonc::Parameters::potential_options_t potential_options
Potential(PotType a_ptype)
Definition Potential.h:35

◆ ~MPIPot()

MPIPot::~MPIPot ( )

Definition at line 30 of file MPIPot.cpp.

30{ cleanMemory(); }
void cleanMemory(void)
Definition MPIPot.cpp:28

Member Function Documentation

◆ cleanMemory()

void MPIPot::cleanMemory ( void )

Definition at line 28 of file MPIPot.cpp.

28{ return; }

◆ force()

void MPIPot::force ( long N,
const double * R,
const int * atomicNrs,
double * F,
double * U,
double * variance,
const double * box )
virtual

Implements eonc::Potential.

Definition at line 32 of file MPIPot.cpp.

33 {
34 variance = nullptr;
35 // Send data to potential
36 int pbc = 1;
37 int failed;
38 char cwd[1024];
39 long icwd[1024];
40 getcwd(cwd, 1024);
41 for (int i = 0; i < 1024; i++) {
42 icwd[i] = static_cast<long>(cwd[i]);
43 }
44 int intn = static_cast<int>(N);
45 MPI_Send(&intn, 1, MPI_INT, potentialRank, 0, MPI_COMM_WORLD);
46 MPI_Send(atomicNrs, N, MPI_INT, potentialRank, 0, MPI_COMM_WORLD);
47 MPI_Send(R, 3 * N, MPI_DOUBLE, potentialRank, 0, MPI_COMM_WORLD);
48 MPI_Send(box, 9, MPI_DOUBLE, potentialRank, 0, MPI_COMM_WORLD);
49 MPI_Send(&pbc, 1, MPI_INT, potentialRank, 0, MPI_COMM_WORLD);
50 MPI_Send(&icwd[0], 1024, MPI_INT, potentialRank, 0, MPI_COMM_WORLD);
51
52 if (poll_period > 0.0) {
53 int eon_flag = 0;
54 MPI_Iprobe(potentialRank, 0, MPI_COMM_WORLD, &eon_flag, MPI_STATUS_IGNORE);
55 while (!eon_flag) {
56 usleep(static_cast<useconds_t>(poll_period / 1000000.0));
57 MPI_Iprobe(potentialRank, 0, MPI_COMM_WORLD, &eon_flag,
58 MPI_STATUS_IGNORE);
59 }
60 }
61
62 // Recv data from potential
63 MPI_Recv(&failed, 1, MPI_INT, potentialRank, 0, MPI_COMM_WORLD,
64 MPI_STATUS_IGNORE);
65 if (failed == 1) {
66 throw 100;
67 }
68
69 MPI_Recv(U, 1, MPI_DOUBLE, potentialRank, 0, MPI_COMM_WORLD,
70 MPI_STATUS_IGNORE);
71 MPI_Recv(F, 3 * N, MPI_DOUBLE, potentialRank, 0, MPI_COMM_WORLD,
72 MPI_STATUS_IGNORE);
73 // printf("energy: %12.4e\n", *U);
74 // printf("forces:\n");
75 // for (int i=0;i<N;i++) printf("%12.4e %12.4e %12.4e\n", F[3*i], F[3*i+1],
76 // F[3*i+2]);
77}

◆ initialize()

void MPIPot::initialize ( )
inline

Definition at line 22 of file MPIPot.h.

22{};

Member Data Documentation

◆ poll_period

double MPIPot::poll_period {0.0}
private

Definition at line 29 of file MPIPot.h.

29{0.0};

◆ potentialRank

int MPIPot::potentialRank {0}
private

Definition at line 28 of file MPIPot.h.

28{0};

The documentation for this class was generated from the following files:
  • /home/runner/work/eOn/eOn/include/eon/potentials/MPIPot/MPIPot.h
  • /home/runner/work/eOn/eOn/client/potentials/MPIPot/MPIPot.cpp