eOn client
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
MPIPot.cpp
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
13
#include "
eon/potentials/MPIPot/MPIPot.h
"
14
#include <mpi.h>
15
#include <stdio.h>
16
#include <time.h>
17
#ifndef _WIN32
18
#include <unistd.h>
19
#endif
20
21
MPIPot::MPIPot
(
const
Parameters
&p)
22
:
Potential
(p) {
23
potentialRank
= p.
potential_options
.
MPIPotentialRank
;
24
poll_period
= p.
potential_options
.
MPIPollPeriod
;
25
return
;
26
}
27
28
void
MPIPot::cleanMemory
(
void
) {
return
; }
29
30
MPIPot::~MPIPot
() {
cleanMemory
(); }
31
32
void
MPIPot::force
(
long
N,
const
double
*R,
const
int
*atomicNrs,
double
*F,
33
double
*U,
double
*variance,
const
double
*box) {
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
}
MPIPot.h
MPIPot::cleanMemory
void cleanMemory(void)
Definition
MPIPot.cpp:28
MPIPot::force
void force(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box)
Definition
MPIPot.cpp:32
MPIPot::poll_period
double poll_period
Definition
MPIPot.h:29
MPIPot::potentialRank
int potentialRank
Definition
MPIPot.h:28
MPIPot::~MPIPot
~MPIPot()
Definition
MPIPot.cpp:30
MPIPot::MPIPot
MPIPot(const Parameters &p)
Definition
MPIPot.cpp:21
eonc::Parameters
Definition
Parameters.h:28
eonc::Parameters::potential_options
struct eonc::Parameters::potential_options_t potential_options
eonc::Potential::Potential
Potential(PotType a_ptype)
Definition
Potential.h:35
eonc::Parameters::potential_options_t::MPIPollPeriod
double MPIPollPeriod
Definition
Parameters.h:68
eonc::Parameters::potential_options_t::MPIPotentialRank
int MPIPotentialRank
Definition
Parameters.h:76
client
potentials
MPIPot
MPIPot.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf