Merge branch 'develop' into avoid-bigint-format-scanf
This commit is contained in:
2
src/.gitignore
vendored
2
src/.gitignore
vendored
@ -460,6 +460,8 @@
|
||||
/compute_fabric.h
|
||||
/compute_fep.cpp
|
||||
/compute_fep.h
|
||||
/compute_fep_ta.cpp
|
||||
/compute_fep_ta.h
|
||||
/compute_force_tally.cpp
|
||||
/compute_force_tally.h
|
||||
/compute_gyration_shape.cpp
|
||||
|
||||
@ -238,6 +238,9 @@ void DumpAtomADIOS::init_style()
|
||||
columnNames = {"id", "type", "xs", "ys", "zs", "ix", "iy", "iz"};
|
||||
}
|
||||
|
||||
for (int icol = 0; icol < (int)columnNames.size(); ++icol)
|
||||
if (keyword_user[icol].size()) columnNames[icol] = keyword_user[icol];
|
||||
|
||||
// setup function ptrs
|
||||
|
||||
if (scale_flag == 1 && image_flag == 0 && domain->triclinic == 0)
|
||||
|
||||
@ -214,6 +214,19 @@ void DumpCustomADIOS::write()
|
||||
|
||||
void DumpCustomADIOS::init_style()
|
||||
{
|
||||
// assemble column string from defaults and user values
|
||||
|
||||
delete[] columns;
|
||||
std::string combined;
|
||||
int icol = 0;
|
||||
for (auto item : utils::split_words(columns_default)) {
|
||||
if (combined.size()) combined += " ";
|
||||
if (keyword_user[icol].size()) combined += keyword_user[icol];
|
||||
else combined += item;
|
||||
++icol;
|
||||
}
|
||||
columns = utils::strdup(combined);
|
||||
|
||||
// setup boundary string
|
||||
|
||||
domain->boundary_string(boundstr);
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -19,17 +18,17 @@
|
||||
#include "compute_msd_nongauss.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "group.h"
|
||||
#include "domain.h"
|
||||
#include "fix_store.h"
|
||||
#include "group.h"
|
||||
#include "update.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeMSDNonGauss::ComputeMSDNonGauss(LAMMPS *lmp, int narg, char **arg) :
|
||||
ComputeMSD(lmp, narg, arg)
|
||||
ComputeMSD(lmp, narg, arg)
|
||||
{
|
||||
size_vector = 3;
|
||||
}
|
||||
@ -43,8 +42,10 @@ void ComputeMSDNonGauss::compute_vector()
|
||||
// cm = current center of mass
|
||||
|
||||
double cm[3];
|
||||
if (comflag) group->xcm(igroup,masstotal,cm);
|
||||
else cm[0] = cm[1] = cm[2] = 0.0;
|
||||
if (comflag)
|
||||
group->xcm(igroup, masstotal, cm);
|
||||
else
|
||||
cm[0] = cm[1] = cm[2] = 0.0;
|
||||
|
||||
// dx,dy,dz = displacement of atom from original position
|
||||
// original unwrapped position is stored by fix
|
||||
@ -63,8 +64,8 @@ void ComputeMSDNonGauss::compute_vector()
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
|
||||
double dx,dy,dz;
|
||||
int xbox,ybox,zbox;
|
||||
double dx, dy, dz;
|
||||
int xbox, ybox, zbox;
|
||||
|
||||
double msd[2];
|
||||
msd[0] = msd[1] = 0.0;
|
||||
@ -75,11 +76,11 @@ void ComputeMSDNonGauss::compute_vector()
|
||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
||||
dx = x[i][0] + xbox*xprd - cm[0] - xoriginal[i][0];
|
||||
dy = x[i][1] + ybox*yprd - cm[1] - xoriginal[i][1];
|
||||
dz = x[i][2] + zbox*zprd - cm[2] - xoriginal[i][2];
|
||||
msd[0] += dx*dx + dy*dy + dz*dz;
|
||||
msd[1] += (dx*dx + dy*dy + dz*dz)*(dx*dx + dy*dy + dz*dz);
|
||||
dx = x[i][0] + xbox * xprd - cm[0] - xoriginal[i][0];
|
||||
dy = x[i][1] + ybox * yprd - cm[1] - xoriginal[i][1];
|
||||
dz = x[i][2] + zbox * zprd - cm[2] - xoriginal[i][2];
|
||||
msd[0] += dx * dx + dy * dy + dz * dz;
|
||||
msd[1] += (dx * dx + dy * dy + dz * dz) * (dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -88,19 +89,18 @@ void ComputeMSDNonGauss::compute_vector()
|
||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
||||
dx = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox -
|
||||
cm[0] - xoriginal[i][0];
|
||||
dy = x[i][1] + h[1]*ybox + h[3]*zbox - cm[1] - xoriginal[i][1];
|
||||
dz = x[i][2] + h[2]*zbox - cm[2] - xoriginal[i][2];
|
||||
msd[0] += dx*dx + dy*dy + dz*dz;
|
||||
msd[1] += (dx*dx + dy*dy + dz*dz)*(dx*dx + dy*dy + dz*dz);
|
||||
dx = x[i][0] + h[0] * xbox + h[5] * ybox + h[4] * zbox - cm[0] - xoriginal[i][0];
|
||||
dy = x[i][1] + h[1] * ybox + h[3] * zbox - cm[1] - xoriginal[i][1];
|
||||
dz = x[i][2] + h[2] * zbox - cm[2] - xoriginal[i][2];
|
||||
msd[0] += dx * dx + dy * dy + dz * dz;
|
||||
msd[1] += (dx * dx + dy * dy + dz * dz) * (dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
}
|
||||
|
||||
MPI_Allreduce(msd,vector,2,MPI_DOUBLE,MPI_SUM,world);
|
||||
MPI_Allreduce(msd, vector, 2, MPI_DOUBLE, MPI_SUM, world);
|
||||
if (nmsd) {
|
||||
vector[0] /= nmsd;
|
||||
vector[1] /= nmsd;
|
||||
vector[2] = (3*vector[1])/(5*vector[0]*vector[0]) - 1;
|
||||
vector[2] = (3 * vector[1]) / (5 * vector[0] * vector[0]) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ action () {
|
||||
|
||||
action compute_fep.cpp
|
||||
action compute_fep.h
|
||||
action compute_fep_ta.cpp
|
||||
action compute_fep_ta.h
|
||||
action fix_adapt_fep.cpp
|
||||
action fix_adapt_fep.h
|
||||
action pair_coul_cut_soft.cpp
|
||||
|
||||
517
src/FEP/compute_fep_ta.cpp
Normal file
517
src/FEP/compute_fep_ta.cpp
Normal file
@ -0,0 +1,517 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Shifeng Ke (Zhejiang University)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "compute_fep_ta.h"
|
||||
|
||||
#include "angle.h"
|
||||
#include "atom.h"
|
||||
#include "bond.h"
|
||||
#include "comm.h"
|
||||
#include "dihedral.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "force.h"
|
||||
#include "improper.h"
|
||||
#include "kspace.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
#include "neighbor.h"
|
||||
#include "pair.h"
|
||||
#include "timer.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
enum { X, Y, Z };
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeFEPTA::ComputeFEPTA(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 6) error->all(FLERR, "Illegal number of arguments in compute fep/ta");
|
||||
|
||||
scalar_flag = 0;
|
||||
vector_flag = 1;
|
||||
size_vector = 3;
|
||||
extvector = 0;
|
||||
|
||||
vector = new double[size_vector];
|
||||
|
||||
fepinitflag = 0; // avoid init to run entirely when called by write_data
|
||||
|
||||
temp_fep = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
|
||||
if (strcmp(arg[4], "xy") == 0) {
|
||||
tan_axis1 = X;
|
||||
tan_axis2 = Y;
|
||||
norm_axis = Z;
|
||||
} else if (strcmp(arg[4], "xz") == 0) {
|
||||
tan_axis1 = X;
|
||||
tan_axis2 = Z;
|
||||
norm_axis = Y;
|
||||
} else if (strcmp(arg[4], "yz") == 0) {
|
||||
tan_axis1 = Y;
|
||||
tan_axis2 = Z;
|
||||
norm_axis = X;
|
||||
} else
|
||||
error->all(FLERR, "Illegal arguments in compute fep/ta");
|
||||
|
||||
scale_factor = utils::numeric(FLERR, arg[5], false, lmp);
|
||||
|
||||
// optional keywords
|
||||
|
||||
tailflag = 0;
|
||||
|
||||
int iarg = 6;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "tail") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal optional keyword in compute fep/ta");
|
||||
tailflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
} else
|
||||
error->all(FLERR, "Illegal optional keyword in compute fep/ta");
|
||||
}
|
||||
|
||||
// allocate space for position, force, energy, virial arrays
|
||||
|
||||
x_orig = nullptr;
|
||||
f_orig = nullptr;
|
||||
peatom_orig = keatom_orig = nullptr;
|
||||
pvatom_orig = kvatom_orig = nullptr;
|
||||
|
||||
allocate_storage();
|
||||
|
||||
fixgpu = nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeFEPTA::~ComputeFEPTA()
|
||||
{
|
||||
delete[] vector;
|
||||
|
||||
deallocate_storage();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::init()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (!fepinitflag) // avoid init to run entirely when called by write_data
|
||||
fepinitflag = 1;
|
||||
else
|
||||
return;
|
||||
|
||||
// setup and error checks
|
||||
|
||||
if (domain->dimension == 2) { error->all(FLERR, "Cannot compute fep/ta in 2d simulation"); }
|
||||
|
||||
if (tailflag) {
|
||||
if (force->pair->tail_flag == 0)
|
||||
error->all(FLERR,
|
||||
"Compute fep/ta tail when pair style does not "
|
||||
"compute tail corrections");
|
||||
}
|
||||
|
||||
// detect if package gpu is present
|
||||
|
||||
int ifixgpu = modify->find_fix("package_gpu");
|
||||
if (ifixgpu >= 0) fixgpu = modify->fix[ifixgpu];
|
||||
|
||||
if (comm->me == 0) {
|
||||
auto mesg = fmt::format("FEP/TA settings ...\n temperature = {:f}\n", temp_fep);
|
||||
mesg += fmt::format(" scale factor = {:f}\n", scale_factor);
|
||||
mesg += fmt::format(" tail {}\n", (tailflag ? "yes" : "no"));
|
||||
utils::logmesg(lmp, mesg);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::compute_vector()
|
||||
{
|
||||
double pe0, pe1;
|
||||
|
||||
eflag = 1;
|
||||
vflag = 0;
|
||||
|
||||
invoked_vector = update->ntimestep;
|
||||
|
||||
if (atom->nmax > nmax) { // reallocate working arrays if necessary
|
||||
deallocate_storage();
|
||||
allocate_storage();
|
||||
}
|
||||
|
||||
backup_xfev(); // backup position, force, energy, virial array values
|
||||
backup_box(); // backup box size
|
||||
|
||||
timer->stamp();
|
||||
if (force->pair && force->pair->compute_flag) {
|
||||
force->pair->compute(eflag, vflag);
|
||||
timer->stamp(Timer::PAIR);
|
||||
}
|
||||
|
||||
if (atom->molecular != Atom::ATOMIC) {
|
||||
if (force->bond) force->bond->compute(eflag, vflag);
|
||||
if (force->angle) force->angle->compute(eflag, vflag);
|
||||
if (force->dihedral) force->dihedral->compute(eflag, vflag);
|
||||
if (force->improper) force->improper->compute(eflag, vflag);
|
||||
timer->stamp(Timer::BOND);
|
||||
}
|
||||
|
||||
if (force->kspace && force->kspace->compute_flag) {
|
||||
force->kspace->compute(eflag, vflag);
|
||||
timer->stamp(Timer::KSPACE);
|
||||
}
|
||||
|
||||
// accumulate force/energy/virial from /gpu pair styles
|
||||
// this is required as to empty the answer queue,
|
||||
// otherwise the force compute on the GPU in the next step would be incorrect
|
||||
if (fixgpu) fixgpu->post_force(vflag);
|
||||
|
||||
pe0 = compute_pe();
|
||||
|
||||
change_box();
|
||||
|
||||
timer->stamp();
|
||||
if (force->pair && force->pair->compute_flag) {
|
||||
force->pair->compute(eflag, vflag);
|
||||
timer->stamp(Timer::PAIR);
|
||||
}
|
||||
|
||||
if (atom->molecular != Atom::ATOMIC) {
|
||||
if (force->bond) force->bond->compute(eflag, vflag);
|
||||
if (force->angle) force->angle->compute(eflag, vflag);
|
||||
if (force->dihedral) force->dihedral->compute(eflag, vflag);
|
||||
if (force->improper) force->improper->compute(eflag, vflag);
|
||||
timer->stamp(Timer::BOND);
|
||||
}
|
||||
|
||||
if (force->kspace && force->kspace->compute_flag) {
|
||||
force->kspace->compute(eflag, vflag);
|
||||
timer->stamp(Timer::KSPACE);
|
||||
}
|
||||
|
||||
// accumulate force/energy/virial from /gpu pair styles
|
||||
// this is required as to empty the answer queue,
|
||||
// otherwise the force compute on the GPU in the next step would be incorrect
|
||||
if (fixgpu) fixgpu->post_force(vflag);
|
||||
|
||||
pe1 = compute_pe();
|
||||
|
||||
restore_xfev(); // restore position, force, energy, virial array values
|
||||
restore_box(); // restore box size
|
||||
|
||||
vector[0] = pe1 - pe0;
|
||||
vector[1] = exp(-(pe1 - pe0) / (force->boltz * temp_fep));
|
||||
vector[2] = area_orig * (scale_factor - 1.0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
obtain potential energy from lammps accumulators
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double ComputeFEPTA::compute_pe()
|
||||
{
|
||||
double eng, eng_potential;
|
||||
|
||||
eng = 0.0;
|
||||
if (force->pair) eng = force->pair->eng_vdwl + force->pair->eng_coul;
|
||||
|
||||
if (atom->molecular != Atom::ATOMIC) {
|
||||
if (force->bond) eng += force->bond->energy;
|
||||
if (force->angle) eng += force->angle->energy;
|
||||
if (force->dihedral) eng += force->dihedral->energy;
|
||||
if (force->improper) eng += force->improper->energy;
|
||||
}
|
||||
|
||||
MPI_Allreduce(&eng, &eng_potential, 1, MPI_DOUBLE, MPI_SUM, world);
|
||||
|
||||
if (tailflag) {
|
||||
double volume = domain->xprd * domain->yprd * domain->zprd;
|
||||
eng_potential += force->pair->etail / volume;
|
||||
}
|
||||
|
||||
if (force->kspace) eng_potential += force->kspace->energy;
|
||||
|
||||
return eng_potential;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
apply changes to box
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::change_box()
|
||||
{
|
||||
int i;
|
||||
double **x = atom->x;
|
||||
int natom = atom->nlocal + atom->nghost;
|
||||
|
||||
for (i = 0; i < natom; i++) domain->x2lamda(x[i], x[i]);
|
||||
|
||||
domain->boxhi[tan_axis1] *= sqrt(scale_factor);
|
||||
domain->boxlo[tan_axis1] *= sqrt(scale_factor);
|
||||
domain->boxhi[tan_axis2] *= sqrt(scale_factor);
|
||||
domain->boxlo[tan_axis2] *= sqrt(scale_factor);
|
||||
domain->boxhi[norm_axis] /= scale_factor;
|
||||
domain->boxlo[norm_axis] /= scale_factor;
|
||||
|
||||
domain->set_global_box();
|
||||
domain->set_local_box();
|
||||
|
||||
// remap atom position
|
||||
for (i = 0; i < natom; i++) domain->lamda2x(x[i], x[i]);
|
||||
|
||||
if (force->kspace) force->kspace->setup();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
backup box size
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::backup_box()
|
||||
{
|
||||
for (int i = 0; i < domain->dimension; i++) {
|
||||
boxhi_orig[i] = domain->boxhi[i];
|
||||
boxlo_orig[i] = domain->boxlo[i];
|
||||
}
|
||||
|
||||
area_orig = domain->prd[tan_axis1] * domain->prd[tan_axis2];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
restore box size to original values
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::restore_box()
|
||||
{
|
||||
for (int i = 0; i < domain->dimension; i++) {
|
||||
domain->boxhi[i] = boxhi_orig[i];
|
||||
domain->boxlo[i] = boxlo_orig[i];
|
||||
}
|
||||
|
||||
domain->set_global_box();
|
||||
domain->set_local_box();
|
||||
|
||||
if (force->kspace) force->kspace->setup();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
manage storage for position, force, energy, virial arrays
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::allocate_storage()
|
||||
{
|
||||
nmax = atom->nmax;
|
||||
memory->create(x_orig, nmax, 3, "fep:x_orig");
|
||||
memory->create(f_orig, nmax, 3, "fep:f_orig");
|
||||
memory->create(peatom_orig, nmax, "fep:peatom_orig");
|
||||
memory->create(pvatom_orig, nmax, 6, "fep:pvatom_orig");
|
||||
if (force->kspace) {
|
||||
memory->create(keatom_orig, nmax, "fep:keatom_orig");
|
||||
memory->create(kvatom_orig, nmax, 6, "fep:kvatom_orig");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::deallocate_storage()
|
||||
{
|
||||
memory->destroy(x_orig);
|
||||
memory->destroy(f_orig);
|
||||
memory->destroy(peatom_orig);
|
||||
memory->destroy(pvatom_orig);
|
||||
memory->destroy(keatom_orig);
|
||||
memory->destroy(kvatom_orig);
|
||||
|
||||
x_orig = nullptr;
|
||||
f_orig = nullptr;
|
||||
peatom_orig = keatom_orig = nullptr;
|
||||
pvatom_orig = kvatom_orig = nullptr;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
backup and restore arrays with position, force, energy, virial
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::backup_xfev()
|
||||
{
|
||||
int i;
|
||||
|
||||
int natom = atom->nlocal + atom->nghost;
|
||||
|
||||
double **x = atom->x;
|
||||
for (i = 0; i < natom; i++) {
|
||||
x_orig[i][0] = x[i][0];
|
||||
x_orig[i][1] = x[i][1];
|
||||
x_orig[i][2] = x[i][2];
|
||||
}
|
||||
|
||||
double **f = atom->f;
|
||||
for (i = 0; i < natom; i++) {
|
||||
f_orig[i][0] = f[i][0];
|
||||
f_orig[i][1] = f[i][1];
|
||||
f_orig[i][2] = f[i][2];
|
||||
}
|
||||
|
||||
eng_vdwl_orig = force->pair->eng_vdwl;
|
||||
eng_coul_orig = force->pair->eng_coul;
|
||||
|
||||
if (atom->molecular != Atom::ATOMIC) {
|
||||
if (force->bond) eng_bond_orig = force->bond->energy;
|
||||
if (force->angle) eng_angle_orig = force->angle->energy;
|
||||
if (force->dihedral) eng_dihedral_orig = force->dihedral->energy;
|
||||
if (force->improper) eng_improper_orig = force->improper->energy;
|
||||
}
|
||||
|
||||
pvirial_orig[0] = force->pair->virial[0];
|
||||
pvirial_orig[1] = force->pair->virial[1];
|
||||
pvirial_orig[2] = force->pair->virial[2];
|
||||
pvirial_orig[3] = force->pair->virial[3];
|
||||
pvirial_orig[4] = force->pair->virial[4];
|
||||
pvirial_orig[5] = force->pair->virial[5];
|
||||
|
||||
if (update->eflag_atom) {
|
||||
double *peatom = force->pair->eatom;
|
||||
for (i = 0; i < natom; i++) peatom_orig[i] = peatom[i];
|
||||
}
|
||||
if (update->vflag_atom) {
|
||||
double **pvatom = force->pair->vatom;
|
||||
for (i = 0; i < natom; i++) {
|
||||
pvatom_orig[i][0] = pvatom[i][0];
|
||||
pvatom_orig[i][1] = pvatom[i][1];
|
||||
pvatom_orig[i][2] = pvatom[i][2];
|
||||
pvatom_orig[i][3] = pvatom[i][3];
|
||||
pvatom_orig[i][4] = pvatom[i][4];
|
||||
pvatom_orig[i][5] = pvatom[i][5];
|
||||
}
|
||||
}
|
||||
|
||||
if (force->kspace) {
|
||||
energy_orig = force->kspace->energy;
|
||||
kvirial_orig[0] = force->kspace->virial[0];
|
||||
kvirial_orig[1] = force->kspace->virial[1];
|
||||
kvirial_orig[2] = force->kspace->virial[2];
|
||||
kvirial_orig[3] = force->kspace->virial[3];
|
||||
kvirial_orig[4] = force->kspace->virial[4];
|
||||
kvirial_orig[5] = force->kspace->virial[5];
|
||||
|
||||
if (update->eflag_atom) {
|
||||
double *keatom = force->kspace->eatom;
|
||||
for (i = 0; i < natom; i++) keatom_orig[i] = keatom[i];
|
||||
}
|
||||
if (update->vflag_atom) {
|
||||
double **kvatom = force->kspace->vatom;
|
||||
for (i = 0; i < natom; i++) {
|
||||
kvatom_orig[i][0] = kvatom[i][0];
|
||||
kvatom_orig[i][1] = kvatom[i][1];
|
||||
kvatom_orig[i][2] = kvatom[i][2];
|
||||
kvatom_orig[i][3] = kvatom[i][3];
|
||||
kvatom_orig[i][4] = kvatom[i][4];
|
||||
kvatom_orig[i][5] = kvatom[i][5];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeFEPTA::restore_xfev()
|
||||
{
|
||||
int i;
|
||||
|
||||
int natom = atom->nlocal + atom->nghost;
|
||||
|
||||
double **x = atom->x;
|
||||
for (i = 0; i < natom; i++) {
|
||||
x[i][0] = x_orig[i][0];
|
||||
x[i][1] = x_orig[i][1];
|
||||
x[i][2] = x_orig[i][2];
|
||||
}
|
||||
|
||||
double **f = atom->f;
|
||||
for (i = 0; i < natom; i++) {
|
||||
f[i][0] = f_orig[i][0];
|
||||
f[i][1] = f_orig[i][1];
|
||||
f[i][2] = f_orig[i][2];
|
||||
}
|
||||
|
||||
force->pair->eng_vdwl = eng_vdwl_orig;
|
||||
force->pair->eng_coul = eng_coul_orig;
|
||||
|
||||
if (atom->molecular != Atom::ATOMIC) {
|
||||
if (force->bond) force->bond->energy = eng_bond_orig;
|
||||
if (force->angle) force->angle->energy = eng_angle_orig;
|
||||
if (force->dihedral) force->dihedral->energy = eng_dihedral_orig;
|
||||
if (force->improper) force->improper->energy = eng_improper_orig;
|
||||
}
|
||||
|
||||
force->pair->virial[0] = pvirial_orig[0];
|
||||
force->pair->virial[1] = pvirial_orig[1];
|
||||
force->pair->virial[2] = pvirial_orig[2];
|
||||
force->pair->virial[3] = pvirial_orig[3];
|
||||
force->pair->virial[4] = pvirial_orig[4];
|
||||
force->pair->virial[5] = pvirial_orig[5];
|
||||
|
||||
if (update->eflag_atom) {
|
||||
double *peatom = force->pair->eatom;
|
||||
for (i = 0; i < natom; i++) peatom[i] = peatom_orig[i];
|
||||
}
|
||||
if (update->vflag_atom) {
|
||||
double **pvatom = force->pair->vatom;
|
||||
for (i = 0; i < natom; i++) {
|
||||
pvatom[i][0] = pvatom_orig[i][0];
|
||||
pvatom[i][1] = pvatom_orig[i][1];
|
||||
pvatom[i][2] = pvatom_orig[i][2];
|
||||
pvatom[i][3] = pvatom_orig[i][3];
|
||||
pvatom[i][4] = pvatom_orig[i][4];
|
||||
pvatom[i][5] = pvatom_orig[i][5];
|
||||
}
|
||||
}
|
||||
|
||||
if (force->kspace) {
|
||||
force->kspace->energy = energy_orig;
|
||||
force->kspace->virial[0] = kvirial_orig[0];
|
||||
force->kspace->virial[1] = kvirial_orig[1];
|
||||
force->kspace->virial[2] = kvirial_orig[2];
|
||||
force->kspace->virial[3] = kvirial_orig[3];
|
||||
force->kspace->virial[4] = kvirial_orig[4];
|
||||
force->kspace->virial[5] = kvirial_orig[5];
|
||||
|
||||
if (update->eflag_atom) {
|
||||
double *keatom = force->kspace->eatom;
|
||||
for (i = 0; i < natom; i++) keatom[i] = keatom_orig[i];
|
||||
}
|
||||
if (update->vflag_atom) {
|
||||
double **kvatom = force->kspace->vatom;
|
||||
for (i = 0; i < natom; i++) {
|
||||
kvatom[i][0] = kvatom_orig[i][0];
|
||||
kvatom[i][1] = kvatom_orig[i][1];
|
||||
kvatom[i][2] = kvatom_orig[i][2];
|
||||
kvatom[i][3] = kvatom_orig[i][3];
|
||||
kvatom[i][4] = kvatom_orig[i][4];
|
||||
kvatom[i][5] = kvatom_orig[i][5];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
src/FEP/compute_fep_ta.h
Normal file
89
src/FEP/compute_fep_ta.h
Normal file
@ -0,0 +1,89 @@
|
||||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Contributing author: Shifeng Ke (Zhejiang University)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef COMPUTE_CLASS
|
||||
// clang-format off
|
||||
ComputeStyle(fep/ta,ComputeFEPTA);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef COMPUTE_FEP_TA_H
|
||||
#define COMPUTE_FEP_TA_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeFEPTA : public Compute {
|
||||
public:
|
||||
ComputeFEPTA(class LAMMPS *, int, char **); // compute ID groupID fep/ta temp xy/xz/yz scale_factor
|
||||
~ComputeFEPTA() override;
|
||||
void init() override;
|
||||
void compute_vector() override;
|
||||
|
||||
private:
|
||||
int tailflag;
|
||||
int fepinitflag;
|
||||
int eflag, vflag;
|
||||
double temp_fep;
|
||||
double scale_factor;
|
||||
int tan_axis1, tan_axis2, norm_axis;
|
||||
|
||||
double boxlo_orig[3], boxhi_orig[3];
|
||||
double area_orig;
|
||||
|
||||
int nmax;
|
||||
double **x_orig;
|
||||
double **f_orig;
|
||||
double eng_vdwl_orig, eng_coul_orig;
|
||||
double eng_bond_orig, eng_angle_orig, eng_dihedral_orig, eng_improper_orig;
|
||||
double pvirial_orig[6];
|
||||
double *peatom_orig, **pvatom_orig;
|
||||
double energy_orig;
|
||||
double kvirial_orig[6];
|
||||
double *keatom_orig, **kvatom_orig;
|
||||
|
||||
class Fix *fixgpu;
|
||||
|
||||
double compute_pe();
|
||||
void change_box();
|
||||
void backup_box();
|
||||
void restore_box();
|
||||
void allocate_storage();
|
||||
void deallocate_storage();
|
||||
void backup_xfev();
|
||||
void restore_xfev();
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Illegal ... command
|
||||
|
||||
Self-explanatory. Check the input script syntax and compare to the
|
||||
documentation for the command. You can use -echo screen as a
|
||||
command-line option when running LAMMPS to see the offending line.
|
||||
|
||||
E: Cannot compute fep/ta in 2d simulation
|
||||
|
||||
Self-explanatory.
|
||||
|
||||
*/
|
||||
@ -205,7 +205,6 @@ void FixACKS2ReaxFFKokkos<DeviceType>::pre_force(int vflag)
|
||||
type = atomKK->k_type.view<DeviceType>();
|
||||
mask = atomKK->k_mask.view<DeviceType>();
|
||||
nlocal = atomKK->nlocal;
|
||||
nall = atom->nlocal + atom->nghost;
|
||||
newton_pair = force->newton_pair;
|
||||
|
||||
k_params.template sync<DeviceType>();
|
||||
@ -219,7 +218,7 @@ void FixACKS2ReaxFFKokkos<DeviceType>::pre_force(int vflag)
|
||||
d_ilist = k_list->d_ilist;
|
||||
|
||||
nn = list->inum;
|
||||
NN = list->inum + list->gnum;
|
||||
NN = atom->nlocal + atom->nghost;
|
||||
|
||||
copymode = 1;
|
||||
|
||||
@ -526,7 +525,7 @@ void FixACKS2ReaxFFKokkos<DeviceType>::allocate_array()
|
||||
if (efield) get_chi_field();
|
||||
|
||||
// init_storage
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagACKS2Zero>(0,NN),*this);
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagACKS2Zero>(0,nn),*this);
|
||||
|
||||
}
|
||||
|
||||
@ -1377,9 +1376,6 @@ int FixACKS2ReaxFFKokkos<DeviceType>::bicgstab_solve()
|
||||
template<class DeviceType>
|
||||
void FixACKS2ReaxFFKokkos<DeviceType>::calculate_Q()
|
||||
{
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagACKS2CalculateQ1>(0,nn),*this);
|
||||
|
||||
pack_flag = 2;
|
||||
//comm->forward_comm( this ); //Dist_vector( s );
|
||||
k_s.modify<DeviceType>();
|
||||
@ -1388,8 +1384,7 @@ void FixACKS2ReaxFFKokkos<DeviceType>::calculate_Q()
|
||||
k_s.modify<LMPHostType>();
|
||||
k_s.sync<DeviceType>();
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagACKS2CalculateQ2>(0,NN),*this);
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagACKS2CalculateQ>(0,NN),*this);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -1822,22 +1817,25 @@ void FixACKS2ReaxFFKokkos<DeviceType>::operator() (TagACKS2Norm3, const int &ii,
|
||||
|
||||
template<class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixACKS2ReaxFFKokkos<DeviceType>::operator() (TagACKS2CalculateQ1, const int &ii) const
|
||||
void FixACKS2ReaxFFKokkos<DeviceType>::operator() (TagACKS2CalculateQ, const int &i) const
|
||||
{
|
||||
const int i = d_ilist[ii];
|
||||
if (mask[i] & groupbit) {
|
||||
|
||||
/* backup s */
|
||||
for (int k = nprev-1; k > 0; --k) {
|
||||
d_s_hist(i,k) = d_s_hist(i,k-1);
|
||||
d_s_hist_X(i,k) = d_s_hist_X(i,k-1);
|
||||
q(i) = d_s(i);
|
||||
|
||||
if (i < nlocal) {
|
||||
/* backup s */
|
||||
for (int k = nprev-1; k > 0; --k) {
|
||||
d_s_hist(i,k) = d_s_hist(i,k-1);
|
||||
d_s_hist_X(i,k) = d_s_hist_X(i,k-1);
|
||||
}
|
||||
d_s_hist(i,0) = d_s[i];
|
||||
d_s_hist_X(i,0) = d_s[NN+i];
|
||||
}
|
||||
d_s_hist(i,0) = d_s[i];
|
||||
d_s_hist_X(i,0) = d_s[NN+i];
|
||||
}
|
||||
|
||||
// last two rows
|
||||
if (last_rows_flag && ii == 0) {
|
||||
if (last_rows_flag && i == 0) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int k = nprev-1; k > 0; --k)
|
||||
d_s_hist_last(i,k) = d_s_hist_last(i,k-1);
|
||||
@ -1848,17 +1846,6 @@ void FixACKS2ReaxFFKokkos<DeviceType>::operator() (TagACKS2CalculateQ1, const in
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template<class DeviceType>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixACKS2ReaxFFKokkos<DeviceType>::operator() (TagACKS2CalculateQ2, const int &ii) const
|
||||
{
|
||||
const int i = d_ilist[ii];
|
||||
if (mask[i] & groupbit)
|
||||
q(i) = d_s(i);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
template<class DeviceType>
|
||||
void FixACKS2ReaxFFKokkos<DeviceType>::cleanup_copy()
|
||||
{
|
||||
|
||||
@ -54,8 +54,7 @@ struct TagACKS2Precon1B{};
|
||||
struct TagACKS2Precon2{};
|
||||
struct TagACKS2Add{};
|
||||
struct TagACKS2ZeroQGhosts{};
|
||||
struct TagACKS2CalculateQ1{};
|
||||
struct TagACKS2CalculateQ2{};
|
||||
struct TagACKS2CalculateQ{};
|
||||
|
||||
template<class DeviceType>
|
||||
class FixACKS2ReaxFFKokkos : public FixACKS2ReaxFF {
|
||||
@ -152,10 +151,7 @@ class FixACKS2ReaxFFKokkos : public FixACKS2ReaxFF {
|
||||
void operator()(TagACKS2ZeroQGhosts, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagACKS2CalculateQ1, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagACKS2CalculateQ2, const int&) const;
|
||||
void operator()(TagACKS2CalculateQ, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
double calculate_H_k(const F_FLOAT &r, const F_FLOAT &shld) const;
|
||||
|
||||
@ -208,7 +208,6 @@ void FixQEqReaxFFKokkos<DeviceType>::pre_force(int /*vflag*/)
|
||||
d_neighbors = k_list->d_neighbors;
|
||||
d_ilist = k_list->d_ilist;
|
||||
nn = list->inum;
|
||||
NN = list->inum + list->gnum;
|
||||
|
||||
copymode = 1;
|
||||
|
||||
@ -375,7 +374,7 @@ void FixQEqReaxFFKokkos<DeviceType>::allocate_array()
|
||||
|
||||
if (efield) get_chi_field();
|
||||
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagQEqZero>(0,NN),*this);
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagQEqZero>(0,nn),*this);
|
||||
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -872,7 +871,8 @@ void FixQEqReaxFFKokkos<DeviceType>::sparse_matvec_kokkos(typename AT::t_ffloat2
|
||||
}
|
||||
|
||||
if (neighflag != FULL) {
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagQEqZeroQGhosts>(nn,NN),*this);
|
||||
int nall = nlocal + atomKK->nghost;
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<DeviceType,TagQEqZeroQGhosts>(atom->nlocal,nall),*this);
|
||||
|
||||
if (need_dup)
|
||||
dup_o.reset_except(d_o);
|
||||
|
||||
@ -1214,6 +1214,12 @@ struct params_lj_coul {
|
||||
F_FLOAT cut_ljsq,cut_coulsq,lj1,lj2,lj3,lj4,offset;
|
||||
};
|
||||
|
||||
// ReaxFF
|
||||
|
||||
struct alignas(4 * sizeof(int)) reax_int4 {
|
||||
int i0, i1, i2, i3;
|
||||
};
|
||||
|
||||
// Pair SNAP
|
||||
|
||||
#define SNAP_KOKKOS_REAL double
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -90,13 +90,13 @@ struct TagPairReaxComputeMulti1{};
|
||||
template<int NEIGHFLAG, int EFLAG>
|
||||
struct TagPairReaxComputeMulti2{};
|
||||
|
||||
template<bool POPULATE>
|
||||
struct TagPairReaxCountAngularTorsion{};
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
struct TagPairReaxComputeAngular{};
|
||||
|
||||
struct TagPairReaxComputeTorsionPreview{};
|
||||
struct TagPairReaxComputeAngularPreprocessed{};
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
struct TagPairReaxComputeTorsion{};
|
||||
struct TagPairReaxComputeTorsionPreprocessed{};
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
struct TagPairReaxComputeHydrogen{};
|
||||
@ -120,7 +120,7 @@ class PairReaxFFKokkos : public PairReaxFF {
|
||||
// "Blocking" factors to reduce thread divergence within some kernels
|
||||
using blocking_t = unsigned short int;
|
||||
|
||||
// "PairReaxFFComputeTorsionBlocking"
|
||||
// "PairReaxFFComputeTorsion"
|
||||
static constexpr int compute_torsion_blocksize = 8;
|
||||
|
||||
// "PairReaxBuildListsHalfBlocking"
|
||||
@ -176,9 +176,28 @@ class PairReaxFFKokkos : public PairReaxFF {
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxBuildListsHalfPreview<NEIGHFLAG>, const int&) const;
|
||||
|
||||
// Isolated function that builds the hbond list, reused across
|
||||
// TagPairReaxBuildListsHalfBlocking, HalfBlockingPreview, HalfPreview
|
||||
template<int NEIGHFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void build_hb_list(F_FLOAT, int, int, int, int, int) const;
|
||||
|
||||
// Isolated function that builds the bond order list, reused across
|
||||
// TagPairReaxBuildListsHalfBlocking, HalfBlockingPreview, HalfPreview
|
||||
// Returns if we need to populate d_d* functions or not
|
||||
template<int NEIGHFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
bool build_bo_list(int, int, int, int, int, int&, int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxBuildListsFull, const int&) const;
|
||||
|
||||
// Isolated function that computes bond order parameters
|
||||
// Returns BO_s, BO_pi, BO_pi2, C12, C34, C56 by reference
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void compute_bo(F_FLOAT, int, int, F_FLOAT, F_FLOAT, F_FLOAT,
|
||||
F_FLOAT&, F_FLOAT&, F_FLOAT&, F_FLOAT&, F_FLOAT&, F_FLOAT&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxZero, const int&) const;
|
||||
|
||||
@ -222,24 +241,39 @@ class PairReaxFFKokkos : public PairReaxFF {
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxComputeMulti2<NEIGHFLAG,EFLAG>, const int&) const;
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
template<bool POPULATE>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxComputeAngular<NEIGHFLAG,EVFLAG>, const int&, EV_FLOAT_REAX&) const;
|
||||
void operator()(TagPairReaxCountAngularTorsion<POPULATE>, const int&) const;
|
||||
|
||||
// Abstraction for computing SBSO2, CSBO2, dSBO1, dsBO2
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void compute_angular_sbo(int, int, int, int) const;
|
||||
|
||||
// Abstraction for counting and populating angular intermediates
|
||||
template<bool POPULATE>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
int preprocess_angular(int, int, int, int, int) const;
|
||||
|
||||
// Abstraction for counting and populating torsion intermediated
|
||||
template<bool POPULATE>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
int preprocess_torsion(int, int, int, F_FLOAT, F_FLOAT, F_FLOAT, int, int, int) const;
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxComputeAngular<NEIGHFLAG,EVFLAG>, const int&) const;
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxComputeTorsionPreview, const int&) const;
|
||||
void operator()(TagPairReaxComputeAngularPreprocessed<NEIGHFLAG,EVFLAG>, const int&, EV_FLOAT_REAX&) const;
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxComputeTorsion<NEIGHFLAG,EVFLAG>, const int&, EV_FLOAT_REAX&) const;
|
||||
void operator()(TagPairReaxComputeAngularPreprocessed<NEIGHFLAG,EVFLAG>, const int&) const;
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxComputeTorsion<NEIGHFLAG,EVFLAG>, const int&) const;
|
||||
void operator()(TagPairReaxComputeTorsionPreprocessed<NEIGHFLAG,EVFLAG>, const int&, EV_FLOAT_REAX&) const;
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(TagPairReaxComputeTorsionPreprocessed<NEIGHFLAG,EVFLAG>, const int&) const;
|
||||
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
@ -395,9 +429,8 @@ class PairReaxFFKokkos : public PairReaxFF {
|
||||
|
||||
typename AT::t_float_1d d_bo_rij, d_hb_rsq, d_Deltap, d_Deltap_boc, d_total_bo, d_s;
|
||||
typename AT::t_float_1d d_Delta, d_Delta_boc, d_Delta_lp, d_dDelta_lp, d_Delta_lp_temp, d_CdDelta;
|
||||
typename AT::t_ffloat_2d_dl d_BO, d_BO_s, d_BO_pi, d_BO_pi2, d_dBOp;
|
||||
typename AT::t_ffloat_2d_dl d_dln_BOp_pix, d_dln_BOp_piy, d_dln_BOp_piz;
|
||||
typename AT::t_ffloat_2d_dl d_dln_BOp_pi2x, d_dln_BOp_pi2y, d_dln_BOp_pi2z;
|
||||
typename AT::t_ffloat_2d_dl d_BO, d_BO_s, d_BO_pi, d_BO_pi2;
|
||||
typename AT::t_ffloat_2d_dl d_dln_BOp_pi, d_dln_BOp_pi2;
|
||||
typename AT::t_ffloat_2d_dl d_C1dbo, d_C2dbo, d_C3dbo;
|
||||
typename AT::t_ffloat_2d_dl d_C1dbopi, d_C2dbopi, d_C3dbopi, d_C4dbopi;
|
||||
typename AT::t_ffloat_2d_dl d_C1dbopi2, d_C2dbopi2, d_C3dbopi2, d_C4dbopi2;
|
||||
@ -447,7 +480,7 @@ class PairReaxFFKokkos : public PairReaxFF {
|
||||
typename AT::t_int_scalar d_resize_bo, d_resize_hb;
|
||||
|
||||
typename AT::t_ffloat_2d_dl d_sum_ovun;
|
||||
typename AT::t_ffloat_2d_dl d_dBOpx, d_dBOpy, d_dBOpz;
|
||||
typename AT::t_ffloat_2d_dl d_dBOp;
|
||||
|
||||
int neighflag, newton_pair, maxnumneigh, maxhb, maxbo;
|
||||
int nlocal,nn,NN,eflag,vflag,acks2_flag;
|
||||
@ -480,15 +513,15 @@ class PairReaxFFKokkos : public PairReaxFF {
|
||||
typename AT::t_ffloat_1d d_buf;
|
||||
DAT::tdual_int_scalar k_nbuf_local;
|
||||
|
||||
// for fast ComputeTorsion preprocessor kernel
|
||||
typedef Kokkos::View<int*, LMPPinnedHostType> t_hostpinned_int_1d;
|
||||
typedef Kokkos::View<reax_int4**, LMPDeviceType::array_layout, DeviceType> t_reax_int4_2d;
|
||||
|
||||
t_reax_int4_2d d_angular_pack, d_torsion_pack;
|
||||
|
||||
typename AT::t_ffloat_2d d_angular_intermediates;
|
||||
|
||||
typename AT::tdual_int_1d k_count_angular_torsion;
|
||||
typename AT::t_int_1d d_count_angular_torsion;
|
||||
|
||||
int inum_store;
|
||||
t_hostpinned_int_1d counters;
|
||||
t_hostpinned_int_1d counters_jj_min;
|
||||
t_hostpinned_int_1d counters_jj_max;
|
||||
t_hostpinned_int_1d counters_kk_min;
|
||||
t_hostpinned_int_1d counters_kk_max;
|
||||
};
|
||||
|
||||
template <class DeviceType>
|
||||
|
||||
@ -102,13 +102,15 @@ void PairSNAPKokkos<DeviceType, real_type, vector_length>::init_style()
|
||||
if (force->newton_pair == 0)
|
||||
error->all(FLERR,"Pair style SNAP requires newton pair on");
|
||||
|
||||
// adjust neighbor list request for KOKKOS
|
||||
// neighbor list request for KOKKOS
|
||||
|
||||
neighflag = lmp->kokkos->neighflag;
|
||||
|
||||
auto request = neighbor->add_request(this, NeighConst::REQ_FULL);
|
||||
request->set_kokkos_host(std::is_same<DeviceType,LMPHostType>::value &&
|
||||
!std::is_same<DeviceType,LMPDeviceType>::value);
|
||||
request->set_kokkos_device(std::is_same<DeviceType,LMPDeviceType>::value);
|
||||
if (lmp->kokkos->neighflag == FULL)
|
||||
if (neighflag == FULL)
|
||||
error->all(FLERR,"Must use half neighbor list style with pair snap/kk");
|
||||
}
|
||||
|
||||
|
||||
@ -224,14 +224,25 @@ void DumpAtomMPIIO::init_style()
|
||||
|
||||
// setup column string
|
||||
|
||||
std::string default_columns;
|
||||
|
||||
if (scale_flag == 0 && image_flag == 0)
|
||||
columns = (char *) "id type x y z";
|
||||
default_columns = "id type x y z";
|
||||
else if (scale_flag == 0 && image_flag == 1)
|
||||
columns = (char *) "id type x y z ix iy iz";
|
||||
default_columns = "id type x y z ix iy iz";
|
||||
else if (scale_flag == 1 && image_flag == 0)
|
||||
columns = (char *) "id type xs ys zs";
|
||||
default_columns = "id type xs ys zs";
|
||||
else if (scale_flag == 1 && image_flag == 1)
|
||||
columns = (char *) "id type xs ys zs ix iy iz";
|
||||
default_columns = "id type xs ys zs ix iy iz";
|
||||
|
||||
int icol = 0;
|
||||
columns.clear();
|
||||
for (auto item : utils::split_words(default_columns)) {
|
||||
if (columns.size()) columns += " ";
|
||||
if (keyword_user[icol].size()) columns += keyword_user[icol];
|
||||
else columns += item;
|
||||
++icol;
|
||||
}
|
||||
|
||||
// setup function ptrs
|
||||
|
||||
|
||||
@ -39,17 +39,6 @@ using namespace LAMMPS_NS;
|
||||
#define DUMP_BUF_CHUNK_SIZE 16384
|
||||
#define DUMP_BUF_INCREMENT_SIZE 4096
|
||||
|
||||
// clang-format off
|
||||
enum{ ID, MOL, TYPE, ELEMENT, MASS,
|
||||
X, Y, Z, XS, YS, ZS, XSTRI, YSTRI, ZSTRI, XU, YU, ZU, XUTRI, YUTRI, ZUTRI,
|
||||
XSU, YSU, ZSU, XSUTRI, YSUTRI, ZSUTRI,
|
||||
IX, IY, IZ, VX, VY, VZ, FX, FY, FZ,
|
||||
Q, MUX, MUY, MUZ, MU, RADIUS, DIAMETER,
|
||||
OMEGAX, OMEGAY, OMEGAZ, ANGMOMX, ANGMOMY, ANGMOMZ,
|
||||
TQX, TQY, TQZ, SPIN, ERADIUS, ERVEL, ERFORCE,
|
||||
COMPUTE, FIX, VARIABLE };
|
||||
enum{ LT, LE, GT, GE, EQ, NEQ };
|
||||
// clang-format on
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpCustomMPIIO::DumpCustomMPIIO(LAMMPS *lmp, int narg, char **arg)
|
||||
@ -216,6 +205,19 @@ void DumpCustomMPIIO::write()
|
||||
|
||||
void DumpCustomMPIIO::init_style()
|
||||
{
|
||||
// assemble ITEMS: column string from defaults and user values
|
||||
|
||||
delete[] columns;
|
||||
std::string combined;
|
||||
int icol = 0;
|
||||
for (auto item : utils::split_words(columns_default)) {
|
||||
if (combined.size()) combined += " ";
|
||||
if (keyword_user[icol].size()) combined += keyword_user[icol];
|
||||
else combined += item;
|
||||
++icol;
|
||||
}
|
||||
columns = utils::strdup(combined);
|
||||
|
||||
// format = copy of default or user-specified line format
|
||||
|
||||
delete[] format;
|
||||
|
||||
@ -38,17 +38,6 @@ using namespace LAMMPS_NS;
|
||||
#define DUMP_BUF_CHUNK_SIZE 16384
|
||||
#define DUMP_BUF_INCREMENT_SIZE 4096
|
||||
|
||||
enum{ID,MOL,TYPE,ELEMENT,MASS,
|
||||
X,Y,Z,XS,YS,ZS,XSTRI,YSTRI,ZSTRI,XU,YU,ZU,XUTRI,YUTRI,ZUTRI,
|
||||
XSU,YSU,ZSU,XSUTRI,YSUTRI,ZSUTRI,
|
||||
IX,IY,IZ,
|
||||
VX,VY,VZ,FX,FY,FZ,
|
||||
Q,MUX,MUY,MUZ,MU,RADIUS,DIAMETER,
|
||||
OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ,
|
||||
TQX,TQY,TQZ,SPIN,ERADIUS,ERVEL,ERFORCE,
|
||||
COMPUTE,FIX,VARIABLE};
|
||||
enum{LT,LE,GT,GE,EQ,NEQ};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpXYZMPIIO::DumpXYZMPIIO(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
@ -237,7 +237,7 @@ void FixQEqReaxFFOMP::init_storage()
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp parallel for schedule(static)
|
||||
#endif
|
||||
for (int i = 0; i < NN; i++) {
|
||||
for (int i = 0; i < nn; i++) {
|
||||
Hdia_inv[i] = 1. / eta[atom->type[i]];
|
||||
b_s[i] = -chi[atom->type[i]];
|
||||
if (efield) b_s[i] -= chi_field[i];
|
||||
@ -254,17 +254,13 @@ void FixQEqReaxFFOMP::pre_force(int /* vflag */)
|
||||
{
|
||||
if (update->ntimestep % nevery) return;
|
||||
|
||||
int n = atom->nlocal;
|
||||
|
||||
if (reaxff) {
|
||||
nn = reaxff->list->inum;
|
||||
NN = reaxff->list->inum + reaxff->list->gnum;
|
||||
ilist = reaxff->list->ilist;
|
||||
numneigh = reaxff->list->numneigh;
|
||||
firstneigh = reaxff->list->firstneigh;
|
||||
} else {
|
||||
nn = list->inum;
|
||||
NN = list->inum + list->gnum;
|
||||
ilist = list->ilist;
|
||||
numneigh = list->numneigh;
|
||||
firstneigh = list->firstneigh;
|
||||
@ -274,7 +270,7 @@ void FixQEqReaxFFOMP::pre_force(int /* vflag */)
|
||||
// need to be atom->nmax in length
|
||||
|
||||
if (atom->nmax > nmax) reallocate_storage();
|
||||
if (n > n_cap*DANGER_ZONE || m_fill > m_cap*DANGER_ZONE)
|
||||
if (atom->nlocal > n_cap*DANGER_ZONE || m_fill > m_cap*DANGER_ZONE)
|
||||
reallocate_matrix();
|
||||
|
||||
if (efield) get_chi_field();
|
||||
@ -487,6 +483,9 @@ void FixQEqReaxFFOMP::sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
{
|
||||
int i, j, itr_j;
|
||||
int ii;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
|
||||
int nthreads = comm->nthreads;
|
||||
#if defined(_OPENMP)
|
||||
int tid = omp_get_thread_num();
|
||||
@ -505,15 +504,14 @@ void FixQEqReaxFFOMP::sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (ii = nn; ii < NN; ++ii) {
|
||||
i = ilist[ii];
|
||||
for (i = nlocal; i < nall; ++i) {
|
||||
if (atom->mask[i] & groupbit) b[i] = 0;
|
||||
}
|
||||
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (i = 0; i < NN; ++i)
|
||||
for (i = 0; i < nall; ++i)
|
||||
for (int t=0; t<nthreads; t++) b_temp[t][i] = 0.0;
|
||||
|
||||
// Wait for b accumulated and b_temp zeroed.
|
||||
@ -538,7 +536,7 @@ void FixQEqReaxFFOMP::sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
#pragma omp barrier
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (i = 0; i < NN; ++i)
|
||||
for (i = 0; i < nall; ++i)
|
||||
for (int t = 0; t < nthreads; ++t) b[i] += b_temp[t][i];
|
||||
|
||||
} //end omp parallel
|
||||
@ -815,6 +813,8 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x1, double *x
|
||||
int i, j, itr_j;
|
||||
int ii;
|
||||
int indxI, indxJ;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
|
||||
int nthreads = comm->nthreads;
|
||||
#if defined(_OPENMP)
|
||||
@ -838,8 +838,7 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x1, double *x
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (ii = nn; ii < NN; ++ii) {
|
||||
i = ilist[ii];
|
||||
for (i = nlocal; i < nall; ++i) {
|
||||
if (atom->mask[i] & groupbit) {
|
||||
indxI = 2 * i;
|
||||
b[indxI] = 0;
|
||||
@ -850,7 +849,7 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x1, double *x
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (i = 0; i < NN; ++i) {
|
||||
for (i = 0; i < nall; ++i) {
|
||||
indxI = 2 * i;
|
||||
for (int t=0; t<nthreads; t++) {
|
||||
b_temp[t][indxI] = 0.0;
|
||||
@ -884,7 +883,7 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x1, double *x
|
||||
#pragma omp barrier
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (i = 0; i < NN; ++i) {
|
||||
for (i = 0; i < nall; ++i) {
|
||||
indxI = 2 * i;
|
||||
for (int t = 0; t < nthreads; ++t) {
|
||||
b[indxI] += b_temp[t][indxI];
|
||||
@ -906,6 +905,8 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
int i, j, itr_j;
|
||||
int ii;
|
||||
int indxI, indxJ;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
|
||||
int nthreads = comm->nthreads;
|
||||
#if defined(_OPENMP)
|
||||
@ -929,8 +930,7 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (ii = nn; ii < NN; ++ii) {
|
||||
i = ilist[ii];
|
||||
for (i = nlocal; i < nall; ++i) {
|
||||
if (atom->mask[i] & groupbit) {
|
||||
indxI = 2 * i;
|
||||
b[indxI] = 0;
|
||||
@ -941,7 +941,7 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
#if defined(_OPENMP)
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (i = 0; i < NN; ++i) {
|
||||
for (i = 0; i < nall; ++i) {
|
||||
indxI = 2 * i;
|
||||
for (int t=0; t<nthreads; t++) {
|
||||
b_temp[t][indxI] = 0.0;
|
||||
@ -975,7 +975,7 @@ void FixQEqReaxFFOMP::dual_sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
#pragma omp barrier
|
||||
#pragma omp for schedule(dynamic,50)
|
||||
#endif
|
||||
for (i = 0; i < NN; ++i) {
|
||||
for (i = 0; i < nall; ++i) {
|
||||
indxI = 2 * i;
|
||||
for (int t = 0; t < nthreads; ++t) {
|
||||
b[indxI] += b_temp[t][indxI];
|
||||
|
||||
@ -356,7 +356,9 @@ void FixPOEMS::init()
|
||||
for (auto ifix : modify->get_fix_list()) {
|
||||
if (utils::strmatch(ifix->style, "^poems")) pflag = true;
|
||||
if (pflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag)
|
||||
if (comm->me == 0) error->warning(FLERR, "Fix {} alters forces after fix poems", ifix->id);
|
||||
if (comm->me == 0)
|
||||
error->warning(FLERR,"Fix {} with ID {} alters forces after fix poems",
|
||||
ifix->style, ifix->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -203,7 +203,8 @@ void FixACKS2ReaxFF::pertype_parameters(char *arg)
|
||||
void FixACKS2ReaxFF::allocate_storage()
|
||||
{
|
||||
nmax = atom->nmax;
|
||||
int size = nmax*2 + 2;
|
||||
NN = atom->nlocal + atom->nghost;
|
||||
const int size = nmax*2 + 2;
|
||||
|
||||
// 0 to nn-1: owned atoms related to H matrix
|
||||
// nn to NN-1: ghost atoms related to H matrix
|
||||
@ -329,17 +330,15 @@ void FixACKS2ReaxFF::pre_force(int /*vflag*/)
|
||||
{
|
||||
if (update->ntimestep % nevery) return;
|
||||
|
||||
int n = atom->nlocal;
|
||||
NN = atom->nlocal + atom->nghost;
|
||||
|
||||
if (reaxff) {
|
||||
nn = reaxff->list->inum;
|
||||
NN = reaxff->list->inum + reaxff->list->gnum;
|
||||
ilist = reaxff->list->ilist;
|
||||
numneigh = reaxff->list->numneigh;
|
||||
firstneigh = reaxff->list->firstneigh;
|
||||
} else {
|
||||
nn = list->inum;
|
||||
NN = list->inum + list->gnum;
|
||||
ilist = list->ilist;
|
||||
numneigh = list->numneigh;
|
||||
firstneigh = list->firstneigh;
|
||||
@ -349,7 +348,7 @@ void FixACKS2ReaxFF::pre_force(int /*vflag*/)
|
||||
// need to be atom->nmax in length
|
||||
|
||||
if (atom->nmax > nmax) reallocate_storage();
|
||||
if (n > n_cap*DANGER_ZONE || m_fill > m_cap*DANGER_ZONE)
|
||||
if (atom->nlocal > n_cap*DANGER_ZONE || m_fill > m_cap*DANGER_ZONE)
|
||||
reallocate_matrix();
|
||||
|
||||
if (efield) get_chi_field();
|
||||
@ -626,8 +625,7 @@ void FixACKS2ReaxFF::sparse_matvec_acks2(sparse_matrix *H, sparse_matrix *X, dou
|
||||
}
|
||||
}
|
||||
|
||||
for (ii = nn; ii < NN; ++ii) {
|
||||
i = ilist[ii];
|
||||
for (i = atom->nlocal; i < NN; ++i) {
|
||||
if (atom->mask[i] & groupbit) {
|
||||
b[i] = 0;
|
||||
b[NN + i] = 0;
|
||||
@ -674,38 +672,34 @@ void FixACKS2ReaxFF::sparse_matvec_acks2(sparse_matrix *H, sparse_matrix *X, dou
|
||||
|
||||
void FixACKS2ReaxFF::calculate_Q()
|
||||
{
|
||||
int i, k;
|
||||
pack_flag = 2;
|
||||
comm->forward_comm(this); //Dist_vector(s);
|
||||
|
||||
for (int ii = 0; ii < nn; ++ii) {
|
||||
i = ilist[ii];
|
||||
for (int i = 0; i < NN; ++i) {
|
||||
if (atom->mask[i] & groupbit) {
|
||||
|
||||
/* backup s */
|
||||
for (k = nprev-1; k > 0; --k) {
|
||||
s_hist[i][k] = s_hist[i][k-1];
|
||||
s_hist_X[i][k] = s_hist_X[i][k-1];
|
||||
atom->q[i] = s[i];
|
||||
|
||||
if (i < atom->nlocal) {
|
||||
|
||||
/* backup s */
|
||||
for (int k = nprev-1; k > 0; --k) {
|
||||
s_hist[i][k] = s_hist[i][k-1];
|
||||
s_hist_X[i][k] = s_hist_X[i][k-1];
|
||||
}
|
||||
s_hist[i][0] = s[i];
|
||||
s_hist_X[i][0] = s[NN+i];
|
||||
}
|
||||
s_hist[i][0] = s[i];
|
||||
s_hist_X[i][0] = s[NN+i];
|
||||
}
|
||||
}
|
||||
// last two rows
|
||||
if (last_rows_flag) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (k = nprev-1; k > 0; --k)
|
||||
for (int k = nprev-1; k > 0; --k)
|
||||
s_hist_last[i][k] = s_hist_last[i][k-1];
|
||||
s_hist_last[i][0] = s[2*NN+i];
|
||||
}
|
||||
}
|
||||
|
||||
pack_flag = 2;
|
||||
comm->forward_comm(this); //Dist_vector(s);
|
||||
|
||||
for (int ii = 0; ii < NN; ++ii) {
|
||||
i = ilist[ii];
|
||||
if (atom->mask[i] & groupbit)
|
||||
atom->q[i] = s[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -37,7 +37,7 @@ class FixACKS2ReaxFF : public FixQEqReaxFF {
|
||||
double *get_s() { return s; }
|
||||
|
||||
protected:
|
||||
int last_rows_rank, last_rows_flag;
|
||||
int NN, last_rows_rank, last_rows_flag;
|
||||
|
||||
double **s_hist_X, **s_hist_last;
|
||||
double *bcut_acks2, bond_softness, **bcut; // acks2 parameters
|
||||
|
||||
@ -104,7 +104,7 @@ FixQEqReaxFF::FixQEqReaxFF(LAMMPS *lmp, int narg, char **arg) :
|
||||
shld = nullptr;
|
||||
|
||||
nn = n_cap = 0;
|
||||
NN = nmax = 0;
|
||||
nmax = 0;
|
||||
m_fill = m_cap = 0;
|
||||
pack_flag = 0;
|
||||
s = nullptr;
|
||||
@ -319,7 +319,7 @@ void FixQEqReaxFF::reallocate_storage()
|
||||
|
||||
void FixQEqReaxFF::allocate_matrix()
|
||||
{
|
||||
int i,ii,n,m;
|
||||
int i,ii,m;
|
||||
|
||||
int mincap;
|
||||
double safezone;
|
||||
@ -332,8 +332,7 @@ void FixQEqReaxFF::allocate_matrix()
|
||||
safezone = REAX_SAFE_ZONE;
|
||||
}
|
||||
|
||||
n = atom->nlocal;
|
||||
n_cap = MAX((int)(n * safezone), mincap);
|
||||
n_cap = MAX((int)(atom->nlocal * safezone), mincap);
|
||||
|
||||
// determine the total space for the H matrix
|
||||
|
||||
@ -493,13 +492,11 @@ void FixQEqReaxFF::setup_pre_force(int vflag)
|
||||
{
|
||||
if (reaxff) {
|
||||
nn = reaxff->list->inum;
|
||||
NN = reaxff->list->inum + reaxff->list->gnum;
|
||||
ilist = reaxff->list->ilist;
|
||||
numneigh = reaxff->list->numneigh;
|
||||
firstneigh = reaxff->list->firstneigh;
|
||||
} else {
|
||||
nn = list->inum;
|
||||
NN = list->inum + list->gnum;
|
||||
ilist = list->ilist;
|
||||
numneigh = list->numneigh;
|
||||
firstneigh = list->firstneigh;
|
||||
@ -537,7 +534,7 @@ void FixQEqReaxFF::init_storage()
|
||||
{
|
||||
if (efield) get_chi_field();
|
||||
|
||||
for (int ii = 0; ii < NN; ii++) {
|
||||
for (int ii = 0; ii < nn; ii++) {
|
||||
int i = ilist[ii];
|
||||
if (atom->mask[i] & groupbit) {
|
||||
Hdia_inv[i] = 1. / eta[atom->type[i]];
|
||||
@ -561,13 +558,11 @@ void FixQEqReaxFF::pre_force(int /*vflag*/)
|
||||
|
||||
if (reaxff) {
|
||||
nn = reaxff->list->inum;
|
||||
NN = reaxff->list->inum + reaxff->list->gnum;
|
||||
ilist = reaxff->list->ilist;
|
||||
numneigh = reaxff->list->numneigh;
|
||||
firstneigh = reaxff->list->firstneigh;
|
||||
} else {
|
||||
nn = list->inum;
|
||||
NN = list->inum + list->gnum;
|
||||
ilist = list->ilist;
|
||||
numneigh = list->numneigh;
|
||||
firstneigh = list->firstneigh;
|
||||
@ -791,11 +786,9 @@ void FixQEqReaxFF::sparse_matvec(sparse_matrix *A, double *x, double *b)
|
||||
b[i] = eta[atom->type[i]] * x[i];
|
||||
}
|
||||
|
||||
for (ii = nn; ii < NN; ++ii) {
|
||||
i = ilist[ii];
|
||||
if (atom->mask[i] & groupbit)
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
for (i = atom->nlocal; i < nall; ++i)
|
||||
b[i] = 0;
|
||||
}
|
||||
|
||||
for (ii = 0; ii < nn; ++ii) {
|
||||
i = ilist[ii];
|
||||
|
||||
@ -59,7 +59,7 @@ class FixQEqReaxFF : public Fix {
|
||||
protected:
|
||||
int nevery, reaxflag;
|
||||
int matvecs;
|
||||
int nn, NN, m_fill;
|
||||
int nn, m_fill;
|
||||
int n_cap, nmax, m_cap;
|
||||
int pack_flag;
|
||||
int nlevels_respa;
|
||||
|
||||
@ -693,7 +693,8 @@ void FixRigid::init()
|
||||
for (auto ifix : modify->get_fix_list()) {
|
||||
if (ifix->rigid_flag) rflag = true;
|
||||
if ((comm->me == 0) && rflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag)
|
||||
error->warning(FLERR,"Fix {} alters forces after fix rigid", ifix->id);
|
||||
error->warning(FLERR,"Fix {} with ID {} alters forces after fix rigid",
|
||||
ifix->style, ifix->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -538,7 +538,8 @@ void FixRigidSmall::init()
|
||||
for (auto ifix : modify->get_fix_list()) {
|
||||
if (ifix->rigid_flag) rflag = true;
|
||||
if ((comm->me == 0) && rflag && (ifix->setmask() & POST_FORCE) && !ifix->rigid_flag)
|
||||
error->warning(FLERR,"Fix {} alters forces after fix rigid", ifix->id);
|
||||
error->warning(FLERR,"Fix {} with ID {} alters forces after fix rigid/small",
|
||||
ifix->style, ifix->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1916,7 +1916,12 @@ void DumpVTK::identify_vectors()
|
||||
name.count(vector3_starts[v3s]+2) )
|
||||
{
|
||||
std::string vectorName = name[vector3_starts[v3s]];
|
||||
vectorName.erase(vectorName.find_first_of('x'));
|
||||
std::string::size_type erase_start = vectorName.find_first_of('x');
|
||||
if (erase_start == 0) {
|
||||
vectorName.erase(0,1);
|
||||
} else {
|
||||
vectorName.erase(erase_start);
|
||||
}
|
||||
name[vector3_starts[v3s]] = vectorName;
|
||||
vector_set.insert(vector3_starts[v3s]);
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -28,11 +27,9 @@ using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
id_fix(nullptr)
|
||||
ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), id_fix(nullptr)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR,"Illegal compute msd command");
|
||||
if (narg < 3) error->all(FLERR, "Illegal compute msd command");
|
||||
|
||||
vector_flag = 1;
|
||||
size_vector = 4;
|
||||
@ -47,28 +44,33 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
int iarg = 3;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"com") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal compute msd command");
|
||||
comflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
|
||||
if (strcmp(arg[iarg], "com") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command");
|
||||
comflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"average") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal compute msd command");
|
||||
avflag = utils::logical(FLERR,arg[iarg+1],false,lmp);
|
||||
} else if (strcmp(arg[iarg], "average") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal compute msd command");
|
||||
avflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal compute msd command");
|
||||
} else
|
||||
error->all(FLERR, "Illegal compute msd command");
|
||||
}
|
||||
|
||||
if (group->dynamic[igroup])
|
||||
error->all(FLERR, "Compute {} is not compatible with dynamic groups", style);
|
||||
|
||||
// create a new fix STORE style for reference positions
|
||||
// id = compute-ID + COMPUTE_STORE, fix group = compute group
|
||||
|
||||
id_fix = utils::strdup(id + std::string("_COMPUTE_STORE"));
|
||||
fix = (FixStore *) modify->add_fix(fmt::format("{} {} STORE peratom 1 3",
|
||||
id_fix, group->names[igroup]));
|
||||
fix = (FixStore *) modify->add_fix(
|
||||
fmt::format("{} {} STORE peratom 1 3", id_fix, group->names[igroup]));
|
||||
|
||||
// calculate xu,yu,zu for fix store array
|
||||
// skip if reset from restart file
|
||||
|
||||
if (fix->restart_reset) fix->restart_reset = 0;
|
||||
if (fix->restart_reset)
|
||||
fix->restart_reset = 0;
|
||||
else {
|
||||
double **xoriginal = fix->astore;
|
||||
|
||||
@ -78,15 +80,17 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) domain->unmap(x[i],image[i],xoriginal[i]);
|
||||
else xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
|
||||
if (mask[i] & groupbit)
|
||||
domain->unmap(x[i], image[i], xoriginal[i]);
|
||||
else
|
||||
xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
|
||||
|
||||
// adjust for COM if requested
|
||||
|
||||
if (comflag) {
|
||||
double cm[3];
|
||||
masstotal = group->mass(igroup);
|
||||
group->xcm(igroup,masstotal,cm);
|
||||
group->xcm(igroup, masstotal, cm);
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
xoriginal[i][0] -= cm[0];
|
||||
@ -124,7 +128,7 @@ void ComputeMSD::init()
|
||||
// set fix which stores reference atom coords
|
||||
|
||||
fix = (FixStore *) modify->get_fix_by_id(id_fix);
|
||||
if (!fix) error->all(FLERR,"Could not find compute msd fix with ID {}", id_fix);
|
||||
if (!fix) error->all(FLERR, "Could not find compute msd fix with ID {}", id_fix);
|
||||
|
||||
// nmsd = # of atoms in group
|
||||
|
||||
@ -141,8 +145,10 @@ void ComputeMSD::compute_vector()
|
||||
// cm = current center of mass
|
||||
|
||||
double cm[3];
|
||||
if (comflag) group->xcm(igroup,masstotal,cm);
|
||||
else cm[0] = cm[1] = cm[2] = 0.0;
|
||||
if (comflag)
|
||||
group->xcm(igroup, masstotal, cm);
|
||||
else
|
||||
cm[0] = cm[1] = cm[2] = 0.0;
|
||||
|
||||
// dx,dy,dz = displacement of atom from reference position
|
||||
// reference unwrapped position is stored by fix
|
||||
@ -161,8 +167,8 @@ void ComputeMSD::compute_vector()
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
|
||||
double dx,dy,dz;
|
||||
int xbox,ybox,zbox;
|
||||
double dx, dy, dz;
|
||||
int xbox, ybox, zbox;
|
||||
|
||||
double msd[4];
|
||||
msd[0] = msd[1] = msd[2] = msd[3] = 0.0;
|
||||
@ -174,36 +180,34 @@ void ComputeMSD::compute_vector()
|
||||
double navfac;
|
||||
if (avflag) {
|
||||
naverage++;
|
||||
navfac = 1.0/(naverage+1);
|
||||
navfac = 1.0 / (naverage + 1);
|
||||
}
|
||||
|
||||
|
||||
if (domain->triclinic == 0) {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
||||
xtmp = x[i][0] + xbox*xprd - cm[0];
|
||||
ytmp = x[i][1] + ybox*yprd - cm[1];
|
||||
ztmp = x[i][2] + zbox*zprd - cm[2];
|
||||
xtmp = x[i][0] + xbox * xprd - cm[0];
|
||||
ytmp = x[i][1] + ybox * yprd - cm[1];
|
||||
ztmp = x[i][2] + zbox * zprd - cm[2];
|
||||
|
||||
// use running average position for reference if requested
|
||||
|
||||
if (avflag) {
|
||||
xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac;
|
||||
xoriginal[i][1] = (xoriginal[i][1]*naverage + ytmp)*navfac;
|
||||
xoriginal[i][2] = (xoriginal[i][2]*naverage + ztmp)*navfac;
|
||||
xoriginal[i][0] = (xoriginal[i][0] * naverage + xtmp) * navfac;
|
||||
xoriginal[i][1] = (xoriginal[i][1] * naverage + ytmp) * navfac;
|
||||
xoriginal[i][2] = (xoriginal[i][2] * naverage + ztmp) * navfac;
|
||||
}
|
||||
|
||||
dx = xtmp - xoriginal[i][0];
|
||||
dy = ytmp - xoriginal[i][1];
|
||||
dz = ztmp - xoriginal[i][2];
|
||||
msd[0] += dx*dx;
|
||||
msd[1] += dy*dy;
|
||||
msd[2] += dz*dz;
|
||||
msd[3] += dx*dx + dy*dy + dz*dz;
|
||||
|
||||
msd[0] += dx * dx;
|
||||
msd[1] += dy * dy;
|
||||
msd[2] += dz * dz;
|
||||
msd[3] += dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
@ -211,29 +215,29 @@ void ComputeMSD::compute_vector()
|
||||
xbox = (image[i] & IMGMASK) - IMGMAX;
|
||||
ybox = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
|
||||
zbox = (image[i] >> IMG2BITS) - IMGMAX;
|
||||
xtmp = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox - cm[0];
|
||||
ytmp = x[i][1] + h[1]*ybox + h[3]*zbox - cm[1];
|
||||
ztmp = x[i][2] + h[2]*zbox - cm[2];
|
||||
xtmp = x[i][0] + h[0] * xbox + h[5] * ybox + h[4] * zbox - cm[0];
|
||||
ytmp = x[i][1] + h[1] * ybox + h[3] * zbox - cm[1];
|
||||
ztmp = x[i][2] + h[2] * zbox - cm[2];
|
||||
|
||||
// use running average position for reference if requested
|
||||
|
||||
if (avflag) {
|
||||
xoriginal[i][0] = (xoriginal[i][0]*naverage + xtmp)*navfac;
|
||||
xoriginal[i][1] = (xoriginal[i][0]*naverage + xtmp)*navfac;
|
||||
xoriginal[i][2] = (xoriginal[i][0]*naverage + xtmp)*navfac;
|
||||
xoriginal[i][0] = (xoriginal[i][0] * naverage + xtmp) * navfac;
|
||||
xoriginal[i][1] = (xoriginal[i][0] * naverage + xtmp) * navfac;
|
||||
xoriginal[i][2] = (xoriginal[i][0] * naverage + xtmp) * navfac;
|
||||
}
|
||||
|
||||
dx = xtmp - xoriginal[i][0];
|
||||
dy = ytmp - xoriginal[i][1];
|
||||
dz = ztmp - xoriginal[i][2];
|
||||
msd[0] += dx*dx;
|
||||
msd[1] += dy*dy;
|
||||
msd[2] += dz*dz;
|
||||
msd[3] += dx*dx + dy*dy + dz*dz;
|
||||
msd[0] += dx * dx;
|
||||
msd[1] += dy * dy;
|
||||
msd[2] += dz * dz;
|
||||
msd[3] += dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
}
|
||||
|
||||
MPI_Allreduce(msd,vector,4,MPI_DOUBLE,MPI_SUM,world);
|
||||
MPI_Allreduce(msd, vector, 4, MPI_DOUBLE, MPI_SUM, world);
|
||||
if (nmsd) {
|
||||
vector[0] /= nmsd;
|
||||
vector[1] /= nmsd;
|
||||
|
||||
66
src/dump.cpp
66
src/dump.cpp
@ -150,19 +150,19 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
|
||||
|
||||
Dump::~Dump()
|
||||
{
|
||||
delete [] id;
|
||||
delete [] style;
|
||||
delete [] filename;
|
||||
delete [] multiname;
|
||||
delete[] id;
|
||||
delete[] style;
|
||||
delete[] filename;
|
||||
delete[] multiname;
|
||||
|
||||
delete [] format;
|
||||
delete [] format_default;
|
||||
delete [] format_line_user;
|
||||
delete [] format_float_user;
|
||||
delete [] format_int_user;
|
||||
delete [] format_bigint_user;
|
||||
delete[] format;
|
||||
delete[] format_default;
|
||||
delete[] format_line_user;
|
||||
delete[] format_float_user;
|
||||
delete[] format_int_user;
|
||||
delete[] format_bigint_user;
|
||||
|
||||
delete [] refresh;
|
||||
delete[] refresh;
|
||||
|
||||
// format_column_user is deallocated by child classes that use it
|
||||
|
||||
@ -1019,7 +1019,7 @@ void Dump::balance()
|
||||
memory->destroy(tmp);
|
||||
memory->destroy(proc_offsets);
|
||||
memory->destroy(proc_new_offsets);
|
||||
delete [] request;
|
||||
delete[] request;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1059,7 +1059,7 @@ void Dump::modify_params(int narg, char **arg)
|
||||
if (strcmp(id,output->dump[idump]->id) == 0) break;
|
||||
int n;
|
||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
|
||||
delete [] output->var_dump[idump];
|
||||
delete[] output->var_dump[idump];
|
||||
output->var_dump[idump] = utils::strdup(&arg[iarg+1][2]);
|
||||
n = 0;
|
||||
} else {
|
||||
@ -1077,7 +1077,7 @@ void Dump::modify_params(int narg, char **arg)
|
||||
if (strcmp(id,output->dump[idump]->id) == 0) break;
|
||||
double delta;
|
||||
if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
|
||||
delete [] output->var_dump[idump];
|
||||
delete[] output->var_dump[idump];
|
||||
output->var_dump[idump] = utils::strdup(&arg[iarg+1][2]);
|
||||
delta = 0.0;
|
||||
} else {
|
||||
@ -1107,7 +1107,7 @@ void Dump::modify_params(int narg, char **arg)
|
||||
MPI_Comm_free(&clustercomm);
|
||||
MPI_Comm_split(world,icluster,0,&clustercomm);
|
||||
|
||||
delete [] multiname;
|
||||
delete[] multiname;
|
||||
char *ptr = strchr(filename,'%');
|
||||
*ptr = '\0';
|
||||
multiname = utils::strdup(fmt::format("{}{}{}", filename, icluster, ptr+1));
|
||||
@ -1124,14 +1124,38 @@ void Dump::modify_params(int narg, char **arg)
|
||||
flush_flag = utils::logical(FLERR,arg[iarg+1],false,lmp);
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg],"colname") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command");
|
||||
if (strcmp(arg[iarg+1],"default") == 0) {
|
||||
for (auto item : keyword_user) item.clear();
|
||||
iarg += 2;
|
||||
} else {
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal dump_modify command");
|
||||
int icol = -1;
|
||||
if (utils::is_integer(arg[iarg + 1])) {
|
||||
icol = utils::inumeric(FLERR,arg[iarg + 1],false,lmp);
|
||||
if (icol < 0) icol = keyword_user.size() + icol + 1;
|
||||
icol--;
|
||||
} else {
|
||||
try {
|
||||
icol = key2col.at(arg[iarg + 1]);
|
||||
} catch (std::out_of_range &) {
|
||||
icol = -1;
|
||||
}
|
||||
}
|
||||
if ((icol < 0) || (icol >= (int)keyword_user.size()))
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
keyword_user[icol] = arg[iarg+2];
|
||||
iarg += 3;
|
||||
}
|
||||
} else if (strcmp(arg[iarg],"format") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command");
|
||||
|
||||
if (strcmp(arg[iarg+1],"none") == 0) {
|
||||
delete [] format_line_user;
|
||||
delete [] format_int_user;
|
||||
delete [] format_bigint_user;
|
||||
delete [] format_float_user;
|
||||
delete[] format_line_user;
|
||||
delete[] format_int_user;
|
||||
delete[] format_bigint_user;
|
||||
delete[] format_float_user;
|
||||
format_line_user = nullptr;
|
||||
format_int_user = nullptr;
|
||||
format_bigint_user = nullptr;
|
||||
@ -1146,7 +1170,7 @@ void Dump::modify_params(int narg, char **arg)
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal dump_modify command");
|
||||
|
||||
if (strcmp(arg[iarg+1],"line") == 0) {
|
||||
delete [] format_line_user;
|
||||
delete[] format_line_user;
|
||||
format_line_user = utils::strdup(arg[iarg+2]);
|
||||
iarg += 3;
|
||||
} else { // pass other format options to child classes
|
||||
@ -1204,7 +1228,7 @@ void Dump::modify_params(int narg, char **arg)
|
||||
MPI_Comm_free(&clustercomm);
|
||||
MPI_Comm_split(world,icluster,0,&clustercomm);
|
||||
|
||||
delete [] multiname;
|
||||
delete[] multiname;
|
||||
char *ptr = strchr(filename,'%');
|
||||
*ptr = '\0';
|
||||
multiname = utils::strdup(fmt::format("{}{}{}", filename, icluster, ptr+1));
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
|
||||
#include "pointers.h" // IWYU pragma: export
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class Dump : protected Pointers {
|
||||
@ -100,6 +102,8 @@ class Dump : protected Pointers {
|
||||
char *format_bigint_user;
|
||||
char **format_column_user;
|
||||
enum { INT, DOUBLE, STRING, BIGINT };
|
||||
std::map<std::string, int> key2col;
|
||||
std::vector<std::string> keyword_user;
|
||||
|
||||
FILE *fp; // file to write dump to
|
||||
int size_one; // # of quantities for one atom
|
||||
|
||||
@ -38,6 +38,9 @@ DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
|
||||
buffer_allow = 1;
|
||||
buffer_flag = 1;
|
||||
format_default = nullptr;
|
||||
key2col = { { "id", 0 }, { "type", 1 }, { "x", 2 }, { "y", 3 },
|
||||
{ "z", 4 }, { "ix", 5 }, { "iy", 6 }, { "iz", 7 } };
|
||||
keyword_user = { "", "", "", "", "", "", "", "" };
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -64,14 +67,25 @@ void DumpAtom::init_style()
|
||||
|
||||
// setup column string
|
||||
|
||||
std::string default_columns;
|
||||
|
||||
if (scale_flag == 0 && image_flag == 0)
|
||||
columns = (char *) "id type x y z";
|
||||
default_columns = "id type x y z";
|
||||
else if (scale_flag == 0 && image_flag == 1)
|
||||
columns = (char *) "id type x y z ix iy iz";
|
||||
default_columns = "id type x y z ix iy iz";
|
||||
else if (scale_flag == 1 && image_flag == 0)
|
||||
columns = (char *) "id type xs ys zs";
|
||||
default_columns = "id type xs ys zs";
|
||||
else if (scale_flag == 1 && image_flag == 1)
|
||||
columns = (char *) "id type xs ys zs ix iy iz";
|
||||
default_columns = "id type xs ys zs ix iy iz";
|
||||
|
||||
int icol = 0;
|
||||
columns.clear();
|
||||
for (auto item : utils::split_words(default_columns)) {
|
||||
if (columns.size()) columns += " ";
|
||||
if (keyword_user[icol].size()) columns += keyword_user[icol];
|
||||
else columns += item;
|
||||
++icol;
|
||||
}
|
||||
|
||||
// setup function ptrs
|
||||
|
||||
@ -201,9 +215,9 @@ void DumpAtom::header_unit_style_binary()
|
||||
|
||||
void DumpAtom::header_columns_binary()
|
||||
{
|
||||
int len = strlen(columns);
|
||||
int len = columns.size();
|
||||
fwrite(&len, sizeof(int), 1, fp);
|
||||
fwrite(columns, sizeof(char), len, fp);
|
||||
fwrite(columns.c_str(), sizeof(char), len, fp);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -293,9 +307,7 @@ void DumpAtom::header_item(bigint ndump)
|
||||
}
|
||||
if (time_flag) fmt::print(fp,"ITEM: TIME\n{:.16}\n",compute_time());
|
||||
|
||||
fmt::print(fp,"ITEM: TIMESTEP\n{}\n"
|
||||
"ITEM: NUMBER OF ATOMS\n{}\n",
|
||||
update->ntimestep, ndump);
|
||||
fmt::print(fp, "ITEM: TIMESTEP\n{}\nITEM: NUMBER OF ATOMS\n{}\n", update->ntimestep, ndump);
|
||||
|
||||
fmt::print(fp,"ITEM: BOX BOUNDS {}\n"
|
||||
"{:>1.16e} {:>1.16e}\n"
|
||||
@ -316,9 +328,7 @@ void DumpAtom::header_item_triclinic(bigint ndump)
|
||||
}
|
||||
if (time_flag) fmt::print(fp,"ITEM: TIME\n{:.16}\n",compute_time());
|
||||
|
||||
fmt::print(fp,"ITEM: TIMESTEP\n{}\n"
|
||||
"ITEM: NUMBER OF ATOMS\n{}\n",
|
||||
update->ntimestep, ndump);
|
||||
fmt::print(fp, "ITEM: TIMESTEP\n{}\nITEM: NUMBER OF ATOMS\n{}\n", update->ntimestep, ndump);
|
||||
|
||||
fmt::print(fp,"ITEM: BOX BOUNDS xy xz yz {}\n"
|
||||
"{:>1.16e} {:>1.16e} {:>1.16e}\n"
|
||||
|
||||
@ -36,7 +36,7 @@ class DumpAtom : public Dump {
|
||||
int scale_flag; // 1 if atom coords are scaled, 0 if no
|
||||
int image_flag; // 1 if append box count to atom coords, 0 if no
|
||||
|
||||
char *columns; // column labels
|
||||
std::string columns; // column labels
|
||||
|
||||
void init_style() override;
|
||||
int modify_param(int, char **) override;
|
||||
|
||||
@ -53,26 +53,26 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
if (strcmp(earg[2],"xs") == 0) {
|
||||
if (strcmp(earg[3],"ysu") == 0 || strcmp(earg[4],"zsu") == 0)
|
||||
error->all(FLERR,
|
||||
"Dump cfg arguments can not mix xs|ys|zs with xsu|ysu|zsu");
|
||||
error->all(FLERR,"Dump cfg arguments can not mix xs|ys|zs with xsu|ysu|zsu");
|
||||
unwrapflag = 0;
|
||||
} else {
|
||||
if (strcmp(earg[3],"ys") == 0 || strcmp(earg[4],"zs") == 0)
|
||||
error->all(FLERR,
|
||||
"Dump cfg arguments can not mix xs|ys|zs with xsu|ysu|zsu");
|
||||
error->all(FLERR,"Dump cfg arguments can not mix xs|ys|zs with xsu|ysu|zsu");
|
||||
unwrapflag = 1;
|
||||
}
|
||||
|
||||
// setup auxiliary property name strings
|
||||
// convert 'X_ID[m]' (X=c,f,v) to 'X_ID_m'
|
||||
|
||||
if (nfield > 5) auxname = new char*[nfield];
|
||||
if (nfield > 5) auxname = new char*[nfield-5];
|
||||
else auxname = nullptr;
|
||||
|
||||
int i = 0;
|
||||
key2col.clear();
|
||||
keyword_user.resize(nfield-5);
|
||||
for (int iarg = 5; iarg < nfield; iarg++, i++) {
|
||||
ArgInfo argi(earg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
||||
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||
ArgInfo argi(earg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE|
|
||||
ArgInfo::DNAME|ArgInfo::INAME);
|
||||
|
||||
if (argi.get_dim() == 1) {
|
||||
std::string newarg = fmt::format("{}_{}_{}", earg[iarg][0], argi.get_name(), argi.get_index1());
|
||||
@ -80,6 +80,8 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
|
||||
} else {
|
||||
auxname[i] = utils::strdup(earg[iarg]);
|
||||
}
|
||||
key2col[earg[iarg]] = i;
|
||||
keyword_user[i].clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,8 +90,8 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
|
||||
DumpCFG::~DumpCFG()
|
||||
{
|
||||
if (auxname) {
|
||||
for (int i = 0; i < nfield-5; i++) delete [] auxname[i];
|
||||
delete [] auxname;
|
||||
for (int i = 0; i < nfield-5; i++) delete[] auxname[i];
|
||||
delete[] auxname;
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,7 +139,10 @@ void DumpCFG::write_header(bigint n)
|
||||
header += fmt::format(".NO_VELOCITY.\n");
|
||||
header += fmt::format("entry_count = {}\n",nfield-2);
|
||||
for (int i = 0; i < nfield-5; i++)
|
||||
header += fmt::format("auxiliary[{}] = {}\n",i,auxname[i]);
|
||||
if (keyword_user[i].size())
|
||||
header += fmt::format("auxiliary[{}] = {}\n",i,keyword_user[i]);
|
||||
else
|
||||
header += fmt::format("auxiliary[{}] = {}\n",i,auxname[i]);
|
||||
fmt::print(fp, header);
|
||||
}
|
||||
|
||||
|
||||
@ -55,14 +55,11 @@ enum{LT,LE,GT,GE,EQ,NEQ,XOR};
|
||||
DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
|
||||
Dump(lmp, narg, arg),
|
||||
idregion(nullptr), thresh_array(nullptr), thresh_op(nullptr), thresh_value(nullptr),
|
||||
thresh_last(nullptr), thresh_fix(nullptr),
|
||||
thresh_fixID(nullptr), thresh_first(nullptr),
|
||||
earg(nullptr), vtype(nullptr), vformat(nullptr), columns(nullptr), choose(nullptr),
|
||||
dchoose(nullptr), clist(nullptr), field2index(nullptr),
|
||||
argindex(nullptr), id_compute(nullptr),
|
||||
compute(nullptr), id_fix(nullptr), fix(nullptr),
|
||||
id_variable(nullptr), variable(nullptr),
|
||||
vbuf(nullptr), id_custom(nullptr), custom(nullptr), custom_flag(nullptr),
|
||||
thresh_last(nullptr), thresh_fix(nullptr), thresh_fixID(nullptr), thresh_first(nullptr),
|
||||
earg(nullptr), vtype(nullptr), vformat(nullptr), columns(nullptr), columns_default(nullptr),
|
||||
choose(nullptr), dchoose(nullptr), clist(nullptr), field2index(nullptr), argindex(nullptr),
|
||||
id_compute(nullptr), compute(nullptr), id_fix(nullptr), fix(nullptr), id_variable(nullptr),
|
||||
variable(nullptr), vbuf(nullptr), id_custom(nullptr), custom(nullptr), custom_flag(nullptr),
|
||||
typenames(nullptr), pack_choice(nullptr)
|
||||
{
|
||||
if (narg == 5) error->all(FLERR,"No dump custom arguments specified");
|
||||
@ -180,13 +177,14 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
|
||||
// setup column string
|
||||
|
||||
cols.clear();
|
||||
keyword_user.resize(nfield);
|
||||
for (int iarg = 0; iarg < nfield; iarg++) {
|
||||
key2col[earg[iarg]] = iarg;
|
||||
keyword_user[iarg].clear();
|
||||
if (cols.size()) cols += " ";
|
||||
cols += earg[iarg];
|
||||
cols += " ";
|
||||
}
|
||||
// remove trailing blank and copy
|
||||
cols.resize(cols.size()-1);
|
||||
columns = utils::strdup(cols);
|
||||
columns_default = utils::strdup(cols);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -257,6 +255,7 @@ DumpCustom::~DumpCustom()
|
||||
delete[] format_column_user;
|
||||
}
|
||||
|
||||
delete[] columns_default;
|
||||
delete[] columns;
|
||||
}
|
||||
|
||||
@ -264,6 +263,19 @@ DumpCustom::~DumpCustom()
|
||||
|
||||
void DumpCustom::init_style()
|
||||
{
|
||||
// assemble ITEMS: column string from defaults and user values
|
||||
|
||||
delete[] columns;
|
||||
std::string combined;
|
||||
int icol = 0;
|
||||
for (auto item : utils::split_words(columns_default)) {
|
||||
if (combined.size()) combined += " ";
|
||||
if (keyword_user[icol].size()) combined += keyword_user[icol];
|
||||
else combined += item;
|
||||
++icol;
|
||||
}
|
||||
columns = utils::strdup(combined);
|
||||
|
||||
// format = copy of default or user-specified line format
|
||||
|
||||
delete[] format;
|
||||
|
||||
@ -60,6 +60,7 @@ class DumpCustom : public Dump {
|
||||
char **vformat; // format string for each vector element
|
||||
//
|
||||
char *columns; // column labels
|
||||
char *columns_default;
|
||||
//
|
||||
int nchoose; // # of selected atoms
|
||||
int maxlocal; // size of atom selection and variable arrays
|
||||
|
||||
852
src/fix_move.cpp
852
src/fix_move.cpp
File diff suppressed because it is too large
Load Diff
@ -249,11 +249,11 @@ void Modify::init()
|
||||
|
||||
for (i = 0; i < nfix; i++)
|
||||
if (!fix[i]->dynamic_group_allow && group->dynamic[fix[i]->igroup])
|
||||
error->all(FLERR, "Fix {} does not allow use with a dynamic group", fix[i]->id);
|
||||
error->all(FLERR, "Fix {} does not allow use with a dynamic group", fix[i]->style);
|
||||
|
||||
for (i = 0; i < ncompute; i++)
|
||||
if (!compute[i]->dynamic_group_allow && group->dynamic[compute[i]->igroup])
|
||||
error->all(FLERR, "Compute {} does not allow use with a dynamic group", compute[i]->id);
|
||||
error->all(FLERR, "Compute {} does not allow use with a dynamic group", compute[i]->style);
|
||||
|
||||
// warn if any particle is time integrated more than once
|
||||
|
||||
|
||||
@ -252,8 +252,12 @@ void Thermo::init()
|
||||
format[i] += format_this + " ";
|
||||
else if (lineflag == YAMLLINE)
|
||||
format[i] += format_this + ", ";
|
||||
else
|
||||
format[i] += fmt::format("{:<8} = {} ", keyword[i], format_this);
|
||||
else {
|
||||
if (keyword_user[i].size())
|
||||
format[i] += fmt::format("{:<8} = {} ", keyword_user[i], format_this);
|
||||
else
|
||||
format[i] += fmt::format("{:<8} = {} ", keyword[i], format_this);
|
||||
}
|
||||
}
|
||||
|
||||
// chop off trailing blank or add closing bracket if needed and then add newline
|
||||
@ -324,11 +328,13 @@ void Thermo::header()
|
||||
std::string hdr;
|
||||
if (lineflag == YAMLLINE) hdr = "---\nkeywords: [";
|
||||
for (int i = 0; i < nfield; i++) {
|
||||
auto head = keyword[i];
|
||||
if (keyword_user[i].size()) head = keyword_user[i];
|
||||
if (lineflag == ONELINE) {
|
||||
if (vtype[i] == FLOAT)
|
||||
hdr += fmt::format("{:^14} ", keyword[i]);
|
||||
hdr += fmt::format("{:^14} ", head);
|
||||
else if ((vtype[i] == INT) || (vtype[i] == BIGINT))
|
||||
hdr += fmt::format("{:^11} ", keyword[i]);
|
||||
hdr += fmt::format("{:^11} ", head);
|
||||
} else if (lineflag == YAMLLINE) {
|
||||
hdr += keyword[i];
|
||||
hdr += ", ";
|
||||
@ -622,6 +628,29 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
error->all(FLERR, "Illegal thermo_modify command");
|
||||
iarg += 2;
|
||||
|
||||
} else if (strcmp(arg[iarg], "colname") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
if (strcmp(arg[iarg + 1], "default") == 0) {
|
||||
for (auto item : keyword_user) item.clear();
|
||||
iarg += 2;
|
||||
} else {
|
||||
if (iarg + 3 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
int icol = -1;
|
||||
if (utils::is_integer(arg[iarg + 1])) {
|
||||
icol = utils::inumeric(FLERR,arg[iarg + 1],false,lmp);
|
||||
if (icol < 0) icol = nfield_initial + icol + 1;
|
||||
icol--;
|
||||
} else {
|
||||
try {
|
||||
icol = key2col.at(arg[iarg + 1]);
|
||||
} catch (std::out_of_range &) {
|
||||
icol = -1;
|
||||
}
|
||||
}
|
||||
if ((icol < 0) || (icol >= nfield_initial)) error->all(FLERR, "Illegal thermo_modify command");
|
||||
keyword_user[icol] = arg[iarg+2];
|
||||
iarg += 3;
|
||||
}
|
||||
} else if (strcmp(arg[iarg], "format") == 0) {
|
||||
if (iarg + 2 > narg) error->all(FLERR, "Illegal thermo_modify command");
|
||||
|
||||
@ -630,7 +659,7 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
format_int_user.clear();
|
||||
format_bigint_user.clear();
|
||||
format_float_user.clear();
|
||||
for (int i = 0; i < nfield_initial + 1; ++i) format_column_user[i].clear();
|
||||
for (auto item : format_column_user) item.clear();
|
||||
iarg += 2;
|
||||
continue;
|
||||
}
|
||||
@ -646,14 +675,24 @@ void Thermo::modify_params(int narg, char **arg)
|
||||
found = format_int_user.find('d', found);
|
||||
if (found == std::string::npos)
|
||||
error->all(FLERR, "Thermo_modify int format does not contain a d conversion character");
|
||||
format_bigint_user =
|
||||
format_int_user.replace(found, 1, std::string(BIGINT_FORMAT).substr(1));
|
||||
format_bigint_user = format_int_user.replace(found, 1, std::string(BIGINT_FORMAT).substr(1));
|
||||
} else if (strcmp(arg[iarg + 1], "float") == 0) {
|
||||
format_float_user = arg[iarg + 2];
|
||||
} else {
|
||||
int i = utils::inumeric(FLERR, arg[iarg + 1], false, lmp) - 1;
|
||||
if (i < 0 || i >= nfield_initial + 1) error->all(FLERR, "Illegal thermo_modify command");
|
||||
format_column_user[i] = arg[iarg + 2];
|
||||
int icol = -1;
|
||||
if (utils::is_integer(arg[iarg + 1])) {
|
||||
icol = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
|
||||
if (icol < 0) icol = nfield_initial + icol + 1;
|
||||
icol--;
|
||||
} else {
|
||||
try {
|
||||
icol = key2col.at(arg[iarg + 1]);
|
||||
} catch (std::out_of_range &) {
|
||||
icol = -1;
|
||||
}
|
||||
}
|
||||
if (icol < 0 || icol >= nfield_initial + 1) error->all(FLERR, "Illegal thermo_modify command");
|
||||
format_column_user[icol] = arg[iarg + 2];
|
||||
}
|
||||
iarg += 3;
|
||||
|
||||
@ -675,10 +714,12 @@ void Thermo::allocate()
|
||||
keyword.resize(n);
|
||||
format.resize(n);
|
||||
format_column_user.resize(n);
|
||||
keyword_user.resize(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
keyword[i].clear();
|
||||
format[i].clear();
|
||||
format_column_user[i].clear();
|
||||
keyword_user[i].clear();
|
||||
}
|
||||
|
||||
vfunc = new FnPtr[n];
|
||||
@ -702,6 +743,12 @@ void Thermo::allocate()
|
||||
nvariable = 0;
|
||||
id_variable = new char *[n];
|
||||
variables = new int[n];
|
||||
|
||||
int i = 0;
|
||||
key2col.clear();
|
||||
for (auto item : utils::split_words(line)) {
|
||||
key2col[item] = i++;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#define LMP_THERMO_H
|
||||
|
||||
#include "pointers.h"
|
||||
#include <map>
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
@ -47,8 +48,9 @@ class Thermo : protected Pointers {
|
||||
int nfield, nfield_initial;
|
||||
int *vtype;
|
||||
std::string line;
|
||||
std::vector<std::string> keyword, format, format_column_user;
|
||||
std::vector<std::string> keyword, format, format_column_user, keyword_user;
|
||||
std::string format_line_user, format_float_user, format_int_user, format_bigint_user;
|
||||
std::map<std::string, int> key2col;
|
||||
|
||||
int normvalue; // use this for normflag unless natoms = 0
|
||||
int normuserflag; // 0 if user has not set, 1 if has
|
||||
|
||||
Reference in New Issue
Block a user