Merge branch 'develop' of https://www.github.com/lammps/lammps into lubricate
This commit is contained in:
@ -918,15 +918,15 @@ int PairOxdnaExcv::pack_forward_comm(int n, int *list, double *buf,
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = nx[j][0];
|
||||
buf[m++] = nx[j][1];
|
||||
buf[m++] = nx[j][2];
|
||||
buf[m++] = ny[j][0];
|
||||
buf[m++] = ny[j][1];
|
||||
buf[m++] = ny[j][2];
|
||||
buf[m++] = nz[j][0];
|
||||
buf[m++] = nz[j][1];
|
||||
buf[m++] = nz[j][2];
|
||||
buf[m++] = nx[j][0];
|
||||
buf[m++] = nx[j][1];
|
||||
buf[m++] = nx[j][2];
|
||||
buf[m++] = ny[j][0];
|
||||
buf[m++] = ny[j][1];
|
||||
buf[m++] = ny[j][2];
|
||||
buf[m++] = nz[j][0];
|
||||
buf[m++] = nz[j][1];
|
||||
buf[m++] = nz[j][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
@ -936,19 +936,18 @@ int PairOxdnaExcv::pack_forward_comm(int n, int *list, double *buf,
|
||||
void PairOxdnaExcv::unpack_forward_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
nx[i][0] = buf[m++];
|
||||
nx[i][1] = buf[m++];
|
||||
nx[i][2] = buf[m++];
|
||||
ny[i][0] = buf[m++];
|
||||
ny[i][1] = buf[m++];
|
||||
ny[i][2] = buf[m++];
|
||||
nz[i][0] = buf[m++];
|
||||
nz[i][1] = buf[m++];
|
||||
nz[i][2] = buf[m++];
|
||||
nx[i][0] = buf[m++];
|
||||
nx[i][1] = buf[m++];
|
||||
nx[i][2] = buf[m++];
|
||||
ny[i][0] = buf[m++];
|
||||
ny[i][1] = buf[m++];
|
||||
ny[i][2] = buf[m++];
|
||||
nz[i][0] = buf[m++];
|
||||
nz[i][1] = buf[m++];
|
||||
nz[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Martin Svoboda (ICPF, UJEP), Martin Lísal (ICPF, UJEP)
|
||||
Contributing authors: Martin Svoboda (ICPF, UJEP), Martin Lisal (ICPF, UJEP)
|
||||
based on pair style dpd by: Kurt Smith (U Pittsburgh)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Martin Svoboda (ICPF, UJEP), Martin Lísal (ICPF, UJEP)
|
||||
Contributing authors: Martin Svoboda (ICPF, UJEP), Martin Lisal (ICPF, UJEP)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_dpd_ext_tstat.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "boundary_correction.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_BOUNDARY_CORRECTION_H
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_ELECTRODE_KSPACE_H
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_ELECTRODE_MATH_H
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "electrode_matrix.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_ELECTRODE_MATRIX_H
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "electrode_vector.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_ELECTRODE_VECTOR_H
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "ewald_electrode.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef KSPACE_CLASS
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_electrode_conp.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef FIX_CLASS
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_electrode_conq.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef FIX_CLASS
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_electrode_thermo.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef FIX_CLASS
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pppm_electrode.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef KSPACE_CLASS
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "slab_2d.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_SLAB_2D_H
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "slab_dipole.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_SLAB_DIPOLE_H
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "wire_dipole.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meißner (TUHH)
|
||||
Contributing authors: Ludwig Ahrens-Iwers (TUHH), Shern Tee (UQ), Robert Meissner (TUHH)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef LMP_WIRE_DIPOLE_H
|
||||
|
||||
@ -163,13 +163,13 @@ FixTTM::FixTTM(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
FixTTM::~FixTTM()
|
||||
{
|
||||
delete [] infile;
|
||||
delete [] outfile;
|
||||
delete[] infile;
|
||||
delete[] outfile;
|
||||
|
||||
delete random;
|
||||
|
||||
delete [] gfactor1;
|
||||
delete [] gfactor2;
|
||||
delete[] gfactor1;
|
||||
delete[] gfactor2;
|
||||
|
||||
memory->destroy(flangevin);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ class BondHarmonicShift : public Bond {
|
||||
void write_data(FILE *) override;
|
||||
double single(int, double, int, int, double &) override;
|
||||
void born_matrix(int, double, int, int, double &, double &) override;
|
||||
void *extract(const char *, int &);
|
||||
void *extract(const char *, int &) override;
|
||||
|
||||
protected:
|
||||
double *k, *r0, *r1;
|
||||
|
||||
@ -238,3 +238,16 @@ void BondHarmonicShiftCut::born_matrix(int type, double rsq, int /*i*/, int /*j*
|
||||
du2 = 2 * k[type];
|
||||
if (r > 0.0) du = du2 * dr;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return ptr to internal members upon request
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
void *BondHarmonicShiftCut::extract(const char *str, int &dim)
|
||||
{
|
||||
dim = 1;
|
||||
if (strcmp(str, "k") == 0) return (void *) k;
|
||||
if (strcmp(str, "r0") == 0) return (void *) r0;
|
||||
if (strcmp(str, "r1") == 0) return (void *) r1;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ class BondHarmonicShiftCut : public Bond {
|
||||
void write_data(FILE *) override;
|
||||
double single(int, double, int, int, double &) override;
|
||||
void born_matrix(int, double, int, int, double &, double &) override;
|
||||
void *extract(const char *, int &) override;
|
||||
|
||||
protected:
|
||||
double *k, *r0, *r1;
|
||||
|
||||
@ -563,7 +563,6 @@ void DomainKokkos::operator()(TagDomain_image_flip, const int &i) const {
|
||||
void DomainKokkos::lamda2x(int n)
|
||||
{
|
||||
atomKK->sync(Device,X_MASK);
|
||||
|
||||
x = atomKK->k_x.view<LMPDeviceType>();
|
||||
|
||||
copymode = 1;
|
||||
@ -573,6 +572,21 @@ void DomainKokkos::lamda2x(int n)
|
||||
atomKK->modified(Device,X_MASK);
|
||||
}
|
||||
|
||||
void DomainKokkos::lamda2x(int n, int groupbit_in)
|
||||
{
|
||||
atomKK->sync(Device,X_MASK);
|
||||
x = atomKK->k_x.view<LMPDeviceType>();
|
||||
mask = atomKK->k_mask.view<LMPDeviceType>();
|
||||
mask = atomKK->k_mask.view<LMPDeviceType>();
|
||||
groupbit = groupbit_in;
|
||||
|
||||
copymode = 1;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<LMPDeviceType, TagDomain_lamda2x_group>(0,n),*this);
|
||||
copymode = 0;
|
||||
|
||||
atomKK->modified(Device,X_MASK);
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_lamda2x, const int &i) const {
|
||||
const double xi1 = x(i,1);
|
||||
@ -582,6 +596,17 @@ void DomainKokkos::operator()(TagDomain_lamda2x, const int &i) const {
|
||||
x(i,2) = h[2]*xi2 + boxlo[2];
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_lamda2x_group, const int &i) const {
|
||||
if (mask[i] & groupbit) {
|
||||
const double xi1 = x(i,1);
|
||||
const double xi2 = x(i,2);
|
||||
x(i,0) = h[0]*x(i,0) + h[5]*xi1 + h[4]*xi2 + boxlo[0];
|
||||
x(i,1) = h[1]*xi1 + h[3]*xi2 + boxlo[1];
|
||||
x(i,2) = h[2]*xi2 + boxlo[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convert box coords to triclinic 0-1 lamda coords for all N atoms
|
||||
lamda = H^-1 (x - x0)
|
||||
@ -590,7 +615,6 @@ void DomainKokkos::operator()(TagDomain_lamda2x, const int &i) const {
|
||||
void DomainKokkos::x2lamda(int n)
|
||||
{
|
||||
atomKK->sync(Device,X_MASK);
|
||||
|
||||
x = atomKK->k_x.view<LMPDeviceType>();
|
||||
|
||||
copymode = 1;
|
||||
@ -600,6 +624,20 @@ void DomainKokkos::x2lamda(int n)
|
||||
atomKK->modified(Device,X_MASK);
|
||||
}
|
||||
|
||||
void DomainKokkos::x2lamda(int n, int groupbit_in)
|
||||
{
|
||||
atomKK->sync(Device,X_MASK);
|
||||
x = atomKK->k_x.view<LMPDeviceType>();
|
||||
mask = atomKK->k_mask.view<LMPDeviceType>();
|
||||
groupbit = groupbit_in;
|
||||
|
||||
copymode = 1;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<LMPDeviceType, TagDomain_x2lamda_group>(0,n),*this);
|
||||
copymode = 0;
|
||||
|
||||
atomKK->modified(Device,X_MASK);
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_x2lamda, const int &i) const {
|
||||
F_FLOAT delta[3];
|
||||
@ -612,3 +650,17 @@ void DomainKokkos::operator()(TagDomain_x2lamda, const int &i) const {
|
||||
x(i,2) = h_inv[2]*delta[2];
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void DomainKokkos::operator()(TagDomain_x2lamda_group, const int &i) const {
|
||||
if (mask[i] & groupbit) {
|
||||
F_FLOAT delta[3];
|
||||
delta[0] = x(i,0) - boxlo[0];
|
||||
delta[1] = x(i,1) - boxlo[1];
|
||||
delta[2] = x(i,2) - boxlo[2];
|
||||
|
||||
x(i,0) = h_inv[0]*delta[0] + h_inv[5]*delta[1] + h_inv[4]*delta[2];
|
||||
x(i,1) = h_inv[1]*delta[1] + h_inv[3]*delta[2];
|
||||
x(i,2) = h_inv[2]*delta[2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,9 @@ namespace LAMMPS_NS {
|
||||
struct TagDomain_remap_all{};
|
||||
struct TagDomain_image_flip{};
|
||||
struct TagDomain_lamda2x{};
|
||||
struct TagDomain_lamda2x_group{};
|
||||
struct TagDomain_x2lamda{};
|
||||
struct TagDomain_x2lamda_group{};
|
||||
|
||||
class DomainKokkos : public Domain {
|
||||
public:
|
||||
@ -35,7 +37,9 @@ class DomainKokkos : public Domain {
|
||||
void remap_all();
|
||||
void image_flip(int, int, int);
|
||||
void x2lamda(int) override;
|
||||
void x2lamda(int,int) override;
|
||||
void lamda2x(int) override;
|
||||
void lamda2x(int,int) override;
|
||||
// forward remaining x2lamda() and lambda2x() variants to parent class
|
||||
void x2lamda(double *a, double *b) override { Domain::x2lamda(a,b); }
|
||||
void lamda2x(double *a, double *b) override { Domain::lamda2x(a,b); }
|
||||
@ -54,18 +58,26 @@ class DomainKokkos : public Domain {
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_lamda2x, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_lamda2x_group, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_x2lamda, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagDomain_x2lamda_group, const int&) const;
|
||||
|
||||
static KOKKOS_INLINE_FUNCTION
|
||||
Few<double,3> unmap(Few<double,3> prd, Few<double,6> h, int triclinic,
|
||||
Few<double,3> x, imageint image);
|
||||
|
||||
private:
|
||||
int groupbit;
|
||||
double lo[3],hi[3],period[3];
|
||||
int n_flip, m_flip, p_flip;
|
||||
ArrayTypes<LMPDeviceType>::t_x_array x;
|
||||
ArrayTypes<LMPDeviceType>::t_imageint_1d image;
|
||||
ArrayTypes<LMPDeviceType>::t_int_1d mask;
|
||||
};
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Pieter in 't Veld (SNL)
|
||||
Contributing author: Pieter in 't Veld (SNL)
|
||||
Refactoring (2024/08): Mitch Murphy (alphataubio@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_deform_kokkos.h"
|
||||
@ -21,31 +22,14 @@
|
||||
#include "atom_kokkos.h"
|
||||
#include "atom_masks.h"
|
||||
#include "domain_kokkos.h"
|
||||
#include "force.h"
|
||||
#include "input.h"
|
||||
#include "irregular.h"
|
||||
#include "kspace.h"
|
||||
#include "math_const.h"
|
||||
#include "modify.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
using namespace MathConst;
|
||||
|
||||
enum{NONE=0,FINAL,DELTA,SCALE,VEL,ERATE,TRATE,VOLUME,WIGGLE,VARIABLE};
|
||||
enum{ONE_FROM_ONE,ONE_FROM_TWO,TWO_FROM_ONE};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixDeformKokkos::FixDeformKokkos(LAMMPS *lmp, int narg, char **arg) : FixDeform(lmp, narg, arg)
|
||||
{
|
||||
kokkosable = 1;
|
||||
domainKK = (DomainKokkos *) domain;
|
||||
|
||||
datamask_read = EMPTY_MASK;
|
||||
datamask_modify = EMPTY_MASK;
|
||||
}
|
||||
@ -62,308 +46,16 @@ FixDeformKokkos::FixDeformKokkos(LAMMPS *lmp, int narg, char **arg) : FixDeform(
|
||||
|
||||
void FixDeformKokkos::pre_exchange()
|
||||
{
|
||||
if (flip == 0) return;
|
||||
|
||||
domain->yz = set[3].tilt_target = set[3].tilt_flip;
|
||||
domain->xz = set[4].tilt_target = set[4].tilt_flip;
|
||||
domain->xy = set[5].tilt_target = set[5].tilt_flip;
|
||||
domain->set_global_box();
|
||||
domain->set_local_box();
|
||||
|
||||
domainKK->image_flip(flipxy,flipxz,flipyz);
|
||||
|
||||
domainKK->remap_all();
|
||||
|
||||
domainKK->x2lamda(atom->nlocal);
|
||||
atomKK->sync(Host,ALL_MASK);
|
||||
irregular->migrate_atoms();
|
||||
FixDeform::pre_exchange();
|
||||
atomKK->modified(Host,ALL_MASK);
|
||||
domainKK->lamda2x(atom->nlocal);
|
||||
|
||||
flip = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixDeformKokkos::end_of_step()
|
||||
{
|
||||
int i;
|
||||
|
||||
double delta = update->ntimestep - update->beginstep;
|
||||
if (delta != 0.0) delta /= update->endstep - update->beginstep;
|
||||
|
||||
// wrap variable evaluations with clear/add
|
||||
|
||||
if (varflag) modify->clearstep_compute();
|
||||
|
||||
// set new box size
|
||||
// for NONE, target is current box size
|
||||
// for TRATE, set target directly based on current time, also set h_rate
|
||||
// for WIGGLE, set target directly based on current time, also set h_rate
|
||||
// for VARIABLE, set target directly via variable eval, also set h_rate
|
||||
// for others except VOLUME, target is linear value between start and stop
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (set[i].style == NONE) {
|
||||
set[i].lo_target = domain->boxlo[i];
|
||||
set[i].hi_target = domain->boxhi[i];
|
||||
} else if (set[i].style == TRATE) {
|
||||
double delt = (update->ntimestep - update->beginstep) * update->dt;
|
||||
set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) -
|
||||
0.5*((set[i].hi_start-set[i].lo_start) * exp(set[i].rate*delt));
|
||||
set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) +
|
||||
0.5*((set[i].hi_start-set[i].lo_start) * exp(set[i].rate*delt));
|
||||
h_rate[i] = set[i].rate * domain->h[i];
|
||||
h_ratelo[i] = -0.5*h_rate[i];
|
||||
} else if (set[i].style == WIGGLE) {
|
||||
double delt = (update->ntimestep - update->beginstep) * update->dt;
|
||||
set[i].lo_target = set[i].lo_start -
|
||||
0.5*set[i].amplitude * sin(MY_2PI*delt/set[i].tperiod);
|
||||
set[i].hi_target = set[i].hi_start +
|
||||
0.5*set[i].amplitude * sin(MY_2PI*delt/set[i].tperiod);
|
||||
h_rate[i] = MY_2PI/set[i].tperiod * set[i].amplitude *
|
||||
cos(MY_2PI*delt/set[i].tperiod);
|
||||
h_ratelo[i] = -0.5*h_rate[i];
|
||||
} else if (set[i].style == VARIABLE) {
|
||||
double del = input->variable->compute_equal(set[i].hvar);
|
||||
set[i].lo_target = set[i].lo_start - 0.5*del;
|
||||
set[i].hi_target = set[i].hi_start + 0.5*del;
|
||||
h_rate[i] = input->variable->compute_equal(set[i].hratevar);
|
||||
h_ratelo[i] = -0.5*h_rate[i];
|
||||
} else if (set[i].style != VOLUME) {
|
||||
set[i].lo_target = set[i].lo_start +
|
||||
delta*(set[i].lo_stop - set[i].lo_start);
|
||||
set[i].hi_target = set[i].hi_start +
|
||||
delta*(set[i].hi_stop - set[i].hi_start);
|
||||
}
|
||||
}
|
||||
|
||||
// set new box size for VOLUME dims that are linked to other dims
|
||||
// NOTE: still need to set h_rate for these dims
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (set[i].style != VOLUME) continue;
|
||||
|
||||
if (set[i].substyle == ONE_FROM_ONE) {
|
||||
set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) -
|
||||
0.5*(set[i].vol_start /
|
||||
(set[set[i].dynamic1].hi_target -
|
||||
set[set[i].dynamic1].lo_target) /
|
||||
(set[set[i].fixed].hi_start-set[set[i].fixed].lo_start));
|
||||
set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) +
|
||||
0.5*(set[i].vol_start /
|
||||
(set[set[i].dynamic1].hi_target -
|
||||
set[set[i].dynamic1].lo_target) /
|
||||
(set[set[i].fixed].hi_start-set[set[i].fixed].lo_start));
|
||||
|
||||
} else if (set[i].substyle == ONE_FROM_TWO) {
|
||||
set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) -
|
||||
0.5*(set[i].vol_start /
|
||||
(set[set[i].dynamic1].hi_target -
|
||||
set[set[i].dynamic1].lo_target) /
|
||||
(set[set[i].dynamic2].hi_target -
|
||||
set[set[i].dynamic2].lo_target));
|
||||
set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) +
|
||||
0.5*(set[i].vol_start /
|
||||
(set[set[i].dynamic1].hi_target -
|
||||
set[set[i].dynamic1].lo_target) /
|
||||
(set[set[i].dynamic2].hi_target -
|
||||
set[set[i].dynamic2].lo_target));
|
||||
|
||||
} else if (set[i].substyle == TWO_FROM_ONE) {
|
||||
set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) -
|
||||
0.5*sqrt(set[i].vol_start /
|
||||
(set[set[i].dynamic1].hi_target -
|
||||
set[set[i].dynamic1].lo_target) /
|
||||
(set[set[i].fixed].hi_start -
|
||||
set[set[i].fixed].lo_start) *
|
||||
(set[i].hi_start - set[i].lo_start));
|
||||
set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) +
|
||||
0.5*sqrt(set[i].vol_start /
|
||||
(set[set[i].dynamic1].hi_target -
|
||||
set[set[i].dynamic1].lo_target) /
|
||||
(set[set[i].fixed].hi_start -
|
||||
set[set[i].fixed].lo_start) *
|
||||
(set[i].hi_start - set[i].lo_start));
|
||||
}
|
||||
}
|
||||
|
||||
// for triclinic, set new box shape
|
||||
// for NONE, target is current tilt
|
||||
// for TRATE, set target directly based on current time. also set h_rate
|
||||
// for WIGGLE, set target directly based on current time. also set h_rate
|
||||
// for VARIABLE, set target directly via variable eval. also set h_rate
|
||||
// for other styles, target is linear value between start and stop values
|
||||
|
||||
if (triclinic) {
|
||||
double *h = domain->h;
|
||||
|
||||
for (i = 3; i < 6; i++) {
|
||||
if (set[i].style == NONE) {
|
||||
if (i == 5) set[i].tilt_target = domain->xy;
|
||||
else if (i == 4) set[i].tilt_target = domain->xz;
|
||||
else if (i == 3) set[i].tilt_target = domain->yz;
|
||||
} else if (set[i].style == TRATE) {
|
||||
double delt = (update->ntimestep - update->beginstep) * update->dt;
|
||||
set[i].tilt_target = set[i].tilt_start * exp(set[i].rate*delt);
|
||||
h_rate[i] = set[i].rate * domain->h[i];
|
||||
} else if (set[i].style == WIGGLE) {
|
||||
double delt = (update->ntimestep - update->beginstep) * update->dt;
|
||||
set[i].tilt_target = set[i].tilt_start +
|
||||
set[i].amplitude * sin(MY_2PI*delt/set[i].tperiod);
|
||||
h_rate[i] = MY_2PI/set[i].tperiod * set[i].amplitude *
|
||||
cos(MY_2PI*delt/set[i].tperiod);
|
||||
} else if (set[i].style == VARIABLE) {
|
||||
double delta_tilt = input->variable->compute_equal(set[i].hvar);
|
||||
set[i].tilt_target = set[i].tilt_start + delta_tilt;
|
||||
h_rate[i] = input->variable->compute_equal(set[i].hratevar);
|
||||
} else {
|
||||
set[i].tilt_target = set[i].tilt_start +
|
||||
delta*(set[i].tilt_stop - set[i].tilt_start);
|
||||
}
|
||||
|
||||
// tilt_target can be large positive or large negative value
|
||||
// add/subtract box lengths until tilt_target is closest to current value
|
||||
|
||||
int idenom = 0;
|
||||
if (i == 5) idenom = 0;
|
||||
else if (i == 4) idenom = 0;
|
||||
else if (i == 3) idenom = 1;
|
||||
double denom = set[idenom].hi_target - set[idenom].lo_target;
|
||||
|
||||
double current = h[i]/h[idenom];
|
||||
|
||||
while (set[i].tilt_target/denom - current > 0.0)
|
||||
set[i].tilt_target -= denom;
|
||||
while (set[i].tilt_target/denom - current < 0.0)
|
||||
set[i].tilt_target += denom;
|
||||
if (fabs(set[i].tilt_target/denom - 1.0 - current) <
|
||||
fabs(set[i].tilt_target/denom - current))
|
||||
set[i].tilt_target -= denom;
|
||||
}
|
||||
}
|
||||
|
||||
if (varflag) modify->addstep_compute(update->ntimestep + nevery);
|
||||
|
||||
// if any tilt ratios exceed 0.5, set flip = 1 and compute new tilt values
|
||||
// do not flip in x or y if non-periodic (can tilt but not flip)
|
||||
// this is b/c the box length would be changed (dramatically) by flip
|
||||
// if yz tilt exceeded, adjust C vector by one B vector
|
||||
// if xz tilt exceeded, adjust C vector by one A vector
|
||||
// if xy tilt exceeded, adjust B vector by one A vector
|
||||
// check yz first since it may change xz, then xz check comes after
|
||||
// flip is performed on next timestep, before reneighboring in pre-exchange()
|
||||
|
||||
if (triclinic && flipflag) {
|
||||
double xprd = set[0].hi_target - set[0].lo_target;
|
||||
double yprd = set[1].hi_target - set[1].lo_target;
|
||||
double xprdinv = 1.0 / xprd;
|
||||
double yprdinv = 1.0 / yprd;
|
||||
if (set[3].tilt_target*yprdinv < -0.5 ||
|
||||
set[3].tilt_target*yprdinv > 0.5 ||
|
||||
set[4].tilt_target*xprdinv < -0.5 ||
|
||||
set[4].tilt_target*xprdinv > 0.5 ||
|
||||
set[5].tilt_target*xprdinv < -0.5 ||
|
||||
set[5].tilt_target*xprdinv > 0.5) {
|
||||
set[3].tilt_flip = set[3].tilt_target;
|
||||
set[4].tilt_flip = set[4].tilt_target;
|
||||
set[5].tilt_flip = set[5].tilt_target;
|
||||
|
||||
flipxy = flipxz = flipyz = 0;
|
||||
|
||||
if (domain->yperiodic) {
|
||||
if (set[3].tilt_flip*yprdinv < -0.5) {
|
||||
set[3].tilt_flip += yprd;
|
||||
set[4].tilt_flip += set[5].tilt_flip;
|
||||
flipyz = 1;
|
||||
} else if (set[3].tilt_flip*yprdinv > 0.5) {
|
||||
set[3].tilt_flip -= yprd;
|
||||
set[4].tilt_flip -= set[5].tilt_flip;
|
||||
flipyz = -1;
|
||||
}
|
||||
}
|
||||
if (domain->xperiodic) {
|
||||
if (set[4].tilt_flip*xprdinv < -0.5) {
|
||||
set[4].tilt_flip += xprd;
|
||||
flipxz = 1;
|
||||
}
|
||||
if (set[4].tilt_flip*xprdinv > 0.5) {
|
||||
set[4].tilt_flip -= xprd;
|
||||
flipxz = -1;
|
||||
}
|
||||
if (set[5].tilt_flip*xprdinv < -0.5) {
|
||||
set[5].tilt_flip += xprd;
|
||||
flipxy = 1;
|
||||
}
|
||||
if (set[5].tilt_flip*xprdinv > 0.5) {
|
||||
set[5].tilt_flip -= xprd;
|
||||
flipxy = -1;
|
||||
}
|
||||
}
|
||||
|
||||
flip = 0;
|
||||
if (flipxy || flipxz || flipyz) flip = 1;
|
||||
if (flip) next_reneighbor = update->ntimestep + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// convert atoms and rigid bodies to lamda coords
|
||||
|
||||
if (remapflag == Domain::X_REMAP) {
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
domainKK->x2lamda(nlocal);
|
||||
|
||||
if (rfix.size() > 0) {
|
||||
atomKK->sync(Host,ALL_MASK);
|
||||
for (auto &ifix : rfix)
|
||||
ifix->deform(0);
|
||||
atomKK->modified(Host,ALL_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
// reset global and local box to new size/shape
|
||||
// only if deform fix is controlling the dimension
|
||||
|
||||
if (set[0].style) {
|
||||
domain->boxlo[0] = set[0].lo_target;
|
||||
domain->boxhi[0] = set[0].hi_target;
|
||||
}
|
||||
if (set[1].style) {
|
||||
domain->boxlo[1] = set[1].lo_target;
|
||||
domain->boxhi[1] = set[1].hi_target;
|
||||
}
|
||||
if (set[2].style) {
|
||||
domain->boxlo[2] = set[2].lo_target;
|
||||
domain->boxhi[2] = set[2].hi_target;
|
||||
}
|
||||
if (triclinic) {
|
||||
if (set[3].style) domain->yz = set[3].tilt_target;
|
||||
if (set[4].style) domain->xz = set[4].tilt_target;
|
||||
if (set[5].style) domain->xy = set[5].tilt_target;
|
||||
}
|
||||
|
||||
domain->set_global_box();
|
||||
domain->set_local_box();
|
||||
|
||||
// convert atoms and rigid bodies back to box coords
|
||||
|
||||
if (remapflag == Domain::X_REMAP) {
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
domainKK->lamda2x(nlocal);
|
||||
|
||||
if (rfix.size() > 0) {
|
||||
atomKK->sync(Host,ALL_MASK);
|
||||
for (auto &ifix : rfix)
|
||||
ifix->deform(1);
|
||||
atomKK->modified(Host,ALL_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
// redo KSpace coeffs since box has changed
|
||||
|
||||
if (kspace_flag) force->kspace->setup();
|
||||
atomKK->sync(Host,ALL_MASK);
|
||||
FixDeform::end_of_step();
|
||||
atomKK->modified(Host,ALL_MASK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -34,13 +34,9 @@ class FixDeformKokkos : public FixDeform {
|
||||
void pre_exchange() override;
|
||||
void end_of_step() override;
|
||||
|
||||
private:
|
||||
class DomainKokkos *domainKK;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -13,22 +13,23 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Trung Nguyen (U Chicago)
|
||||
Contributing authors: Trung Nguyen (U Chicago)
|
||||
Mitch Murphy (alphataubio at gmail)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_efield_kokkos.h"
|
||||
|
||||
#include "atom_kokkos.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "domain_kokkos.h"
|
||||
#include "region.h"
|
||||
#include "input.h"
|
||||
#include "variable.h"
|
||||
#include "memory_kokkos.h"
|
||||
#include "error.h"
|
||||
#include "atom_masks.h"
|
||||
#include "domain_kokkos.h"
|
||||
#include "error.h"
|
||||
#include "input.h"
|
||||
#include "kokkos_base.h"
|
||||
#include "memory_kokkos.h"
|
||||
#include "modify_kokkos.h"
|
||||
#include "region.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -44,12 +45,12 @@ FixEfieldKokkos<DeviceType>::FixEfieldKokkos(LAMMPS *lmp, int narg, char **arg)
|
||||
kokkosable = 1;
|
||||
atomKK = (AtomKokkos *) atom;
|
||||
execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
|
||||
datamask_read = EMPTY_MASK;
|
||||
datamask_modify = EMPTY_MASK;
|
||||
datamask_read = X_MASK | F_MASK | TORQUE_MASK | Q_MASK | MU_MASK | IMAGE_MASK | MASK_MASK;
|
||||
datamask_modify = F_MASK | TORQUE_MASK;
|
||||
|
||||
memory->destroy(efield);
|
||||
memoryKK->create_kokkos(k_efield,efield,maxatom,4,"efield:efield");
|
||||
d_efield = k_efield.view<DeviceType>();
|
||||
d_efield = k_efield.template view<DeviceType>();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -60,7 +61,7 @@ FixEfieldKokkos<DeviceType>::~FixEfieldKokkos()
|
||||
if (copymode) return;
|
||||
|
||||
memoryKK->destroy_kokkos(k_efield,efield);
|
||||
efield = nullptr;
|
||||
memoryKK->destroy_kokkos(k_vatom,vatom);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -77,17 +78,30 @@ void FixEfieldKokkos<DeviceType>::init()
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template<class DeviceType>
|
||||
void FixEfieldKokkos<DeviceType>::post_force(int /*vflag*/)
|
||||
void FixEfieldKokkos<DeviceType>::post_force(int vflag)
|
||||
{
|
||||
atomKK->sync(execution_space, X_MASK | F_MASK | Q_MASK | IMAGE_MASK | MASK_MASK);
|
||||
atomKK->sync(execution_space, datamask_read);
|
||||
|
||||
x = atomKK->k_x.view<DeviceType>();
|
||||
f = atomKK->k_f.view<DeviceType>();
|
||||
q = atomKK->k_q.view<DeviceType>();
|
||||
image = atomKK->k_image.view<DeviceType>();
|
||||
mask = atomKK->k_mask.view<DeviceType>();
|
||||
d_x = atomKK->k_x.template view<DeviceType>();
|
||||
d_f = atomKK->k_f.template view<DeviceType>();
|
||||
d_q = atomKK->k_q.template view<DeviceType>();
|
||||
d_mu = atomKK->k_mu.template view<DeviceType>();
|
||||
d_torque = atomKK->k_torque.template view<DeviceType>();
|
||||
d_image = atomKK->k_image.template view<DeviceType>();
|
||||
d_mask = atomKK->k_mask.template view<DeviceType>();
|
||||
int nlocal = atomKK->nlocal;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
// virial setup
|
||||
|
||||
v_init(vflag);
|
||||
|
||||
// reallocate per-atom arrays if necessary
|
||||
|
||||
if (vflag_atom) {
|
||||
memoryKK->destroy_kokkos(k_vatom,vatom);
|
||||
memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"efield:vatom");
|
||||
d_vatom = k_vatom.template view<DeviceType>();
|
||||
}
|
||||
|
||||
// update region if necessary
|
||||
|
||||
@ -111,53 +125,24 @@ void FixEfieldKokkos<DeviceType>::post_force(int /*vflag*/)
|
||||
d_efield = k_efield.view<DeviceType>();
|
||||
}
|
||||
|
||||
fsum[0] = fsum[1] = fsum[2] = fsum[3] = 0.0;
|
||||
double_4 fsum_kk;
|
||||
force_flag = 0;
|
||||
double result[10] = {0.0};
|
||||
|
||||
if (varflag == CONSTANT) {
|
||||
|
||||
prd = domain->prd;
|
||||
h = domain->h;
|
||||
triclinic = domain->triclinic;
|
||||
copymode = 1;
|
||||
|
||||
// It would be more concise to use the operators below, but there is still an issue with unwrap (TODO below)
|
||||
//Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldConstant>(0,nlocal),*this,fsum_kk);
|
||||
|
||||
{
|
||||
// local variables for lambda capture
|
||||
auto prd = Few<double,3>(domain->prd);
|
||||
auto h = Few<double,6>(domain->h);
|
||||
auto triclinic = domain->triclinic;
|
||||
auto l_ex = ex;
|
||||
auto l_ey = ey;
|
||||
auto l_ez = ez;
|
||||
|
||||
auto l_x = x;
|
||||
auto l_q = q;
|
||||
auto l_f = f;
|
||||
auto l_mask = mask;
|
||||
auto l_image = image;
|
||||
auto l_groupbit = groupbit;
|
||||
|
||||
Kokkos::parallel_reduce(nlocal, LAMMPS_LAMBDA(const int& i, double_4& fsum_kk) {
|
||||
if (l_mask[i] & l_groupbit) {
|
||||
Few<double,3> x_i;
|
||||
x_i[0] = l_x(i,0);
|
||||
x_i[1] = l_x(i,1);
|
||||
x_i[2] = l_x(i,2);
|
||||
auto unwrap = DomainKokkos::unmap(prd,h,triclinic,x_i,l_image(i));
|
||||
auto qtmp = l_q(i);
|
||||
auto fx = qtmp * l_ex;
|
||||
auto fy = qtmp * l_ey;
|
||||
auto fz = qtmp * l_ez;
|
||||
l_f(i,0) += fx;
|
||||
l_f(i,1) += fy;
|
||||
l_f(i,2) += fz;
|
||||
fsum_kk.d0 -= fx * unwrap[0] + fy * unwrap[1] + fz * unwrap[2];
|
||||
fsum_kk.d1 += fx;
|
||||
fsum_kk.d2 += fy;
|
||||
fsum_kk.d3 += fz;
|
||||
}
|
||||
},fsum_kk);
|
||||
}
|
||||
if(qflag && muflag)
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldConstant<1,1> >(0,nlocal),*this,result);
|
||||
else if(qflag && !muflag)
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldConstant<1,0> >(0,nlocal),*this,result);
|
||||
else if(!qflag && muflag)
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldConstant<0,1> >(0,nlocal),*this,result);
|
||||
else
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldConstant<0,0> >(0,nlocal),*this,result);
|
||||
|
||||
copymode = 0;
|
||||
|
||||
@ -167,19 +152,7 @@ void FixEfieldKokkos<DeviceType>::post_force(int /*vflag*/)
|
||||
|
||||
atomKK->sync(Host,ALL_MASK); // this can be removed when variable class is ported to Kokkos
|
||||
|
||||
modify->clearstep_compute();
|
||||
|
||||
if (xstyle == EQUAL) ex = input->variable->compute_equal(xvar);
|
||||
else if (xstyle == ATOM)
|
||||
input->variable->compute_atom(xvar,igroup,&efield[0][0],4,0);
|
||||
if (ystyle == EQUAL) ey = input->variable->compute_equal(yvar);
|
||||
else if (ystyle == ATOM)
|
||||
input->variable->compute_atom(yvar,igroup,&efield[0][1],4,0);
|
||||
if (zstyle == EQUAL) ez = input->variable->compute_equal(zvar);
|
||||
else if (zstyle == ATOM)
|
||||
input->variable->compute_atom(zvar,igroup,&efield[0][2],4,0);
|
||||
|
||||
modify->addstep_compute(update->ntimestep + 1);
|
||||
FixEfield::update_efield_variables();
|
||||
|
||||
if (varflag == ATOM) { // this can be removed when variable class is ported to Kokkos
|
||||
k_efield.modify<LMPHostType>();
|
||||
@ -187,121 +160,154 @@ void FixEfieldKokkos<DeviceType>::post_force(int /*vflag*/)
|
||||
}
|
||||
|
||||
copymode = 1;
|
||||
// It would be more concise to use the operators below, but there is still an issue with unwrap (TODO below)
|
||||
//Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldNonConstant>(0,nlocal),*this,fsum_kk);
|
||||
{
|
||||
// local variables for lambda capture
|
||||
auto prd = Few<double,3>(domain->prd);
|
||||
auto h = Few<double,6>(domain->h);
|
||||
auto triclinic = domain->triclinic;
|
||||
auto l_ex = ex;
|
||||
auto l_ey = ey;
|
||||
auto l_ez = ez;
|
||||
auto l_d_efield = d_efield;
|
||||
|
||||
auto l_x = x;
|
||||
auto l_q = q;
|
||||
auto l_f = f;
|
||||
auto l_mask = mask;
|
||||
auto l_image = image;
|
||||
auto l_groupbit = groupbit;
|
||||
auto l_xstyle = xstyle;
|
||||
auto l_ystyle = ystyle;
|
||||
auto l_zstyle = zstyle;
|
||||
|
||||
Kokkos::parallel_reduce(nlocal, LAMMPS_LAMBDA(const int& i, double_4& fsum_kk) {
|
||||
if (l_mask[i] & l_groupbit) {
|
||||
Few<double,3> x_i;
|
||||
x_i[0] = l_x(i,0);
|
||||
x_i[1] = l_x(i,1);
|
||||
x_i[2] = l_x(i,2);
|
||||
auto unwrap = DomainKokkos::unmap(prd,h,triclinic,x_i,l_image(i));
|
||||
auto qtmp = l_q(i);
|
||||
auto fx = qtmp * l_ex;
|
||||
auto fy = qtmp * l_ey;
|
||||
auto fz = qtmp * l_ez;
|
||||
if (l_xstyle == ATOM) l_f(i,0) += qtmp * l_d_efield(i,0);
|
||||
else if (l_xstyle) l_f(i,0) += fx;
|
||||
if (l_ystyle == ATOM) l_f(i,1) += qtmp * l_d_efield(i,1);
|
||||
else if (l_ystyle) l_f(i,1) += fy;
|
||||
if (l_zstyle == ATOM) l_f(i,2) += qtmp * l_d_efield(i,2);
|
||||
else if (l_zstyle) l_f(i,2) += fz;
|
||||
fsum_kk.d0 -= fx * unwrap[0] + fy * unwrap[1] + fz * unwrap[2];
|
||||
fsum_kk.d1 += fx;
|
||||
fsum_kk.d2 += fy;
|
||||
fsum_kk.d3 += fz;
|
||||
}
|
||||
},fsum_kk);
|
||||
}
|
||||
if(qflag && muflag)
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldNonConstant<1,1> >(0,nlocal),*this,result);
|
||||
else if(qflag && !muflag)
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldNonConstant<1,0> >(0,nlocal),*this,result);
|
||||
else if(!qflag && muflag)
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldNonConstant<0,1> >(0,nlocal),*this,result);
|
||||
else
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagFixEfieldNonConstant<0,0> >(0,nlocal),*this,result);
|
||||
|
||||
copymode = 0;
|
||||
|
||||
}
|
||||
|
||||
atomKK->modified(execution_space, F_MASK);
|
||||
atomKK->modified(execution_space, datamask_modify);
|
||||
|
||||
fsum[0] = fsum_kk.d0;
|
||||
fsum[1] = fsum_kk.d1;
|
||||
fsum[2] = fsum_kk.d2;
|
||||
fsum[3] = fsum_kk.d3;
|
||||
}
|
||||
fsum[0]=result[0];
|
||||
fsum[1]=result[1];
|
||||
fsum[2]=result[2];
|
||||
fsum[3]=result[3];
|
||||
|
||||
template<class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixEfieldKokkos<DeviceType>::operator()(TagFixEfieldConstant, const int &i, double_4& fsum_kk) const {
|
||||
if (mask[i] & groupbit) {
|
||||
if (region && !d_match[i]) return;
|
||||
if (vflag_global) {
|
||||
virial[0] += result[4];
|
||||
virial[1] += result[5];
|
||||
virial[2] += result[6];
|
||||
virial[3] += result[7];
|
||||
virial[4] += result[8];
|
||||
virial[5] += result[9];
|
||||
}
|
||||
|
||||
auto prd = Few<double,3>(domain->prd);
|
||||
auto h = Few<double,6>(domain->h);
|
||||
auto triclinic = domain->triclinic;
|
||||
Few<double,3> x_i;
|
||||
x_i[0] = x(i,0);
|
||||
x_i[1] = x(i,1);
|
||||
x_i[2] = x(i,2);
|
||||
auto unwrap = DomainKokkos::unmap(prd,h,triclinic,x_i,image(i));
|
||||
const F_FLOAT qtmp = q(i);
|
||||
const F_FLOAT fx = qtmp * ex;
|
||||
const F_FLOAT fy = qtmp * ey;
|
||||
const F_FLOAT fz = qtmp * ez;
|
||||
f(i,0) += fx;
|
||||
f(i,1) += fy;
|
||||
f(i,2) += fz;
|
||||
// TODO: access to unwrap below crashes
|
||||
fsum_kk.d0 -= fx * unwrap[0] + fy * unwrap[1] + fz * unwrap[2];
|
||||
fsum_kk.d1 += fx;
|
||||
fsum_kk.d2 += fy;
|
||||
fsum_kk.d3 += fz;
|
||||
if (vflag_atom) {
|
||||
k_vatom.template modify<DeviceType>();
|
||||
k_vatom.template sync<LMPHostType>();
|
||||
}
|
||||
}
|
||||
|
||||
template<class DeviceType>
|
||||
template<int QFLAG, int MUFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixEfieldKokkos<DeviceType>::operator()(TagFixEfieldNonConstant, const int &i, double_4& fsum_kk) const {
|
||||
auto prd = Few<double,3>(domain->prd);
|
||||
auto h = Few<double,6>(domain->h);
|
||||
auto triclinic = domain->triclinic;
|
||||
if (mask[i] & groupbit) {
|
||||
void FixEfieldKokkos<DeviceType>::operator()(TagFixEfieldConstant<QFLAG,MUFLAG>, const int &i, value_type result) const {
|
||||
if ( QFLAG && (d_mask(i) & groupbit)) {
|
||||
if (region && !d_match[i]) return;
|
||||
|
||||
Few<double,3> x_i;
|
||||
x_i[0] = x(i,0);
|
||||
x_i[1] = x(i,1);
|
||||
x_i[2] = x(i,2);
|
||||
auto unwrap = DomainKokkos::unmap(prd,h,triclinic,x_i,image(i));
|
||||
const F_FLOAT qtmp = q[i];
|
||||
const F_FLOAT fx = qtmp * ex;
|
||||
const F_FLOAT fy = qtmp * ey;
|
||||
const F_FLOAT fz = qtmp * ez;
|
||||
if (xstyle == ATOM) f(i,0) += d_efield(i,0);
|
||||
else if (xstyle) f(i,0) += fx;
|
||||
if (ystyle == ATOM) f(i,1) += d_efield(i,1);
|
||||
else if (ystyle) f(i,1) += fy;
|
||||
if (zstyle == ATOM) f(i,2) += d_efield(i,2);
|
||||
else if (zstyle) f(i,2) += fz;
|
||||
// TODO: access to unwrap below crashes
|
||||
fsum_kk.d0 -= fx * unwrap[0] + fy * unwrap[1] + fz * unwrap[2];
|
||||
fsum_kk.d1 += fx;
|
||||
fsum_kk.d2 += fy;
|
||||
fsum_kk.d3 += fz;
|
||||
x_i[0] = d_x(i,0);
|
||||
x_i[1] = d_x(i,1);
|
||||
x_i[2] = d_x(i,2);
|
||||
auto unwrapKK = DomainKokkos::unmap(prd,h,triclinic,x_i,d_image(i));
|
||||
const F_FLOAT fx = d_q(i) * ex;
|
||||
const F_FLOAT fy = d_q(i) * ey;
|
||||
const F_FLOAT fz = d_q(i) * ez;
|
||||
d_f(i,0) += fx;
|
||||
d_f(i,1) += fy;
|
||||
d_f(i,2) += fz;
|
||||
result[0] -= fx * unwrapKK[0] + fy * unwrapKK[1] + fz * unwrapKK[2];
|
||||
result[1] += fx;
|
||||
result[2] += fy;
|
||||
result[3] += fz;
|
||||
|
||||
if (evflag) {
|
||||
double v[6];
|
||||
v[0] = fx * unwrapKK[0];
|
||||
v[1] = fy * unwrapKK[1];
|
||||
v[2] = fz * unwrapKK[2];
|
||||
v[3] = fx * unwrapKK[1];
|
||||
v[4] = fx * unwrapKK[2];
|
||||
v[5] = fy * unwrapKK[2];
|
||||
v_tally(result, i, v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (MUFLAG && (d_mask(i) & groupbit)) {
|
||||
if (region && !d_match[i]) return;
|
||||
d_torque(i,0) += ez * d_mu(i,1) - ey * d_mu(i,2);
|
||||
d_torque(i,1) += ex * d_mu(i,2) - ez * d_mu(i,0);
|
||||
d_torque(i,2) += ey * d_mu(i,0) - ex * d_mu(i,1);
|
||||
result[0] -= d_mu(i,0) * ex + d_mu(i,1) * ey + d_mu(i,2) * ez;
|
||||
}
|
||||
}
|
||||
|
||||
template<class DeviceType>
|
||||
template<int QFLAG, int MUFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixEfieldKokkos<DeviceType>::operator()(TagFixEfieldNonConstant<QFLAG,MUFLAG>, const int &i, value_type result) const {
|
||||
if ( QFLAG && (d_mask(i) & groupbit)) {
|
||||
if (region && !d_match[i]) return;
|
||||
|
||||
F_FLOAT fx, fy, fz;
|
||||
|
||||
if (xstyle == ATOM) fx = qe2f * d_q(i) * d_efield(i,0);
|
||||
else fx = d_q(i) * ex;
|
||||
if (ystyle == ATOM) fy = qe2f * d_q(i) * d_efield(i,1);
|
||||
else fy = d_q(i) * ey;
|
||||
if (zstyle == ATOM) fz = qe2f * d_q(i) * d_efield(i,2);
|
||||
else fz = d_q(i) * ez;
|
||||
|
||||
d_f(i,0) += fx;
|
||||
d_f(i,1) += fy;
|
||||
d_f(i,2) += fz;
|
||||
result[1] += fx;
|
||||
result[2] += fy;
|
||||
result[3] += fz;
|
||||
|
||||
if (pstyle == ATOM) result[0] += qe2f * d_q(i) * d_efield(i,3);
|
||||
else if (estyle == ATOM) result[0] += d_efield(i,3);
|
||||
}
|
||||
|
||||
if (MUFLAG && (d_mask(i) & groupbit)) {
|
||||
if (region && !d_match[i]) return;
|
||||
d_torque(i,0) += ez * d_mu(i,1) - ey * d_mu(i,2);
|
||||
d_torque(i,1) += ex * d_mu(i,2) - ez * d_mu(i,0);
|
||||
d_torque(i,2) += ey * d_mu(i,0) - ex * d_mu(i,1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
tally virial into global and per-atom accumulators
|
||||
i = local index of atom
|
||||
v = total virial for the interaction
|
||||
increment global virial by v
|
||||
increment per-atom virial by v
|
||||
this method can be used when fix computes forces in post_force()
|
||||
and the force depends on a distance to some external object
|
||||
e.g. fix wall/lj93: compute virial only on owned atoms
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
template <class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixEfieldKokkos<DeviceType>::v_tally(value_type result, int i, double *v) const
|
||||
{
|
||||
if (vflag_global) {
|
||||
result[4] += v[0];
|
||||
result[5] += v[1];
|
||||
result[6] += v[2];
|
||||
result[7] += v[3];
|
||||
result[8] += v[4];
|
||||
result[9] += v[5];
|
||||
}
|
||||
|
||||
if (vflag_atom) {
|
||||
Kokkos::atomic_add(&(d_vatom(i,0)),v[0]);
|
||||
Kokkos::atomic_add(&(d_vatom(i,1)),v[1]);
|
||||
Kokkos::atomic_add(&(d_vatom(i,2)),v[2]);
|
||||
Kokkos::atomic_add(&(d_vatom(i,3)),v[3]);
|
||||
Kokkos::atomic_add(&(d_vatom(i,4)),v[4]);
|
||||
Kokkos::atomic_add(&(d_vatom(i,5)),v[5]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,4 +317,3 @@ template class FixEfieldKokkos<LMPDeviceType>;
|
||||
template class FixEfieldKokkos<LMPHostType>;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -25,35 +25,20 @@ FixStyle(efield/kk/host,FixEfieldKokkos<LMPHostType>);
|
||||
|
||||
#include "fix_efield.h"
|
||||
#include "kokkos_type.h"
|
||||
#include "kokkos_few.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
struct e_double_4 {
|
||||
double d0, d1, d2, d3;
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
e_double_4() {
|
||||
d0 = d1 = d2 = d3 = 0.0;
|
||||
}
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
e_double_4& operator+=(const e_double_4 &rhs) {
|
||||
d0 += rhs.d0;
|
||||
d1 += rhs.d1;
|
||||
d2 += rhs.d2;
|
||||
d3 += rhs.d3;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
typedef e_double_4 double_4;
|
||||
|
||||
template<int QFLAG, int MUFLAG>
|
||||
struct TagFixEfieldConstant{};
|
||||
|
||||
template<int QFLAG, int MUFLAG>
|
||||
struct TagFixEfieldNonConstant{};
|
||||
|
||||
template<class DeviceType>
|
||||
class FixEfieldKokkos : public FixEfield {
|
||||
public:
|
||||
typedef DeviceType device_type;
|
||||
typedef double_4 value_type;
|
||||
typedef ArrayTypes<DeviceType> AT;
|
||||
|
||||
FixEfieldKokkos(class LAMMPS *, int, char **);
|
||||
@ -61,22 +46,40 @@ class FixEfieldKokkos : public FixEfield {
|
||||
void init() override;
|
||||
void post_force(int) override;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagFixEfieldConstant, const int&, double_4&) const;
|
||||
typedef double value_type[];
|
||||
const int value_count = 10;
|
||||
|
||||
template<int QFLAG, int MUFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagFixEfieldNonConstant, const int&, double_4&) const;
|
||||
void operator()(TagFixEfieldConstant<QFLAG,MUFLAG>, const int&, value_type) const;
|
||||
|
||||
template<int QFLAG, int MUFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagFixEfieldNonConstant<QFLAG,MUFLAG>, const int&, value_type) const;
|
||||
|
||||
private:
|
||||
|
||||
DAT::tdual_ffloat_2d k_efield;
|
||||
typename AT::t_ffloat_2d_randomread d_efield;
|
||||
typename AT::t_int_1d d_match;
|
||||
|
||||
typename AT::t_x_array_randomread x;
|
||||
typename AT::t_float_1d_randomread q;
|
||||
typename AT::t_f_array f;
|
||||
typename AT::t_imageint_1d_randomread image;
|
||||
typename AT::t_int_1d_randomread mask;
|
||||
typename AT::t_x_array_randomread d_x;
|
||||
typename AT::t_float_1d_randomread d_q;
|
||||
typename AT::t_mu_array_randomread d_mu;
|
||||
typename AT::t_f_array d_f;
|
||||
typename AT::t_f_array d_torque;
|
||||
typename AT::t_imageint_1d_randomread d_image;
|
||||
typename AT::t_int_1d_randomread d_mask;
|
||||
|
||||
Few<double,3> prd;
|
||||
Few<double,6> h;
|
||||
int triclinic;
|
||||
|
||||
DAT::tdual_virial_array k_vatom;
|
||||
typename AT::t_virial_array d_vatom;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void v_tally(value_type, int, double*) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Stan Moore (SNL)
|
||||
Contributing authors: Stan Moore (SNL)
|
||||
Mitch Murphy (alphataubio@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_nh_kokkos.h"
|
||||
@ -37,6 +38,7 @@ using namespace FixConst;
|
||||
|
||||
static constexpr double DELTAFLIP = 0.1;
|
||||
static constexpr double TILTMAX = 1.5;
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
enum{NOBIAS,BIAS};
|
||||
enum{NONE,XYZ,XY,YZ,XZ};
|
||||
@ -50,6 +52,7 @@ template<class DeviceType>
|
||||
FixNHKokkos<DeviceType>::FixNHKokkos(LAMMPS *lmp, int narg, char **arg) : FixNH(lmp, narg, arg)
|
||||
{
|
||||
kokkosable = 1;
|
||||
atomKK = (AtomKokkos *)atom;
|
||||
domainKK = (DomainKokkos *) domain;
|
||||
execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
|
||||
|
||||
@ -89,18 +92,21 @@ void FixNHKokkos<DeviceType>::setup(int /*vflag*/)
|
||||
} else if (pstat_flag) {
|
||||
|
||||
// t0 = reference temperature for masses
|
||||
// set equal to either ptemp or the current temperature
|
||||
// cannot be done in init() b/c temperature cannot be called there
|
||||
// is b/c Modify::init() inits computes after fixes due to dof dependence
|
||||
// guesstimate a unit-dependent t0 if actual T = 0.0
|
||||
// error if T less than 1e-6
|
||||
// if it was read in from a restart file, leave it be
|
||||
|
||||
if (t0 == 0.0) {
|
||||
atomKK->sync(temperature->execution_space,temperature->datamask_read);
|
||||
t0 = temperature->compute_scalar();
|
||||
atomKK->modified(temperature->execution_space,temperature->datamask_modify);
|
||||
if (t0 == 0.0) {
|
||||
if (strcmp(update->unit_style,"lj") == 0) t0 = 1.0;
|
||||
else t0 = 300.0;
|
||||
if (p_temp_flag) {
|
||||
t0 = p_temp;
|
||||
} else {
|
||||
atomKK->sync(temperature->execution_space,temperature->datamask_read);
|
||||
t0 = temperature->compute_scalar();
|
||||
atomKK->modified(temperature->execution_space,temperature->datamask_modify);
|
||||
if (t0 < EPSILON)
|
||||
error->all(FLERR,"Current temperature too close to zero, consider using ptemp keyword");
|
||||
}
|
||||
}
|
||||
t_target = t0;
|
||||
@ -298,13 +304,14 @@ void FixNHKokkos<DeviceType>::remap()
|
||||
|
||||
// convert pertinent atoms and rigid bodies to lamda coords
|
||||
|
||||
domainKK->x2lamda(nlocal);
|
||||
//if (allremap) domainKK->x2lamda(nlocal);
|
||||
//else {
|
||||
// for (i = 0; i < nlocal; i++)
|
||||
// if (mask[i] & dilate_group_bit)
|
||||
// domain->x2lamda(x[i],x[i]);
|
||||
//}
|
||||
x = atomKK->k_x.template view<DeviceType>();
|
||||
|
||||
if (allremap) domainKK->x2lamda(nlocal);
|
||||
else {
|
||||
for ( int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & dilate_group_bit)
|
||||
domainKK->x2lamda(&x(i,0), &x(i,0));
|
||||
}
|
||||
|
||||
if (rfix.size() > 0)
|
||||
error->all(FLERR,"Cannot (yet) use rigid bodies with fix nh and Kokkos");
|
||||
@ -446,13 +453,12 @@ void FixNHKokkos<DeviceType>::remap()
|
||||
|
||||
// convert pertinent atoms and rigid bodies back to box coords
|
||||
|
||||
domainKK->lamda2x(nlocal);
|
||||
//if (allremap) domainKK->lamda2x(nlocal);
|
||||
//else {
|
||||
// for (i = 0; i < nlocal; i++)
|
||||
// if (mask[i] & dilate_group_bit)
|
||||
// domain->lamda2x(x[i],x[i]);
|
||||
//}
|
||||
if (allremap) domainKK->lamda2x(nlocal);
|
||||
else {
|
||||
for ( int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & dilate_group_bit)
|
||||
domainKK->lamda2x(&x(i,0), &x(i,0));
|
||||
}
|
||||
|
||||
// for (auto &ifix : rfix) ifix->deform(1);
|
||||
}
|
||||
|
||||
@ -12,11 +12,19 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Mitch Murphy (alphataubio@gmail.com)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fix_wall_lj93_kokkos.h"
|
||||
|
||||
#include "atom_masks.h"
|
||||
#include "atom_kokkos.h"
|
||||
#include "error.h"
|
||||
#include "atom_masks.h"
|
||||
#include "input.h"
|
||||
#include "memory_kokkos.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -29,9 +37,91 @@ FixWallLJ93Kokkos<DeviceType>::FixWallLJ93Kokkos(LAMMPS *lmp, int narg, char **a
|
||||
kokkosable = 1;
|
||||
atomKK = (AtomKokkos *) atom;
|
||||
execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
|
||||
datamask_read = EMPTY_MASK;
|
||||
datamask_modify = EMPTY_MASK;
|
||||
virial_global_flag = virial_peratom_flag = 0;
|
||||
datamask_read = X_MASK | V_MASK | MASK_MASK;
|
||||
datamask_modify = F_MASK;
|
||||
|
||||
memoryKK->create_kokkos(k_cutoff,6,"wall_lj93:cutoff");
|
||||
memoryKK->create_kokkos(k_coeff1,6,"wall_lj93:coeff1");
|
||||
memoryKK->create_kokkos(k_coeff2,6,"wall_lj93:coeff2");
|
||||
memoryKK->create_kokkos(k_coeff3,6,"wall_lj93:coeff3");
|
||||
memoryKK->create_kokkos(k_coeff4,6,"wall_lj93:coeff4");
|
||||
memoryKK->create_kokkos(k_offset,6,"wall_lj93:offset");
|
||||
|
||||
d_cutoff = k_cutoff.template view<DeviceType>();
|
||||
d_coeff1 = k_coeff1.template view<DeviceType>();
|
||||
d_coeff2 = k_coeff2.template view<DeviceType>();
|
||||
d_coeff3 = k_coeff3.template view<DeviceType>();
|
||||
d_coeff4 = k_coeff4.template view<DeviceType>();
|
||||
d_offset = k_offset.template view<DeviceType>();
|
||||
}
|
||||
|
||||
template<class DeviceType>
|
||||
FixWallLJ93Kokkos<DeviceType>::~FixWallLJ93Kokkos()
|
||||
{
|
||||
if (copymode) return;
|
||||
|
||||
memoryKK->destroy_kokkos(k_cutoff);
|
||||
memoryKK->destroy_kokkos(k_coeff1);
|
||||
memoryKK->destroy_kokkos(k_coeff2);
|
||||
memoryKK->destroy_kokkos(k_coeff3);
|
||||
memoryKK->destroy_kokkos(k_coeff4);
|
||||
memoryKK->destroy_kokkos(k_offset);
|
||||
memoryKK->destroy_kokkos(k_vatom,vatom);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template <class DeviceType>
|
||||
void FixWallLJ93Kokkos<DeviceType>::precompute(int m)
|
||||
{
|
||||
FixWallLJ93::precompute(m);
|
||||
|
||||
for( int i=0 ; i<6 ; i++ ) {
|
||||
k_cutoff.h_view(i) = cutoff[i];
|
||||
k_coeff1.h_view(i) = coeff1[i];
|
||||
k_coeff2.h_view(i) = coeff2[i];
|
||||
k_coeff3.h_view(i) = coeff3[i];
|
||||
k_coeff4.h_view(i) = coeff4[i];
|
||||
k_offset.h_view(i) = offset[i];
|
||||
}
|
||||
|
||||
k_cutoff.template modify<LMPHostType>();
|
||||
k_coeff1.template modify<LMPHostType>();
|
||||
k_coeff2.template modify<LMPHostType>();
|
||||
k_coeff3.template modify<LMPHostType>();
|
||||
k_coeff4.template modify<LMPHostType>();
|
||||
k_offset.template modify<LMPHostType>();
|
||||
|
||||
k_cutoff.template sync<DeviceType>();
|
||||
k_coeff1.template sync<DeviceType>();
|
||||
k_coeff2.template sync<DeviceType>();
|
||||
k_coeff3.template sync<DeviceType>();
|
||||
k_coeff4.template sync<DeviceType>();
|
||||
k_offset.template sync<DeviceType>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template <class DeviceType>
|
||||
void FixWallLJ93Kokkos<DeviceType>::post_force(int vflag)
|
||||
{
|
||||
|
||||
// reallocate per-atom arrays if necessary
|
||||
|
||||
if (vflag_atom) {
|
||||
memoryKK->destroy_kokkos(k_vatom,vatom);
|
||||
memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"wall_lj93:vatom");
|
||||
d_vatom = k_vatom.template view<DeviceType>();
|
||||
}
|
||||
|
||||
FixWallLJ93::post_force(vflag);
|
||||
|
||||
if (vflag_atom) {
|
||||
k_vatom.template modify<DeviceType>();
|
||||
k_vatom.template sync<LMPHostType>();
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -47,47 +137,89 @@ void FixWallLJ93Kokkos<DeviceType>::wall_particle(int m_in, int which, double co
|
||||
m = m_in;
|
||||
coord = coord_in;
|
||||
|
||||
atomKK->sync(execution_space, X_MASK|F_MASK|MASK_MASK);
|
||||
x = atomKK->k_x.view<DeviceType>();
|
||||
f = atomKK->k_f.view<DeviceType>();
|
||||
mask = atomKK->k_mask.view<DeviceType>();
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
atomKK->sync(execution_space,datamask_read);
|
||||
d_x = atomKK->k_x.template view<DeviceType>();
|
||||
d_f = atomKK->k_f.template view<DeviceType>();
|
||||
d_mask = atomKK->k_mask.template view<DeviceType>();
|
||||
int nlocal = atomKK->nlocal;
|
||||
|
||||
dim = which / 2;
|
||||
side = which % 2;
|
||||
if (side == 0) side = -1;
|
||||
|
||||
double result[13] = {0.0};
|
||||
|
||||
copymode = 1;
|
||||
FixWallLJ93KokkosFunctor<DeviceType> wp_functor(this);
|
||||
Kokkos::parallel_reduce(nlocal,wp_functor,ewall);
|
||||
Kokkos::parallel_reduce(nlocal,*this,result);
|
||||
copymode = 0;
|
||||
|
||||
atomKK->modified(execution_space, F_MASK);
|
||||
ewall[0] += result[0];
|
||||
ewall[m+1] += result[m+1];
|
||||
atomKK->modified(execution_space,datamask_modify);
|
||||
|
||||
if (vflag_global) {
|
||||
virial[0] += result[7];
|
||||
virial[1] += result[8];
|
||||
virial[2] += result[9];
|
||||
virial[3] += result[10];
|
||||
virial[4] += result[11];
|
||||
virial[5] += result[12];
|
||||
}
|
||||
}
|
||||
|
||||
template <class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixWallLJ93Kokkos<DeviceType>::wall_particle_item(int i, value_type ewall) const {
|
||||
if (mask(i) & groupbit) {
|
||||
void FixWallLJ93Kokkos<DeviceType>::operator()(const int &i, value_type result) const {
|
||||
if (d_mask(i) & groupbit) {
|
||||
double delta;
|
||||
if (side < 0) delta = x(i,dim) - coord;
|
||||
else delta = coord - x(i,dim);
|
||||
if (delta >= cutoff[m]) return;
|
||||
if (side < 0) delta = d_x(i,dim) - coord;
|
||||
else delta = coord - d_x(i,dim);
|
||||
if (delta >= d_cutoff(m)) return;
|
||||
if (delta <= 0.0)
|
||||
Kokkos::abort("Particle on or inside fix wall surface");
|
||||
double rinv = 1.0/delta;
|
||||
double r2inv = rinv*rinv;
|
||||
double r4inv = r2inv*r2inv;
|
||||
double r10inv = r4inv*r4inv*r2inv;
|
||||
double fwall = side * (coeff1[m]*r10inv - coeff2[m]*r4inv);
|
||||
f(i,dim) -= fwall;
|
||||
ewall[0] += coeff3[m]*r4inv*r4inv*rinv -
|
||||
coeff4[m]*r2inv*rinv - offset[m];
|
||||
ewall[m+1] += fwall;
|
||||
double fwall = side * (d_coeff1(m)*r10inv - d_coeff2(m)*r4inv);
|
||||
d_f(i,dim) -= fwall;
|
||||
result[0] += d_coeff3(m)*r4inv*r4inv*rinv - d_coeff4(m)*r2inv*rinv - d_offset(m);
|
||||
result[m+1] += fwall;
|
||||
|
||||
if (evflag) {
|
||||
double vn;
|
||||
if (side < 0)
|
||||
vn = -fwall * delta;
|
||||
else
|
||||
vn = fwall * delta;
|
||||
v_tally(result, dim, i, vn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
tally virial component into global and per-atom accumulators
|
||||
n = index of virial component (0-5)
|
||||
i = local index of atom
|
||||
vn = nth component of virial for the interaction
|
||||
increment nth component of global virial by vn
|
||||
increment nth component of per-atom virial by vn
|
||||
this method can be used when fix computes forces in post_force()
|
||||
and the force depends on a distance to some external object
|
||||
e.g. fix wall/lj93: compute virial only on owned atoms
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
template <class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixWallLJ93Kokkos<DeviceType>::v_tally(value_type result, int n, int i, double vn) const
|
||||
{
|
||||
if (vflag_global)
|
||||
result[n+7] += vn;
|
||||
|
||||
if (vflag_atom)
|
||||
Kokkos::atomic_add(&(d_vatom(i,n)),vn);
|
||||
}
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
template class FixWallLJ93Kokkos<LMPDeviceType>;
|
||||
#ifdef LMP_KOKKOS_GPU
|
||||
|
||||
@ -33,38 +33,37 @@ class FixWallLJ93Kokkos : public FixWallLJ93 {
|
||||
public:
|
||||
typedef DeviceType device_type;
|
||||
typedef ArrayTypes<DeviceType> AT;
|
||||
typedef double value_type[];
|
||||
|
||||
FixWallLJ93Kokkos(class LAMMPS *, int, char **);
|
||||
~FixWallLJ93Kokkos() override;
|
||||
void precompute(int) override;
|
||||
void post_force(int) override;
|
||||
void wall_particle(int, int, double) override;
|
||||
|
||||
int m;
|
||||
|
||||
typedef double value_type[];
|
||||
const int value_count = 13;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void wall_particle_item(int, value_type) const;
|
||||
void operator()(const int&, value_type) const;
|
||||
|
||||
private:
|
||||
int dim,side;
|
||||
double coord;
|
||||
|
||||
typename AT::t_x_array x;
|
||||
typename AT::t_f_array f;
|
||||
typename AT::t_int_1d mask;
|
||||
};
|
||||
typename AT::t_x_array d_x;
|
||||
typename AT::t_f_array d_f;
|
||||
typename AT::t_int_1d d_mask;
|
||||
|
||||
template <class DeviceType>
|
||||
struct FixWallLJ93KokkosFunctor {
|
||||
typedef DeviceType device_type ;
|
||||
typedef double value_type[];
|
||||
const int value_count;
|
||||
DAT::tdual_virial_array k_vatom;
|
||||
typename AT::t_virial_array d_vatom;
|
||||
|
||||
typename AT::tdual_ffloat_1d k_cutoff,k_coeff1,k_coeff2,k_coeff3,k_coeff4,k_offset;
|
||||
typename AT::t_ffloat_1d d_cutoff,d_coeff1,d_coeff2,d_coeff3,d_coeff4,d_offset;
|
||||
|
||||
FixWallLJ93Kokkos<DeviceType> c;
|
||||
FixWallLJ93KokkosFunctor(FixWallLJ93Kokkos<DeviceType>* c_ptr):
|
||||
value_count(c_ptr->m+1), c(*c_ptr) {}
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(const int i, value_type ewall) const {
|
||||
c.wall_particle_item(i,ewall);
|
||||
}
|
||||
void v_tally(value_type, int, int, double) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -23,10 +23,6 @@
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
enum{XLO=0,XHI=1,YLO=2,YHI=3,ZLO=4,ZHI=5};
|
||||
enum{NONE=0,EDGE,CONSTANT,VARIABLE};
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template<class DeviceType>
|
||||
|
||||
@ -18,7 +18,7 @@ using namespace LAMMPS_NS;
|
||||
*
|
||||
* Copyright:
|
||||
* (C) 2012 Massachusetts Institute of Technology
|
||||
* (C) 2013 Forschungszentrum Jülich GmbH
|
||||
* (C) 2013 Forschungszentrum Juelich GmbH
|
||||
*
|
||||
* Licence:
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -42,7 +42,7 @@ using namespace LAMMPS_NS;
|
||||
*
|
||||
* Authors:
|
||||
* Steven G. Johnson, Massachusetts Institute of Technology, 2012, core author
|
||||
* Joachim Wuttke, Forschungszentrum Jülich, 2013, package maintainer
|
||||
* Joachim Wuttke, Forschungszentrum Juelich, 2013, package maintainer
|
||||
*
|
||||
* Website:
|
||||
* https://jugit.fz-juelich.de/mlz/libcerf
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Ajinkya Hire (Univ. of Florida),
|
||||
Hendrik Kraß (Univ. of Constance),
|
||||
Hendrik Krass (Univ. of Constance),
|
||||
Matthias Rupp (Luxembourg Institute of Science and Technology),
|
||||
Richard Hennig (Univ of Florida)
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Ajinkya Hire (Univ. of Florida),
|
||||
Hendrik Kraß (Univ. of Constance),
|
||||
Hendrik Krass (Univ. of Constance),
|
||||
Matthias Rupp (Luxembourg Institute of Science and Technology),
|
||||
Richard Hennig (Univ of Florida)
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Dominik Wójt (Wroclaw University of Technology)
|
||||
Contributing author: Dominik Wojt (Wroclaw University of Technology)
|
||||
based on pair_airebo by Ase Henry (MIT)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ FixAtomSwap::FixAtomSwap(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
memory->create(type_list, atom->ntypes, "atom/swap:type_list");
|
||||
memory->create(mu, atom->ntypes + 1, "atom/swap:mu");
|
||||
for (int i = 1; i <= atom->ntypes; i++) mu[i] = 0.0;
|
||||
for (int i = 0; i <= atom->ntypes; i++) mu[i] = 0.0;
|
||||
|
||||
// read options from end of input line
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Sebastian Hütter (OvGU)
|
||||
Contributing author: Sebastian Huetter (OvGU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "meam.h"
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Sebastian Hütter (OvGU)
|
||||
Contributing author: Sebastian Huetter (OvGU)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "meam.h"
|
||||
|
||||
@ -829,7 +829,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou
|
||||
case L12:
|
||||
*rho01 = 8 * rhoa01 + 4 * rhoa02;
|
||||
*rho02 = 12 * rhoa01;
|
||||
if (ialloy ==1){
|
||||
if (ialloy == 1) {
|
||||
*rho21 = 8. / 3. * MathSpecial::square(rhoa21 * t2_meam[a] - rhoa22 * t2_meam[b]);
|
||||
denom = 8 * rhoa01 * MathSpecial::square(t2_meam[a]) + 4 * rhoa02 * MathSpecial::square(t2_meam[b]);
|
||||
if (denom > 0.)
|
||||
@ -837,6 +837,7 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou
|
||||
} else
|
||||
*rho21 = 8. / 3. * (rhoa21 - rhoa22) * (rhoa21 - rhoa22);
|
||||
if (msmeamflag) {
|
||||
*rho21 = 8. / 3. * (rhoa21 - rhoa22) * (rhoa21 - rhoa22);
|
||||
*rho2m1 = 8. / 3. * (rhoa2m1 - rhoa2m2) * (rhoa2m1 - rhoa2m2);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -547,9 +547,9 @@ void PairMEAM::read_user_meam_file(const std::string &userfile)
|
||||
|
||||
// open user param file on proc 0
|
||||
|
||||
std::shared_ptr<PotentialFileReader> reader;
|
||||
PotentialFileReader *reader = nullptr;
|
||||
|
||||
if (comm->me == 0) reader = std::make_shared<PotentialFileReader>(lmp, userfile, "MEAM");
|
||||
if (comm->me == 0) reader = new PotentialFileReader(lmp, userfile, "MEAM");
|
||||
|
||||
// read settings
|
||||
// pass them one at a time to MEAM package
|
||||
@ -623,6 +623,7 @@ void PairMEAM::read_user_meam_file(const std::string &userfile)
|
||||
keyword, descr[errorflag]);
|
||||
}
|
||||
}
|
||||
if (comm->me == 0) delete reader;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -40,7 +40,7 @@ using namespace FixConst;
|
||||
* Please cite:
|
||||
* Ceriotti, M., More, J., & Manolopoulos, D. E. (2014).
|
||||
* i-PI: A Python interface for ab initio path integral molecular dynamics simulations.
|
||||
* Computer Physics Communications, 185, 1019–1026. doi:10.1016/j.cpc.2013.10.027
|
||||
* Computer Physics Communications, 185, 1019-1026. doi:10.1016/j.cpc.2013.10.027
|
||||
* And see [https://github.com/i-pi/i-pi] to download a version of i-PI
|
||||
******************************************************************************************/
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Pedro Antonio Santos Flórez (UNLV)
|
||||
Contributing author: Pedro Antonio Santos Florez (UNLV)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mliap_model_nn.h"
|
||||
|
||||
@ -1580,8 +1580,8 @@ double SNA::compute_dsfac(double r, double rcut, double sinner, double dinner)
|
||||
else if (r <= rmin0) sfac_outer = 1.0;
|
||||
else if (r > rcut) sfac_outer = 0.0;
|
||||
else {
|
||||
double rcutfac = MY_PI / (rcut - rmin0);
|
||||
sfac_outer = 0.5 * (cos((r - rmin0) * rcutfac) + 1.0);
|
||||
double rcutfac = MY_PI / (rcut - rmin0);
|
||||
sfac_outer = 0.5 * (cos((r - rmin0) * rcutfac) + 1.0);
|
||||
}
|
||||
|
||||
// calculate sfac_inner
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Ajinkya Hire (Univ. of Florida),
|
||||
Hendrik Kraß (Univ. of Constance),
|
||||
Hendrik Krass (Univ. of Constance),
|
||||
Matthias Rupp (Luxembourg Institute of Science and Technology),
|
||||
Richard Hennig (Univ of Florida)
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Ajinkya Hire (Univ. of Florida),
|
||||
Hendrik Kraß (Univ. of Constance),
|
||||
Hendrik Krass (Univ. of Constance),
|
||||
Matthias Rupp (Luxembourg Institute of Science and Technology),
|
||||
Richard Hennig (Univ of Florida)
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
@ -291,3 +291,15 @@ void AngleCosineSquared::born_matrix(int type, int i1, int i2, int i3, double &d
|
||||
du2 = 2 * k[type];
|
||||
du = du2 * dcostheta;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return ptr to internal members upon request
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
void *AngleCosineSquared::extract(const char *str, int &dim)
|
||||
{
|
||||
dim = 1;
|
||||
if (strcmp(str, "k") == 0) return (void *) k;
|
||||
if (strcmp(str, "theta0") == 0) return (void *) theta0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ class AngleCosineSquared : public Angle {
|
||||
void write_data(FILE *) override;
|
||||
double single(int, int, int, int) override;
|
||||
void born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) override;
|
||||
void *extract(const char *, int &) override;
|
||||
|
||||
protected:
|
||||
double *k, *theta0;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -49,36 +48,31 @@ static const char plumed_default_kernel[] = "PLUMED_KERNEL=" PLUMED_QUOTE(__PLUM
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
|
||||
FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg),
|
||||
p(nullptr), nlocal(0), gatindex(nullptr), masses(nullptr), charges(nullptr),
|
||||
id_pe(nullptr), id_press(nullptr)
|
||||
Fix(lmp, narg, arg), p(nullptr), nlocal(0), gatindex(nullptr), masses(nullptr),
|
||||
charges(nullptr), id_pe(nullptr), id_press(nullptr)
|
||||
{
|
||||
|
||||
if (!atom->tag_enable)
|
||||
error->all(FLERR,"Fix plumed requires atom tags");
|
||||
if (!atom->tag_enable) error->all(FLERR, "Fix plumed requires atom tags");
|
||||
|
||||
if (atom->tag_consecutive() == 0)
|
||||
error->all(FLERR,"Fix plumed requires consecutive atom IDs");
|
||||
if (atom->tag_consecutive() == 0) error->all(FLERR, "Fix plumed requires consecutive atom IDs");
|
||||
|
||||
if (igroup != 0 && comm->me == 0)
|
||||
error->warning(FLERR,"Fix group for fix plumed is not 'all'. "
|
||||
"Group will be ignored.");
|
||||
error->warning(FLERR, "Fix group for fix plumed is not 'all'. Group will be ignored.");
|
||||
|
||||
#if defined(__PLUMED_DEFAULT_KERNEL)
|
||||
if (getenv("PLUMED_KERNEL") == nullptr)
|
||||
platform::putenv(plumed_default_kernel);
|
||||
if (getenv("PLUMED_KERNEL") == nullptr) platform::putenv(plumed_default_kernel);
|
||||
#endif
|
||||
|
||||
p=new PLMD::Plumed;
|
||||
p = new PLMD::Plumed;
|
||||
|
||||
// Check API version
|
||||
|
||||
int api_version=0;
|
||||
p->cmd("getApiVersion",&api_version);
|
||||
int api_version = 0;
|
||||
p->cmd("getApiVersion", &api_version);
|
||||
if ((api_version < 5) || (api_version > 10))
|
||||
error->all(FLERR,"Incompatible API version for PLUMED in fix plumed. "
|
||||
error->all(FLERR,
|
||||
"Incompatible API version for PLUMED in fix plumed. "
|
||||
"Only Plumed 2.4.x, 2.5.x, 2.6.x, 2.7.x, 2.8.x, 2.9.x are tested and supported.");
|
||||
|
||||
#if !defined(MPI_STUBS)
|
||||
@ -86,21 +80,19 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
|
||||
// inter-partition communication
|
||||
|
||||
if (universe->existflag == 1) {
|
||||
int me;
|
||||
MPI_Comm inter_comm;
|
||||
MPI_Comm_rank(world,&me);
|
||||
|
||||
// Change MPI_COMM_WORLD to universe->uworld which seems more appropriate
|
||||
|
||||
MPI_Comm_split(universe->uworld,me,0,&inter_comm);
|
||||
p->cmd("GREX setMPIIntracomm",&world);
|
||||
if (me == 0) {
|
||||
MPI_Comm_split(universe->uworld, comm->me, 0, &inter_comm);
|
||||
p->cmd("GREX setMPIIntracomm", &world);
|
||||
if (comm->me == 0) {
|
||||
// The inter-partition communicator is only defined for the root in
|
||||
// each partition (a.k.a. world). This is due to the way in which
|
||||
// it is defined inside plumed.
|
||||
p->cmd("GREX setMPIIntercomm",&inter_comm);
|
||||
p->cmd("GREX setMPIIntercomm", &inter_comm);
|
||||
}
|
||||
p->cmd("GREX init",nullptr);
|
||||
p->cmd("GREX init", nullptr);
|
||||
}
|
||||
|
||||
// The general communicator is independent of the existence of partitions,
|
||||
@ -110,100 +102,103 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// plumed does not know about LAMMPS using the MPI STUBS library and will
|
||||
// fail if this is called under these circumstances
|
||||
p->cmd("setMPIComm",&world);
|
||||
p->cmd("setMPIComm", &world);
|
||||
#endif
|
||||
|
||||
// Set up units
|
||||
// LAMMPS units wrt kj/mol - nm - ps
|
||||
// Set up units
|
||||
|
||||
if (strcmp(update->unit_style,"lj") == 0) {
|
||||
if (strcmp(update->unit_style, "lj") == 0) {
|
||||
// LAMMPS units lj
|
||||
p->cmd("setNaturalUnits");
|
||||
} else {
|
||||
|
||||
// Conversion factor from LAMMPS energy units to kJ/mol (units of PLUMED)
|
||||
|
||||
double energyUnits=1.0;
|
||||
double energyUnits = 1.0;
|
||||
|
||||
// LAMMPS units real :: kcal/mol;
|
||||
|
||||
if (strcmp(update->unit_style,"real") == 0) {
|
||||
energyUnits=4.184;
|
||||
if (strcmp(update->unit_style, "real") == 0) {
|
||||
energyUnits = 4.184;
|
||||
|
||||
// LAMMPS units metal :: eV;
|
||||
|
||||
} else if (strcmp(update->unit_style,"metal") == 0) {
|
||||
energyUnits=96.48530749925792;
|
||||
} else if (strcmp(update->unit_style, "metal") == 0) {
|
||||
energyUnits = 96.48530749925792;
|
||||
|
||||
// LAMMPS units si :: Joule;
|
||||
|
||||
} else if (strcmp(update->unit_style,"si") == 0) {
|
||||
energyUnits=0.001;
|
||||
} else if (strcmp(update->unit_style, "si") == 0) {
|
||||
energyUnits = 0.001;
|
||||
|
||||
// LAMMPS units cgs :: erg;
|
||||
|
||||
} else if (strcmp(update->unit_style,"cgs") == 0) {
|
||||
energyUnits=6.0221418e13;
|
||||
} else if (strcmp(update->unit_style, "cgs") == 0) {
|
||||
energyUnits = 6.0221418e13;
|
||||
|
||||
// LAMMPS units electron :: Hartree;
|
||||
|
||||
} else if (strcmp(update->unit_style,"electron") == 0) {
|
||||
energyUnits=2625.5257;
|
||||
} else if (strcmp(update->unit_style, "electron") == 0) {
|
||||
energyUnits = 2625.5257;
|
||||
|
||||
} else error->all(FLERR,"Fix plumed cannot handle your choice of units");
|
||||
} else
|
||||
error->all(FLERR, "Fix plumed cannot handle {} units", update->unit_style);
|
||||
|
||||
// Conversion factor from LAMMPS length units to nm (units of PLUMED)
|
||||
|
||||
double lengthUnits=0.1/force->angstrom;
|
||||
double lengthUnits = 0.1 / force->angstrom;
|
||||
|
||||
// Conversion factor from LAMMPS time unit to ps (units of PLUMED)
|
||||
|
||||
double timeUnits=0.001/force->femtosecond;
|
||||
double timeUnits = 0.001 / force->femtosecond;
|
||||
|
||||
p->cmd("setMDEnergyUnits",&energyUnits);
|
||||
p->cmd("setMDLengthUnits",&lengthUnits);
|
||||
p->cmd("setMDTimeUnits",&timeUnits);
|
||||
p->cmd("setMDEnergyUnits", &energyUnits);
|
||||
p->cmd("setMDLengthUnits", &lengthUnits);
|
||||
p->cmd("setMDTimeUnits", &timeUnits);
|
||||
}
|
||||
|
||||
// Read fix parameters:
|
||||
|
||||
int next=0;
|
||||
for (int i=3;i<narg;++i) {
|
||||
if (!strcmp(arg[i],"outfile")) {
|
||||
next=1;
|
||||
} else if (next==1) {
|
||||
int next = 0;
|
||||
for (int i = 3; i < narg; ++i) {
|
||||
if (!strcmp(arg[i], "outfile")) {
|
||||
next = 1;
|
||||
} else if (next == 1) {
|
||||
if (universe->existflag == 1) {
|
||||
// Each replica writes an independent log file
|
||||
// with suffix equal to the replica id
|
||||
p->cmd("setLogFile",fmt::format("{}.{}",arg[i],universe->iworld).c_str());
|
||||
next=0;
|
||||
p->cmd("setLogFile", fmt::format("{}.{}", arg[i], universe->iworld).c_str());
|
||||
next = 0;
|
||||
} else {
|
||||
// partition option not used
|
||||
p->cmd("setLogFile",arg[i]);
|
||||
next=0;
|
||||
p->cmd("setLogFile", arg[i]);
|
||||
next = 0;
|
||||
}
|
||||
} else if (!strcmp(arg[i],"plumedfile")) {
|
||||
next=2;
|
||||
} else if (next==2) {
|
||||
p->cmd("setPlumedDat",arg[i]);
|
||||
next=0;
|
||||
} else error->all(FLERR,"Syntax error - use 'fix <fix-ID> plumed "
|
||||
"plumedfile plumed.dat outfile plumed.out' ");
|
||||
} else if (!strcmp(arg[i], "plumedfile")) {
|
||||
next = 2;
|
||||
} else if (next == 2) {
|
||||
p->cmd("setPlumedDat", arg[i]);
|
||||
next = 0;
|
||||
} else
|
||||
error->all(FLERR,
|
||||
"Syntax error - use 'fix <fix-ID> plumed "
|
||||
"plumedfile plumed.dat outfile plumed.out' ");
|
||||
}
|
||||
if (next==1) error->all(FLERR,"missing argument for outfile option");
|
||||
if (next==2) error->all(FLERR,"missing argument for plumedfile option");
|
||||
if (next == 1) error->all(FLERR, "missing argument for outfile option");
|
||||
if (next == 2) error->all(FLERR, "missing argument for plumedfile option");
|
||||
|
||||
p->cmd("setMDEngine","LAMMPS");
|
||||
p->cmd("setMDEngine", "LAMMPS");
|
||||
|
||||
if (atom->natoms > MAXSMALLINT)
|
||||
error->all(FLERR,"Fix plumed can only handle up to 2.1 billion atoms");
|
||||
error->all(FLERR, "Fix plumed can only handle up to 2.1 billion atoms");
|
||||
|
||||
natoms=int(atom->natoms);
|
||||
p->cmd("setNatoms",&natoms);
|
||||
natoms = int(atom->natoms);
|
||||
p->cmd("setNatoms", &natoms);
|
||||
|
||||
double dt=update->dt;
|
||||
p->cmd("setTimestep",&dt);
|
||||
double dt = update->dt;
|
||||
p->cmd("setTimestep", &dt);
|
||||
|
||||
extscalar = 1;
|
||||
scalar_flag = 1;
|
||||
@ -224,27 +219,24 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
|
||||
id_press = utils::strdup("plmd_press");
|
||||
c_press = modify->add_compute(std::string(id_press) + " all pressure NULL virial");
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++) {
|
||||
const char * const check_style = modify->fix[i]->style;
|
||||
for (const auto &fix : modify->get_fix_list()) {
|
||||
const char *const check_style = fix->style;
|
||||
|
||||
// There must be only one
|
||||
|
||||
if (strcmp(check_style,"plumed") == 0)
|
||||
error->all(FLERR,"There must be only one instance of fix plumed");
|
||||
if (strcmp(check_style, "plumed") == 0)
|
||||
error->all(FLERR, "There must be only one instance of fix plumed");
|
||||
|
||||
// Avoid conflict with fixes that define internal pressure computes.
|
||||
// See comment in the setup method
|
||||
|
||||
if (utils::strmatch(check_style,"^nph") ||
|
||||
utils::strmatch(check_style,"^npt") ||
|
||||
utils::strmatch(check_style,"^rigid/nph") ||
|
||||
utils::strmatch(check_style,"^rigid/npt") ||
|
||||
utils::strmatch(check_style,"^msst") ||
|
||||
utils::strmatch(check_style,"^nphug") ||
|
||||
utils::strmatch(check_style,"^ipi") ||
|
||||
utils::strmatch(check_style,"^press/berendsen") ||
|
||||
utils::strmatch(check_style,"^qbmsst"))
|
||||
error->all(FLERR,"Fix plumed must be defined before any other fixes, "
|
||||
if (utils::strmatch(check_style, "^nph") || utils::strmatch(check_style, "^npt") ||
|
||||
utils::strmatch(check_style, "^rigid/nph") || utils::strmatch(check_style, "^rigid/npt") ||
|
||||
utils::strmatch(check_style, "^msst") || utils::strmatch(check_style, "^nphug") ||
|
||||
utils::strmatch(check_style, "^ipi") || utils::strmatch(check_style, "^press/berendsen") ||
|
||||
utils::strmatch(check_style, "^qbmsst"))
|
||||
error->all(FLERR,
|
||||
"Fix plumed must be defined before any other fixes, "
|
||||
"that compute pressure internally");
|
||||
}
|
||||
}
|
||||
@ -273,13 +265,13 @@ int FixPlumed::setmask()
|
||||
|
||||
void FixPlumed::init()
|
||||
{
|
||||
if (utils::strmatch(update->integrate_style,"^respa"))
|
||||
if (utils::strmatch(update->integrate_style, "^respa"))
|
||||
nlevels_respa = ((Respa *) update->integrate)->nlevels;
|
||||
|
||||
// This avoids nan pressure if compute_pressure is called
|
||||
// in a setup method
|
||||
|
||||
for (int i=0;i<6;i++) virial[i] = 0.;
|
||||
for (int i = 0; i < 6; i++) virial[i] = 0.;
|
||||
}
|
||||
|
||||
void FixPlumed::setup(int vflag)
|
||||
@ -293,10 +285,10 @@ void FixPlumed::setup(int vflag)
|
||||
// has to be executed first. This creates a race condition with the
|
||||
// setup method of fix_nh. This is why in the constructor I check if
|
||||
// nh fixes have already been called.
|
||||
if (utils::strmatch(update->integrate_style,"^respa")) {
|
||||
((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1);
|
||||
post_force_respa(vflag,nlevels_respa-1,0);
|
||||
((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1);
|
||||
if (utils::strmatch(update->integrate_style, "^respa")) {
|
||||
((Respa *) update->integrate)->copy_flevel_f(nlevels_respa - 1);
|
||||
post_force_respa(vflag, nlevels_respa - 1, 0);
|
||||
((Respa *) update->integrate)->copy_f_flevel(nlevels_respa - 1);
|
||||
} else {
|
||||
post_force(vflag);
|
||||
}
|
||||
@ -312,11 +304,10 @@ void FixPlumed::min_setup(int vflag)
|
||||
void FixPlumed::post_force(int /* vflag */)
|
||||
{
|
||||
|
||||
int update_gatindex=0;
|
||||
int update_gatindex = 0;
|
||||
|
||||
if (natoms != int(atom->natoms))
|
||||
error->all(FLERR,"Fix plumed does not support simulations with varying "
|
||||
"numbers of atoms");
|
||||
error->all(FLERR, "Fix plumed does not support simulations with varying numbers of atoms");
|
||||
|
||||
// Try to find out if the domain decomposition has been updated:
|
||||
|
||||
@ -326,95 +317,97 @@ void FixPlumed::post_force(int /* vflag */)
|
||||
delete[] masses;
|
||||
delete[] gatindex;
|
||||
|
||||
nlocal=atom->nlocal;
|
||||
gatindex=new int [nlocal];
|
||||
masses=new double [nlocal];
|
||||
charges=new double [nlocal];
|
||||
update_gatindex=1;
|
||||
nlocal = atom->nlocal;
|
||||
gatindex = new int[nlocal];
|
||||
masses = new double[nlocal];
|
||||
charges = new double[nlocal];
|
||||
update_gatindex = 1;
|
||||
|
||||
} else {
|
||||
|
||||
for (int i=0;i<nlocal;i++) {
|
||||
if (gatindex[i]!=atom->tag[i]-1) {
|
||||
update_gatindex=1;
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (gatindex[i] != atom->tag[i] - 1) {
|
||||
update_gatindex = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
MPI_Allreduce(MPI_IN_PLACE,&update_gatindex,1,MPI_INT,MPI_SUM,world);
|
||||
MPI_Allreduce(MPI_IN_PLACE, &update_gatindex, 1, MPI_INT, MPI_SUM, world);
|
||||
|
||||
// In case it has been updated, rebuild the local mass/charges array
|
||||
// and tell plumed about the change:
|
||||
|
||||
if (update_gatindex) {
|
||||
for (int i=0;i<nlocal;i++) gatindex[i]=atom->tag[i]-1;
|
||||
for (int i = 0; i < nlocal; i++) gatindex[i] = atom->tag[i] - 1;
|
||||
// Get masses
|
||||
if (atom->rmass_flag) {
|
||||
for (int i=0;i<nlocal;i++) masses[i]=atom->rmass[i];
|
||||
for (int i = 0; i < nlocal; i++) masses[i] = atom->rmass[i];
|
||||
} else {
|
||||
for (int i=0;i<nlocal;i++) masses[i]=atom->mass[atom->type[i]];
|
||||
for (int i = 0; i < nlocal; i++) masses[i] = atom->mass[atom->type[i]];
|
||||
}
|
||||
// Get charges
|
||||
if (atom->q_flag) {
|
||||
for (int i=0;i<nlocal;i++) charges[i]=atom->q[i];
|
||||
for (int i = 0; i < nlocal; i++) charges[i] = atom->q[i];
|
||||
} else {
|
||||
for (int i=0;i<nlocal;i++) charges[i]=0.0;
|
||||
for (int i = 0; i < nlocal; i++) charges[i] = 0.0;
|
||||
}
|
||||
p->cmd("setAtomsNlocal",&nlocal);
|
||||
p->cmd("setAtomsGatindex",gatindex);
|
||||
p->cmd("setAtomsNlocal", &nlocal);
|
||||
p->cmd("setAtomsGatindex", gatindex);
|
||||
}
|
||||
|
||||
|
||||
// set up local virial/box. plumed uses full 3x3 matrices
|
||||
double plmd_virial[3][3];
|
||||
for (int i=0;i<3;i++) for (int j=0;j<3;j++) plmd_virial[i][j]=0.0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 3; j++) plmd_virial[i][j] = 0.0;
|
||||
double box[3][3];
|
||||
for (int i=0;i<3;i++) for (int j=0;j<3;j++) box[i][j]=0.0;
|
||||
box[0][0]=domain->h[0];
|
||||
box[1][1]=domain->h[1];
|
||||
box[2][2]=domain->h[2];
|
||||
box[2][1]=domain->h[3];
|
||||
box[2][0]=domain->h[4];
|
||||
box[1][0]=domain->h[5];
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 3; j++) box[i][j] = 0.0;
|
||||
box[0][0] = domain->h[0];
|
||||
box[1][1] = domain->h[1];
|
||||
box[2][2] = domain->h[2];
|
||||
box[2][1] = domain->h[3];
|
||||
box[2][0] = domain->h[4];
|
||||
box[1][0] = domain->h[5];
|
||||
|
||||
// Make initial of virial of this fix zero
|
||||
// The following line is very important, otherwise
|
||||
// the compute pressure will include
|
||||
for (int i=0;i<6;++i) virial[i] = 0.;
|
||||
for (int i = 0; i < 6; ++i) virial[i] = 0.;
|
||||
|
||||
// local variable with timestep:
|
||||
if (update->ntimestep > MAXSMALLINT)
|
||||
error->all(FLERR,"Fix plumed can only handle up to 2.1 billion timesteps");
|
||||
int step=int(update->ntimestep);
|
||||
error->all(FLERR, "Fix plumed can only handle up to 2.1 billion timesteps");
|
||||
int step = int(update->ntimestep);
|
||||
|
||||
// pass all pointers to plumed:
|
||||
p->cmd("setStep",&step);
|
||||
int plumedStopCondition=0;
|
||||
p->cmd("setStopFlag",&plumedStopCondition);
|
||||
p->cmd("setPositions",&atom->x[0][0]);
|
||||
p->cmd("setBox",&box[0][0]);
|
||||
p->cmd("setForces",&atom->f[0][0]);
|
||||
p->cmd("setMasses",&masses[0]);
|
||||
p->cmd("setCharges",&charges[0]);
|
||||
p->cmd("getBias",&bias);
|
||||
p->cmd("setStep", &step);
|
||||
int plumedStopCondition = 0;
|
||||
p->cmd("setStopFlag", &plumedStopCondition);
|
||||
p->cmd("setPositions", &atom->x[0][0]);
|
||||
p->cmd("setBox", &box[0][0]);
|
||||
p->cmd("setForces", &atom->f[0][0]);
|
||||
p->cmd("setMasses", &masses[0]);
|
||||
p->cmd("setCharges", &charges[0]);
|
||||
p->cmd("getBias", &bias);
|
||||
|
||||
// Pass virial to plumed
|
||||
// If energy is needed plmd_virial is equal to LAMMPS' virial
|
||||
// If energy is not needed plmd_virial is initialized to zero
|
||||
// In the first case the virial will be rescaled and an extra term will be added
|
||||
// In the latter case only an extra term will be added
|
||||
p->cmd("setVirial",&plmd_virial[0][0]);
|
||||
p->cmd("setVirial", &plmd_virial[0][0]);
|
||||
p->cmd("prepareCalc");
|
||||
|
||||
plumedNeedsEnergy=0;
|
||||
p->cmd("isEnergyNeeded",&plumedNeedsEnergy);
|
||||
plumedNeedsEnergy = 0;
|
||||
p->cmd("isEnergyNeeded", &plumedNeedsEnergy);
|
||||
|
||||
// Pass potential energy and virial if needed
|
||||
double *virial_lmp;
|
||||
if (plumedNeedsEnergy) {
|
||||
// Error if tail corrections are included
|
||||
if (force->pair && force->pair->tail_flag && comm->me == 0)
|
||||
error->warning(FLERR,"Tail corrections to the pair potential included."
|
||||
error->warning(FLERR,
|
||||
"Tail corrections to the pair potential included."
|
||||
" The energy cannot be biased correctly in this case."
|
||||
" Remove the tail corrections by removing the"
|
||||
" command: pair_modify tail yes");
|
||||
@ -426,20 +419,18 @@ void FixPlumed::post_force(int /* vflag */)
|
||||
|
||||
// Divide energy by number of processes
|
||||
// Plumed wants it this way
|
||||
int nprocs;
|
||||
MPI_Comm_size(world,&nprocs);
|
||||
pot_energy /= nprocs;
|
||||
p->cmd("setEnergy",&pot_energy);
|
||||
pot_energy /= comm->nprocs;
|
||||
p->cmd("setEnergy", &pot_energy);
|
||||
|
||||
// Compute pressure due to the virial (no kinetic energy term!)
|
||||
c_press->compute_vector();
|
||||
virial_lmp = c_press->vector;
|
||||
|
||||
// Check if pressure is finite
|
||||
if (!std::isfinite(virial_lmp[0]) || !std::isfinite(virial_lmp[1])
|
||||
|| !std::isfinite(virial_lmp[2]) || !std::isfinite(virial_lmp[3])
|
||||
|| !std::isfinite(virial_lmp[4]) || !std::isfinite(virial_lmp[5]))
|
||||
error->all(FLERR,"Non-numeric virial - Plumed cannot work with that");
|
||||
if (!std::isfinite(virial_lmp[0]) || !std::isfinite(virial_lmp[1]) ||
|
||||
!std::isfinite(virial_lmp[2]) || !std::isfinite(virial_lmp[3]) ||
|
||||
!std::isfinite(virial_lmp[4]) || !std::isfinite(virial_lmp[5]))
|
||||
error->all(FLERR, "Non-numeric virial - Plumed cannot work with that");
|
||||
|
||||
// Convert pressure to virial per number of MPI processes
|
||||
// From now on all virials are divided by the number of MPI processes
|
||||
@ -451,14 +442,14 @@ void FixPlumed::post_force(int /* vflag */)
|
||||
} else {
|
||||
inv_volume = 1.0 / (domain->xprd * domain->yprd);
|
||||
}
|
||||
for (int i=0;i<6;i++) virial_lmp[i] /= (inv_volume * nktv2p * nprocs);
|
||||
for (int i = 0; i < 6; i++) virial_lmp[i] /= (inv_volume * nktv2p * comm->nprocs);
|
||||
// Convert virial from lammps to plumed representation
|
||||
plmd_virial[0][0]=-virial_lmp[0];
|
||||
plmd_virial[1][1]=-virial_lmp[1];
|
||||
plmd_virial[2][2]=-virial_lmp[2];
|
||||
plmd_virial[0][1]=-virial_lmp[3];
|
||||
plmd_virial[0][2]=-virial_lmp[4];
|
||||
plmd_virial[1][2]=-virial_lmp[5];
|
||||
plmd_virial[0][0] = -virial_lmp[0];
|
||||
plmd_virial[1][1] = -virial_lmp[1];
|
||||
plmd_virial[2][2] = -virial_lmp[2];
|
||||
plmd_virial[0][1] = -virial_lmp[3];
|
||||
plmd_virial[0][2] = -virial_lmp[4];
|
||||
plmd_virial[1][2] = -virial_lmp[5];
|
||||
}
|
||||
// do the real calculation:
|
||||
p->cmd("performCalc");
|
||||
@ -472,12 +463,12 @@ void FixPlumed::post_force(int /* vflag */)
|
||||
// The calculation of the pressure will be done by a compute pressure
|
||||
// and will include this contribution.
|
||||
if (plumedNeedsEnergy) {
|
||||
virial[0] = -plmd_virial[0][0]-virial_lmp[0];
|
||||
virial[1] = -plmd_virial[1][1]-virial_lmp[1];
|
||||
virial[2] = -plmd_virial[2][2]-virial_lmp[2];
|
||||
virial[3] = -plmd_virial[0][1]-virial_lmp[3];
|
||||
virial[4] = -plmd_virial[0][2]-virial_lmp[4];
|
||||
virial[5] = -plmd_virial[1][2]-virial_lmp[5];
|
||||
virial[0] = -plmd_virial[0][0] - virial_lmp[0];
|
||||
virial[1] = -plmd_virial[1][1] - virial_lmp[1];
|
||||
virial[2] = -plmd_virial[2][2] - virial_lmp[2];
|
||||
virial[3] = -plmd_virial[0][1] - virial_lmp[3];
|
||||
virial[4] = -plmd_virial[0][2] - virial_lmp[4];
|
||||
virial[5] = -plmd_virial[1][2] - virial_lmp[5];
|
||||
} else {
|
||||
virial[0] = -plmd_virial[0][0];
|
||||
virial[1] = -plmd_virial[1][1];
|
||||
@ -491,13 +482,13 @@ void FixPlumed::post_force(int /* vflag */)
|
||||
// such that the virial and energy are tallied.
|
||||
// This should be changed to something that triggers the
|
||||
// calculation only if plumed needs it.
|
||||
c_pe->addstep(update->ntimestep+1);
|
||||
c_press->addstep(update->ntimestep+1);
|
||||
c_pe->addstep(update->ntimestep + 1);
|
||||
c_press->addstep(update->ntimestep + 1);
|
||||
}
|
||||
|
||||
void FixPlumed::post_force_respa(int vflag, int ilevel, int /* iloop */)
|
||||
{
|
||||
if (ilevel == nlevels_respa-1) post_force(vflag);
|
||||
if (ilevel == nlevels_respa - 1) post_force(vflag);
|
||||
}
|
||||
|
||||
void FixPlumed::min_post_force(int vflag)
|
||||
@ -507,7 +498,7 @@ void FixPlumed::min_post_force(int vflag)
|
||||
|
||||
void FixPlumed::reset_dt()
|
||||
{
|
||||
error->all(FLERR,"Cannot change the time step when fix plumed is active");
|
||||
error->all(FLERR, "Fix plumed is not compatible with changing the timestep");
|
||||
}
|
||||
|
||||
double FixPlumed::compute_scalar()
|
||||
@ -517,35 +508,36 @@ double FixPlumed::compute_scalar()
|
||||
|
||||
int FixPlumed::modify_param(int narg, char **arg)
|
||||
{
|
||||
if (strcmp(arg[0],"pe") == 0) {
|
||||
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
|
||||
if (strcmp(arg[0], "pe") == 0) {
|
||||
if (narg < 2) error->all(FLERR, "Fix_modify pe requires an argument");
|
||||
modify->delete_compute(id_pe);
|
||||
delete[] id_pe;
|
||||
id_pe = utils::strdup(arg[1]);
|
||||
|
||||
c_pe = modify->get_compute_by_id(id_pe);
|
||||
if (!c_pe) error->all(FLERR,"Could not find fix_modify potential energy ID {}", id_pe);
|
||||
if (!c_pe) error->all(FLERR, "Could not find fix_modify potential energy ID {}", id_pe);
|
||||
|
||||
if (c_pe->peflag == 0)
|
||||
error->all(FLERR,"Fix_modify compute pe ID {} does not compute potential energy", id_pe);
|
||||
error->all(FLERR, "Fix_modify compute pe ID {} does not compute potential energy", id_pe);
|
||||
if (c_pe->igroup != 0 && comm->me == 0)
|
||||
error->warning(FLERR,"Potential energy compute {} for fix PLUMED is not for group all", id_pe);
|
||||
error->warning(FLERR, "Potential energy compute {} for fix PLUMED is not for group all",
|
||||
id_pe);
|
||||
|
||||
return 2;
|
||||
|
||||
} else if (strcmp(arg[0],"press") == 0) {
|
||||
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
|
||||
} else if (strcmp(arg[0], "press") == 0) {
|
||||
if (narg < 2) error->all(FLERR, "Fix_modify press requires an argument");
|
||||
modify->delete_compute(id_press);
|
||||
delete[] id_press;
|
||||
id_press = utils::strdup(arg[1]);
|
||||
|
||||
c_press = modify->get_compute_by_id(id_press);
|
||||
if (!c_press) error->all(FLERR,"Could not find fix_modify compute pressure ID {}", id_press);
|
||||
if (!c_press) error->all(FLERR, "Could not find fix_modify compute pressure ID {}", id_press);
|
||||
|
||||
if (c_press->pressflag == 0)
|
||||
error->all(FLERR,"Fix_modify compute pressure ID {} does not compute pressure", id_press);
|
||||
error->all(FLERR, "Fix_modify compute pressure ID {} does not compute pressure", id_press);
|
||||
if (c_press->igroup != 0 && comm->me == 0)
|
||||
error->warning(FLERR,"Virial for fix PLUMED is not for group all");
|
||||
error->warning(FLERR, "Virial for fix PLUMED is not for group all");
|
||||
|
||||
return 2;
|
||||
}
|
||||
@ -554,5 +546,5 @@ int FixPlumed::modify_param(int narg, char **arg)
|
||||
|
||||
double FixPlumed::memory_usage()
|
||||
{
|
||||
return double((8+8+4)*atom->nlocal);
|
||||
return double((8 + 8 + 4) * atom->nlocal);
|
||||
}
|
||||
|
||||
@ -844,7 +844,7 @@ void FixBondReact::init_list(int /*id*/, NeighList *ptr)
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Identify all pairs of potentially reactive atoms for this time step.
|
||||
This function is modified from LAMMPS’ fix bond/create.
|
||||
This function is modified from LAMMPS' fix bond/create.
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
void FixBondReact::post_integrate()
|
||||
|
||||
@ -127,9 +127,9 @@ void ComputeRHEOSurface::compute_peratom()
|
||||
size_t nbytes = nmax_store * sizeof(double);
|
||||
memset(&divr[0], 0, nbytes);
|
||||
memset(&rsurface[0], 0, nbytes);
|
||||
memset(&nsurface[0][0], 0, dim * nbytes);
|
||||
memset(&gradC[0][0], 0, dim * dim * nbytes);
|
||||
memset(&B[0][0], 0, dim * dim * nbytes);
|
||||
memset(&nsurface[0][0], 0, nbytes * dim);
|
||||
memset(&gradC[0][0], 0, nbytes * dim * dim);
|
||||
memset(&B[0][0], 0, nbytes * dim * dim);
|
||||
|
||||
// loop over neighbors to calculate the average orientation of neighbors
|
||||
for (ii = 0; ii < inum; ii++) {
|
||||
|
||||
@ -55,7 +55,7 @@ static const char cite_rheo_oxide[] =
|
||||
FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg), compute_surface(nullptr), fix_rheo(nullptr)
|
||||
{
|
||||
if (narg != 6) error->all(FLERR, "Illegal fix command");
|
||||
if (narg != 6) error->all(FLERR, "Illegal fix rheo/oxidation command");
|
||||
|
||||
force_reneighbor = 1;
|
||||
next_reneighbor = -1;
|
||||
@ -69,7 +69,7 @@ FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) :
|
||||
error->all(FLERR, "Illegal value {} for bond type in fix rheo/oxidation", btype);
|
||||
|
||||
rsurf = utils::numeric(FLERR, arg[5], false, lmp);
|
||||
if (rsurf <= 0.0) error->all(FLERR, "Illegal surface distance {} in fix rheo/oxidation", cut);
|
||||
if (rsurf <= 0.0) error->all(FLERR, "Illegal surface distance {} in fix rheo/oxidation", rsurf);
|
||||
|
||||
cutsq = cut * cut;
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
The SMTBQ code has been developed with the financial support of CNRS and
|
||||
of the Regional Council of Burgundy (Convention n¡ 2010-9201AAO037S03129)
|
||||
of the Regional Council of Burgundy (Convention No 2010-9201AAO037S03129)
|
||||
|
||||
Copyright (2015)
|
||||
Universite de Bourgogne : Nicolas SALLES, Olivier POLITANO
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
Contact: Nicolas Salles <nsalles33@gmail.com>
|
||||
Olivier Politano <olivier.politano@u-bourgogne.fr>
|
||||
Robert Tétot <robert.tetot@universite-paris-saclay.fr>
|
||||
Robert Tetot <robert.tetot@universite-paris-saclay.fr>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
@ -895,7 +895,7 @@ void PairSMTBQ::compute(int eflag, int vflag)
|
||||
3 -> Short int. Ox-Ox
|
||||
4 -> Short int. SMTB (repulsion)
|
||||
5 -> Covalent energy SMTB
|
||||
6 -> Somme des Q(i)²
|
||||
6 -> Sum over Q(i)**2
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* -------------- N-body forces Calcul --------------- */
|
||||
@ -2980,9 +2980,6 @@ void PairSMTBQ::groupQEqAllParallel_QEq()
|
||||
|
||||
ngp = igp = 0; nelt[ngp] = 0;
|
||||
|
||||
// On prend un oxygène
|
||||
// printf ("[me %d] On prend un oxygene\n",me);
|
||||
|
||||
for (ii = 0; ii < inum; ii++) {
|
||||
i = ilist[ii] ; itype = map[type[i]];
|
||||
if (itype != 0 || flag_QEq[i] == 0) continue;
|
||||
|
||||
@ -292,7 +292,7 @@ double PairSPHLJ::init_one(int i, int j)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* Lennard-Jones EOS,
|
||||
Francis H. Ree
|
||||
"Analytic representation of thermodynamic data for the Lennard‐Jones fluid",
|
||||
Analytic representation of thermodynamic data for the Lennard-Jones fluid,
|
||||
Journal of Chemical Physics 73 pp. 5401-5403 (1980)
|
||||
*/
|
||||
|
||||
@ -331,7 +331,7 @@ void PairSPHLJ::LJEOS2(double rho, double e, double cv, double *p, double *c)
|
||||
|
||||
/* ------------------------------------------------------------------------------ */
|
||||
|
||||
/* Jirí Kolafa, Ivo Nezbeda
|
||||
/* Jiri Kolafa, Ivo Nezbeda
|
||||
* "The Lennard-Jones fluid: an accurate analytic and theoretically-based equation of state",
|
||||
* Fluid Phase Equilibria 100 pp. 1-34 (1994) */
|
||||
/*double PairSPHLJ::LJEOS2(double rho, double e, double cv) {
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Contributing authors: Julien Tranchida (SNL)
|
||||
|
||||
Please cite the related publication:
|
||||
Bessarab, P. F., Uzdin, V. M., & Jónsson, H. (2015).
|
||||
Bessarab, P. F., Uzdin, V. M., & Jonsson, H. (2015).
|
||||
Method for finding mechanism and activation energy of magnetic transitions,
|
||||
applied to skyrmion and antivortex annihilation.
|
||||
Computer Physics Communications, 196, 335-347.
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
Julien Tranchida (SNL)
|
||||
|
||||
Please cite the related publication:
|
||||
Ivanov, A. V., Uzdin, V. M., & Jónsson, H. (2019). Fast and Robust
|
||||
Ivanov, A. V., Uzdin, V. M., & Jonsson, H. (2019). Fast and Robust
|
||||
Algorithm for the Minimisation of the Energy of Spin Systems. arXiv
|
||||
preprint arXiv:1904.02669.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
Julien Tranchida (SNL)
|
||||
|
||||
Please cite the related publication:
|
||||
Ivanov, A. V., Uzdin, V. M., & Jónsson, H. (2019). Fast and Robust
|
||||
Ivanov, A. V., Uzdin, V. M., & Jonsson, H. (2019). Fast and Robust
|
||||
Algorithm for the Minimisation of the Energy of Spin Systems. arXiv
|
||||
preprint arXiv:1904.02669.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Contributing authors: Julien Tranchida (SNL)
|
||||
|
||||
Please cite the related publication:
|
||||
Bessarab, P. F., Uzdin, V. M., & Jónsson, H. (2015).
|
||||
Bessarab, P. F., Uzdin, V. M., & Jonsson, H. (2015).
|
||||
Method for finding mechanism and activation energy of magnetic transitions,
|
||||
applied to skyrmion and antivortex annihilation.
|
||||
Computer Physics Communications, 196, 335-347.
|
||||
|
||||
@ -1663,6 +1663,27 @@ void Domain::remap(double *x)
|
||||
if (triclinic) lamda2x(coord,x);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
remap all points into the periodic box no matter how far away
|
||||
adjust 3 image flags encoded in image accordingly
|
||||
resulting coord must satisfy lo <= coord < hi
|
||||
MAX is important since coord - prd < lo can happen when coord = hi
|
||||
for triclinic, point is converted to lamda coords (0-1) before doing remap
|
||||
image = 10 bits for each dimension
|
||||
increment/decrement in wrap-around fashion
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Domain::remap_all()
|
||||
{
|
||||
double **x = atom->x;
|
||||
imageint *image = atom->image;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (triclinic) x2lamda(nlocal);
|
||||
for (int i = 0; i < nlocal; i++) remap(x[i],image[i]);
|
||||
if (triclinic) lamda2x(nlocal);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
remap xnew to be within half box length of xold
|
||||
do it directly, not iteratively, in case is far away
|
||||
@ -2188,6 +2209,19 @@ void Domain::lamda2x(int n)
|
||||
}
|
||||
}
|
||||
|
||||
void Domain::lamda2x(int n, int groupbit)
|
||||
{
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
x[i][0] = h[0]*x[i][0] + h[5]*x[i][1] + h[4]*x[i][2] + boxlo[0];
|
||||
x[i][1] = h[1]*x[i][1] + h[3]*x[i][2] + boxlo[1];
|
||||
x[i][2] = h[2]*x[i][2] + boxlo[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convert box coords to triclinic 0-1 lamda coords for all N atoms
|
||||
lamda = H^-1 (x - x0)
|
||||
@ -2209,6 +2243,25 @@ void Domain::x2lamda(int n)
|
||||
}
|
||||
}
|
||||
|
||||
void Domain::x2lamda(int n, int groupbit)
|
||||
{
|
||||
double delta[3];
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
delta[0] = x[i][0] - boxlo[0];
|
||||
delta[1] = x[i][1] - boxlo[1];
|
||||
delta[2] = x[i][2] - boxlo[2];
|
||||
|
||||
x[i][0] = h_inv[0]*delta[0] + h_inv[5]*delta[1] + h_inv[4]*delta[2];
|
||||
x[i][1] = h_inv[1]*delta[1] + h_inv[3]*delta[2];
|
||||
x[i][2] = h_inv[2]*delta[2];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convert triclinic 0-1 lamda coords to box coords for one atom
|
||||
x = H lamda + x0;
|
||||
|
||||
@ -136,6 +136,7 @@ class Domain : protected Pointers {
|
||||
void closest_image(const double *const, const double *const, double *const);
|
||||
void remap(double *, imageint &);
|
||||
void remap(double *);
|
||||
void remap_all();
|
||||
void remap_near(double *, double *);
|
||||
void unmap_inv(double *x, imageint);
|
||||
void unmap(double *, imageint);
|
||||
@ -166,7 +167,9 @@ class Domain : protected Pointers {
|
||||
void boundary_string(char *);
|
||||
|
||||
virtual void lamda2x(int);
|
||||
virtual void lamda2x(int, int);
|
||||
virtual void x2lamda(int);
|
||||
virtual void x2lamda(int, int);
|
||||
virtual void lamda2x(double *, double *);
|
||||
virtual void x2lamda(double *, double *);
|
||||
int inside(double *);
|
||||
|
||||
@ -220,7 +220,7 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
// allocate angle style arrays:
|
||||
|
||||
n = atom->nbondtypes;
|
||||
n = atom->nangletypes;
|
||||
for (int m = 0; m < nadapt; ++m)
|
||||
if (adapt[m].which == ANGLE) memory->create(adapt[m].vector_orig,n+1,"adapt:vector_orig");
|
||||
}
|
||||
|
||||
@ -648,11 +648,7 @@ void FixDeform::pre_exchange()
|
||||
domain->set_local_box();
|
||||
|
||||
domain->image_flip(flipxy, flipxz, flipyz);
|
||||
|
||||
double **x = atom->x;
|
||||
imageint *image = atom->image;
|
||||
int nlocal = atom->nlocal;
|
||||
for (int i = 0; i < nlocal; i++) domain->remap(x[i],image[i]);
|
||||
domain->remap_all();
|
||||
|
||||
domain->x2lamda(atom->nlocal);
|
||||
irregular->migrate_atoms();
|
||||
@ -898,13 +894,7 @@ void FixDeform::update_domain()
|
||||
// convert atoms and rigid bodies to lamda coords
|
||||
|
||||
if (remapflag == Domain::X_REMAP) {
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
domain->x2lamda(x[i], x[i]);
|
||||
domain->x2lamda(atom->nlocal, groupbit);
|
||||
|
||||
for (auto &ifix : rfix)
|
||||
ifix->deform(0);
|
||||
@ -937,13 +927,7 @@ void FixDeform::update_domain()
|
||||
// convert atoms and rigid bodies back to box coords
|
||||
|
||||
if (remapflag == Domain::X_REMAP) {
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
domain->lamda2x(x[i], x[i]);
|
||||
domain->lamda2x(atom->nlocal, groupbit);
|
||||
|
||||
for (auto &ifix : rfix)
|
||||
ifix->deform(1);
|
||||
|
||||
@ -318,7 +318,6 @@ void FixEfield::post_force(int vflag)
|
||||
double **x = atom->x;
|
||||
double fx, fy, fz;
|
||||
double v[6], unwrap[3];
|
||||
;
|
||||
|
||||
// constant efield
|
||||
|
||||
|
||||
@ -27,8 +27,6 @@
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
enum { XLO = 0, XHI = 1, YLO = 2, YHI = 3, ZLO = 4, ZHI = 5 };
|
||||
|
||||
static const char *wallpos[] = {"xlo", "xhi", "ylo", "yhi", "zlo", "zhi"};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -20,6 +20,7 @@ namespace LAMMPS_NS {
|
||||
|
||||
class FixWall : public Fix {
|
||||
public:
|
||||
enum { XLO = 0, XHI = 1, YLO = 2, YHI = 3, ZLO = 4, ZHI = 5 };
|
||||
int nwall;
|
||||
int wallwhich[6];
|
||||
double coord0[6];
|
||||
|
||||
@ -33,7 +33,7 @@ static const char cite_type_label_framework[] =
|
||||
" year = 2024,\n"
|
||||
" volume = 128,\n"
|
||||
" number = 13,\n"
|
||||
" pages = {3282–-3297}\n"
|
||||
" pages = {3282--3297}\n"
|
||||
"}\n\n";
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -501,6 +501,50 @@ void lammps_error(void *handle, int error_type, const char *error_text)
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** expand a single LAMMPS input line from a string.
|
||||
*
|
||||
\verbatim embed:rst
|
||||
|
||||
This function tells LAMMPS to expand the string in *cmd* like it would process
|
||||
an input line fed to :cpp:func:`lammps_command` **without** executing it.
|
||||
The *entire* string is considered as input and need not have a (final) newline
|
||||
character. Newline characters in the body of the string, however, will be
|
||||
treated as part of the command and will **not** start a second command.
|
||||
|
||||
The function returns the expanded string in a new string buffer that
|
||||
must be freed with :cpp:func:`lammps_free` after use to avoid a memory leak.
|
||||
|
||||
\endverbatim
|
||||
*
|
||||
* \param handle pointer to a previously created LAMMPS instance
|
||||
* \param cmd string with a single LAMMPS input line
|
||||
* \return string with expanded line */
|
||||
|
||||
char *lammps_expand(void *handle, const char *line)
|
||||
{
|
||||
auto lmp = (LAMMPS *) handle;
|
||||
char *copy, *work;
|
||||
int n, maxcopy, maxwork;
|
||||
|
||||
if (!line) return nullptr;
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
n = strlen(line) + 1;
|
||||
copy = (char *) malloc(n * sizeof(char));
|
||||
work = (char *) malloc(n * sizeof(char));
|
||||
maxwork = maxcopy = n;
|
||||
memcpy(copy, line, maxcopy);
|
||||
lmp->input->substitute(copy, work, maxcopy, maxwork, 0);
|
||||
free(work);
|
||||
}
|
||||
END_CAPTURE
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Library functions to process commands
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@ -133,6 +133,8 @@ void lammps_python_finalize();
|
||||
|
||||
void lammps_error(void *handle, int error_type, const char *error_text);
|
||||
|
||||
char *lammps_expand(void *handle, const char *line);
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Library functions to process commands
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -209,7 +209,7 @@ double MathSpecial::factorial(const int n)
|
||||
*
|
||||
* Copyright:
|
||||
* (C) 2012 Massachusetts Institute of Technology
|
||||
* (C) 2013 Forschungszentrum Jülich GmbH
|
||||
* (C) 2013 Forschungszentrum Juelich GmbH
|
||||
*
|
||||
* Licence:
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -233,7 +233,7 @@ double MathSpecial::factorial(const int n)
|
||||
*
|
||||
* Authors:
|
||||
* Steven G. Johnson, Massachusetts Institute of Technology, 2012, core author
|
||||
* Joachim Wuttke, Forschungszentrum Jülich, 2013, package maintainer
|
||||
* Joachim Wuttke, Forschungszentrum Juelich, 2013, package maintainer
|
||||
*
|
||||
* Website:
|
||||
* https://jugit.fz-juelich.de/mlz/libcerf
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing authors: Julien Guénolé, CNRS and
|
||||
Contributing authors: Julien Guenole, CNRS and
|
||||
Erik Bitzek, FAU Erlangen-Nuernberg
|
||||
|
||||
Support for ABC-FIRE:
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -18,12 +17,15 @@
|
||||
|
||||
#include "reader_xyz.h"
|
||||
|
||||
#include "memory.h"
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
#include "label_map.h"
|
||||
#include "memory.h"
|
||||
#include "tokenizer.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static constexpr int MAXLINE = 1024; // max line length in dump file
|
||||
static constexpr int MAXLINE = 1024; // max line length in dump file
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -50,22 +52,21 @@ ReaderXYZ::~ReaderXYZ()
|
||||
|
||||
int ReaderXYZ::read_time(bigint &ntimestep)
|
||||
{
|
||||
char *eof = fgets(line,MAXLINE,fp);
|
||||
char *eof = fgets(line, MAXLINE, fp);
|
||||
if (eof == nullptr) return 1;
|
||||
|
||||
// first line has to have the number of atoms
|
||||
// truncate the string to the first whitespace,
|
||||
// so force->bnumeric() does not hiccup
|
||||
|
||||
for (int i=0; (i < MAXLINE) && (eof[i] != '\0'); ++i) {
|
||||
for (int i = 0; (i < MAXLINE) && (eof[i] != '\0'); ++i) {
|
||||
if (eof[i] == '\n' || eof[i] == '\r' || eof[i] == ' ' || eof[i] == '\t') {
|
||||
eof[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
natoms = utils::bnumeric(FLERR,line,false,lmp);
|
||||
if (natoms < 1)
|
||||
error->one(FLERR,"Dump file is incorrectly formatted");
|
||||
natoms = utils::bnumeric(FLERR, line, false, lmp);
|
||||
if (natoms < 1) error->one(FLERR, "Dump file is incorrectly formatted");
|
||||
|
||||
// skip over comment/title line
|
||||
|
||||
@ -93,8 +94,8 @@ void ReaderXYZ::skip()
|
||||
bigint nchunk;
|
||||
bigint nremain = natoms;
|
||||
while (nremain) {
|
||||
nchunk = MIN(nremain,MAXSMALLINT);
|
||||
read_lines((int)nchunk);
|
||||
nchunk = MIN(nremain, MAXSMALLINT);
|
||||
read_lines((int) nchunk);
|
||||
nremain -= nchunk;
|
||||
}
|
||||
}
|
||||
@ -113,11 +114,10 @@ void ReaderXYZ::skip()
|
||||
only called by proc 0
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclinic*/,
|
||||
int fieldinfo, int nfield,
|
||||
int *fieldtype, char **/*fieldlabel*/,
|
||||
int scaleflag, int wrapflag, int &fieldflag,
|
||||
int &xflag, int &yflag, int &zflag)
|
||||
bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int & /*triclinic*/,
|
||||
int fieldinfo, int nfield, int *fieldtype, char ** /*fieldlabel*/,
|
||||
int scaleflag, int wrapflag, int &fieldflag, int &xflag, int &yflag,
|
||||
int &zflag)
|
||||
{
|
||||
|
||||
nid = 0;
|
||||
@ -130,24 +130,21 @@ bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclin
|
||||
|
||||
if (!fieldinfo) return natoms;
|
||||
|
||||
memory->create(fieldindex,nfield,"read_dump:fieldindex");
|
||||
memory->create(fieldindex, nfield, "read_dump:fieldindex");
|
||||
|
||||
// for xyz we know nothing about the style of coordinates,
|
||||
// so caller has to set the proper flags
|
||||
|
||||
xflag = 2*scaleflag + wrapflag + 1;
|
||||
yflag = 2*scaleflag + wrapflag + 1;
|
||||
zflag = 2*scaleflag + wrapflag + 1;
|
||||
xflag = 2 * scaleflag + wrapflag + 1;
|
||||
yflag = 2 * scaleflag + wrapflag + 1;
|
||||
zflag = 2 * scaleflag + wrapflag + 1;
|
||||
|
||||
// copy fieldtype list for supported fields
|
||||
|
||||
fieldflag = 0;
|
||||
for (int i = 0; i < nfield; i++) {
|
||||
if ( (fieldtype[i] == X) ||
|
||||
(fieldtype[i] == Y) ||
|
||||
(fieldtype[i] == Z) ||
|
||||
(fieldtype[i] == ID) ||
|
||||
(fieldtype[i] == TYPE)) {
|
||||
if ((fieldtype[i] == X) || (fieldtype[i] == Y) || (fieldtype[i] == Z) || (fieldtype[i] == ID) ||
|
||||
(fieldtype[i] == TYPE)) {
|
||||
fieldindex[i] = fieldtype[i];
|
||||
} else {
|
||||
fieldflag = 1;
|
||||
@ -166,43 +163,55 @@ bigint ReaderXYZ::read_header(double /*box*/[3][3], int &boxinfo, int &/*triclin
|
||||
|
||||
void ReaderXYZ::read_atoms(int n, int nfield, double **fields)
|
||||
{
|
||||
int i,m,rv;
|
||||
int i, m;
|
||||
char *eof;
|
||||
int mytype;
|
||||
double myx, myy, myz;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
eof = fgets(line,MAXLINE,fp);
|
||||
if (eof == nullptr) error->one(FLERR,"Unexpected end of dump file");
|
||||
try {
|
||||
for (i = 0; i < n; i++) {
|
||||
eof = fgets(line, MAXLINE, fp);
|
||||
if (eof == nullptr) error->one(FLERR, "Unexpected end of dump file");
|
||||
|
||||
++nid;
|
||||
rv = sscanf(line,"%*s%lg%lg%lg", &myx, &myy, &myz);
|
||||
if (rv != 3) error->one(FLERR,"Dump file is incorrectly formatted");
|
||||
++nid;
|
||||
|
||||
// XXX: we could insert an element2type translation here
|
||||
// XXX: for now we flag unrecognized types as type 0,
|
||||
// XXX: which should trigger an error, if LAMMPS uses it.
|
||||
mytype = std::stoi(line);
|
||||
auto values = ValueTokenizer(line);
|
||||
auto label = values.next_string();
|
||||
|
||||
for (m = 0; m < nfield; m++) {
|
||||
switch (fieldindex[m]) {
|
||||
case X:
|
||||
fields[i][m] = myx;
|
||||
break;
|
||||
case Y:
|
||||
fields[i][m] = myy;
|
||||
break;
|
||||
case Z:
|
||||
fields[i][m] = myz;
|
||||
break;
|
||||
case ID:
|
||||
fields[i][m] = nid;
|
||||
break;
|
||||
case TYPE:
|
||||
fields[i][m] = mytype;
|
||||
break;
|
||||
// must have a complete atom type label map to parse xyz files with string labels
|
||||
if (!utils::is_integer(label)) {
|
||||
if (!atom->labelmapflag || !atom->lmap->is_complete(Atom::ATOM))
|
||||
error->one(FLERR, "Must define atom labelmap to parse XYZ files with strings for types");
|
||||
}
|
||||
mytype = utils::expand_type_int(FLERR, label, Atom::ATOM, lmp);
|
||||
myx = values.next_double();
|
||||
myy = values.next_double();
|
||||
myz = values.next_double();
|
||||
|
||||
for (m = 0; m < nfield; m++) {
|
||||
switch (fieldindex[m]) {
|
||||
case X:
|
||||
fields[i][m] = myx;
|
||||
break;
|
||||
case Y:
|
||||
fields[i][m] = myy;
|
||||
break;
|
||||
case Z:
|
||||
fields[i][m] = myz;
|
||||
break;
|
||||
case ID:
|
||||
fields[i][m] = nid;
|
||||
break;
|
||||
case TYPE:
|
||||
fields[i][m] = mytype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (TokenizerException &e) {
|
||||
error->one(FLERR, "Error reading xyz file: {}", e.what());
|
||||
} catch (LAMMPSAbortException &e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,6 +225,6 @@ void ReaderXYZ::read_lines(int n)
|
||||
{
|
||||
char *eof = nullptr;
|
||||
if (n <= 0) return;
|
||||
for (int i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp);
|
||||
if (eof == nullptr) error->one(FLERR,"Unexpected end of dump file");
|
||||
for (int i = 0; i < n; i++) eof = fgets(line, MAXLINE, fp);
|
||||
if (eof == nullptr) error->one(FLERR, "Unexpected end of dump file");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user