Merge pull request #3954 from bnebgen-LANL/mliap_null_fix
Mliap null fix
This commit is contained in:
@ -85,6 +85,7 @@ void MLIAPDataKokkos<DeviceType>::generate_neighdata(class NeighList *list_in, i
|
||||
// clear gradforce and elems arrays
|
||||
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
nlocal = atom->nlocal;
|
||||
ntotal = nall;
|
||||
if (gradgradflag > -1){
|
||||
auto d_gradforce = k_gradforce.template view<DeviceType>();
|
||||
|
||||
@ -118,6 +118,7 @@ public:
|
||||
egradient(nullptr),
|
||||
ntotal(base.ntotal),
|
||||
nlistatoms(base.nlistatoms),
|
||||
nlocal(base.nlocal),
|
||||
natomneigh(base.natomneigh),
|
||||
numneighs(base.numneighs),
|
||||
iatoms(base.k_iatoms.d_view.data()),
|
||||
@ -171,6 +172,7 @@ public:
|
||||
// Neighborlist stuff
|
||||
const int ntotal;
|
||||
const int nlistatoms;
|
||||
const int nlocal;
|
||||
const int natomneigh;
|
||||
int *numneighs;
|
||||
int *iatoms;
|
||||
@ -191,7 +193,7 @@ public:
|
||||
int dev;
|
||||
|
||||
#ifdef LMP_KOKKOS_GPU
|
||||
MLIAPDataKokkosDevice(MLIAPDataKokkos<LMPHostType> &base) : ndescriptors(-1),nparams(-1),nelements(-1),ntotal(-1),nlistatoms(-1),natomneigh(-1),
|
||||
MLIAPDataKokkosDevice(MLIAPDataKokkos<LMPHostType> &base) : ndescriptors(-1),nparams(-1),nelements(-1),ntotal(-1),nlistatoms(-1),nlocal(-1),natomneigh(-1),
|
||||
nneigh_max(-1),npairs(-1)
|
||||
{
|
||||
// It cannot get here, but needed for compilation
|
||||
|
||||
@ -25,6 +25,7 @@ cdef extern from "mliap_data_kokkos.h" namespace "LAMMPS_NS":
|
||||
cdef cppclass MLIAPDataKokkosDevice:
|
||||
# Array shapes
|
||||
int nlistatoms
|
||||
int nlocal
|
||||
int ndescriptors
|
||||
|
||||
# Input data
|
||||
|
||||
@ -59,6 +59,7 @@ cdef extern from "mliap_data_kokkos.h" namespace "LAMMPS_NS":
|
||||
|
||||
int ntotal # total number of owned and ghost atoms on this proc
|
||||
int nlistatoms # current number of atoms in local atom lists
|
||||
int nlocal
|
||||
int natomneigh # current number of atoms and ghosts in atom neighbor arrays
|
||||
int * numneighs # neighbors count for each atom
|
||||
int * iatoms # index of each atom
|
||||
@ -290,6 +291,10 @@ cdef class MLIAPDataPy:
|
||||
@property
|
||||
def nlistatoms(self):
|
||||
return self.data.nlistatoms
|
||||
|
||||
@property
|
||||
def nlocal(self):
|
||||
return self.data.nlocal
|
||||
|
||||
@property
|
||||
def natomneigh(self):
|
||||
|
||||
@ -271,8 +271,8 @@ void LAMMPS_NS::update_pair_energy(MLIAPDataKokkosDevice *data, double *eij)
|
||||
{
|
||||
auto d_eatoms = data->eatoms;
|
||||
auto d_pair_i= data->pair_i;
|
||||
const auto nlistatoms = data->nlistatoms;
|
||||
Kokkos::parallel_for(nlistatoms, KOKKOS_LAMBDA(int ii){
|
||||
const auto nlocal = data->nlocal;
|
||||
Kokkos::parallel_for(nlocal, KOKKOS_LAMBDA(int ii){
|
||||
d_eatoms[ii] = 0;
|
||||
});
|
||||
|
||||
@ -281,7 +281,7 @@ void LAMMPS_NS::update_pair_energy(MLIAPDataKokkosDevice *data, double *eij)
|
||||
double e = 0.5 * eij[ii];
|
||||
|
||||
// must not count any contribution where i is not a local atom
|
||||
if (i < nlistatoms) {
|
||||
if (i < nlocal) {
|
||||
Kokkos::atomic_add(&d_eatoms[i], e);
|
||||
local_sum += e;
|
||||
}
|
||||
@ -294,7 +294,7 @@ void LAMMPS_NS::update_pair_energy(MLIAPDataKokkosDevice *data, double *eij)
|
||||
|
||||
void LAMMPS_NS::update_pair_forces(MLIAPDataKokkosDevice *data, double *fij)
|
||||
{
|
||||
const auto nlistatoms = data->nlistatoms;
|
||||
const auto nlocal = data->nlocal;
|
||||
auto *f = data->f;
|
||||
auto pair_i = data->pair_i;
|
||||
auto j_atoms = data->jatoms;
|
||||
@ -315,7 +315,7 @@ void LAMMPS_NS::update_pair_forces(MLIAPDataKokkosDevice *data, double *fij)
|
||||
int i = pair_i[ii];
|
||||
int j = j_atoms[ii];
|
||||
// must not count any contribution where i is not a local atom
|
||||
if (i < nlistatoms) {
|
||||
if (i < nlocal) {
|
||||
Kokkos::atomic_add(&f[i*3+0], fij[ii3+0]);
|
||||
Kokkos::atomic_add(&f[i*3+1], fij[ii3+1]);
|
||||
Kokkos::atomic_add(&f[i*3+2], fij[ii3+2]);
|
||||
@ -378,12 +378,12 @@ void LAMMPS_NS::update_pair_forces(MLIAPDataKokkosDevice *data, double *fij)
|
||||
void LAMMPS_NS::update_atom_energy(MLIAPDataKokkosDevice *data, double *ei)
|
||||
{
|
||||
auto d_eatoms = data->eatoms;
|
||||
const auto nlistatoms = data->nlistatoms;
|
||||
const auto nlocal = data->nlocal;
|
||||
|
||||
Kokkos::parallel_reduce(nlistatoms, KOKKOS_LAMBDA(int i, double &local_sum){
|
||||
Kokkos::parallel_reduce(nlocal, KOKKOS_LAMBDA(int i, double &local_sum){
|
||||
double e = ei[i];
|
||||
// must not count any contribution where i is not a local atom
|
||||
if (i < nlistatoms) {
|
||||
if (i < nlocal) {
|
||||
d_eatoms[i] = e;
|
||||
local_sum += e;
|
||||
}
|
||||
|
||||
@ -138,6 +138,7 @@ template<class DeviceType>
|
||||
void PairMLIAPKokkos<DeviceType>::allocate()
|
||||
{
|
||||
int n = atom->ntypes;
|
||||
|
||||
memoryKK->destroy_kokkos(k_map, map);
|
||||
memoryKK->destroy_kokkos(k_cutsq, cutsq);
|
||||
memoryKK->destroy_kokkos(k_setflag, setflag);
|
||||
@ -275,7 +276,10 @@ void PairMLIAPKokkos<DeviceType>::coeff(int narg, char **arg) {
|
||||
auto h_cutsq=k_cutsq.template view<LMPHostType>();
|
||||
for (int itype=1; itype <= atom->ntypes; ++itype)
|
||||
for (int jtype=1; jtype <= atom->ntypes; ++jtype)
|
||||
h_cutsq(itype,jtype) = descriptor->cutsq[map[itype]][map[jtype]];
|
||||
// do not set cuts for NULL atoms
|
||||
if (map[itype] >= 0 && map[jtype] >= 0) {
|
||||
h_cutsq(itype,jtype) = descriptor->cutsq[map[itype]][map[jtype]];
|
||||
}
|
||||
k_cutsq.modify<LMPHostType>();
|
||||
k_cutsq.sync<DeviceType>();
|
||||
constexpr int gradgradflag = -1;
|
||||
|
||||
@ -115,6 +115,7 @@ void MLIAPData::generate_neighdata(NeighList *list_in, int eflag_in, int vflag_i
|
||||
int **firstneigh = list->firstneigh;
|
||||
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
nlocal = atom->nlocal;
|
||||
ntotal = nall;
|
||||
|
||||
// grow nmax gradforce, elems arrays if necessary
|
||||
|
||||
@ -60,6 +60,7 @@ class MLIAPData : protected Pointers {
|
||||
|
||||
int ntotal; // total number of owned and ghost atoms on this proc
|
||||
int nlistatoms; // current number of atoms in local atom lists
|
||||
int nlocal;
|
||||
int nlistatoms_max; // allocated size of descriptor array
|
||||
int natomneigh; // current number of atoms and ghosts in atom neighbor arrays
|
||||
int natomneigh_max; // allocated size of atom neighbor arrays
|
||||
|
||||
@ -18,6 +18,7 @@ cdef extern from "mliap_data.h" namespace "LAMMPS_NS":
|
||||
cdef cppclass MLIAPData:
|
||||
# Array shapes
|
||||
int nlistatoms
|
||||
int nlocal
|
||||
int ndescriptors
|
||||
|
||||
# Input data
|
||||
|
||||
@ -246,6 +246,7 @@ void LAMMPS_NS::update_pair_energy(MLIAPData *data, double *eij)
|
||||
{
|
||||
double e_total = 0.0;
|
||||
const auto nlistatoms = data->nlistatoms;
|
||||
const auto nlocal = data->nlocal;
|
||||
for (int ii = 0; ii < nlistatoms; ii++) data->eatoms[ii] = 0;
|
||||
|
||||
for (int ii = 0; ii < data->npairs; ii++) {
|
||||
@ -253,7 +254,7 @@ void LAMMPS_NS::update_pair_energy(MLIAPData *data, double *eij)
|
||||
double e = 0.5 * eij[ii];
|
||||
|
||||
// must not count any contribution where i is not a local atom
|
||||
if (i < nlistatoms) {
|
||||
if (i < nlocal) {
|
||||
data->eatoms[i] += e;
|
||||
e_total += e;
|
||||
}
|
||||
@ -267,7 +268,9 @@ void LAMMPS_NS::update_pair_energy(MLIAPData *data, double *eij)
|
||||
|
||||
void LAMMPS_NS::update_pair_forces(MLIAPData *data, double *fij)
|
||||
{
|
||||
const auto nlistatoms = data->nlistatoms;
|
||||
//Bugfix: need to account for Null atoms in local atoms
|
||||
//const auto nlistatoms = data->nlistatoms;
|
||||
const auto nlocal = data->nlocal;
|
||||
double **f = data->f;
|
||||
for (int ii = 0; ii < data->npairs; ii++) {
|
||||
int ii3 = ii * 3;
|
||||
@ -275,7 +278,7 @@ void LAMMPS_NS::update_pair_forces(MLIAPData *data, double *fij)
|
||||
int j = data->jatoms[ii];
|
||||
|
||||
// must not count any contribution where i is not a local atom
|
||||
if (i < nlistatoms) {
|
||||
if (i < nlocal) {
|
||||
f[i][0] += fij[ii3];
|
||||
f[i][1] += fij[ii3 + 1];
|
||||
f[i][2] += fij[ii3 + 2];
|
||||
|
||||
@ -53,7 +53,8 @@ cdef extern from "mliap_data.h" namespace "LAMMPS_NS":
|
||||
# only neighbors strictly inside descriptor cutoff
|
||||
|
||||
int ntotal # total number of owned and ghost atoms on this proc
|
||||
int nlistatoms # current number of atoms in local atom lists
|
||||
int nlistatoms # current number of non-NULL atoms in local atom lists
|
||||
int nlocal # current number of NULL and normal atoms in local atom lists
|
||||
int natomneigh # current number of atoms and ghosts in atom neighbor arrays
|
||||
int * numneighs # neighbors count for each atom
|
||||
int * iatoms # index of each atom
|
||||
@ -226,6 +227,10 @@ cdef class MLIAPDataPy:
|
||||
@property
|
||||
def nlistatoms(self):
|
||||
return self.data.nlistatoms
|
||||
|
||||
@property
|
||||
def nlocal(self):
|
||||
return self.data.nlocal
|
||||
|
||||
@property
|
||||
def natomneigh(self):
|
||||
|
||||
Reference in New Issue
Block a user