forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@255 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
209f169cbc
commit
284c1f2d04
|
@ -0,0 +1,51 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_LJ_CLASS2_COUL_LONG_H
|
||||
#define PAIR_LJ_CLASS2_COUL_LONG_H
|
||||
|
||||
#include "pair.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairLJClass2CoulLong : public Pair {
|
||||
public:
|
||||
PairLJClass2CoulLong(class LAMMPS *);
|
||||
~PairLJClass2CoulLong();
|
||||
void compute(int, int);
|
||||
void settings(int, char **);
|
||||
void coeff(int, char **);
|
||||
double init_one(int, int);
|
||||
void init_style();
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
void write_restart_settings(FILE *);
|
||||
void read_restart_settings(FILE *);
|
||||
void single(int, int, int, int, double, double, double, int, One &);
|
||||
|
||||
void extract_long(double *);
|
||||
|
||||
private:
|
||||
double cut_lj_global;
|
||||
double **cut_lj,**cut_ljsq;
|
||||
double cut_coul,cut_coulsq;
|
||||
double **epsilon,**sigma;
|
||||
double **lj1,**lj2,**lj3,**lj4,**offset;
|
||||
double g_ewald;
|
||||
|
||||
void allocate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,212 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "atom_vec_dpd.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecDPD::AtomVecDPD(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVecAtomic(lmp, narg, arg)
|
||||
{
|
||||
mass_type = 1;
|
||||
comm_x_only = 0;
|
||||
size_comm = 6;
|
||||
size_reverse = 3;
|
||||
size_border = 9;
|
||||
size_data_atom = 5;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 3;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for n ghost atoms
|
||||
data in border(), not including x,tag,type,mask
|
||||
grow() is here since zero_ghost called first in hybrid::unpack_border()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecDPD::zero_ghost(int n, int first)
|
||||
{
|
||||
int last = first + n;
|
||||
for (int i = first; i < last; i++) {
|
||||
if (i == nmax) atom->avec->grow(0);
|
||||
v[i][0] = 0.0;
|
||||
v[i][1] = 0.0;
|
||||
v[i][2] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecDPD::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecDPD::pack_comm_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = v[i][0];
|
||||
buf[1] = v[i][1];
|
||||
buf[2] = v[i][2];
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecDPD::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
v[i][0] = buf[m++];
|
||||
v[i][1] = buf[m++];
|
||||
v[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecDPD::unpack_comm_one(int i, double *buf)
|
||||
{
|
||||
v[i][0] = buf[0];
|
||||
v[i][1] = buf[1];
|
||||
v[i][2] = buf[2];
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecDPD::pack_border(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecDPD::pack_border_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = v[i][0];
|
||||
buf[1] = v[i][1];
|
||||
buf[2] = v[i][2];
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecDPD::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
v[i][0] = buf[m++];
|
||||
v[i][1] = buf[m++];
|
||||
v[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecDPD::unpack_border_one(int i, double *buf)
|
||||
{
|
||||
v[i][0] = buf[0];
|
||||
v[i][1] = buf[1];
|
||||
v[i][2] = buf[2];
|
||||
return 3;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_DPD_H
|
||||
#define ATOM_VEC_DPD_H
|
||||
|
||||
#include "atom_vec_atomic.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecDPD : public AtomVecAtomic {
|
||||
public:
|
||||
AtomVecDPD(class LAMMPS *, int, char **);
|
||||
void zero_ghost(int, int);
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
int pack_comm_one(int, double *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int unpack_comm_one(int, double *);
|
||||
int pack_border(int, int *, double *, int *);
|
||||
int pack_border_one(int, double *);
|
||||
void unpack_border(int, int, double *);
|
||||
int unpack_border_one(int, double *);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,744 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "math.h"
|
||||
#include "stdlib.h"
|
||||
#include "atom_vec_granular.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "force.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecGranular::AtomVecGranular(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVec(lmp, narg, arg)
|
||||
{
|
||||
comm_x_only = comm_f_only = 0;
|
||||
size_comm = 9;
|
||||
size_reverse = 6;
|
||||
size_border = 14;
|
||||
size_data_atom = 7;
|
||||
size_data_vel = 7;
|
||||
xcol_data = 5;
|
||||
|
||||
PI = 4.0*atan(1.0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by DELTA
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::grow(int n)
|
||||
{
|
||||
if (n == 0) nmax += DELTA;
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
|
||||
tag = atom->tag = (int *)
|
||||
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
|
||||
type = atom->type = (int *)
|
||||
memory->srealloc(atom->type,nmax*sizeof(int),"atom:type");
|
||||
mask = atom->mask = (int *)
|
||||
memory->srealloc(atom->mask,nmax*sizeof(int),"atom:mask");
|
||||
image = atom->image = (int *)
|
||||
memory->srealloc(atom->image,nmax*sizeof(int),"atom:image");
|
||||
x = atom->x = memory->grow_2d_double_array(atom->x,nmax,3,"atom:x");
|
||||
v = atom->v = memory->grow_2d_double_array(atom->v,nmax,3,"atom:v");
|
||||
f = atom->f = memory->grow_2d_double_array(atom->f,nmax,3,"atom:f");
|
||||
|
||||
radius = atom->radius = (double *)
|
||||
memory->srealloc(atom->radius,nmax*sizeof(double),"atom:radius");
|
||||
density = atom->density = (double *)
|
||||
memory->srealloc(atom->density,nmax*sizeof(double),"atom:density");
|
||||
rmass = atom->rmass = (double *)
|
||||
memory->srealloc(atom->rmass,nmax*sizeof(double),"atom:rmass");
|
||||
|
||||
phix = atom->phix =
|
||||
memory->grow_2d_double_array(atom->phix,nmax,3,"atom:phix");
|
||||
phiv = atom->phiv =
|
||||
memory->grow_2d_double_array(atom->phiv,nmax,3,"atom:phiv");
|
||||
phia = atom->phia =
|
||||
memory->grow_2d_double_array(atom->phia,nmax,3,"atom:phia");
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::reset_ptrs()
|
||||
{
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
|
||||
radius = atom->radius;
|
||||
density = atom->density;
|
||||
rmass = atom->rmass;
|
||||
phix = atom->phix;
|
||||
phiv = atom->phiv;
|
||||
phia = atom->phia;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for owned atom I
|
||||
data in copy(), not including tag,type,mask,image,x,v
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::zero_owned(int i)
|
||||
{
|
||||
radius[i] = 0.0;
|
||||
density[i] = 0.0;
|
||||
rmass[i] = 0.0;
|
||||
phix[i][0] = 0.0;
|
||||
phix[i][1] = 0.0;
|
||||
phix[i][2] = 0.0;
|
||||
phiv[i][0] = 0.0;
|
||||
phiv[i][1] = 0.0;
|
||||
phiv[i][2] = 0.0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for n ghost atoms
|
||||
data in border(), not including x,tag,type,mask
|
||||
grow() is here since zero_ghost called first in hybrid::unpack_border()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::zero_ghost(int n, int first)
|
||||
{
|
||||
int last = first + n;
|
||||
for (int i = first; i < last; i++) {
|
||||
if (i == nmax) atom->avec->grow(0);
|
||||
v[i][0] = 0.0;
|
||||
v[i][1] = 0.0;
|
||||
v[i][2] = 0.0;
|
||||
radius[i] = 0.0;
|
||||
rmass[i] = 0.0;
|
||||
phiv[i][0] = 0.0;
|
||||
phiv[i][1] = 0.0;
|
||||
phiv[i][2] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::copy(int i, int j)
|
||||
{
|
||||
tag[j] = tag[i];
|
||||
type[j] = type[i];
|
||||
mask[j] = mask[i];
|
||||
image[j] = image[i];
|
||||
x[j][0] = x[i][0];
|
||||
x[j][1] = x[i][1];
|
||||
x[j][2] = x[i][2];
|
||||
v[j][0] = v[i][0];
|
||||
v[j][1] = v[i][1];
|
||||
v[j][2] = v[i][2];
|
||||
|
||||
radius[j] = radius[i];
|
||||
density[j] = density[i];
|
||||
rmass[j] = rmass[i];
|
||||
phix[j][0] = phix[i][0];
|
||||
phix[j][1] = phix[i][1];
|
||||
phix[j][2] = phix[i][2];
|
||||
phiv[j][0] = phiv[i][0];
|
||||
phiv[j][1] = phiv[i][1];
|
||||
phiv[j][2] = phiv[i][2];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
buf[m++] = phiv[j][0];
|
||||
buf[m++] = phiv[j][1];
|
||||
buf[m++] = phiv[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
buf[m++] = phiv[j][0];
|
||||
buf[m++] = phiv[j][1];
|
||||
buf[m++] = phiv[j][2];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_comm_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = v[i][0];
|
||||
buf[1] = v[i][1];
|
||||
buf[2] = v[i][2];
|
||||
buf[3] = phiv[i][0];
|
||||
buf[4] = phiv[i][1];
|
||||
buf[5] = phiv[i][2];
|
||||
return 6;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
v[i][0] = buf[m++];
|
||||
v[i][1] = buf[m++];
|
||||
v[i][2] = buf[m++];
|
||||
phiv[i][0] = buf[m++];
|
||||
phiv[i][1] = buf[m++];
|
||||
phiv[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::unpack_comm_one(int i, double *buf)
|
||||
{
|
||||
v[i][0] = buf[0];
|
||||
v[i][1] = buf[1];
|
||||
v[i][2] = buf[2];
|
||||
phiv[i][0] = buf[3];
|
||||
phiv[i][1] = buf[4];
|
||||
phiv[i][2] = buf[5];
|
||||
return 6;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
buf[m++] = phia[i][0];
|
||||
buf[m++] = phia[i][1];
|
||||
buf[m++] = phia[i][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_reverse_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = phia[i][0];
|
||||
buf[1] = phia[i][1];
|
||||
buf[2] = phia[i][2];
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
f[j][0] += buf[m++];
|
||||
f[j][1] += buf[m++];
|
||||
f[j][2] += buf[m++];
|
||||
phia[j][0] += buf[m++];
|
||||
phia[j][1] += buf[m++];
|
||||
phia[j][2] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::unpack_reverse_one(int i, double *buf)
|
||||
{
|
||||
phia[i][0] = buf[0];
|
||||
phia[i][1] = buf[1];
|
||||
phia[i][2] = buf[2];
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_border(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
buf[m++] = radius[j];
|
||||
buf[m++] = rmass[j];
|
||||
buf[m++] = phiv[j][0];
|
||||
buf[m++] = phiv[j][1];
|
||||
buf[m++] = phiv[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = v[j][0];
|
||||
buf[m++] = v[j][1];
|
||||
buf[m++] = v[j][2];
|
||||
buf[m++] = radius[j];
|
||||
buf[m++] = rmass[j];
|
||||
buf[m++] = phiv[j][0];
|
||||
buf[m++] = phiv[j][1];
|
||||
buf[m++] = phiv[j][2];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_border_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = v[i][0];
|
||||
buf[1] = v[i][1];
|
||||
buf[2] = v[i][2];
|
||||
buf[3] = radius[i];
|
||||
buf[4] = rmass[i];
|
||||
buf[5] = phiv[i][0];
|
||||
buf[6] = phiv[i][1];
|
||||
buf[7] = phiv[i][2];
|
||||
return 8;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
v[i][0] = buf[m++];
|
||||
v[i][1] = buf[m++];
|
||||
v[i][2] = buf[m++];
|
||||
radius[i] = buf[m++];
|
||||
rmass[i] = buf[m++];
|
||||
phiv[i][0] = buf[m++];
|
||||
phiv[i][1] = buf[m++];
|
||||
phiv[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::unpack_border_one(int i, double *buf)
|
||||
{
|
||||
v[i][0] = buf[0];
|
||||
v[i][1] = buf[1];
|
||||
v[i][2] = buf[2];
|
||||
radius[i] = buf[3];
|
||||
rmass[i] = buf[4];
|
||||
phiv[i][0] = buf[5];
|
||||
phiv[i][1] = buf[6];
|
||||
phiv[i][2] = buf[7];
|
||||
return 8;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
xyz must be 1st 3 values, so comm::exchange() can test on them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
|
||||
buf[m++] = radius[i];
|
||||
buf[m++] = density[i];
|
||||
buf[m++] = rmass[i];
|
||||
buf[m++] = phix[i][0];
|
||||
buf[m++] = phix[i][1];
|
||||
buf[m++] = phix[i][2];
|
||||
buf[m++] = phiv[i][0];
|
||||
buf[m++] = phiv[i][1];
|
||||
buf[m++] = phiv[i][2];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::unpack_exchange(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
radius[nlocal] = buf[m++];
|
||||
density[nlocal] = buf[m++];
|
||||
rmass[nlocal] = buf[m++];
|
||||
phix[nlocal][0] = buf[m++];
|
||||
phix[nlocal][1] = buf[m++];
|
||||
phix[nlocal][2] = buf[m++];
|
||||
phiv[nlocal][0] = buf[m++];
|
||||
phiv[nlocal][1] = buf[m++];
|
||||
phiv[nlocal][2] = buf[m++];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->
|
||||
unpack_exchange(nlocal,&buf[m]);
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for all atoms owned by this proc
|
||||
include extra data stored by fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::size_restart()
|
||||
{
|
||||
int i;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
int n = 19 * nlocal;
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for atom I
|
||||
do not include extra data stored by fixes, included by caller
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::size_restart_one(int i)
|
||||
{
|
||||
return 19;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file including extra quantities
|
||||
xyz must be 1st 3 values, so that read_restart can test on them
|
||||
molecular types may be negative, but write as positive
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::pack_restart(int i, double *buf)
|
||||
{
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
|
||||
buf[m++] = radius[i];
|
||||
buf[m++] = density[i];
|
||||
buf[m++] = phix[i][0];
|
||||
buf[m++] = phix[i][1];
|
||||
buf[m++] = phix[i][2];
|
||||
buf[m++] = phiv[i][0];
|
||||
buf[m++] = phiv[i][1];
|
||||
buf[m++] = phiv[i][2];
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::unpack_restart(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) {
|
||||
grow(0);
|
||||
if (atom->nextra_store)
|
||||
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
|
||||
atom->nextra_store,
|
||||
"atom:extra");
|
||||
}
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
|
||||
radius[nlocal] = buf[m++];
|
||||
density[nlocal] = buf[m++];
|
||||
if (force->dimension == 3)
|
||||
rmass[nlocal] = 4.0*PI/3.0 *
|
||||
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
|
||||
else
|
||||
rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
|
||||
|
||||
phix[nlocal][0] = buf[m++];
|
||||
phix[nlocal][1] = buf[m++];
|
||||
phix[nlocal][2] = buf[m++];
|
||||
phiv[nlocal][0] = buf[m++];
|
||||
phiv[nlocal][1] = buf[m++];
|
||||
phiv[nlocal][2] = buf[m++];
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (buf[0]) - m;
|
||||
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
|
||||
}
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of type itype at x0,y0,z0
|
||||
set other values to defaults
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::create_atom(int itype, double x0, double y0, double z0,
|
||||
int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = 0;
|
||||
type[nlocal] = itype;
|
||||
x[nlocal][0] = x0;
|
||||
x[nlocal][1] = y0;
|
||||
x[nlocal][2] = z0;
|
||||
mask[nlocal] = 1;
|
||||
image[nlocal] = (512 << 20) | (512 << 10) | 512;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
radius[nlocal] = 0.5;
|
||||
density[nlocal] = 1.0;
|
||||
if (force->dimension == 3)
|
||||
rmass[nlocal] = 4.0*PI/3.0 *
|
||||
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
|
||||
else
|
||||
rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
|
||||
phix[nlocal][0] = 0.0;
|
||||
phix[nlocal][1] = 0.0;
|
||||
phix[nlocal][2] = 0.0;
|
||||
phiv[nlocal][0] = 0.0;
|
||||
phiv[nlocal][1] = 0.0;
|
||||
phiv[nlocal][2] = 0.0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::data_atom(double xtmp, double ytmp, double ztmp,
|
||||
int imagetmp, char **values, int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = atoi(values[0]);
|
||||
if (tag[nlocal] <= 0)
|
||||
error->one("Invalid atom ID in Atoms section of data file");
|
||||
|
||||
type[nlocal] = atoi(values[1]);
|
||||
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
|
||||
error->one("Invalid atom type in Atoms section of data file");
|
||||
|
||||
radius[nlocal] = 0.5 * atof(values[2]);
|
||||
density[nlocal] = atof(values[3]);
|
||||
if (force->dimension == 3)
|
||||
rmass[nlocal] = 4.0*PI/3.0 *
|
||||
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
|
||||
else
|
||||
rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
|
||||
|
||||
x[nlocal][0] = xtmp;
|
||||
x[nlocal][1] = ytmp;
|
||||
x[nlocal][2] = ztmp;
|
||||
|
||||
image[nlocal] = imagetmp;
|
||||
|
||||
mask[nlocal] = 1;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
phix[nlocal][0] = 0.0;
|
||||
phix[nlocal][1] = 0.0;
|
||||
phix[nlocal][2] = 0.0;
|
||||
phiv[nlocal][0] = 0.0;
|
||||
phiv[nlocal][1] = 0.0;
|
||||
phiv[nlocal][2] = 0.0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack a single line from Velocity section of data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecGranular::data_vel(int m, char *line, int ihybrid)
|
||||
{
|
||||
int tmp;
|
||||
sscanf(line,"%d %lg %lg %lg %lg %lg %lg",
|
||||
&tmp,&v[m][0],&v[m][1],&v[m][2],&phiv[m][0],&phiv[m][1],&phiv[m][2]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecGranular::memory_usage()
|
||||
{
|
||||
int bytes = 0;
|
||||
|
||||
if (atom->memcheck("tag")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("type")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("mask")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("image")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double);
|
||||
|
||||
if (atom->memcheck("radius")) bytes += nmax * sizeof(double);
|
||||
if (atom->memcheck("density")) bytes += nmax * sizeof(double);
|
||||
if (atom->memcheck("rmass")) bytes += nmax * sizeof(double);
|
||||
if (atom->memcheck("phix")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("phiv")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("phia")) bytes += nmax*3 * sizeof(double);
|
||||
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_GRANULAR_H
|
||||
#define ATOM_VEC_GRANULAR_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecGranular : public AtomVec {
|
||||
public:
|
||||
AtomVecGranular(class LAMMPS *, int, char **);
|
||||
~AtomVecGranular() {}
|
||||
void grow(int);
|
||||
void reset_ptrs();
|
||||
void zero_owned(int);
|
||||
void zero_ghost(int, int);
|
||||
void copy(int, int);
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
int pack_comm_one(int, double *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int unpack_comm_one(int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
int pack_reverse_one(int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int unpack_reverse_one(int, double *);
|
||||
int pack_border(int, int *, double *, int *);
|
||||
int pack_border_one(int, double *);
|
||||
void unpack_border(int, int, double *);
|
||||
int unpack_border_one(int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
int size_restart();
|
||||
int size_restart_one(int);
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void create_atom(int, double, double, double, int);
|
||||
void data_atom(double, double, double, int, char **, int);
|
||||
void data_vel(int, char *, int);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
double PI;
|
||||
int *tag,*type,*mask,*image;
|
||||
double **x,**v,**f;
|
||||
double *radius,*density,*rmass;
|
||||
double **phix,**phiv,**phia;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,66 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_LJ_CHARMM_COUL_LONG_H
|
||||
#define PAIR_LJ_CHARMM_COUL_LONG_H
|
||||
|
||||
#include "pair.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairLJCharmmCoulLong : public Pair {
|
||||
public:
|
||||
PairLJCharmmCoulLong(class LAMMPS *);
|
||||
~PairLJCharmmCoulLong();
|
||||
void compute(int, int);
|
||||
void settings(int, char **);
|
||||
void coeff(int, char **);
|
||||
double init_one(int, int);
|
||||
void init_style();
|
||||
void write_restart(FILE *);
|
||||
void read_restart(FILE *);
|
||||
void write_restart_settings(FILE *);
|
||||
void read_restart_settings(FILE *);
|
||||
void single(int, int, int, int, double, double, double, int, One &);
|
||||
|
||||
void compute_inner();
|
||||
void compute_middle();
|
||||
void compute_outer(int, int);
|
||||
void extract_charmm(double ***, double ***, double ***, double ***, int *);
|
||||
void extract_long(double *);
|
||||
|
||||
protected:
|
||||
double cut_lj_inner,cut_lj;
|
||||
double cut_lj_innersq,cut_ljsq;
|
||||
double cut_coul,cut_coulsq;
|
||||
double cut_bothsq;
|
||||
double denom_lj;
|
||||
double **epsilon,**sigma,**eps14,**sigma14;
|
||||
double **lj1,**lj2,**lj3,**lj4,**offset;
|
||||
double **lj14_1,**lj14_2,**lj14_3,**lj14_4;
|
||||
double *cut_respa;
|
||||
double g_ewald;
|
||||
|
||||
double tabinnersq;
|
||||
double *rtable,*drtable,*ftable,*dftable,*ctable,*dctable;
|
||||
double *etable,*detable,*ptable,*dptable,*vtable,*dvtable;
|
||||
int ncoulshiftbits,ncoulmask;
|
||||
|
||||
void allocate();
|
||||
void init_tables();
|
||||
void free_tables();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
# g++_meam = RedHat Linux box, g++, MPICH, FFTW, MEAM
|
||||
|
||||
SHELL = /bin/sh
|
||||
#.IGNORE:
|
||||
|
||||
# System-specific settings
|
||||
|
||||
CC = g++
|
||||
CCFLAGS = -g -O -I/home/sjplimp/tools/mpich/include \
|
||||
-I/home/sjplimp/tools/fftw/include -DFFT_FFTW -DGZIP
|
||||
DEPFLAGS = -M
|
||||
LINK = g++
|
||||
LINKFLAGS = -g -O -L/home/sjplimp/tools/mpich/lib \
|
||||
-L/home/sjplimp/tools/fftw/lib \
|
||||
-L/home/sjplimp/lammps/lib/meam \
|
||||
-L/opt/intel/fc/9.0/lib
|
||||
USRLIB = -lfftw -lmpich -lmeam
|
||||
SYSLIB = -lifcore
|
||||
ARCHIVE = ar
|
||||
ARFLAGS = -rc
|
||||
SIZE = size
|
||||
|
||||
# Link target
|
||||
|
||||
$(EXE): $(OBJ)
|
||||
$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
|
||||
$(SIZE) $(EXE)
|
||||
|
||||
# Library target
|
||||
|
||||
lib: $(OBJ)
|
||||
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp
|
||||
$(CC) $(CCFLAGS) -c $<
|
||||
|
||||
%.d:%.cpp
|
||||
$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
|
||||
|
||||
# Individual dependencies
|
||||
|
||||
DEPENDS = $(OBJ:.o=.d)
|
||||
include $(DEPENDS)
|
|
@ -0,0 +1,45 @@
|
|||
# linux = RedHat Linux box, Intel icc, MPICH, FFTW, MEAM
|
||||
|
||||
SHELL = /bin/sh
|
||||
#.IGNORE:
|
||||
|
||||
# System-specific settings
|
||||
|
||||
CC = icc
|
||||
CCFLAGS = -O -I/home/sjplimp/tools/mpich/include \
|
||||
-I/home/sjplimp/tools/fftw/include -DFFT_FFTW -DGZIP
|
||||
DEPFLAGS = -M
|
||||
LINK = icc
|
||||
LINKFLAGS = -O -L/home/sjplimp/tools/mpich/lib \
|
||||
-L/home/sjplimp/tools/fftw/lib \
|
||||
-L/home/sjplimp/lammps/lib/meam \
|
||||
-L/opt/intel/fc/9.0/lib
|
||||
USRLIB = -lfftw -lmpich -lmeam
|
||||
SYSLIB = -lcxa -lunwind -lstdc++ -lifcore
|
||||
ARCHIVE = ar
|
||||
ARFLAGS = -rc
|
||||
SIZE = size
|
||||
|
||||
# Link target
|
||||
|
||||
$(EXE): $(OBJ)
|
||||
$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
|
||||
$(SIZE) $(EXE)
|
||||
|
||||
# Library target
|
||||
|
||||
lib: $(OBJ)
|
||||
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
|
||||
|
||||
# Compilation rules
|
||||
|
||||
%.o:%.cpp
|
||||
$(CC) $(CCFLAGS) -c $<
|
||||
|
||||
%.d:%.cpp
|
||||
$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
|
||||
|
||||
# Individual dependencies
|
||||
|
||||
DEPENDS = $(OBJ:.o=.d)
|
||||
include $(DEPENDS)
|
|
@ -0,0 +1,106 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_EAM_H
|
||||
#define PAIR_EAM_H
|
||||
|
||||
#include "pair.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairEAM : public Pair {
|
||||
public:
|
||||
PairEAM(class LAMMPS *);
|
||||
virtual ~PairEAM();
|
||||
void compute(int, int);
|
||||
void settings(int, char **);
|
||||
virtual void coeff(int, char **);
|
||||
double init_one(int, int);
|
||||
void init_style();
|
||||
void single(int, int, int, int, double, double, double, int, One &);
|
||||
|
||||
void single_embed(int, int, double &);
|
||||
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int pack_reverse_comm(int, int, double *);
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
int memory_usage();
|
||||
|
||||
void extract_eam(double *, double **);
|
||||
|
||||
void foo();
|
||||
|
||||
protected:
|
||||
double cutforcesq,cutmax;
|
||||
|
||||
// per-atom arrays
|
||||
|
||||
int nmax;
|
||||
double *rho,*fp;
|
||||
|
||||
// potentials as file data
|
||||
|
||||
int *map; // which element each atom type maps to
|
||||
|
||||
struct Funcfl {
|
||||
char *file;
|
||||
int nrho,nr;
|
||||
double drho,dr,cut,mass;
|
||||
double *frho,*rhor,*zr;
|
||||
};
|
||||
Funcfl *funcfl;
|
||||
int nfuncfl;
|
||||
|
||||
struct Setfl {
|
||||
char **elements;
|
||||
int nelements,nrho,nr;
|
||||
double drho,dr,cut;
|
||||
double *mass;
|
||||
double **frho,**rhor,***z2r;
|
||||
};
|
||||
Setfl *setfl;
|
||||
|
||||
struct Fs {
|
||||
char **elements;
|
||||
int nelements,nrho,nr;
|
||||
double drho,dr,cut;
|
||||
double *mass;
|
||||
double **frho,***rhor,***z2r;
|
||||
};
|
||||
Fs *fs;
|
||||
|
||||
// potentials as array data
|
||||
|
||||
int nrho,nr;
|
||||
int nfrho,nrhor,nz2r;
|
||||
double **frho,**rhor,**z2r;
|
||||
int *type2frho,**type2rhor,**type2z2r;
|
||||
|
||||
// potentials in spline form used for force computation
|
||||
|
||||
double dr,rdr,drho,rdrho;
|
||||
double ***rhor_spline,***frho_spline,***z2r_spline;
|
||||
|
||||
void allocate();
|
||||
void array2spline();
|
||||
void interpolate(int, double, double *, double **);
|
||||
void grab(FILE *, int, double *);
|
||||
|
||||
virtual void read_file(char *);
|
||||
virtual void file2array();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,694 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "atom_vec_angle.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MIN(A,B) ((A) < (B)) ? (A) : (B)
|
||||
#define MAX(A,B) ((A) > (B)) ? (A) : (B)
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecAngle::AtomVecAngle(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVec(lmp, narg, arg)
|
||||
{
|
||||
molecular = 1;
|
||||
bonds_allow = 1;
|
||||
angles_allow = 1;
|
||||
mass_type = 1;
|
||||
size_comm = 3;
|
||||
size_reverse = 3;
|
||||
size_border = 7;
|
||||
size_data_atom = 6;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 4;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by DELTA
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::grow(int n)
|
||||
{
|
||||
if (n == 0) nmax += DELTA;
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
|
||||
tag = atom->tag = (int *)
|
||||
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
|
||||
type = atom->type = (int *)
|
||||
memory->srealloc(atom->type,nmax*sizeof(int),"atom:type");
|
||||
mask = atom->mask = (int *)
|
||||
memory->srealloc(atom->mask,nmax*sizeof(int),"atom:mask");
|
||||
image = atom->image = (int *)
|
||||
memory->srealloc(atom->image,nmax*sizeof(int),"atom:image");
|
||||
x = atom->x = memory->grow_2d_double_array(atom->x,nmax,3,"atom:x");
|
||||
v = atom->v = memory->grow_2d_double_array(atom->v,nmax,3,"atom:v");
|
||||
f = atom->f = memory->grow_2d_double_array(atom->f,nmax,3,"atom:f");
|
||||
|
||||
molecule = atom->molecule = (int *)
|
||||
memory->srealloc(atom->molecule,nmax*sizeof(int),"atom:molecule");
|
||||
|
||||
nspecial = atom->nspecial =
|
||||
memory->grow_2d_int_array(atom->nspecial,nmax,3,"atom:nspecial");
|
||||
special = atom->special =
|
||||
memory->grow_2d_int_array(atom->special,nmax,atom->maxspecial,
|
||||
"atom:special");
|
||||
|
||||
num_bond = atom->num_bond = (int *)
|
||||
memory->srealloc(atom->num_bond,nmax*sizeof(int),"atom:num_bond");
|
||||
bond_type = atom->bond_type =
|
||||
memory->grow_2d_int_array(atom->bond_type,nmax,atom->bond_per_atom,
|
||||
"atom:bond_type");
|
||||
bond_atom = atom->bond_atom =
|
||||
memory->grow_2d_int_array(atom->bond_atom,nmax,atom->bond_per_atom,
|
||||
"atom:bond_atom");
|
||||
|
||||
num_angle = atom->num_angle = (int *)
|
||||
memory->srealloc(atom->num_angle,nmax*sizeof(int),"atom:num_angle");
|
||||
angle_type = atom->angle_type =
|
||||
memory->grow_2d_int_array(atom->angle_type,nmax,atom->angle_per_atom,
|
||||
"atom:angle_type");
|
||||
angle_atom1 = atom->angle_atom1 =
|
||||
memory->grow_2d_int_array(atom->angle_atom1,nmax,atom->angle_per_atom,
|
||||
"atom:angle_atom1");
|
||||
angle_atom2 = atom->angle_atom2 =
|
||||
memory->grow_2d_int_array(atom->angle_atom2,nmax,atom->angle_per_atom,
|
||||
"atom:angle_atom2");
|
||||
angle_atom3 = atom->angle_atom3 =
|
||||
memory->grow_2d_int_array(atom->angle_atom3,nmax,atom->angle_per_atom,
|
||||
"atom:angle_atom3");
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::reset_ptrs()
|
||||
{
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
|
||||
molecule = atom->molecule;
|
||||
nspecial = atom->nspecial;
|
||||
special = atom->special;
|
||||
|
||||
num_bond = atom->num_bond;
|
||||
bond_type = atom->bond_type;
|
||||
bond_atom = atom->bond_atom;
|
||||
|
||||
num_angle = atom->num_angle;
|
||||
angle_type = atom->angle_type;
|
||||
angle_atom1 = atom->angle_atom1;
|
||||
angle_atom2 = atom->angle_atom2;
|
||||
angle_atom3 = atom->angle_atom3;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for owned atom I
|
||||
data in copy(), not including tag,type,mask,image,x,v
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::zero_owned(int i)
|
||||
{
|
||||
molecule[i] = 0;
|
||||
num_bond[i] = 0;
|
||||
num_angle[i] = 0;
|
||||
nspecial[i][0] = 0;
|
||||
nspecial[i][1] = 0;
|
||||
nspecial[i][2] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for n ghost atoms
|
||||
data in border(), not including x,tag,type,mask
|
||||
grow() is here since zero_ghost called first in hybrid::unpack_border()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::zero_ghost(int n, int first)
|
||||
{
|
||||
int last = first + n;
|
||||
for (int i = first; i < last; i++) {
|
||||
if (i == nmax) atom->avec->grow(0);
|
||||
molecule[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::copy(int i, int j)
|
||||
{
|
||||
int k;
|
||||
|
||||
tag[j] = tag[i];
|
||||
type[j] = type[i];
|
||||
mask[j] = mask[i];
|
||||
image[j] = image[i];
|
||||
x[j][0] = x[i][0];
|
||||
x[j][1] = x[i][1];
|
||||
x[j][2] = x[i][2];
|
||||
v[j][0] = v[i][0];
|
||||
v[j][1] = v[i][1];
|
||||
v[j][2] = v[i][2];
|
||||
|
||||
molecule[j] = molecule[i];
|
||||
|
||||
num_bond[j] = num_bond[i];
|
||||
for (k = 0; k < num_bond[j]; k++) {
|
||||
bond_type[j][k] = bond_type[i][k];
|
||||
bond_atom[j][k] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
num_angle[j] = num_angle[i];
|
||||
for (k = 0; k < num_angle[j]; k++) {
|
||||
angle_type[j][k] = angle_type[i][k];
|
||||
angle_atom1[j][k] = angle_atom1[i][k];
|
||||
angle_atom2[j][k] = angle_atom2[i][k];
|
||||
angle_atom3[j][k] = angle_atom3[i][k];
|
||||
}
|
||||
|
||||
nspecial[j][0] = nspecial[i][0];
|
||||
nspecial[j][1] = nspecial[i][1];
|
||||
nspecial[j][2] = nspecial[i][2];
|
||||
for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
f[j][0] += buf[m++];
|
||||
f[j][1] += buf[m++];
|
||||
f[j][2] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::pack_border(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = molecule[j];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = molecule[j];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::pack_border_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = v[i][0];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
molecule[i] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::unpack_border_one(int i, double *buf)
|
||||
{
|
||||
molecule[i] = static_cast<int> (buf[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
xyz must be 1st 3 values, so comm::exchange() can test on them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
|
||||
buf[m++] = molecule[i];
|
||||
|
||||
buf[m++] = num_bond[i];
|
||||
for (k = 0; k < num_bond[i]; k++) {
|
||||
buf[m++] = bond_type[i][k];
|
||||
buf[m++] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_angle[i];
|
||||
for (k = 0; k < num_angle[i]; k++) {
|
||||
buf[m++] = angle_type[i][k];
|
||||
buf[m++] = angle_atom1[i][k];
|
||||
buf[m++] = angle_atom2[i][k];
|
||||
buf[m++] = angle_atom3[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = nspecial[i][0];
|
||||
buf[m++] = nspecial[i][1];
|
||||
buf[m++] = nspecial[i][2];
|
||||
for (k = 0; k < nspecial[i][2]; k++) buf[m++] = special[i][k];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::unpack_exchange(double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
molecule[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
num_bond[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_bond[nlocal]; k++) {
|
||||
bond_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_angle[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_angle[nlocal]; k++) {
|
||||
angle_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
nspecial[nlocal][0] = static_cast<int> (buf[m++]);
|
||||
nspecial[nlocal][1] = static_cast<int> (buf[m++]);
|
||||
nspecial[nlocal][2] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < nspecial[nlocal][2]; k++)
|
||||
special[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->
|
||||
unpack_exchange(nlocal,&buf[m]);
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for all atoms owned by this proc
|
||||
include extra data stored by fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::size_restart()
|
||||
{
|
||||
int i;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
int n = 0;
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += 14 + 2*num_bond[i] + 4*num_angle[i];
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for atom I
|
||||
do not include extra data stored by fixes, included by caller
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::size_restart_one(int i)
|
||||
{
|
||||
int n = 14 + 2*num_bond[i] + 4*num_angle[i];
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file including extra quantities
|
||||
xyz must be 1st 3 values, so that read_restart can test on them
|
||||
molecular types may be negative, but write as positive
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::pack_restart(int i, double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
|
||||
buf[m++] = molecule[i];
|
||||
|
||||
buf[m++] = num_bond[i];
|
||||
for (k = 0; k < num_bond[i]; k++) {
|
||||
buf[m++] = MAX(bond_type[i][k],-bond_type[i][k]);
|
||||
buf[m++] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_angle[i];
|
||||
for (k = 0; k < num_angle[i]; k++) {
|
||||
buf[m++] = MAX(angle_type[i][k],-angle_type[i][k]);
|
||||
buf[m++] = angle_atom1[i][k];
|
||||
buf[m++] = angle_atom2[i][k];
|
||||
buf[m++] = angle_atom3[i][k];
|
||||
}
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::unpack_restart(double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) {
|
||||
grow(0);
|
||||
if (atom->nextra_store)
|
||||
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
|
||||
atom->nextra_store,
|
||||
"atom:extra");
|
||||
}
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
|
||||
molecule[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
num_bond[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_bond[nlocal]; k++) {
|
||||
bond_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_angle[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_angle[nlocal]; k++) {
|
||||
angle_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (buf[0]) - m;
|
||||
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
|
||||
}
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of type itype at x0,y0,z0
|
||||
set other values to defaults
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::create_atom(int itype, double x0, double y0, double z0,
|
||||
int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = 0;
|
||||
type[nlocal] = itype;
|
||||
x[nlocal][0] = x0;
|
||||
x[nlocal][1] = y0;
|
||||
x[nlocal][2] = z0;
|
||||
mask[nlocal] = 1;
|
||||
image[nlocal] = (512 << 20) | (512 << 10) | 512;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
molecule[nlocal] = 0;
|
||||
num_bond[nlocal] = 0;
|
||||
num_angle[nlocal] = 0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAngle::data_atom(double xtmp, double ytmp, double ztmp,
|
||||
int imagetmp, char **values, int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = atoi(values[0]);
|
||||
if (tag[nlocal] <= 0)
|
||||
error->one("Invalid atom ID in Atoms section of data file");
|
||||
|
||||
molecule[nlocal] = atoi(values[1]);
|
||||
|
||||
type[nlocal] = atoi(values[2]);
|
||||
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
|
||||
error->one("Invalid atom type in Atoms section of data file");
|
||||
|
||||
x[nlocal][0] = xtmp;
|
||||
x[nlocal][1] = ytmp;
|
||||
x[nlocal][2] = ztmp;
|
||||
|
||||
image[nlocal] = imagetmp;
|
||||
|
||||
mask[nlocal] = 1;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
num_bond[nlocal] = 0;
|
||||
num_angle[nlocal] = 0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAngle::memory_usage()
|
||||
{
|
||||
int bytes = 0;
|
||||
|
||||
if (atom->memcheck("tag")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("type")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("mask")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("image")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double);
|
||||
|
||||
if (atom->memcheck("molecule")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("nspecial")) bytes += nmax*3 * sizeof(int);
|
||||
if (atom->memcheck("special")) bytes += nmax*atom->maxspecial * sizeof(int);
|
||||
|
||||
if (atom->memcheck("num_bond")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("bond_type"))
|
||||
bytes += nmax*atom->bond_per_atom * sizeof(int);
|
||||
if (atom->memcheck("bond_atom"))
|
||||
bytes += nmax*atom->bond_per_atom * sizeof(int);
|
||||
|
||||
if (atom->memcheck("num_angle")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("angle_type"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
if (atom->memcheck("angle_atom1"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
if (atom->memcheck("angle_atom2"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
if (atom->memcheck("angle_atom3"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_ANGLE_H
|
||||
#define ATOM_VEC_ANGLE_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecAngle : public AtomVec {
|
||||
public:
|
||||
AtomVecAngle(class LAMMPS *, int, char **);
|
||||
void grow(int);
|
||||
void reset_ptrs();
|
||||
void zero_owned(int);
|
||||
void zero_ghost(int, int);
|
||||
void copy(int, int);
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int pack_border(int, int *, double *, int *);
|
||||
int pack_border_one(int, double *);
|
||||
void unpack_border(int, int, double *);
|
||||
int unpack_border_one(int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
int size_restart();
|
||||
int size_restart_one(int);
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void create_atom(int, double, double, double, int);
|
||||
void data_atom(double, double, double, int, char **, int);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int *tag,*type,*mask,*image;
|
||||
double **x,**v,**f;
|
||||
int *molecule;
|
||||
int **nspecial,**special;
|
||||
int *num_bond;
|
||||
int **bond_type,**bond_atom;
|
||||
int *num_angle;
|
||||
int **angle_type;
|
||||
int **angle_atom1,**angle_atom2,**angle_atom3;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,619 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "atom_vec_bond.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MIN(A,B) ((A) < (B)) ? (A) : (B)
|
||||
#define MAX(A,B) ((A) > (B)) ? (A) : (B)
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecBond::AtomVecBond(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVec(lmp, narg, arg)
|
||||
{
|
||||
molecular = 1;
|
||||
bonds_allow = 1;
|
||||
mass_type = 1;
|
||||
size_comm = 3;
|
||||
size_reverse = 3;
|
||||
size_border = 7;
|
||||
size_data_atom = 6;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 4;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by DELTA
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::grow(int n)
|
||||
{
|
||||
if (n == 0) nmax += DELTA;
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
|
||||
tag = atom->tag = (int *)
|
||||
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
|
||||
type = atom->type = (int *)
|
||||
memory->srealloc(atom->type,nmax*sizeof(int),"atom:type");
|
||||
mask = atom->mask = (int *)
|
||||
memory->srealloc(atom->mask,nmax*sizeof(int),"atom:mask");
|
||||
image = atom->image = (int *)
|
||||
memory->srealloc(atom->image,nmax*sizeof(int),"atom:image");
|
||||
x = atom->x = memory->grow_2d_double_array(atom->x,nmax,3,"atom:x");
|
||||
v = atom->v = memory->grow_2d_double_array(atom->v,nmax,3,"atom:v");
|
||||
f = atom->f = memory->grow_2d_double_array(atom->f,nmax,3,"atom:f");
|
||||
|
||||
molecule = atom->molecule = (int *)
|
||||
memory->srealloc(atom->molecule,nmax*sizeof(int),"atom:molecule");
|
||||
|
||||
nspecial = atom->nspecial =
|
||||
memory->grow_2d_int_array(atom->nspecial,nmax,3,"atom:nspecial");
|
||||
special = atom->special =
|
||||
memory->grow_2d_int_array(atom->special,nmax,atom->maxspecial,
|
||||
"atom:special");
|
||||
|
||||
num_bond = atom->num_bond = (int *)
|
||||
memory->srealloc(atom->num_bond,nmax*sizeof(int),"atom:num_bond");
|
||||
bond_type = atom->bond_type =
|
||||
memory->grow_2d_int_array(atom->bond_type,nmax,atom->bond_per_atom,
|
||||
"atom:bond_type");
|
||||
bond_atom = atom->bond_atom =
|
||||
memory->grow_2d_int_array(atom->bond_atom,nmax,atom->bond_per_atom,
|
||||
"atom:bond_atom");
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::reset_ptrs()
|
||||
{
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
|
||||
molecule = atom->molecule;
|
||||
nspecial = atom->nspecial;
|
||||
special = atom->special;
|
||||
|
||||
num_bond = atom->num_bond;
|
||||
bond_type = atom->bond_type;
|
||||
bond_atom = atom->bond_atom;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for owned atom I
|
||||
data in copy(), not including tag,type,mask,image,x,v
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::zero_owned(int i)
|
||||
{
|
||||
molecule[i] = 0;
|
||||
num_bond[i] = 0;
|
||||
nspecial[i][0] = 0;
|
||||
nspecial[i][1] = 0;
|
||||
nspecial[i][2] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for n ghost atoms
|
||||
data in border(), not including x,tag,type,mask
|
||||
grow() is here since zero_ghost called first in hybrid::unpack_border()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::zero_ghost(int n, int first)
|
||||
{
|
||||
int last = first + n;
|
||||
for (int i = first; i < last; i++) {
|
||||
if (i == nmax) atom->avec->grow(0);
|
||||
molecule[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::copy(int i, int j)
|
||||
{
|
||||
int k;
|
||||
|
||||
tag[j] = tag[i];
|
||||
type[j] = type[i];
|
||||
mask[j] = mask[i];
|
||||
image[j] = image[i];
|
||||
x[j][0] = x[i][0];
|
||||
x[j][1] = x[i][1];
|
||||
x[j][2] = x[i][2];
|
||||
v[j][0] = v[i][0];
|
||||
v[j][1] = v[i][1];
|
||||
v[j][2] = v[i][2];
|
||||
|
||||
molecule[j] = molecule[i];
|
||||
|
||||
num_bond[j] = num_bond[i];
|
||||
for (k = 0; k < num_bond[j]; k++) {
|
||||
bond_type[j][k] = bond_type[i][k];
|
||||
bond_atom[j][k] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
nspecial[j][0] = nspecial[i][0];
|
||||
nspecial[j][1] = nspecial[i][1];
|
||||
nspecial[j][2] = nspecial[i][2];
|
||||
for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
f[j][0] += buf[m++];
|
||||
f[j][1] += buf[m++];
|
||||
f[j][2] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::pack_border(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = molecule[j];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = molecule[j];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::pack_border_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = molecule[i];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
molecule[i] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::unpack_border_one(int i, double *buf)
|
||||
{
|
||||
molecule[i] = static_cast<int> (buf[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
xyz must be 1st 3 values, so comm::exchange() can test on them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
|
||||
buf[m++] = molecule[i];
|
||||
|
||||
buf[m++] = num_bond[i];
|
||||
for (k = 0; k < num_bond[i]; k++) {
|
||||
buf[m++] = bond_type[i][k];
|
||||
buf[m++] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = nspecial[i][0];
|
||||
buf[m++] = nspecial[i][1];
|
||||
buf[m++] = nspecial[i][2];
|
||||
for (k = 0; k < nspecial[i][2]; k++) buf[m++] = special[i][k];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::unpack_exchange(double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
molecule[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
num_bond[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_bond[nlocal]; k++) {
|
||||
bond_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
nspecial[nlocal][0] = static_cast<int> (buf[m++]);
|
||||
nspecial[nlocal][1] = static_cast<int> (buf[m++]);
|
||||
nspecial[nlocal][2] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < nspecial[nlocal][2]; k++)
|
||||
special[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->
|
||||
unpack_exchange(nlocal,&buf[m]);
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for all atoms owned by this proc
|
||||
include extra data stored by fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::size_restart()
|
||||
{
|
||||
int i;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
int n = 0;
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += 13 + 2*num_bond[i];
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for atom I
|
||||
do not include extra data stored by fixes, included by caller
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::size_restart_one(int i)
|
||||
{
|
||||
int n = 13 + 2*num_bond[i];
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file including extra quantities
|
||||
xyz must be 1st 3 values, so that read_restart can test on them
|
||||
molecular types may be negative, but write as positive
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::pack_restart(int i, double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
|
||||
buf[m++] = molecule[i];
|
||||
|
||||
buf[m++] = num_bond[i];
|
||||
for (k = 0; k < num_bond[i]; k++) {
|
||||
buf[m++] = MAX(bond_type[i][k],-bond_type[i][k]);
|
||||
buf[m++] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::unpack_restart(double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) {
|
||||
grow(0);
|
||||
if (atom->nextra_store)
|
||||
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
|
||||
atom->nextra_store,
|
||||
"atom:extra");
|
||||
}
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
|
||||
molecule[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
num_bond[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_bond[nlocal]; k++) {
|
||||
bond_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (buf[0]) - m;
|
||||
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
|
||||
}
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of type itype at x0,y0,z0
|
||||
set other values to defaults
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::create_atom(int itype, double x0, double y0, double z0,
|
||||
int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = 0;
|
||||
type[nlocal] = itype;
|
||||
x[nlocal][0] = x0;
|
||||
x[nlocal][1] = y0;
|
||||
x[nlocal][2] = z0;
|
||||
mask[nlocal] = 1;
|
||||
image[nlocal] = (512 << 20) | (512 << 10) | 512;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
molecule[nlocal] = 0;
|
||||
num_bond[nlocal] = 0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecBond::data_atom(double xtmp, double ytmp, double ztmp,
|
||||
int imagetmp, char **values, int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = atoi(values[0]);
|
||||
if (tag[nlocal] <= 0)
|
||||
error->one("Invalid atom ID in Atoms section of data file");
|
||||
|
||||
molecule[nlocal] = atoi(values[1]);
|
||||
|
||||
type[nlocal] = atoi(values[2]);
|
||||
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
|
||||
error->one("Invalid atom type in Atoms section of data file");
|
||||
|
||||
x[nlocal][0] = xtmp;
|
||||
x[nlocal][1] = ytmp;
|
||||
x[nlocal][2] = ztmp;
|
||||
|
||||
image[nlocal] = imagetmp;
|
||||
|
||||
mask[nlocal] = 1;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
num_bond[nlocal] = 0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecBond::memory_usage()
|
||||
{
|
||||
int bytes = 0;
|
||||
|
||||
if (atom->memcheck("tag")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("type")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("mask")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("image")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double);
|
||||
|
||||
if (atom->memcheck("molecule")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("nspecial")) bytes += nmax*3 * sizeof(int);
|
||||
if (atom->memcheck("special")) bytes += nmax*atom->maxspecial * sizeof(int);
|
||||
|
||||
if (atom->memcheck("num_bond")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("bond_type"))
|
||||
bytes += nmax*atom->bond_per_atom * sizeof(int);
|
||||
if (atom->memcheck("bond_atom"))
|
||||
bytes += nmax*atom->bond_per_atom * sizeof(int);
|
||||
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_BOND_H
|
||||
#define ATOM_VEC_BOND_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecBond : public AtomVec {
|
||||
public:
|
||||
AtomVecBond(class LAMMPS *, int, char **);
|
||||
void grow(int);
|
||||
void reset_ptrs();
|
||||
void zero_owned(int);
|
||||
void zero_ghost(int, int);
|
||||
void copy(int, int);
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int pack_border(int, int *, double *, int *);
|
||||
int pack_border_one(int, double *);
|
||||
void unpack_border(int, int, double *);
|
||||
int unpack_border_one(int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
int size_restart();
|
||||
int size_restart_one(int);
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void create_atom(int, double, double, double, int);
|
||||
void data_atom(double, double, double, int, char **, int);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int *tag,*type,*mask,*image;
|
||||
double **x,**v,**f;
|
||||
int *molecule;
|
||||
int **nspecial,**special;
|
||||
int *num_bond;
|
||||
int **bond_type,**bond_atom;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,887 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "atom_vec_molecular.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MIN(A,B) ((A) < (B)) ? (A) : (B)
|
||||
#define MAX(A,B) ((A) > (B)) ? (A) : (B)
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecMolecular::AtomVecMolecular(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVec(lmp, narg, arg)
|
||||
{
|
||||
molecular = 1;
|
||||
bonds_allow = 1;
|
||||
angles_allow = 1;
|
||||
dihedrals_allow = 1;
|
||||
impropers_allow = 1;
|
||||
mass_type = 1;
|
||||
size_comm = 3;
|
||||
size_reverse = 3;
|
||||
size_border = 8;
|
||||
size_data_atom = 7;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 5;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by DELTA
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::grow(int n)
|
||||
{
|
||||
if (n == 0) nmax += DELTA;
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
|
||||
tag = atom->tag = (int *)
|
||||
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
|
||||
type = atom->type = (int *)
|
||||
memory->srealloc(atom->type,nmax*sizeof(int),"atom:type");
|
||||
mask = atom->mask = (int *)
|
||||
memory->srealloc(atom->mask,nmax*sizeof(int),"atom:mask");
|
||||
image = atom->image = (int *)
|
||||
memory->srealloc(atom->image,nmax*sizeof(int),"atom:image");
|
||||
x = atom->x = memory->grow_2d_double_array(atom->x,nmax,3,"atom:x");
|
||||
v = atom->v = memory->grow_2d_double_array(atom->v,nmax,3,"atom:v");
|
||||
f = atom->f = memory->grow_2d_double_array(atom->f,nmax,3,"atom:f");
|
||||
|
||||
q = atom->q = (double *)
|
||||
memory->srealloc(atom->q,nmax*sizeof(double),"atom:q");
|
||||
molecule = atom->molecule = (int *)
|
||||
memory->srealloc(atom->molecule,nmax*sizeof(int),"atom:molecule");
|
||||
|
||||
nspecial = atom->nspecial =
|
||||
memory->grow_2d_int_array(atom->nspecial,nmax,3,"atom:nspecial");
|
||||
special = atom->special =
|
||||
memory->grow_2d_int_array(atom->special,nmax,atom->maxspecial,
|
||||
"atom:special");
|
||||
|
||||
num_bond = atom->num_bond = (int *)
|
||||
memory->srealloc(atom->num_bond,nmax*sizeof(int),"atom:num_bond");
|
||||
bond_type = atom->bond_type =
|
||||
memory->grow_2d_int_array(atom->bond_type,nmax,atom->bond_per_atom,
|
||||
"atom:bond_type");
|
||||
bond_atom = atom->bond_atom =
|
||||
memory->grow_2d_int_array(atom->bond_atom,nmax,atom->bond_per_atom,
|
||||
"atom:bond_atom");
|
||||
|
||||
num_angle = atom->num_angle = (int *)
|
||||
memory->srealloc(atom->num_angle,nmax*sizeof(int),"atom:num_angle");
|
||||
angle_type = atom->angle_type =
|
||||
memory->grow_2d_int_array(atom->angle_type,nmax,atom->angle_per_atom,
|
||||
"atom:angle_type");
|
||||
angle_atom1 = atom->angle_atom1 =
|
||||
memory->grow_2d_int_array(atom->angle_atom1,nmax,atom->angle_per_atom,
|
||||
"atom:angle_atom1");
|
||||
angle_atom2 = atom->angle_atom2 =
|
||||
memory->grow_2d_int_array(atom->angle_atom2,nmax,atom->angle_per_atom,
|
||||
"atom:angle_atom2");
|
||||
angle_atom3 = atom->angle_atom3 =
|
||||
memory->grow_2d_int_array(atom->angle_atom3,nmax,atom->angle_per_atom,
|
||||
"atom:angle_atom3");
|
||||
|
||||
num_dihedral = atom->num_dihedral = (int *)
|
||||
memory->srealloc(atom->num_dihedral,nmax*sizeof(int),"atom:num_dihedral");
|
||||
dihedral_type = atom->dihedral_type =
|
||||
memory->grow_2d_int_array(atom->dihedral_type,nmax,atom->dihedral_per_atom,
|
||||
"atom:dihedral_type");
|
||||
dihedral_atom1 = atom->dihedral_atom1 =
|
||||
memory->grow_2d_int_array(atom->dihedral_atom1,nmax,
|
||||
atom->dihedral_per_atom,"atom:dihedral_atom1");
|
||||
dihedral_atom2 = atom->dihedral_atom2 =
|
||||
memory->grow_2d_int_array(atom->dihedral_atom2,nmax,
|
||||
atom->dihedral_per_atom,"atom:dihedral_atom2");
|
||||
dihedral_atom3 = atom->dihedral_atom3 =
|
||||
memory->grow_2d_int_array(atom->dihedral_atom3,nmax,
|
||||
atom->dihedral_per_atom,"atom:dihedral_atom3");
|
||||
dihedral_atom4 = atom->dihedral_atom4 =
|
||||
memory->grow_2d_int_array(atom->dihedral_atom4,nmax,
|
||||
atom->dihedral_per_atom,"atom:dihedral_atom4");
|
||||
|
||||
num_improper = atom->num_improper = (int *)
|
||||
memory->srealloc(atom->num_improper,nmax*sizeof(int),"atom:num_improper");
|
||||
improper_type = atom->improper_type =
|
||||
memory->grow_2d_int_array(atom->improper_type,nmax,atom->improper_per_atom,
|
||||
"atom:improper_type");
|
||||
improper_atom1 = atom->improper_atom1 =
|
||||
memory->grow_2d_int_array(atom->improper_atom1,nmax,
|
||||
atom->improper_per_atom,"atom:improper_atom1");
|
||||
improper_atom2 = atom->improper_atom2 =
|
||||
memory->grow_2d_int_array(atom->improper_atom2,nmax,
|
||||
atom->improper_per_atom,"atom:improper_atom2");
|
||||
improper_atom3 = atom->improper_atom3 =
|
||||
memory->grow_2d_int_array(atom->improper_atom3,nmax,
|
||||
atom->improper_per_atom,"atom:improper_atom3");
|
||||
improper_atom4 = atom->improper_atom4 =
|
||||
memory->grow_2d_int_array(atom->improper_atom4,nmax,
|
||||
atom->improper_per_atom,"atom:improper_atom4");
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::reset_ptrs()
|
||||
{
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
|
||||
q = atom->q;
|
||||
molecule = atom->molecule;
|
||||
nspecial = atom->nspecial;
|
||||
special = atom->special;
|
||||
|
||||
num_bond = atom->num_bond;
|
||||
bond_type = atom->bond_type;
|
||||
bond_atom = atom->bond_atom;
|
||||
|
||||
num_angle = atom->num_angle;
|
||||
angle_type = atom->angle_type;
|
||||
angle_atom1 = atom->angle_atom1;
|
||||
angle_atom2 = atom->angle_atom2;
|
||||
angle_atom3 = atom->angle_atom3;
|
||||
|
||||
num_dihedral = atom->num_dihedral;
|
||||
dihedral_type = atom->dihedral_type;
|
||||
dihedral_atom1 = atom->dihedral_atom1;
|
||||
dihedral_atom2 = atom->dihedral_atom2;
|
||||
dihedral_atom3 = atom->dihedral_atom3;
|
||||
dihedral_atom4 = atom->dihedral_atom4;
|
||||
|
||||
num_improper = atom->num_improper;
|
||||
improper_type = atom->improper_type;
|
||||
improper_atom1 = atom->improper_atom1;
|
||||
improper_atom2 = atom->improper_atom2;
|
||||
improper_atom3 = atom->improper_atom3;
|
||||
improper_atom4 = atom->improper_atom4;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for owned atom I
|
||||
data in copy(), not including tag,type,mask,image,x,v
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::zero_owned(int i)
|
||||
{
|
||||
q[i] = 0.0;
|
||||
molecule[i] = 0;
|
||||
num_bond[i] = 0;
|
||||
num_angle[i] = 0;
|
||||
num_dihedral[i] = 0;
|
||||
num_improper[i] = 0;
|
||||
nspecial[i][0] = 0;
|
||||
nspecial[i][1] = 0;
|
||||
nspecial[i][2] = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for n ghost atoms
|
||||
data in border(), not including x,tag,type,mask
|
||||
grow() is here since zero_ghost called first in hybrid::unpack_border()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::zero_ghost(int n, int first)
|
||||
{
|
||||
int last = first + n;
|
||||
for (int i = first; i < last; i++) {
|
||||
if (i == nmax) atom->avec->grow(0);
|
||||
q[i] = 0.0;
|
||||
molecule[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::copy(int i, int j)
|
||||
{
|
||||
int k;
|
||||
|
||||
tag[j] = tag[i];
|
||||
type[j] = type[i];
|
||||
mask[j] = mask[i];
|
||||
image[j] = image[i];
|
||||
x[j][0] = x[i][0];
|
||||
x[j][1] = x[i][1];
|
||||
x[j][2] = x[i][2];
|
||||
v[j][0] = v[i][0];
|
||||
v[j][1] = v[i][1];
|
||||
v[j][2] = v[i][2];
|
||||
|
||||
q[j] = q[i];
|
||||
molecule[j] = molecule[i];
|
||||
|
||||
num_bond[j] = num_bond[i];
|
||||
for (k = 0; k < num_bond[j]; k++) {
|
||||
bond_type[j][k] = bond_type[i][k];
|
||||
bond_atom[j][k] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
num_angle[j] = num_angle[i];
|
||||
for (k = 0; k < num_angle[j]; k++) {
|
||||
angle_type[j][k] = angle_type[i][k];
|
||||
angle_atom1[j][k] = angle_atom1[i][k];
|
||||
angle_atom2[j][k] = angle_atom2[i][k];
|
||||
angle_atom3[j][k] = angle_atom3[i][k];
|
||||
}
|
||||
|
||||
num_dihedral[j] = num_dihedral[i];
|
||||
for (k = 0; k < num_dihedral[j]; k++) {
|
||||
dihedral_type[j][k] = dihedral_type[i][k];
|
||||
dihedral_atom1[j][k] = dihedral_atom1[i][k];
|
||||
dihedral_atom2[j][k] = dihedral_atom2[i][k];
|
||||
dihedral_atom3[j][k] = dihedral_atom3[i][k];
|
||||
dihedral_atom4[j][k] = dihedral_atom4[i][k];
|
||||
}
|
||||
|
||||
num_improper[j] = num_improper[i];
|
||||
for (k = 0; k < num_improper[j]; k++) {
|
||||
improper_type[j][k] = improper_type[i][k];
|
||||
improper_atom1[j][k] = improper_atom1[i][k];
|
||||
improper_atom2[j][k] = improper_atom2[i][k];
|
||||
improper_atom3[j][k] = improper_atom3[i][k];
|
||||
improper_atom4[j][k] = improper_atom4[i][k];
|
||||
}
|
||||
|
||||
nspecial[j][0] = nspecial[i][0];
|
||||
nspecial[j][1] = nspecial[i][1];
|
||||
nspecial[j][2] = nspecial[i][2];
|
||||
for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
f[j][0] += buf[m++];
|
||||
f[j][1] += buf[m++];
|
||||
f[j][2] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::pack_border(int n, int *list, double *buf,
|
||||
int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = q[j];
|
||||
buf[m++] = molecule[j];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = q[j];
|
||||
buf[m++] = molecule[j];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::pack_border_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = q[i];
|
||||
buf[1] = molecule[i];
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
q[i] = buf[m++];
|
||||
molecule[i] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::unpack_border_one(int i, double *buf)
|
||||
{
|
||||
q[i] = buf[0];
|
||||
molecule[i] = static_cast<int> (buf[1]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
xyz must be 1st 3 values, so comm::exchange() can test on them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
|
||||
buf[m++] = q[i];
|
||||
buf[m++] = molecule[i];
|
||||
|
||||
buf[m++] = num_bond[i];
|
||||
for (k = 0; k < num_bond[i]; k++) {
|
||||
buf[m++] = bond_type[i][k];
|
||||
buf[m++] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_angle[i];
|
||||
for (k = 0; k < num_angle[i]; k++) {
|
||||
buf[m++] = angle_type[i][k];
|
||||
buf[m++] = angle_atom1[i][k];
|
||||
buf[m++] = angle_atom2[i][k];
|
||||
buf[m++] = angle_atom3[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_dihedral[i];
|
||||
for (k = 0; k < num_dihedral[i]; k++) {
|
||||
buf[m++] = dihedral_type[i][k];
|
||||
buf[m++] = dihedral_atom1[i][k];
|
||||
buf[m++] = dihedral_atom2[i][k];
|
||||
buf[m++] = dihedral_atom3[i][k];
|
||||
buf[m++] = dihedral_atom4[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_improper[i];
|
||||
for (k = 0; k < num_improper[i]; k++) {
|
||||
buf[m++] = improper_type[i][k];
|
||||
buf[m++] = improper_atom1[i][k];
|
||||
buf[m++] = improper_atom2[i][k];
|
||||
buf[m++] = improper_atom3[i][k];
|
||||
buf[m++] = improper_atom4[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = nspecial[i][0];
|
||||
buf[m++] = nspecial[i][1];
|
||||
buf[m++] = nspecial[i][2];
|
||||
for (k = 0; k < nspecial[i][2]; k++) buf[m++] = special[i][k];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::unpack_exchange(double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
q[nlocal] = buf[m++];
|
||||
molecule[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
num_bond[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_bond[nlocal]; k++) {
|
||||
bond_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_angle[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_angle[nlocal]; k++) {
|
||||
angle_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_dihedral[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_dihedral[nlocal]; k++) {
|
||||
dihedral_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom4[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_improper[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_improper[nlocal]; k++) {
|
||||
improper_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom4[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
nspecial[nlocal][0] = static_cast<int> (buf[m++]);
|
||||
nspecial[nlocal][1] = static_cast<int> (buf[m++]);
|
||||
nspecial[nlocal][2] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < nspecial[nlocal][2]; k++)
|
||||
special[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->
|
||||
unpack_exchange(nlocal,&buf[m]);
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for all atoms owned by this proc
|
||||
include extra data stored by fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::size_restart()
|
||||
{
|
||||
int i;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
int n = 0;
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += 17 + 2*num_bond[i] + 4*num_angle[i] +
|
||||
5*num_dihedral[i] + 5*num_improper[i];
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for atom I
|
||||
do not include extra data stored by fixes, included by caller
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::size_restart_one(int i)
|
||||
{
|
||||
int n = 17 + 2*num_bond[i] + 4*num_angle[i] +
|
||||
5*num_dihedral[i] + 5*num_improper[i];
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file including extra quantities
|
||||
xyz must be 1st 3 values, so that read_restart can test on them
|
||||
molecular types may be negative, but write as positive
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::pack_restart(int i, double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
|
||||
buf[m++] = q[i];
|
||||
buf[m++] = molecule[i];
|
||||
|
||||
buf[m++] = num_bond[i];
|
||||
for (k = 0; k < num_bond[i]; k++) {
|
||||
buf[m++] = MAX(bond_type[i][k],-bond_type[i][k]);
|
||||
buf[m++] = bond_atom[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_angle[i];
|
||||
for (k = 0; k < num_angle[i]; k++) {
|
||||
buf[m++] = MAX(angle_type[i][k],-angle_type[i][k]);
|
||||
buf[m++] = angle_atom1[i][k];
|
||||
buf[m++] = angle_atom2[i][k];
|
||||
buf[m++] = angle_atom3[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_dihedral[i];
|
||||
for (k = 0; k < num_dihedral[i]; k++) {
|
||||
buf[m++] = MAX(dihedral_type[i][k],-dihedral_type[i][k]);
|
||||
buf[m++] = dihedral_atom1[i][k];
|
||||
buf[m++] = dihedral_atom2[i][k];
|
||||
buf[m++] = dihedral_atom3[i][k];
|
||||
buf[m++] = dihedral_atom4[i][k];
|
||||
}
|
||||
|
||||
buf[m++] = num_improper[i];
|
||||
for (k = 0; k < num_improper[i]; k++) {
|
||||
buf[m++] = MAX(improper_type[i][k],-improper_type[i][k]);
|
||||
buf[m++] = improper_atom1[i][k];
|
||||
buf[m++] = improper_atom2[i][k];
|
||||
buf[m++] = improper_atom3[i][k];
|
||||
buf[m++] = improper_atom4[i][k];
|
||||
}
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::unpack_restart(double *buf)
|
||||
{
|
||||
int k;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) {
|
||||
grow(0);
|
||||
if (atom->nextra_store)
|
||||
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
|
||||
atom->nextra_store,
|
||||
"atom:extra");
|
||||
}
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
|
||||
q[nlocal] = buf[m++];
|
||||
molecule[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
num_bond[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_bond[nlocal]; k++) {
|
||||
bond_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_angle[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_angle[nlocal]; k++) {
|
||||
angle_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
angle_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_dihedral[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_dihedral[nlocal]; k++) {
|
||||
dihedral_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
dihedral_atom4[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
num_improper[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (k = 0; k < num_improper[nlocal]; k++) {
|
||||
improper_type[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom1[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom2[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom3[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
improper_atom4[nlocal][k] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (buf[0]) - m;
|
||||
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
|
||||
}
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of type itype at x0,y0,z0
|
||||
set other values to defaults
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::create_atom(int itype, double x0, double y0, double z0,
|
||||
int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = 0;
|
||||
type[nlocal] = itype;
|
||||
x[nlocal][0] = x0;
|
||||
x[nlocal][1] = y0;
|
||||
x[nlocal][2] = z0;
|
||||
mask[nlocal] = 1;
|
||||
image[nlocal] = (512 << 20) | (512 << 10) | 512;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
q[nlocal] = 0.0;
|
||||
molecule[nlocal] = 0;
|
||||
num_bond[nlocal] = 0;
|
||||
num_angle[nlocal] = 0;
|
||||
num_dihedral[nlocal] = 0;
|
||||
num_improper[nlocal] = 0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecMolecular::data_atom(double xtmp, double ytmp, double ztmp,
|
||||
int imagetmp, char **values, int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = atoi(values[0]);
|
||||
if (tag[nlocal] <= 0)
|
||||
error->one("Invalid atom ID in Atoms section of data file");
|
||||
|
||||
molecule[nlocal] = atoi(values[1]);
|
||||
|
||||
type[nlocal] = atoi(values[2]);
|
||||
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
|
||||
error->one("Invalid atom type in Atoms section of data file");
|
||||
|
||||
q[nlocal] = atof(values[3]);
|
||||
|
||||
x[nlocal][0] = xtmp;
|
||||
x[nlocal][1] = ytmp;
|
||||
x[nlocal][2] = ztmp;
|
||||
|
||||
image[nlocal] = imagetmp;
|
||||
|
||||
mask[nlocal] = 1;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
num_bond[nlocal] = 0;
|
||||
num_angle[nlocal] = 0;
|
||||
num_dihedral[nlocal] = 0;
|
||||
num_improper[nlocal] = 0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecMolecular::memory_usage()
|
||||
{
|
||||
int bytes = 0;
|
||||
|
||||
if (atom->memcheck("tag")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("type")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("mask")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("image")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double);
|
||||
|
||||
if (atom->memcheck("molecule")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("nspecial")) bytes += nmax*3 * sizeof(int);
|
||||
if (atom->memcheck("special")) bytes += nmax*atom->maxspecial * sizeof(int);
|
||||
|
||||
if (atom->memcheck("num_bond")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("bond_type"))
|
||||
bytes += nmax*atom->bond_per_atom * sizeof(int);
|
||||
if (atom->memcheck("bond_atom"))
|
||||
bytes += nmax*atom->bond_per_atom * sizeof(int);
|
||||
|
||||
if (atom->memcheck("num_angle")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("angle_type"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
if (atom->memcheck("angle_atom1"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
if (atom->memcheck("angle_atom2"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
if (atom->memcheck("angle_atom3"))
|
||||
bytes += nmax*atom->angle_per_atom * sizeof(int);
|
||||
|
||||
if (atom->memcheck("num_dihedral")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("dihedral_type"))
|
||||
bytes += nmax*atom->dihedral_per_atom * sizeof(int);
|
||||
if (atom->memcheck("dihedral_atom1"))
|
||||
bytes += nmax*atom->dihedral_per_atom * sizeof(int);
|
||||
if (atom->memcheck("dihedral_atom2"))
|
||||
bytes += nmax*atom->dihedral_per_atom * sizeof(int);
|
||||
if (atom->memcheck("dihedral_atom3"))
|
||||
bytes += nmax*atom->dihedral_per_atom * sizeof(int);
|
||||
if (atom->memcheck("dihedral_atom4"))
|
||||
bytes += nmax*atom->dihedral_per_atom * sizeof(int);
|
||||
|
||||
if (atom->memcheck("num_improper")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("improper_type"))
|
||||
bytes += nmax*atom->improper_per_atom * sizeof(int);
|
||||
if (atom->memcheck("improper_atom1"))
|
||||
bytes += nmax*atom->improper_per_atom * sizeof(int);
|
||||
if (atom->memcheck("improper_atom2"))
|
||||
bytes += nmax*atom->improper_per_atom * sizeof(int);
|
||||
if (atom->memcheck("improper_atom3"))
|
||||
bytes += nmax*atom->improper_per_atom * sizeof(int);
|
||||
if (atom->memcheck("improper_atom4"))
|
||||
bytes += nmax*atom->improper_per_atom * sizeof(int);
|
||||
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_MOLECULAR_H
|
||||
#define ATOM_VEC_MOLECULAR_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecMolecular : public AtomVec {
|
||||
public:
|
||||
AtomVecMolecular(class LAMMPS *, int, char **);
|
||||
void grow(int);
|
||||
void reset_ptrs();
|
||||
void zero_owned(int);
|
||||
void zero_ghost(int, int);
|
||||
void copy(int, int);
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int pack_border(int, int *, double *, int *);
|
||||
int pack_border_one(int, double *);
|
||||
void unpack_border(int, int, double *);
|
||||
int unpack_border_one(int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
int size_restart();
|
||||
int size_restart_one(int);
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void create_atom(int, double, double, double, int);
|
||||
void data_atom(double, double, double, int, char **, int);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int *tag,*type,*mask,*image;
|
||||
double **x,**v,**f;
|
||||
double *q;
|
||||
int *molecule;
|
||||
int **nspecial,**special;
|
||||
int *num_bond;
|
||||
int **bond_type,**bond_atom;
|
||||
int *num_angle;
|
||||
int **angle_type;
|
||||
int **angle_atom1,**angle_atom2,**angle_atom3;
|
||||
int *num_dihedral;
|
||||
int **dihedral_type;
|
||||
int **dihedral_atom1,**dihedral_atom2,**dihedral_atom3,**dihedral_atom4;
|
||||
int *num_improper;
|
||||
int **improper_type;
|
||||
int **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,40 @@
|
|||
# Install/unInstall package classes in LAMMPS
|
||||
|
||||
if ($1 == 1) then
|
||||
|
||||
cp style_opt.h ..
|
||||
|
||||
cp pair_eam_opt.cpp ..
|
||||
cp pair_eam_alloy_opt.cpp ..
|
||||
cp pair_eam_fs_opt.cpp ..
|
||||
cp pair_lj_charmm_coul_long_opt.cpp ..
|
||||
cp pair_lj_cut_opt.cpp ..
|
||||
cp pair_morse_opt.cpp ..
|
||||
|
||||
cp pair_eam_opt.h ..
|
||||
cp pair_eam_alloy_opt.h ..
|
||||
cp pair_eam_fs_opt.h ..
|
||||
cp pair_lj_charmm_coul_long_opt.h ..
|
||||
cp pair_lj_cut_opt.h ..
|
||||
cp pair_morse_opt.h ..
|
||||
|
||||
else if ($1 == 0) then
|
||||
|
||||
rm ../style_opt.h
|
||||
touch ../style_opt.h
|
||||
|
||||
rm ../pair_eam_opt.cpp
|
||||
rm ../pair_eam_alloy_opt.cpp
|
||||
rm ../pair_eam_fs_opt.cpp
|
||||
rm ../pair_lj_charmm_coul_long_opt.cpp
|
||||
rm ../pair_lj_cut_opt.cpp
|
||||
rm ../pair_morse_opt.cpp
|
||||
|
||||
rm ../pair_eam_opt.h
|
||||
rm ../pair_eam_alloy_opt.h
|
||||
rm ../pair_eam_fs_opt.h
|
||||
rm ../pair_lj_charmm_coul_long_opt.h
|
||||
rm ../pair_lj_cut_opt.h
|
||||
rm ../pair_morse_opt.h
|
||||
|
||||
endif
|
|
@ -0,0 +1,24 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_eam_alloy_opt.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
multiple inheritance from two parent classes
|
||||
invoke constructor of grandparent class, then of each parent
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
PairEAMAlloyOpt::PairEAMAlloyOpt(LAMMPS *lmp) :
|
||||
PairEAM(lmp), PairEAMAlloy(lmp), PairEAMOpt(lmp) {}
|
|
@ -0,0 +1,33 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_EAM_ALLOY_OPT_H
|
||||
#define PAIR_EAM_ALLOY_OPT_H
|
||||
|
||||
#include "pair_eam_alloy.h"
|
||||
#include "pair_eam_opt.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
// multiple inheritance from two parent classes
|
||||
// optimized compute() from PairEAMOpt
|
||||
// everything else from PairEAMAlloy
|
||||
|
||||
class PairEAMAlloyOpt : public PairEAMAlloy, public PairEAMOpt {
|
||||
public:
|
||||
PairEAMAlloyOpt(class LAMMPS *);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,24 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_eam_fs_opt.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
multiple inheritance from two parent classes
|
||||
invoke constructor of grandparent class, then of each parent
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
PairEAMFSOpt::PairEAMFSOpt(LAMMPS *lmp) :
|
||||
PairEAM(lmp), PairEAMFS(lmp), PairEAMOpt(lmp) {}
|
|
@ -0,0 +1,34 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_EAM_FS_OPT_H
|
||||
#define PAIR_EAM_FS_OPT_H
|
||||
|
||||
#include "pair_eam_fs.h"
|
||||
#include "pair_eam_opt.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
// multiple inheritance from two parent classes
|
||||
// optimized compute() from PairEAMOpt
|
||||
// everything else from PairEAMFS
|
||||
|
||||
class PairEAMFSOpt : public PairEAMFS, public PairEAMOpt {
|
||||
public:
|
||||
PairEAMFSOpt(class LAMMPS *);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
Charles Cornwell, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_eam_opt.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairEAMOpt::PairEAMOpt(LAMMPS *lmp) : PairEAM(lmp)
|
||||
{
|
||||
rhor_ = NULL;
|
||||
frho_ = NULL;
|
||||
z2r_ = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairEAMOpt::compute(int eflag, int vflag)
|
||||
{
|
||||
if (eflag) {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,1>();
|
||||
case 1: return eval<1,1,1>();
|
||||
case 2: return eval<1,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,0>();
|
||||
case 1: return eval<1,1,0>();
|
||||
case 2: return eval<1,2,0>();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,1>();
|
||||
case 1: return eval<0,1,1>();
|
||||
case 2: return eval<0,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,0>();
|
||||
case 1: return eval<0,1,0>();
|
||||
case 2: return eval<0,2,0>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,345 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
Charles Cornwell, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_EAM_OPT_H
|
||||
#define PAIR_EAM_OPT_H
|
||||
|
||||
#include "math.h"
|
||||
#include "stdlib.h"
|
||||
#include "pair_eam.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "force.h"
|
||||
#include "neighbor.h"
|
||||
#include "comm.h"
|
||||
#include "memory.h"
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
// use virtual public since this class is parent in multiple inheritance
|
||||
|
||||
class PairEAMOpt : virtual public PairEAM {
|
||||
public:
|
||||
PairEAMOpt(class LAMMPS *);
|
||||
virtual ~PairEAMOpt() {}
|
||||
void compute(int, int);
|
||||
|
||||
protected:
|
||||
double* restrict rhor_;
|
||||
double* restrict frho_;
|
||||
double* restrict z2r_;
|
||||
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR > void eval();
|
||||
};
|
||||
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR >
|
||||
void PairEAMOpt::eval()
|
||||
{
|
||||
typedef struct { double x,y,z; } vec3_t;
|
||||
|
||||
typedef struct {
|
||||
double rhor0i,rhor1i,rhor2i,rhor3i;
|
||||
double rhor0j,rhor1j,rhor2j,rhor3j;
|
||||
} fast_alpha_t;
|
||||
|
||||
typedef struct {
|
||||
double frho0,frho1,frho2,frho3,frho4,frho5,frho6;
|
||||
double _pad[1];
|
||||
} fast_beta_t;
|
||||
|
||||
typedef struct {
|
||||
double rhor4i,rhor5i,rhor6i;
|
||||
double rhor4j,rhor5j,rhor6j;
|
||||
double z2r0,z2r1,z2r2,z2r3,z2r4,z2r5,z2r6;
|
||||
double _pad[3];
|
||||
} fast_gamma_t;
|
||||
|
||||
double** restrict f;
|
||||
double* restrict coeff;
|
||||
|
||||
// grow energy array if necessary
|
||||
|
||||
if (atom->nmax > nmax) {
|
||||
memory->sfree(rho);
|
||||
memory->sfree(fp);
|
||||
nmax = atom->nmax;
|
||||
rho = (double *) memory->smalloc(nmax*sizeof(double),"pair:rho");
|
||||
fp = (double *) memory->smalloc(nmax*sizeof(double),"pair:fp");
|
||||
}
|
||||
|
||||
eng_vdwl = 0.0;
|
||||
if (VFLAG) for (int i = 0; i < 6; i++) virial[i] = 0.0;
|
||||
|
||||
if (VFLAG == 2) f = update->f_pair;
|
||||
else f = atom->f;
|
||||
|
||||
double** restrict x = atom->x;
|
||||
int* restrict type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
vec3_t* restrict xx = (vec3_t*)x[0];
|
||||
vec3_t* restrict ff = (vec3_t*)f[0];
|
||||
|
||||
double tmp_cutforcesq = cutforcesq;
|
||||
double tmp_rdr = rdr;
|
||||
int nr2 = nr-2;
|
||||
int nr1 = nr-1;
|
||||
|
||||
int** restrict firstneigh = neighbor->firstneigh;
|
||||
int* restrict num = neighbor->numneigh;
|
||||
|
||||
int ntypes = atom->ntypes;
|
||||
int ntypes2 = ntypes*ntypes;
|
||||
|
||||
fast_alpha_t* restrict fast_alpha =
|
||||
(fast_alpha_t*) malloc(ntypes2*(nr+1)*sizeof(fast_alpha_t));
|
||||
for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
|
||||
fast_alpha_t* restrict tab = &fast_alpha[i*ntypes*nr+j*nr];
|
||||
for(int m = 1; m <= nr; m++) {
|
||||
tab[m].rhor0i = rhor_spline[type2rhor[i+1][j+1]][m][6];
|
||||
tab[m].rhor1i = rhor_spline[type2rhor[i+1][j+1]][m][5];
|
||||
tab[m].rhor2i = rhor_spline[type2rhor[i+1][j+1]][m][4];
|
||||
tab[m].rhor3i = rhor_spline[type2rhor[i+1][j+1]][m][3];
|
||||
tab[m].rhor0j = rhor_spline[type2rhor[j+1][i+1]][m][6];
|
||||
tab[m].rhor1j = rhor_spline[type2rhor[j+1][i+1]][m][5];
|
||||
tab[m].rhor2j = rhor_spline[type2rhor[j+1][i+1]][m][4];
|
||||
tab[m].rhor3j = rhor_spline[type2rhor[j+1][i+1]][m][3];
|
||||
}
|
||||
}
|
||||
fast_alpha_t* restrict tabeight = fast_alpha;
|
||||
|
||||
fast_gamma_t* restrict fast_gamma =
|
||||
(fast_gamma_t*) malloc(ntypes2*(nr+1)*sizeof(fast_gamma_t));
|
||||
for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
|
||||
fast_gamma_t* restrict tab = &fast_gamma[i*ntypes*nr+j*nr];
|
||||
for(int m = 1; m <= nr; m++) {
|
||||
tab[m].rhor4i = rhor_spline[type2rhor[i+1][j+1]][m][2];
|
||||
tab[m].rhor5i = rhor_spline[type2rhor[i+1][j+1]][m][1];
|
||||
tab[m].rhor6i = rhor_spline[type2rhor[i+1][j+1]][m][0];
|
||||
tab[m].rhor4j = rhor_spline[type2rhor[j+1][i+1]][m][2];
|
||||
tab[m].rhor5j = rhor_spline[type2rhor[j+1][i+1]][m][1];
|
||||
tab[m].rhor6j = rhor_spline[type2rhor[j+1][i+1]][m][0];
|
||||
tab[m].z2r0 = z2r_spline[type2z2r[i+1][j+1]][m][6];
|
||||
tab[m].z2r1 = z2r_spline[type2z2r[i+1][j+1]][m][5];
|
||||
tab[m].z2r2 = z2r_spline[type2z2r[i+1][j+1]][m][4];
|
||||
tab[m].z2r3 = z2r_spline[type2z2r[i+1][j+1]][m][3];
|
||||
tab[m].z2r4 = z2r_spline[type2z2r[i+1][j+1]][m][2];
|
||||
tab[m].z2r5 = z2r_spline[type2z2r[i+1][j+1]][m][1];
|
||||
tab[m].z2r6 = z2r_spline[type2z2r[i+1][j+1]][m][0];
|
||||
}
|
||||
}
|
||||
fast_gamma_t* restrict tabss = fast_gamma;
|
||||
|
||||
// zero out density
|
||||
|
||||
if (NEWTON_PAIR) {
|
||||
int m = nlocal + atom->nghost;
|
||||
for (int i = 0; i < m; i++) rho[i] = 0.0;
|
||||
} else for (int i = 0; i < nlocal; i++) rho[i] = 0.0;
|
||||
|
||||
// rho = density at each atom
|
||||
// loop over neighbors of my atoms
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
double xtmp = xx[i].x;
|
||||
double ytmp = xx[i].y;
|
||||
double ztmp = xx[i].z;
|
||||
int itype = type[i] - 1;
|
||||
int* restrict neighs = firstneigh[i];
|
||||
int numneigh = num[i];
|
||||
|
||||
double tmprho = rho[i];
|
||||
|
||||
fast_alpha_t* restrict tabeighti = &tabeight[itype*ntypes*nr];
|
||||
for (int k = 0; k < numneigh; k++) {
|
||||
int j = neighs[k];
|
||||
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
double rsq = delx*delx + dely*dely + delz*delz;
|
||||
|
||||
if (rsq < tmp_cutforcesq) {
|
||||
|
||||
int jtype = type[j] - 1;
|
||||
|
||||
double p = sqrt(rsq)*tmp_rdr;
|
||||
if ( (int)p <= nr2 ) {
|
||||
int m = (int)p + 1;
|
||||
p -= (double)((int)p);
|
||||
fast_alpha_t& a = tabeighti[jtype*nr+m];
|
||||
tmprho += ((a.rhor3j*p+a.rhor2j)*p+a.rhor1j)*p+a.rhor0j;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
rho[j] += ((a.rhor3i*p+a.rhor2i)*p+a.rhor1i)*p+a.rhor0i;
|
||||
}
|
||||
} else {
|
||||
fast_alpha_t& a = tabeighti[jtype*nr+nr1];
|
||||
tmprho += a.rhor3j+a.rhor2j+a.rhor1j+a.rhor0j;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
rho[j] += a.rhor3i+a.rhor2i+a.rhor1i+a.rhor0i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
rho[i] = tmprho;
|
||||
}
|
||||
|
||||
// communicate and sum densities
|
||||
|
||||
if (NEWTON_PAIR) comm->reverse_comm_pair(this);
|
||||
|
||||
// fp = derivative of embedding energy at each atom
|
||||
// phi = embedding energy at each atom
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
int itype = type[i];
|
||||
double p = rho[i]*rdrho;
|
||||
int m = MIN((int)p,nrho-2);
|
||||
p -= (double)m;
|
||||
++m;
|
||||
coeff = frho_spline[type2frho[type[i]]][m];
|
||||
fp[i] = (coeff[0]*p + coeff[1])*p + coeff[2];
|
||||
if (EFLAG) eng_vdwl += ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6];
|
||||
}
|
||||
|
||||
// communicate derivative of embedding function
|
||||
|
||||
comm->comm_pair(this);
|
||||
|
||||
// compute forces on each atom
|
||||
// loop over neighbors of my atoms
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
double xtmp = xx[i].x;
|
||||
double ytmp = xx[i].y;
|
||||
double ztmp = xx[i].z;
|
||||
int itype = type[i];
|
||||
int itype1 = type[i] - 1;
|
||||
int* restrict neighs = firstneigh[i];
|
||||
int numneigh = num[i];
|
||||
|
||||
double tmpfx = 0.0;
|
||||
double tmpfy = 0.0;
|
||||
double tmpfz = 0.0;
|
||||
|
||||
double fpi = fp[i];
|
||||
|
||||
fast_gamma_t* restrict tabssi = &tabss[itype1*ntypes*nr];
|
||||
for (int k = 0; k < numneigh; k++) {
|
||||
int j = neighs[k];
|
||||
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
double rsq = delx*delx + dely*dely + delz*delz;
|
||||
|
||||
if (rsq < tmp_cutforcesq) {
|
||||
int jtype = type[j] -1;
|
||||
double r = sqrt(rsq);
|
||||
double rhoip,rhojp,z2,z2p;
|
||||
double p = r*tmp_rdr;
|
||||
if ( (int)p <= nr2 ) {
|
||||
int m = (int)p + 1;
|
||||
p -= (double)((int)p);
|
||||
|
||||
fast_gamma_t& a = tabssi[jtype*nr+m];
|
||||
rhoip = (a.rhor6i*p + a.rhor5i)*p + a.rhor4i;
|
||||
rhojp = (a.rhor6j*p + a.rhor5j)*p + a.rhor4j;
|
||||
z2 = ((a.z2r3*p + a.z2r2)*p + a.z2r1)*p + a.z2r0;
|
||||
z2p = (a.z2r6*p + a.z2r5)*p + a.z2r4;
|
||||
|
||||
} else {
|
||||
|
||||
fast_gamma_t& a = tabssi[jtype*nr+nr1];
|
||||
rhoip = a.rhor6i + a.rhor5i + a.rhor4i;
|
||||
rhojp = a.rhor6j + a.rhor5j + a.rhor4j;
|
||||
z2 = a.z2r3 + a.z2r2 + a.z2r1 + a.z2r0;
|
||||
z2p = a.z2r6 + a.z2r5 + a.z2r4;
|
||||
}
|
||||
|
||||
// rhoip = derivative of (density at atom j due to atom i)
|
||||
// rhojp = derivative of (density at atom i due to atom j)
|
||||
// phi = pair potential energy
|
||||
// phip = phi'
|
||||
// z2 = phi * r
|
||||
// z2p = (phi * r)' = (phi' r) + phi
|
||||
// psip needs both fp[i] and fp[j] terms since r_ij appears in two
|
||||
// terms of embed eng: Fi(sum rho_ij) and Fj(sum rho_ji)
|
||||
// hence embed' = Fi(sum rho_ij) rhojp + Fj(sum rho_ji) rhoip
|
||||
|
||||
double recip = 1.0/r;
|
||||
double phi = z2*recip;
|
||||
double phip = z2p*recip - phi*recip;
|
||||
double psip = fp[i]*rhojp + fp[j]*rhoip + phip;
|
||||
double fforce = psip*recip;
|
||||
|
||||
tmpfx += delx*fforce;
|
||||
tmpfy += dely*fforce;
|
||||
tmpfz += delz*fforce;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
ff[j].x += delx*fforce;
|
||||
ff[j].y += dely*fforce;
|
||||
ff[j].z += delz*fforce;
|
||||
}
|
||||
|
||||
if (EFLAG) {
|
||||
if (NEWTON_PAIR || j < nlocal) eng_vdwl += phi;
|
||||
else eng_vdwl += 0.5*phi;
|
||||
}
|
||||
|
||||
if (VFLAG == 1) {
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
virial[0] -= delx*delx*fforce;
|
||||
virial[1] -= dely*dely*fforce;
|
||||
virial[2] -= delz*delz*fforce;
|
||||
virial[3] -= delx*dely*fforce;
|
||||
virial[4] -= delx*delz*fforce;
|
||||
virial[5] -= dely*delz*fforce;
|
||||
} else {
|
||||
virial[0] -= 0.5*delx*delx*fforce;
|
||||
virial[1] -= 0.5*dely*dely*fforce;
|
||||
virial[2] -= 0.5*delz*delz*fforce;
|
||||
virial[3] -= 0.5*delx*dely*fforce;
|
||||
virial[4] -= 0.5*delx*delz*fforce;
|
||||
virial[5] -= 0.5*dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ff[i].x -= tmpfx;
|
||||
ff[i].y -= tmpfy;
|
||||
ff[i].z -= tmpfz;
|
||||
}
|
||||
|
||||
free(fast_alpha); fast_alpha = 0;
|
||||
free(fast_gamma); fast_gamma = 0;
|
||||
|
||||
if (VFLAG == 2) virial_compute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,64 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_lj_charmm_coul_long_opt.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCharmmCoulLongOpt::PairLJCharmmCoulLongOpt(LAMMPS *lmp) :
|
||||
PairLJCharmmCoulLong(lmp) {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairLJCharmmCoulLongOpt::compute(int eflag, int vflag)
|
||||
{
|
||||
if (eflag) {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,1>();
|
||||
case 1: return eval<1,1,1>();
|
||||
case 2: return eval<1,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,0>();
|
||||
case 1: return eval<1,1,0>();
|
||||
case 2: return eval<1,2,0>();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,1>();
|
||||
case 1: return eval<0,1,1>();
|
||||
case 2: return eval<0,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,0>();
|
||||
case 1: return eval<0,1,0>();
|
||||
case 2: return eval<0,2,0>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,363 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_LJ_CHARMM_COUL_LONG_OPT_H
|
||||
#define PAIR_LJ_CHARMM_COUL_LONG_OPT_H
|
||||
|
||||
#include "pair_lj_charmm_coul_long.h"
|
||||
#include "math.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "force.h"
|
||||
#include "kspace.h"
|
||||
#include "update.h"
|
||||
#include "integrate.h"
|
||||
#include "respa.h"
|
||||
#include "memory.h"
|
||||
#include "neighbor.h"
|
||||
#include "error.h"
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
#define EWALD_F 1.12837917
|
||||
#define EWALD_P 0.3275911
|
||||
#define A1 0.254829592
|
||||
#define A2 -0.284496736
|
||||
#define A3 1.421413741
|
||||
#define A4 -1.453152027
|
||||
#define A5 1.061405429
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairLJCharmmCoulLongOpt : public PairLJCharmmCoulLong {
|
||||
public:
|
||||
PairLJCharmmCoulLongOpt(class LAMMPS *);
|
||||
void compute(int, int);
|
||||
|
||||
private:
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR > void eval();
|
||||
};
|
||||
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR >
|
||||
void PairLJCharmmCoulLongOpt::eval()
|
||||
{
|
||||
typedef struct { double x,y,z; } vec3_t;
|
||||
|
||||
typedef struct {
|
||||
double cutsq,lj1,lj2,lj3,lj4,offset;
|
||||
double _pad[2];
|
||||
} fast_alpha_t;
|
||||
|
||||
int i,j,k,numneigh,itype,jtype,itable;
|
||||
double fraction,table;
|
||||
double r,r2inv,r6inv,forcecoul,forcelj,fforce,factor_coul,factor_lj;
|
||||
double grij,expm2,prefactor,t,erfc;
|
||||
double factor,phicoul,philj,switch1,switch2;
|
||||
|
||||
int* restrict neighs;
|
||||
double** restrict f;
|
||||
|
||||
float rsq;
|
||||
int *int_rsq = (int *) &rsq;
|
||||
|
||||
eng_vdwl = eng_coul = 0.0;
|
||||
if (VFLAG) for (i = 0; i < 6; i++) virial[i] = 0.0;
|
||||
|
||||
if (VFLAG == 2) f = update->f_pair;
|
||||
else f = atom->f;
|
||||
|
||||
double** restrict x = atom->x;
|
||||
double* restrict q = atom->q;
|
||||
int* restrict type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
double* restrict special_coul = force->special_coul;
|
||||
double* restrict special_lj = force->special_lj;
|
||||
double qqrd2e = force->qqrd2e;
|
||||
int** restrict firstneigh = neighbor->firstneigh;
|
||||
int* restrict num = neighbor->numneigh;
|
||||
|
||||
vec3_t* restrict xx = (vec3_t*)x[0];
|
||||
vec3_t* restrict ff = (vec3_t*)f[0];
|
||||
|
||||
int ntypes = atom->ntypes;
|
||||
int ntypes2 = ntypes*ntypes;
|
||||
|
||||
double tmp_coef1 = 1.0/denom_lj;
|
||||
double tmp_coef2 = cut_ljsq - 3.0*cut_lj_innersq;
|
||||
|
||||
fast_alpha_t* restrict fast_alpha =
|
||||
(fast_alpha_t*)malloc(ntypes2*sizeof(fast_alpha_t));
|
||||
for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
|
||||
fast_alpha_t& a = fast_alpha[i*ntypes+j];
|
||||
a.cutsq = cutsq[i+1][j+1];
|
||||
a.lj1 = lj1[i+1][j+1];
|
||||
a.lj2 = lj2[i+1][j+1];
|
||||
a.lj3 = lj3[i+1][j+1];
|
||||
a.lj4 = lj4[i+1][j+1];
|
||||
}
|
||||
fast_alpha_t* restrict tabsix = fast_alpha;
|
||||
|
||||
// loop over neighbors of my atoms
|
||||
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
double qtmp = q[i];
|
||||
double xtmp = xx[i].x;
|
||||
double ytmp = xx[i].y;
|
||||
double ztmp = xx[i].z;
|
||||
itype = type[i] - 1;
|
||||
int* restrict neighs = firstneigh[i];
|
||||
int numneigh = num[i];
|
||||
|
||||
double tmpfx = 0.0;
|
||||
double tmpfy = 0.0;
|
||||
double tmpfz = 0.0;
|
||||
|
||||
fast_alpha_t* restrict tabsixi = (fast_alpha_t*) &tabsix[itype*ntypes];
|
||||
for (k = 0; k < numneigh; k++) {
|
||||
j = neighs[k];
|
||||
|
||||
if (j < nall) {
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
rsq = delx*delx + dely*dely + delz*delz;
|
||||
double tmp_coef3 = qtmp*q[j];
|
||||
|
||||
if (rsq < cut_bothsq) {
|
||||
r2inv = 1.0/rsq;
|
||||
|
||||
forcecoul = 0.0;
|
||||
if (rsq < cut_coulsq) {
|
||||
if (!ncoultablebits || rsq <= tabinnersq) {
|
||||
r = sqrtf(rsq);
|
||||
grij = g_ewald * r;
|
||||
expm2 = exp(-grij*grij);
|
||||
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||
erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2;
|
||||
prefactor = qqrd2e * tmp_coef3/r;
|
||||
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2);
|
||||
} else {
|
||||
itable = *int_rsq & ncoulmask;
|
||||
itable >>= ncoulshiftbits;
|
||||
fraction = (rsq - rtable[itable]) * drtable[itable];
|
||||
table = ftable[itable] + fraction*dftable[itable];
|
||||
forcecoul = tmp_coef3 * table;
|
||||
}
|
||||
}
|
||||
|
||||
forcelj = 0.0;
|
||||
if (rsq < cut_ljsq) {
|
||||
r6inv = r2inv*r2inv*r2inv;
|
||||
jtype = type[j] - 1;
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
forcelj = r6inv * (a.lj1*r6inv - a.lj2);
|
||||
if (rsq > cut_lj_innersq) {
|
||||
switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) *
|
||||
(tmp_coef2 + 2.0*rsq) * tmp_coef1;
|
||||
switch2 = 12.0*rsq * (cut_ljsq-rsq) *
|
||||
(rsq-cut_lj_innersq) * tmp_coef1;
|
||||
philj = r6inv * (a.lj3*r6inv - a.lj4);
|
||||
forcelj = forcelj*switch1 + philj*switch2;
|
||||
}
|
||||
}
|
||||
|
||||
fforce = (forcecoul + forcelj) * r2inv;
|
||||
|
||||
tmpfx += delx*fforce;
|
||||
tmpfy += dely*fforce;
|
||||
tmpfz += delz*fforce;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
ff[j].x -= delx*fforce;
|
||||
ff[j].y -= dely*fforce;
|
||||
ff[j].z -= delz*fforce;
|
||||
}
|
||||
|
||||
if (EFLAG) {
|
||||
if (NEWTON_PAIR || j < nlocal) factor = 1.0;
|
||||
else factor = 0.5;
|
||||
if (rsq < cut_coulsq) {
|
||||
if (!ncoultablebits || rsq <= tabinnersq)
|
||||
phicoul = prefactor*erfc;
|
||||
else {
|
||||
table = etable[itable] + fraction*detable[itable];
|
||||
phicoul = tmp_coef3 * table;
|
||||
}
|
||||
eng_coul += factor*phicoul;
|
||||
}
|
||||
if (rsq < cut_ljsq) {
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
philj = r6inv*(a.lj3*r6inv-a.lj4);
|
||||
if (rsq > cut_lj_innersq) {
|
||||
switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) *
|
||||
(tmp_coef2 + 2.0*rsq) * tmp_coef1;
|
||||
philj *= switch1;
|
||||
}
|
||||
eng_vdwl += factor*philj;
|
||||
}
|
||||
}
|
||||
|
||||
if (VFLAG == 1) {
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
virial[0] += delx*delx*fforce;
|
||||
virial[1] += dely*dely*fforce;
|
||||
virial[2] += delz*delz*fforce;
|
||||
virial[3] += delx*dely*fforce;
|
||||
virial[4] += delx*delz*fforce;
|
||||
virial[5] += dely*delz*fforce;
|
||||
} else {
|
||||
virial[0] += 0.5*delx*delx*fforce;
|
||||
virial[1] += 0.5*dely*dely*fforce;
|
||||
virial[2] += 0.5*delz*delz*fforce;
|
||||
virial[3] += 0.5*delx*dely*fforce;
|
||||
virial[4] += 0.5*delx*delz*fforce;
|
||||
virial[5] += 0.5*dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
factor_coul = special_coul[j/nall];
|
||||
factor_lj = special_lj[j/nall];
|
||||
j %= nall;
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
rsq = delx*delx + dely*dely + delz*delz;
|
||||
double tmp_coef3 = qtmp*q[j];
|
||||
|
||||
if (rsq < cut_bothsq) {
|
||||
r2inv = 1.0/rsq;
|
||||
|
||||
forcecoul = 0.0;
|
||||
if (rsq < cut_coulsq) {
|
||||
if (!ncoultablebits || rsq <= tabinnersq) {
|
||||
r = sqrtf(rsq);
|
||||
grij = g_ewald * r;
|
||||
expm2 = exp(-grij*grij);
|
||||
t = 1.0 / (1.0 + EWALD_P*grij);
|
||||
erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2;
|
||||
prefactor = qqrd2e * tmp_coef3/r;
|
||||
forcecoul = prefactor * (erfc + EWALD_F*grij*expm2);
|
||||
if (factor_coul < 1.0) {
|
||||
forcecoul -= (1.0-factor_coul)*prefactor;
|
||||
}
|
||||
} else {
|
||||
itable = *int_rsq & ncoulmask;
|
||||
itable >>= ncoulshiftbits;
|
||||
fraction = (rsq - rtable[itable]) * drtable[itable];
|
||||
table = ftable[itable] + fraction*dftable[itable];
|
||||
forcecoul = tmp_coef3 * table;
|
||||
if (factor_coul < 1.0) {
|
||||
table = ctable[itable] + fraction*dctable[itable];
|
||||
prefactor = tmp_coef3 * table;
|
||||
forcecoul -= (1.0-factor_coul)*prefactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forcelj = 0.0;
|
||||
if (rsq < cut_ljsq) {
|
||||
r6inv = r2inv*r2inv*r2inv;
|
||||
jtype = type[j] - 1;
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
forcelj = r6inv * (a.lj1*r6inv - a.lj2);
|
||||
if (rsq > cut_lj_innersq) {
|
||||
switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) *
|
||||
(tmp_coef2 + 2.0*rsq) * tmp_coef1;
|
||||
switch2 = 12.0*rsq * (cut_ljsq-rsq) *
|
||||
(rsq-cut_lj_innersq) * tmp_coef1;
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
philj = r6inv * (a.lj3*r6inv - a.lj4);
|
||||
forcelj = forcelj*switch1 + philj*switch2;
|
||||
}
|
||||
}
|
||||
|
||||
fforce = (forcecoul + factor_lj*forcelj) * r2inv;
|
||||
|
||||
tmpfx += delx*fforce;
|
||||
tmpfy += dely*fforce;
|
||||
tmpfz += delz*fforce;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
ff[j].x -= delx*fforce;
|
||||
ff[j].y -= dely*fforce;
|
||||
ff[j].z -= delz*fforce;
|
||||
}
|
||||
|
||||
if (EFLAG) {
|
||||
if (NEWTON_PAIR || j < nlocal) factor = 1.0;
|
||||
else factor = 0.5;
|
||||
if (rsq < cut_coulsq) {
|
||||
if (!ncoultablebits || rsq <= tabinnersq)
|
||||
phicoul = prefactor*erfc;
|
||||
else {
|
||||
table = etable[itable] + fraction*detable[itable];
|
||||
phicoul = tmp_coef3 * table;
|
||||
}
|
||||
if (factor_coul < 1.0)
|
||||
phicoul -= (1.0-factor_coul)*prefactor;
|
||||
eng_coul += factor*phicoul;
|
||||
}
|
||||
if (rsq < cut_ljsq) {
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
philj = r6inv*(a.lj3*r6inv-a.lj4);
|
||||
if (rsq > cut_lj_innersq) {
|
||||
switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) *
|
||||
(tmp_coef2 + 2.0*rsq) * tmp_coef1;
|
||||
philj *= switch1;
|
||||
}
|
||||
eng_vdwl += factor*factor_lj*philj;
|
||||
}
|
||||
}
|
||||
|
||||
if (VFLAG == 1) {
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
virial[0] += delx*delx*fforce;
|
||||
virial[1] += dely*dely*fforce;
|
||||
virial[2] += delz*delz*fforce;
|
||||
virial[3] += delx*dely*fforce;
|
||||
virial[4] += delx*delz*fforce;
|
||||
virial[5] += dely*delz*fforce;
|
||||
} else {
|
||||
virial[0] += 0.5*delx*delx*fforce;
|
||||
virial[1] += 0.5*dely*dely*fforce;
|
||||
virial[2] += 0.5*delz*delz*fforce;
|
||||
virial[3] += 0.5*delx*dely*fforce;
|
||||
virial[4] += 0.5*delx*delz*fforce;
|
||||
virial[5] += 0.5*dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ff[i].x += tmpfx;
|
||||
ff[i].y += tmpfy;
|
||||
ff[i].z += tmpfz;
|
||||
}
|
||||
if (VFLAG == 2) virial_compute();
|
||||
free(fast_alpha); fast_alpha = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,63 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_lj_cut_opt.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairLJCutOpt::PairLJCutOpt(LAMMPS *lmp) : PairLJCut(lmp) {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairLJCutOpt::compute(int eflag, int vflag)
|
||||
{
|
||||
if (eflag) {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,1>();
|
||||
case 1: return eval<1,1,1>();
|
||||
case 2: return eval<1,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,0>();
|
||||
case 1: return eval<1,1,0>();
|
||||
case 2: return eval<1,2,0>();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,1>();
|
||||
case 1: return eval<0,1,1>();
|
||||
case 2: return eval<0,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,0>();
|
||||
case 1: return eval<0,1,0>();
|
||||
case 2: return eval<0,2,0>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_LJ_CUT_OPT_H
|
||||
#define PAIR_LJ_CUT_OPT_H
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "pair_lj_cut.h"
|
||||
#include "atom.h"
|
||||
#include "update.h"
|
||||
#include "force.h"
|
||||
#include "neighbor.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairLJCutOpt : public PairLJCut {
|
||||
public:
|
||||
PairLJCutOpt(class LAMMPS *);
|
||||
void compute(int, int);
|
||||
|
||||
private:
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR > void eval();
|
||||
};
|
||||
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR >
|
||||
void PairLJCutOpt::eval()
|
||||
{
|
||||
typedef struct { double x,y,z; } vec3_t;
|
||||
|
||||
typedef struct {
|
||||
double cutsq,lj1,lj2,lj3,lj4,offset;
|
||||
double _pad[2];
|
||||
} fast_alpha_t;
|
||||
|
||||
int* restrict neighs;
|
||||
double** restrict f;
|
||||
|
||||
eng_vdwl = 0.0;
|
||||
if (VFLAG) for (int i = 0; i < 6; i++) virial[i] = 0.0;
|
||||
|
||||
if (VFLAG == 2) f = update->f_pair;
|
||||
else f = atom->f;
|
||||
|
||||
double** restrict x = atom->x;
|
||||
int* restrict type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
double* restrict special_lj = force->special_lj;
|
||||
int** restrict firstneigh = neighbor->firstneigh;
|
||||
int* restrict num = neighbor->numneigh;
|
||||
|
||||
vec3_t* restrict xx = (vec3_t*)x[0];
|
||||
vec3_t* restrict ff = (vec3_t*)f[0];
|
||||
|
||||
int ntypes = atom->ntypes;
|
||||
int ntypes2 = ntypes*ntypes;
|
||||
|
||||
fast_alpha_t* restrict fast_alpha =
|
||||
(fast_alpha_t*) malloc(ntypes2*sizeof(fast_alpha_t));
|
||||
for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
|
||||
fast_alpha_t& a = fast_alpha[i*ntypes+j];
|
||||
a.cutsq = cutsq[i+1][j+1];
|
||||
a.lj1 = lj1[i+1][j+1];
|
||||
a.lj2 = lj2[i+1][j+1];
|
||||
a.lj3 = lj3[i+1][j+1];
|
||||
a.lj4 = lj4[i+1][j+1];
|
||||
a.offset = offset[i+1][j+1];
|
||||
}
|
||||
fast_alpha_t* restrict tabsix = fast_alpha;
|
||||
|
||||
// loop over neighbors of my atoms
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
double xtmp = xx[i].x;
|
||||
double ytmp = xx[i].y;
|
||||
double ztmp = xx[i].z;
|
||||
int itype = type[i] - 1;
|
||||
int* restrict neighs = firstneigh[i];
|
||||
int numneigh = num[i];
|
||||
|
||||
double tmpfx = 0.0;
|
||||
double tmpfy = 0.0;
|
||||
double tmpfz = 0.0;
|
||||
|
||||
fast_alpha_t* restrict tabsixi = (fast_alpha_t*)&tabsix[itype*ntypes];
|
||||
|
||||
for (int k = 0; k < numneigh; k++) {
|
||||
int j = neighs[k];
|
||||
double factor_lj;
|
||||
|
||||
if (j < nall) {
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
double rsq = delx*delx + dely*dely + delz*delz;
|
||||
|
||||
int jtype = type[j] - 1;
|
||||
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
|
||||
if (rsq < a.cutsq) {
|
||||
double r2inv = 1.0/rsq;
|
||||
double r6inv = r2inv*r2inv*r2inv;
|
||||
double forcelj = r6inv * (a.lj1*r6inv - a.lj2);
|
||||
if (EFLAG) {
|
||||
double philj = r6inv*(a.lj3*r6inv-a.lj4) - a.offset;
|
||||
if (NEWTON_PAIR || j < nlocal) eng_vdwl += philj;
|
||||
else eng_vdwl += 0.5*philj;
|
||||
}
|
||||
double fforce = forcelj*r2inv;
|
||||
|
||||
tmpfx += delx*fforce;
|
||||
tmpfy += dely*fforce;
|
||||
tmpfz += delz*fforce;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
ff[j].x -= delx*fforce;
|
||||
ff[j].y -= dely*fforce;
|
||||
ff[j].z -= delz*fforce;
|
||||
}
|
||||
|
||||
if (VFLAG == 1) {
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
virial[0] += delx*delx*fforce;
|
||||
virial[1] += dely*dely*fforce;
|
||||
virial[2] += delz*delz*fforce;
|
||||
virial[3] += delx*dely*fforce;
|
||||
virial[4] += delx*delz*fforce;
|
||||
virial[5] += dely*delz*fforce;
|
||||
} else {
|
||||
virial[0] += 0.5*delx*delx*fforce;
|
||||
virial[1] += 0.5*dely*dely*fforce;
|
||||
virial[2] += 0.5*delz*delz*fforce;
|
||||
virial[3] += 0.5*delx*dely*fforce;
|
||||
virial[4] += 0.5*delx*delz*fforce;
|
||||
virial[5] += 0.5*dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
factor_lj = special_lj[j/nall];
|
||||
j = j % nall;
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
double rsq = delx*delx + dely*dely + delz*delz;
|
||||
|
||||
int jtype1 = type[j];
|
||||
int jtype = jtype1 - 1;
|
||||
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
if (rsq < a.cutsq) {
|
||||
|
||||
double r2inv = 1.0/rsq;
|
||||
double r6inv = r2inv*r2inv*r2inv;
|
||||
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
double forcelj = r6inv * (a.lj1*r6inv - a.lj2);
|
||||
if (EFLAG) {
|
||||
double philj = r6inv*(a.lj3*r6inv-a.lj4) - a.offset;
|
||||
if (NEWTON_PAIR || j < nlocal) eng_vdwl += factor_lj*philj;
|
||||
else eng_vdwl += 0.5*factor_lj*philj;
|
||||
}
|
||||
|
||||
double fforce = factor_lj*forcelj*r2inv;
|
||||
|
||||
tmpfx += delx*fforce;
|
||||
tmpfy += dely*fforce;
|
||||
tmpfz += delz*fforce;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
ff[j].x -= delx*fforce;
|
||||
ff[j].y -= dely*fforce;
|
||||
ff[j].z -= delz*fforce;
|
||||
}
|
||||
|
||||
if (VFLAG == 1) {
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
virial[0] += delx*delx*fforce;
|
||||
virial[1] += dely*dely*fforce;
|
||||
virial[2] += delz*delz*fforce;
|
||||
virial[3] += delx*dely*fforce;
|
||||
virial[4] += delx*delz*fforce;
|
||||
virial[5] += dely*delz*fforce;
|
||||
} else {
|
||||
virial[0] += 0.5*delx*delx*fforce;
|
||||
virial[1] += 0.5*dely*dely*fforce;
|
||||
virial[2] += 0.5*delz*delz*fforce;
|
||||
virial[3] += 0.5*delx*dely*fforce;
|
||||
virial[4] += 0.5*delx*delz*fforce;
|
||||
virial[5] += 0.5*dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ff[i].x += tmpfx;
|
||||
ff[i].y += tmpfy;
|
||||
ff[i].z += tmpfz;
|
||||
}
|
||||
|
||||
if (VFLAG == 2) virial_compute();
|
||||
|
||||
free(fast_alpha); fast_alpha = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,63 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "pair_morse_opt.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
PairMorseOpt::PairMorseOpt(LAMMPS *lmp) : PairMorse(lmp) {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void PairMorseOpt::compute(int eflag, int vflag)
|
||||
{
|
||||
if (eflag) {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,1>();
|
||||
case 1: return eval<1,1,1>();
|
||||
case 2: return eval<1,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<1,0,0>();
|
||||
case 1: return eval<1,1,0>();
|
||||
case 2: return eval<1,2,0>();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (force->newton_pair) {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,1>();
|
||||
case 1: return eval<0,1,1>();
|
||||
case 2: return eval<0,2,1>();
|
||||
}
|
||||
} else {
|
||||
switch (vflag) {
|
||||
case 0: return eval<0,0,0>();
|
||||
case 1: return eval<0,1,0>();
|
||||
case 2: return eval<0,2,0>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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 authors:
|
||||
James Fischer, High Performance Technologies, Inc.
|
||||
David Richie, Stone Ridge Technology
|
||||
Vincent Natol, Stone Ridge Technology
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PAIR_MORSE_OPT_H
|
||||
#define PAIR_MORSE_OPT_H
|
||||
|
||||
#include "math.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "pair_morse.h"
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "memory.h"
|
||||
#include "neighbor.h"
|
||||
#include "error.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PairMorseOpt : public PairMorse {
|
||||
public:
|
||||
PairMorseOpt(class LAMMPS *);
|
||||
void compute(int, int);
|
||||
|
||||
private:
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR > void eval();
|
||||
};
|
||||
|
||||
template < int EFLAG, int VFLAG, int NEWTON_PAIR >
|
||||
void PairMorseOpt::eval()
|
||||
{
|
||||
typedef struct { double x,y,z; } vec3_t;
|
||||
|
||||
typedef struct {
|
||||
double cutsq,r0,alpha,morse1,d0,offset;
|
||||
double _pad[2];
|
||||
} fast_alpha_t;
|
||||
|
||||
int* restrict neighs;
|
||||
double** restrict f;
|
||||
|
||||
eng_vdwl = 0.0;
|
||||
if (VFLAG) for (int i = 0; i < 6; i++) virial[i] = 0.0;
|
||||
|
||||
if (VFLAG == 2) f = update->f_pair;
|
||||
else f = atom->f;
|
||||
|
||||
double** restrict x = atom->x;
|
||||
int* restrict type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
double* restrict special_lj = force->special_lj;
|
||||
|
||||
int** restrict firstneigh = neighbor->firstneigh;
|
||||
int* restrict num = neighbor->numneigh;
|
||||
|
||||
vec3_t* restrict xx = (vec3_t*)x[0];
|
||||
vec3_t* restrict ff = (vec3_t*)f[0];
|
||||
|
||||
int ntypes = atom->ntypes;
|
||||
int ntypes2 = ntypes*ntypes;
|
||||
|
||||
fast_alpha_t* restrict fast_alpha =
|
||||
(fast_alpha_t*) malloc(ntypes2*sizeof(fast_alpha_t));
|
||||
for( int i = 0; i < ntypes; i++) for( int j = 0; j < ntypes; j++) {
|
||||
fast_alpha_t& a = fast_alpha[i*ntypes+j];
|
||||
a.cutsq = cutsq[i+1][j+1];
|
||||
a.r0 = r0[i+1][j+1];
|
||||
a.alpha = alpha[i+1][j+1];
|
||||
a.morse1 = morse1[i+1][j+1];
|
||||
a.d0 = d0[i+1][j+1];
|
||||
a.offset = offset[i+1][j+1];
|
||||
}
|
||||
fast_alpha_t* restrict tabsix = fast_alpha;
|
||||
|
||||
// loop over neighbors of my atoms
|
||||
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
double xtmp = xx[i].x;
|
||||
double ytmp = xx[i].y;
|
||||
double ztmp = xx[i].z;
|
||||
int itype = type[i] - 1;
|
||||
int* restrict neighs = firstneigh[i];
|
||||
int numneigh = num[i];
|
||||
|
||||
double tmpfx = 0.0;
|
||||
double tmpfy = 0.0;
|
||||
double tmpfz = 0.0;
|
||||
|
||||
fast_alpha_t* restrict tabsixi = (fast_alpha_t*)&tabsix[itype*ntypes];
|
||||
|
||||
for (int k = 0; k < numneigh; k++) {
|
||||
int j = neighs[k];
|
||||
|
||||
double factor_lj;
|
||||
if (j < nall) {
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
double rsq = delx*delx + dely*dely + delz*delz;
|
||||
|
||||
int jtype = type[j] - 1;
|
||||
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
if (rsq < a.cutsq) {
|
||||
double r = sqrt(rsq);
|
||||
double dr = r - a.r0;
|
||||
double dexp = exp(-a.alpha * dr);
|
||||
double fforce = a.morse1 * (dexp*dexp - dexp) / r;
|
||||
if (EFLAG) {
|
||||
double phi = a.d0 * (dexp*dexp - 2.0*dexp) - a.offset;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
eng_vdwl += phi;
|
||||
} else {
|
||||
eng_vdwl += 0.5*phi;
|
||||
}
|
||||
}
|
||||
|
||||
tmpfx += delx*fforce;
|
||||
tmpfy += dely*fforce;
|
||||
tmpfz += delz*fforce;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
ff[j].x -= delx*fforce;
|
||||
ff[j].y -= dely*fforce;
|
||||
ff[j].z -= delz*fforce;
|
||||
}
|
||||
|
||||
if (VFLAG == 1) {
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
virial[0] += delx*delx*fforce;
|
||||
virial[1] += dely*dely*fforce;
|
||||
virial[2] += delz*delz*fforce;
|
||||
virial[3] += delx*dely*fforce;
|
||||
virial[4] += delx*delz*fforce;
|
||||
virial[5] += dely*delz*fforce;
|
||||
} else {
|
||||
virial[0] += 0.5*delx*delx*fforce;
|
||||
virial[1] += 0.5*dely*dely*fforce;
|
||||
virial[2] += 0.5*delz*delz*fforce;
|
||||
virial[3] += 0.5*delx*dely*fforce;
|
||||
virial[4] += 0.5*delx*delz*fforce;
|
||||
virial[5] += 0.5*dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
factor_lj = special_lj[j/nall];
|
||||
j = j % nall;
|
||||
|
||||
double delx = xtmp - xx[j].x;
|
||||
double dely = ytmp - xx[j].y;
|
||||
double delz = ztmp - xx[j].z;
|
||||
double rsq = delx*delx + dely*dely + delz*delz;
|
||||
|
||||
int jtype = type[j] - 1;
|
||||
|
||||
fast_alpha_t& a = tabsixi[jtype];
|
||||
if (rsq < a.cutsq) {
|
||||
double r = sqrt(rsq);
|
||||
double dr = r - a.r0;
|
||||
double dexp = exp(-a.alpha * dr);
|
||||
double fforce = factor_lj * a.morse1 * (dexp*dexp - dexp) / r;
|
||||
if (EFLAG) {
|
||||
double phi = a.d0 * (dexp*dexp - 2.0*dexp) - a.offset;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
eng_vdwl += factor_lj*phi;
|
||||
} else {
|
||||
eng_vdwl += 0.5*factor_lj*phi;
|
||||
}
|
||||
}
|
||||
|
||||
tmpfx += delx*fforce;
|
||||
tmpfy += dely*fforce;
|
||||
tmpfz += delz*fforce;
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
ff[j].x -= delx*fforce;
|
||||
ff[j].y -= dely*fforce;
|
||||
ff[j].z -= delz*fforce;
|
||||
}
|
||||
|
||||
if (VFLAG == 1) {
|
||||
if (NEWTON_PAIR || j < nlocal) {
|
||||
virial[0] += delx*delx*fforce;
|
||||
virial[1] += dely*dely*fforce;
|
||||
virial[2] += delz*delz*fforce;
|
||||
virial[3] += delx*dely*fforce;
|
||||
virial[4] += delx*delz*fforce;
|
||||
virial[5] += dely*delz*fforce;
|
||||
} else {
|
||||
virial[0] += 0.5*delx*delx*fforce;
|
||||
virial[1] += 0.5*dely*dely*fforce;
|
||||
virial[2] += 0.5*delz*delz*fforce;
|
||||
virial[3] += 0.5*delx*dely*fforce;
|
||||
virial[4] += 0.5*delx*delz*fforce;
|
||||
virial[5] += 0.5*dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ff[i].x += tmpfx;
|
||||
ff[i].y += tmpfy;
|
||||
ff[i].z += tmpfz;
|
||||
}
|
||||
|
||||
if (VFLAG == 2) virial_compute();
|
||||
|
||||
free(fast_alpha); fast_alpha = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,30 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef PairInclude
|
||||
#include "pair_eam_opt.h"
|
||||
#include "pair_eam_alloy_opt.h"
|
||||
#include "pair_eam_fs_opt.h"
|
||||
#include "pair_lj_charmm_coul_long_opt.h"
|
||||
#include "pair_lj_cut_opt.h"
|
||||
#include "pair_morse_opt.h"
|
||||
#endif
|
||||
|
||||
#ifdef PairClass
|
||||
PairStyle(eam/opt,PairEAMOpt)
|
||||
PairStyle(eam/alloy/opt,PairEAMAlloyOpt)
|
||||
PairStyle(eam/fs/opt,PairEAMFSOpt)
|
||||
PairStyle(lj/cut/opt,PairLJCutOpt)
|
||||
PairStyle(lj/charmm/coul/long/opt,PairLJCharmmCoulLongOpt)
|
||||
PairStyle(morse/opt,PairMorseOpt)
|
||||
#endif
|
|
@ -0,0 +1,42 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "atom_vec.h"
|
||||
#include "atom.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVec::AtomVec(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
{
|
||||
nmax = 0;
|
||||
molecular = 0;
|
||||
bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 0;
|
||||
mass_type = dipole_type = 0;
|
||||
comm_x_only = comm_f_only = 1;
|
||||
size_comm = size_reverse = size_border = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack a single line from Velocity section of data file
|
||||
individual style may override this
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVec::data_vel(int m, char *line, int ihybrid)
|
||||
{
|
||||
int tmp;
|
||||
double **v = atom->v;
|
||||
sscanf(line,"%d %lg %lg %lg",&tmp,&v[m][0],&v[m][1],&v[m][2]);
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef FOO_H
|
||||
#define FOO_H
|
||||
|
||||
#include "pointers.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVec : protected Pointers {
|
||||
public:
|
||||
int molecular; // 0 = atomic, 1 = molecular system
|
||||
int bonds_allow,angles_allow; // 1 if bonds, angles are used
|
||||
int dihedrals_allow,impropers_allow; // 1 if dihedrals, impropers used
|
||||
int mass_type; // 1 if per-type masses
|
||||
int dipole_type; // 1 if per-type dipole moments
|
||||
int comm_x_only; // 1 if only exchange x in forward comm
|
||||
int comm_f_only; // 1 if only exchange f in reverse comm
|
||||
int size_comm; // # of values per atom in comm
|
||||
int size_reverse; // # in reverse comm
|
||||
int size_border; // # in border comm
|
||||
int size_data_atom; // number of values in Atom line
|
||||
int size_data_vel; // number of values in Velocity line
|
||||
int xcol_data; // column (1-N) where x is in Atom line
|
||||
|
||||
AtomVec(class LAMMPS *, int, char **);
|
||||
virtual ~AtomVec() {}
|
||||
virtual void init() {}
|
||||
|
||||
virtual void grow(int) = 0;
|
||||
virtual void reset_ptrs() = 0;
|
||||
virtual void zero_owned(int) {}
|
||||
virtual void zero_ghost(int,int) {}
|
||||
virtual void copy(int, int) = 0;
|
||||
|
||||
virtual int pack_comm(int, int *, double *, int *) = 0;
|
||||
virtual int pack_comm_one(int, double *) {return 0;}
|
||||
virtual void unpack_comm(int, int, double *) = 0;
|
||||
virtual int unpack_comm_one(int, double *) {return 0;}
|
||||
|
||||
virtual int pack_reverse(int, int, double *) = 0;
|
||||
virtual int pack_reverse_one(int, double *) {return 0;}
|
||||
virtual void unpack_reverse(int, int *, double *) = 0;
|
||||
virtual int unpack_reverse_one(int, double *) {return 0;}
|
||||
|
||||
virtual int pack_border(int, int *, double *, int *) = 0;
|
||||
virtual int pack_border_one(int, double *) {return 0;}
|
||||
virtual void unpack_border(int, int, double *) = 0;
|
||||
virtual int unpack_border_one(int, double *) {return 0;}
|
||||
|
||||
virtual int pack_exchange(int, double *) = 0;
|
||||
virtual int unpack_exchange(double *) = 0;
|
||||
|
||||
virtual int size_restart() = 0;
|
||||
virtual int size_restart_one(int) = 0;
|
||||
virtual int pack_restart(int, double *) = 0;
|
||||
virtual int unpack_restart(double *) = 0;
|
||||
|
||||
virtual void create_atom(int, double, double, double, int) = 0;
|
||||
virtual void data_atom(double, double, double, int, char **, int) = 0;
|
||||
virtual void data_vel(int, char *, int);
|
||||
virtual void data_params(int) {}
|
||||
|
||||
virtual int memory_usage() = 0;
|
||||
|
||||
protected:
|
||||
int nmax; // local copy of atom->nmax
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,455 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "atom_vec_atomic.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecAtomic::AtomVecAtomic(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVec(lmp, narg, arg)
|
||||
{
|
||||
mass_type = 1;
|
||||
size_comm = 3;
|
||||
size_reverse = 3;
|
||||
size_border = 6;
|
||||
size_data_atom = 5;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 3;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by DELTA
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::grow(int n)
|
||||
{
|
||||
if (n == 0) nmax += DELTA;
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
|
||||
tag = atom->tag = (int *)
|
||||
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
|
||||
type = atom->type = (int *)
|
||||
memory->srealloc(atom->type,nmax*sizeof(int),"atom:type");
|
||||
mask = atom->mask = (int *)
|
||||
memory->srealloc(atom->mask,nmax*sizeof(int),"atom:mask");
|
||||
image = atom->image = (int *)
|
||||
memory->srealloc(atom->image,nmax*sizeof(int),"atom:image");
|
||||
x = atom->x = memory->grow_2d_double_array(atom->x,nmax,3,"atom:x");
|
||||
v = atom->v = memory->grow_2d_double_array(atom->v,nmax,3,"atom:v");
|
||||
f = atom->f = memory->grow_2d_double_array(atom->f,nmax,3,"atom:f");
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::reset_ptrs()
|
||||
{
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::copy(int i, int j)
|
||||
{
|
||||
tag[j] = tag[i];
|
||||
type[j] = type[i];
|
||||
mask[j] = mask[i];
|
||||
image[j] = image[i];
|
||||
x[j][0] = x[i][0];
|
||||
x[j][1] = x[i][1];
|
||||
x[j][2] = x[i][2];
|
||||
v[j][0] = v[i][0];
|
||||
v[j][1] = v[i][1];
|
||||
v[j][2] = v[i][2];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
f[j][0] += buf[m++];
|
||||
f[j][1] += buf[m++];
|
||||
f[j][2] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::pack_border(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
xyz must be 1st 3 values, so comm::exchange() can test on them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::unpack_exchange(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->
|
||||
unpack_exchange(nlocal,&buf[m]);
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for all atoms owned by this proc
|
||||
include extra data stored by fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::size_restart()
|
||||
{
|
||||
int i;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
int n = 11 * nlocal;
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for atom I
|
||||
do not include extra data stored by fixes, included by caller
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::size_restart_one(int i)
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file including extra quantities
|
||||
xyz must be 1st 3 values, so that read_restart can test on them
|
||||
molecular types may be negative, but write as positive
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::pack_restart(int i, double *buf)
|
||||
{
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::unpack_restart(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) {
|
||||
grow(0);
|
||||
if (atom->nextra_store)
|
||||
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
|
||||
atom->nextra_store,
|
||||
"atom:extra");
|
||||
}
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (buf[0]) - m;
|
||||
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
|
||||
}
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of type itype at x0,y0,z0
|
||||
set other values to defaults
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::create_atom(int itype, double x0, double y0, double z0,
|
||||
int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = 0;
|
||||
type[nlocal] = itype;
|
||||
x[nlocal][0] = x0;
|
||||
x[nlocal][1] = y0;
|
||||
x[nlocal][2] = z0;
|
||||
mask[nlocal] = 1;
|
||||
image[nlocal] = (512 << 20) | (512 << 10) | 512;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecAtomic::data_atom(double xtmp, double ytmp, double ztmp,
|
||||
int imagetmp, char **values, int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = atoi(values[0]);
|
||||
if (tag[nlocal] <= 0)
|
||||
error->one("Invalid atom ID in Atoms section of data file");
|
||||
|
||||
type[nlocal] = atoi(values[1]);
|
||||
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
|
||||
error->one("Invalid atom type in Atoms section of data file");
|
||||
|
||||
x[nlocal][0] = xtmp;
|
||||
x[nlocal][1] = ytmp;
|
||||
x[nlocal][2] = ztmp;
|
||||
|
||||
image[nlocal] = imagetmp;
|
||||
|
||||
mask[nlocal] = 1;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecAtomic::memory_usage()
|
||||
{
|
||||
int bytes = 0;
|
||||
|
||||
if (atom->memcheck("tag")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("type")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("mask")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("image")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double);
|
||||
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_ATOMIC_H
|
||||
#define ATOM_VEC_ATOMIC_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecAtomic : public AtomVec {
|
||||
public:
|
||||
AtomVecAtomic(class LAMMPS *, int, char **);
|
||||
virtual ~AtomVecAtomic() {}
|
||||
void grow(int);
|
||||
void reset_ptrs();
|
||||
void copy(int, int);
|
||||
virtual int pack_comm(int, int *, double *, int *);
|
||||
virtual void unpack_comm(int, int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
virtual int pack_border(int, int *, double *, int *);
|
||||
virtual void unpack_border(int, int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
int size_restart();
|
||||
int size_restart_one(int);
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void create_atom(int, double, double, double, int);
|
||||
void data_atom(double, double, double, int, char **, int);
|
||||
int memory_usage();
|
||||
|
||||
protected:
|
||||
int *tag,*type,*mask,*image;
|
||||
double **x,**v,**f;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,520 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "atom_vec_charge.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecCharge::AtomVecCharge(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVec(lmp, narg, arg)
|
||||
{
|
||||
mass_type = 1;
|
||||
size_comm = 3;
|
||||
size_reverse = 3;
|
||||
size_border = 7;
|
||||
size_data_atom = 6;
|
||||
size_data_vel = 4;
|
||||
xcol_data = 4;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by DELTA
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::grow(int n)
|
||||
{
|
||||
if (n == 0) nmax += DELTA;
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
|
||||
tag = atom->tag = (int *)
|
||||
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
|
||||
type = atom->type = (int *)
|
||||
memory->srealloc(atom->type,nmax*sizeof(int),"atom:type");
|
||||
mask = atom->mask = (int *)
|
||||
memory->srealloc(atom->mask,nmax*sizeof(int),"atom:mask");
|
||||
image = atom->image = (int *)
|
||||
memory->srealloc(atom->image,nmax*sizeof(int),"atom:image");
|
||||
x = atom->x = memory->grow_2d_double_array(atom->x,nmax,3,"atom:x");
|
||||
v = atom->v = memory->grow_2d_double_array(atom->v,nmax,3,"atom:v");
|
||||
f = atom->f = memory->grow_2d_double_array(atom->f,nmax,3,"atom:f");
|
||||
|
||||
q = atom->q = (double *)
|
||||
memory->srealloc(atom->q,nmax*sizeof(double),"atom:q");
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::reset_ptrs()
|
||||
{
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
|
||||
q = atom->q;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for owned atom I
|
||||
data in copy(), not including tag,type,mask,image,x,v
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::zero_owned(int i)
|
||||
{
|
||||
q[i] = 0.0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
zero auxiliary data for n ghost atoms
|
||||
data in border(), not including x,tag,type,mask
|
||||
grow() is here since zero_ghost called first in hybrid::unpack_border()
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::zero_ghost(int n, int first)
|
||||
{
|
||||
int last = first + n;
|
||||
for (int i = first; i < last; i++) {
|
||||
if (i == nmax) atom->avec->grow(0);
|
||||
q[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::copy(int i, int j)
|
||||
{
|
||||
tag[j] = tag[i];
|
||||
type[j] = type[i];
|
||||
mask[j] = mask[i];
|
||||
image[j] = image[i];
|
||||
x[j][0] = x[i][0];
|
||||
x[j][1] = x[i][1];
|
||||
x[j][2] = x[i][2];
|
||||
v[j][0] = v[i][0];
|
||||
v[j][1] = v[i][1];
|
||||
v[j][2] = v[i][2];
|
||||
|
||||
q[j] = q[i];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
f[j][0] += buf[m++];
|
||||
f[j][1] += buf[m++];
|
||||
f[j][2] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::pack_border(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = q[j];
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = q[j];
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::pack_border_one(int i, double *buf)
|
||||
{
|
||||
buf[0] = q[i];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
q[i] = buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::unpack_border_one(int i, double *buf)
|
||||
{
|
||||
q[i] = buf[0];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
xyz must be 1st 3 values, so comm::exchange() can test on them
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
|
||||
buf[m++] = q[i];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::unpack_exchange(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
|
||||
q[nlocal] = buf[m++];
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
m += modify->fix[atom->extra_grow[iextra]]->
|
||||
unpack_exchange(nlocal,&buf[m]);
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for all atoms owned by this proc
|
||||
include extra data stored by fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::size_restart()
|
||||
{
|
||||
int i;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
int n = 12 * nlocal;
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for atom I
|
||||
do not include extra data stored by fixes, included by caller
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::size_restart_one(int i)
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file including extra quantities
|
||||
xyz must be 1st 3 values, so that read_restart can test on them
|
||||
molecular types may be negative, but write as positive
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::pack_restart(int i, double *buf)
|
||||
{
|
||||
int m = 1;
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = mask[i];
|
||||
buf[m++] = image[i];
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
|
||||
buf[m++] = q[i];
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
|
||||
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::unpack_restart(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) {
|
||||
grow(0);
|
||||
if (atom->nextra_store)
|
||||
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
|
||||
atom->nextra_store,
|
||||
"atom:extra");
|
||||
}
|
||||
|
||||
int m = 1;
|
||||
x[nlocal][0] = buf[m++];
|
||||
x[nlocal][1] = buf[m++];
|
||||
x[nlocal][2] = buf[m++];
|
||||
tag[nlocal] = static_cast<int> (buf[m++]);
|
||||
type[nlocal] = static_cast<int> (buf[m++]);
|
||||
mask[nlocal] = static_cast<int> (buf[m++]);
|
||||
image[nlocal] = static_cast<int> (buf[m++]);
|
||||
v[nlocal][0] = buf[m++];
|
||||
v[nlocal][1] = buf[m++];
|
||||
v[nlocal][2] = buf[m++];
|
||||
|
||||
q[nlocal] = buf[m++];
|
||||
|
||||
double **extra = atom->extra;
|
||||
if (atom->nextra_store) {
|
||||
int size = static_cast<int> (buf[0]) - m;
|
||||
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
|
||||
}
|
||||
|
||||
atom->nlocal++;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of type itype at x0,y0,z0
|
||||
set other values to defaults
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::create_atom(int itype, double x0, double y0, double z0,
|
||||
int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = 0;
|
||||
type[nlocal] = itype;
|
||||
x[nlocal][0] = x0;
|
||||
x[nlocal][1] = y0;
|
||||
x[nlocal][2] = z0;
|
||||
mask[nlocal] = 1;
|
||||
image[nlocal] = (512 << 20) | (512 << 10) | 512;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
q[nlocal] = 0.0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
initialize other atom quantities
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecCharge::data_atom(double xtmp, double ytmp, double ztmp,
|
||||
int imagetmp, char **values, int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
tag[nlocal] = atoi(values[0]);
|
||||
if (tag[nlocal] <= 0)
|
||||
error->one("Invalid atom ID in Atoms section of data file");
|
||||
|
||||
type[nlocal] = atoi(values[1]);
|
||||
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
|
||||
error->one("Invalid atom type in Atoms section of data file");
|
||||
|
||||
q[nlocal] = atof(values[2]);
|
||||
|
||||
x[nlocal][0] = xtmp;
|
||||
x[nlocal][1] = ytmp;
|
||||
x[nlocal][2] = ztmp;
|
||||
|
||||
image[nlocal] = imagetmp;
|
||||
|
||||
mask[nlocal] = 1;
|
||||
v[nlocal][0] = 0.0;
|
||||
v[nlocal][1] = 0.0;
|
||||
v[nlocal][2] = 0.0;
|
||||
|
||||
atom->nlocal++;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecCharge::memory_usage()
|
||||
{
|
||||
int bytes = 0;
|
||||
|
||||
if (atom->memcheck("tag")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("type")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("mask")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("image")) bytes += nmax * sizeof(int);
|
||||
if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double);
|
||||
if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double);
|
||||
|
||||
if (atom->memcheck("q")) bytes += nmax * sizeof(double);
|
||||
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_CHARGE_H
|
||||
#define ATOM_VEC_CHARGE_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecCharge : public AtomVec {
|
||||
public:
|
||||
AtomVecCharge(class LAMMPS *, int, char **);
|
||||
void grow(int);
|
||||
void reset_ptrs();
|
||||
void zero_owned(int);
|
||||
void zero_ghost(int, int);
|
||||
void copy(int, int);
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int pack_border(int, int *, double *, int *);
|
||||
int pack_border_one(int, double *);
|
||||
void unpack_border(int, int, double *);
|
||||
int unpack_border_one(int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
int size_restart();
|
||||
int size_restart_one(int);
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void create_atom(int, double, double, double, int);
|
||||
void data_atom(double, double, double, int, char **, int);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int *tag,*type,*mask,*image;
|
||||
double **x,**v,**f;
|
||||
double *q;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,466 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "atom_vec_hybrid.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MIN(A,B) ((A) < (B)) ? (A) : (B)
|
||||
#define MAX(A,B) ((A) > (B)) ? (A) : (B)
|
||||
|
||||
#define DELTA 10000
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) :
|
||||
AtomVec(lmp, narg, arg)
|
||||
{
|
||||
int i,m;
|
||||
|
||||
if (narg < 1) error->all("Illegal atom_style command");
|
||||
|
||||
// create sub-styles
|
||||
|
||||
nstyles = narg;
|
||||
styles = new AtomVec*[nstyles];
|
||||
keywords = new char*[nstyles];
|
||||
|
||||
for (i = 0; i < narg; i++) {
|
||||
for (m = 0; m < i; m++)
|
||||
if (strcmp(arg[i],keywords[m]) == 0)
|
||||
error->all("Atom style hybrid cannot use same atom style twice");
|
||||
if (strcmp(arg[i],"hybrid") == 0)
|
||||
error->all("Atom style hybrid cannot have hybrid as an argument");
|
||||
styles[i] = atom->new_avec(arg[i],0,NULL);
|
||||
keywords[i] = new char[strlen(arg[i])+1];
|
||||
strcpy(keywords[i],arg[i]);
|
||||
}
|
||||
|
||||
// hybrid settings are MAX or MIN of sub-style settings
|
||||
// size_border has +1 for hybrid[] value that is also communicated
|
||||
|
||||
for (m = 0; m < nstyles; m++) {
|
||||
molecular = MAX(molecular,styles[m]->molecular);
|
||||
bonds_allow = MAX(bonds_allow,styles[m]->bonds_allow);
|
||||
angles_allow = MAX(angles_allow,styles[m]->angles_allow);
|
||||
dihedrals_allow = MAX(dihedrals_allow,styles[m]->dihedrals_allow);
|
||||
impropers_allow = MAX(impropers_allow,styles[m]->impropers_allow);
|
||||
mass_type = MAX(mass_type,styles[m]->mass_type);
|
||||
dipole_type = MAX(dipole_type,styles[m]->dipole_type);
|
||||
comm_x_only = MIN(comm_x_only,styles[m]->comm_x_only);
|
||||
comm_f_only = MIN(comm_f_only,styles[m]->comm_f_only);
|
||||
size_comm = MAX(size_comm,styles[m]->size_comm);
|
||||
size_reverse = MAX(size_reverse,styles[m]->size_reverse);
|
||||
size_border = MAX(size_border,styles[m]->size_border) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
AtomVecHybrid::~AtomVecHybrid()
|
||||
{
|
||||
for (int m = 0; m < nstyles; m++) delete styles[m];
|
||||
delete [] styles;
|
||||
for (int m = 0; m < nstyles; m++) delete [] keywords[m];
|
||||
delete [] keywords;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
grow atom arrays
|
||||
n = 0 grows arrays by DELTA
|
||||
n > 0 allocates arrays to size n
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::grow(int n)
|
||||
{
|
||||
if (n == 0) nmax += DELTA;
|
||||
else nmax = n;
|
||||
atom->nmax = nmax;
|
||||
|
||||
int tmp = atom->nextra_grow;
|
||||
for (int m = 0; m < nstyles; m++) {
|
||||
atom->nextra_grow = 0;
|
||||
styles[m]->grow(nmax);
|
||||
atom->nextra_grow = tmp;
|
||||
}
|
||||
|
||||
// pointers for arrays used directly by hybrid style
|
||||
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
|
||||
hybrid = atom->hybrid = (int *)
|
||||
memory->srealloc(atom->hybrid,nmax*sizeof(int),"atom:hybrid");
|
||||
|
||||
if (atom->nextra_grow)
|
||||
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
|
||||
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::reset_ptrs()
|
||||
{
|
||||
for (int m = 0; m < nstyles; m++) styles[m]->reset_ptrs();
|
||||
|
||||
tag = atom->tag;
|
||||
type = atom->type;
|
||||
mask = atom->mask;
|
||||
image = atom->image;
|
||||
x = atom->x;
|
||||
v = atom->v;
|
||||
f = atom->f;
|
||||
|
||||
hybrid = atom->hybrid;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy array values based on hybrid style of atom i
|
||||
zero auxiliary arrays for all other styles before copy
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::copy(int i, int j)
|
||||
{
|
||||
int ihybrid = hybrid[i];
|
||||
for (int m = 0; m < nstyles; m++)
|
||||
if (m != ihybrid) styles[m]->zero_owned(j);
|
||||
styles[ihybrid]->copy(i,j);
|
||||
hybrid[j] = ihybrid;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_comm(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
m += styles[hybrid[j]]->pack_comm_one(j,&buf[m]);
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
m += styles[hybrid[j]]->pack_comm_one(j,&buf[m]);
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
m += styles[hybrid[i]]->unpack_comm_one(i,&buf[m]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_reverse(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
m += styles[hybrid[i]]->pack_reverse_one(i,&buf[m]);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_reverse(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
f[j][0] += buf[m++];
|
||||
f[j][1] += buf[m++];
|
||||
f[j][2] += buf[m++];
|
||||
m += styles[hybrid[j]]->unpack_reverse_one(j,&buf[m]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_border(int n, int *list, double *buf, int *pbc_flags)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
if (pbc_flags[0] == 0) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0];
|
||||
buf[m++] = x[j][1];
|
||||
buf[m++] = x[j][2];
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = hybrid[j];
|
||||
m += styles[hybrid[j]]->pack_border_one(j,&buf[m]);
|
||||
}
|
||||
} else {
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
buf[m++] = x[j][0] + pbc_flags[1]*xprd;
|
||||
buf[m++] = x[j][1] + pbc_flags[2]*yprd;
|
||||
buf[m++] = x[j][2] + pbc_flags[3]*zprd;
|
||||
buf[m++] = tag[j];
|
||||
buf[m++] = type[j];
|
||||
buf[m++] = mask[j];
|
||||
buf[m++] = hybrid[j];
|
||||
m += styles[hybrid[j]]->pack_border_one(j,&buf[m]);
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack border ghost atom data
|
||||
zero auxiliary ghost arrays for all styles before unpack
|
||||
grow() is called in zero_ghost() and here (in case zero_ghost is no-op)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::unpack_border(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
for (m = 0; m < nstyles; m++) styles[m]->zero_ghost(n,first);
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
if (i == nmax) grow(0);
|
||||
x[i][0] = buf[m++];
|
||||
x[i][1] = buf[m++];
|
||||
x[i][2] = buf[m++];
|
||||
tag[i] = static_cast<int> (buf[m++]);
|
||||
type[i] = static_cast<int> (buf[m++]);
|
||||
mask[i] = static_cast<int> (buf[m++]);
|
||||
hybrid[i] = static_cast<int> (buf[m++]);
|
||||
m += styles[hybrid[i]]->unpack_border_one(i,&buf[m]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack data for atom I for sending to another proc
|
||||
sub-style does packing
|
||||
append hybrid[i] and increment count stored in buf[0]
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int m = styles[hybrid[i]]->pack_exchange(i,buf);
|
||||
buf[m++] = hybrid[i];
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for single atom received from another proc
|
||||
sub-style does unpacking
|
||||
grow() must occur here so arrays for all sub-styles are grown
|
||||
extract hybrid[nlocal] from end of buf
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::unpack_exchange(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
int m = static_cast<int> (buf[0]);
|
||||
hybrid[nlocal] = static_cast<int> (buf[m-1]);
|
||||
int tmp = styles[hybrid[nlocal]]->unpack_exchange(buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of restart data for all atoms owned by this proc
|
||||
include extra data stored by fixes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::size_restart()
|
||||
{
|
||||
int i;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
int n = 0;
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += styles[hybrid[i]]->size_restart_one(i);
|
||||
|
||||
if (atom->nextra_restart)
|
||||
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack atom I's data for restart file including extra quantities
|
||||
sub-style does packing
|
||||
append hybrid[i] and increment count stored in buf[0]
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::pack_restart(int i, double *buf)
|
||||
{
|
||||
int m = styles[hybrid[i]]->pack_restart(i,buf);
|
||||
buf[m++] = hybrid[i];
|
||||
buf[0] = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack data for one atom from restart file including extra quantities
|
||||
sub-style does unpacking
|
||||
grow() must occur here so arrays for all sub-styles are grown
|
||||
zero auxiliary arrays for all other styles before unpack
|
||||
extract hybrid[nlocal] from end of buf
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::unpack_restart(double *buf)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) {
|
||||
grow(0);
|
||||
if (atom->nextra_store)
|
||||
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
|
||||
atom->nextra_store,
|
||||
"atom:extra");
|
||||
}
|
||||
|
||||
int m = static_cast<int> (buf[0]);
|
||||
int ihybrid = static_cast<int> (buf[m-1]);
|
||||
for (int m = 0; m < nstyles; m++)
|
||||
if (m != ihybrid) styles[m]->zero_owned(nlocal);
|
||||
hybrid[nlocal] = ihybrid;
|
||||
|
||||
// size of extra unpack in sub-style includes end-of-buf entry of hybrid
|
||||
// avoid this by resetting buf[0] to one less
|
||||
|
||||
buf[0] = m-1;
|
||||
int tmp = styles[ihybrid]->unpack_restart(buf);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create one atom of type itype at x0,y0,z0 for ihybrid style
|
||||
sub-style does create
|
||||
grow() must occur here so arrays for all sub-styles are grown
|
||||
zero auxiliary arrays for all other styles before create
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::create_atom(int itype, double x0, double y0, double z0,
|
||||
int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
for (int m = 0; m < nstyles; m++)
|
||||
if (m != ihybrid) styles[m]->zero_owned(nlocal);
|
||||
hybrid[nlocal] = ihybrid;
|
||||
styles[ihybrid]->create_atom(itype,x0,y0,z0,0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Atoms section of data file
|
||||
zero auxiliary arrays for all other styles before unpack
|
||||
sub-style will increment nlocal
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_atom(double xtmp, double ytmp, double ztmp,
|
||||
int imagetmp, char **values, int ihybrid)
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal == nmax) grow(0);
|
||||
|
||||
for (int m = 0; m < nstyles; m++)
|
||||
if (m != ihybrid) styles[m]->zero_owned(nlocal);
|
||||
hybrid[nlocal] = ihybrid;
|
||||
styles[ihybrid]->data_atom(xtmp,ytmp,ztmp,imagetmp,values,0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack one line from Velocities section of data file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_vel(int m, char *line, int ihybrid)
|
||||
{
|
||||
styles[ihybrid]->data_vel(m,line,0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
set data file parameters for ihybrid sub-style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void AtomVecHybrid::data_params(int ihybrid)
|
||||
{
|
||||
size_data_atom = styles[ihybrid]->size_data_atom;
|
||||
size_data_vel = styles[ihybrid]->size_data_vel;
|
||||
xcol_data = styles[ihybrid]->xcol_data;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
return # of bytes of allocated memory
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int AtomVecHybrid::memory_usage()
|
||||
{
|
||||
int bytes = 0;
|
||||
for (int m = 0; m < nstyles; m++)
|
||||
bytes += styles[m]->memory_usage();
|
||||
if (atom->memcheck("hybrid")) bytes += nmax * sizeof(int);
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef ATOM_VEC_HYBRID_H
|
||||
#define ATOM_VEC_HYBRID_H
|
||||
|
||||
#include "atom_vec.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class AtomVecHybrid : public AtomVec {
|
||||
public:
|
||||
int nstyles;
|
||||
class AtomVec **styles;
|
||||
char **keywords;
|
||||
|
||||
AtomVecHybrid(class LAMMPS *, int, char **);
|
||||
~AtomVecHybrid();
|
||||
void grow(int);
|
||||
void reset_ptrs();
|
||||
void copy(int, int);
|
||||
int pack_comm(int, int *, double *, int *);
|
||||
void unpack_comm(int, int, double *);
|
||||
int pack_reverse(int, int, double *);
|
||||
void unpack_reverse(int, int *, double *);
|
||||
int pack_border(int, int *, double *, int *);
|
||||
void unpack_border(int, int, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(double *);
|
||||
int size_restart();
|
||||
int size_restart_one(int) {return 0;}
|
||||
int pack_restart(int, double *);
|
||||
int unpack_restart(double *);
|
||||
void create_atom(int, double, double, double, int);
|
||||
void data_atom(double, double, double, int, char **, int);
|
||||
void data_vel(int, char *, int);
|
||||
void data_params(int);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int *tag,*type,*mask,*image;
|
||||
double **x,**v,**f;
|
||||
int *hybrid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,89 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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. //
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "compute.h"
|
||||
#include "group.h"
|
||||
#include "domain.h"
|
||||
#include "lattice.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Compute::Compute(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
|
||||
{
|
||||
if (narg < 3) error->all("Illegal compute command");
|
||||
|
||||
// compute ID, group, and style
|
||||
|
||||
int n = strlen(arg[0]) + 1;
|
||||
id = new char[n];
|
||||
strcpy(id,arg[0]);
|
||||
|
||||
igroup = group->find(arg[1]);
|
||||
groupbit = group->bitmask[igroup];
|
||||
|
||||
n = strlen(arg[2]) + 1;
|
||||
style = new char[n];
|
||||
strcpy(style,arg[2]);
|
||||
|
||||
// set child class defaults
|
||||
|
||||
vector = NULL;
|
||||
scalar_atom = NULL;
|
||||
vector_atom = NULL;
|
||||
|
||||
scalar_flag = vector_flag = peratom_flag = 0;
|
||||
tempflag = pressflag = 0;
|
||||
id_pre = NULL;
|
||||
comm_forward = comm_reverse = 0;
|
||||
neigh_half_once = neigh_full_once = 0;
|
||||
|
||||
// set modify defaults
|
||||
|
||||
extra_dof = 3;
|
||||
dynamic = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Compute::~Compute()
|
||||
{
|
||||
delete [] id;
|
||||
delete [] style;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void Compute::modify_params(int narg, char **arg)
|
||||
{
|
||||
if (narg == 0) error->all("Illegal compute_modify command");
|
||||
|
||||
int iarg = 0; while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"extra") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal compute_modify command");
|
||||
extra_dof = atoi(arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"dynamic") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal compute_modify command");
|
||||
if (strcmp(arg[iarg+1],"no") == 0) dynamic = 0;
|
||||
else if (strcmp(arg[iarg+1],"yes") == 0) dynamic = 1;
|
||||
else error->all("Illegal compute_modify command");
|
||||
iarg += 2;
|
||||
} else error->all("Illegal compute_modify command");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_H
|
||||
#define COMPUTE_H
|
||||
|
||||
#include "pointers.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class Compute : protected Pointers {
|
||||
public:
|
||||
char *id,*style;
|
||||
int igroup,groupbit;
|
||||
|
||||
double scalar; // computed scalar
|
||||
double *vector; // computed vector
|
||||
double *scalar_atom; // computed per-atom scalar
|
||||
double **vector_atom; // computed per-atom vector
|
||||
|
||||
int scalar_flag; // 0/1 if compute_scalar() function exists
|
||||
int vector_flag; // 0/1 if compute_vector() function exists
|
||||
int peratom_flag; // 0/1 if compute_peratom() function exists
|
||||
int size_vector; // N = size of vector
|
||||
int size_peratom; // 0 = just scalar_atom, N = size of vector_atom
|
||||
|
||||
int extensive; // 0/1 if scalar,vector are intensive/extensive values
|
||||
int tempflag; // 1 if Compute can be used as temperature
|
||||
// must have both compute_scalar, compute_vector
|
||||
int pressflag; // 1 if Compute can be used as pressure (uses virial)
|
||||
// must have both compute_scalar, compute_vector
|
||||
char *id_pre; // ID of Compute that needs to be computed before this
|
||||
double dof; // degrees-of-freedom for temperature
|
||||
|
||||
int comm_forward; // size of forward communication (0 if none)
|
||||
int comm_reverse; // size of reverse communication (0 if none)
|
||||
int neigh_half_once; // 1 if requires half neighbor lists
|
||||
int neigh_full_once; // 1 if requires full neighbor lists
|
||||
|
||||
Compute(class LAMMPS *, int, char **);
|
||||
virtual ~Compute();
|
||||
void modify_params(int, char **);
|
||||
virtual void init() = 0;
|
||||
virtual double compute_scalar() {return 0.0;}
|
||||
virtual void compute_vector() {}
|
||||
virtual void compute_peratom() {}
|
||||
|
||||
virtual int pack_comm(int, int *, double *, int *) {return 0;}
|
||||
virtual void unpack_comm(int, int, double *) {}
|
||||
virtual int pack_reverse_comm(int, int, double *) {return 0;}
|
||||
virtual void unpack_reverse_comm(int, int *, double *) {}
|
||||
|
||||
virtual int memory_usage() {return 0;}
|
||||
|
||||
protected:
|
||||
int extra_dof,dynamic;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,290 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "compute_centro_atom.h"
|
||||
#include "atom.h"
|
||||
#include "modify.h"
|
||||
#include "update.h"
|
||||
#include "neighbor.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "comm.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeCentroAtom::ComputeCentroAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute centro/atom command");
|
||||
|
||||
peratom_flag = 1;
|
||||
size_peratom = 0;
|
||||
neigh_full_once = 1;
|
||||
|
||||
nmax = 0;
|
||||
centro = NULL;
|
||||
maxneigh = 0;
|
||||
distsq = NULL;
|
||||
nearest = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeCentroAtom::~ComputeCentroAtom()
|
||||
{
|
||||
memory->sfree(centro);
|
||||
memory->sfree(distsq);
|
||||
memory->sfree(nearest);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeCentroAtom::init()
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < modify->ncompute; i++)
|
||||
if (strcmp(modify->compute[i]->style,"centro/atom") == 0) count++;
|
||||
if (count > 1 && comm->me == 0)
|
||||
error->warning("More than one compute centro/atom defined");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeCentroAtom::compute_peratom()
|
||||
{
|
||||
int j,k,jj,kk,n,numneigh;
|
||||
double xtmp,ytmp,ztmp,delx,dely,delz,rsq,value;
|
||||
int *neighs;
|
||||
double pairs[66];
|
||||
|
||||
// grow centro array if necessary
|
||||
|
||||
if (atom->nlocal > nmax) {
|
||||
memory->sfree(centro);
|
||||
nmax = atom->nmax;
|
||||
centro = (double *)
|
||||
memory->smalloc(nmax*sizeof(double),"compute/centro/atom:centro");
|
||||
scalar_atom = centro;
|
||||
}
|
||||
|
||||
// if needed, build a full neighbor list
|
||||
|
||||
if (!neighbor->full_every) neighbor->build_full();
|
||||
|
||||
// compute centro-symmetry parameter for each atom in group
|
||||
// use full neighbor list
|
||||
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
double cutsq = force->pair->cutforce * force->pair->cutforce;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
xtmp = x[i][0];
|
||||
ytmp = x[i][1];
|
||||
ztmp = x[i][2];
|
||||
neighs = neighbor->firstneigh_full[i];
|
||||
numneigh = neighbor->numneigh_full[i];
|
||||
|
||||
// insure distsq and nearest arrays are long enough
|
||||
|
||||
if (numneigh > maxneigh) {
|
||||
memory->sfree(distsq);
|
||||
memory->sfree(nearest);
|
||||
maxneigh = numneigh;
|
||||
distsq = (double *) memory->smalloc(maxneigh*sizeof(double),
|
||||
"compute/centro/atom:distsq");
|
||||
nearest = (int *) memory->smalloc(maxneigh*sizeof(int),
|
||||
"compute/centro/atom:nearest");
|
||||
}
|
||||
|
||||
// loop over list of all neighbors within force cutoff
|
||||
// distsq[] = distance sq to each
|
||||
// nearest[] = atom indices of neighbors
|
||||
|
||||
n = 0;
|
||||
for (k = 0; k < numneigh; k++) {
|
||||
j = neighs[k];
|
||||
if (j >= nall) j %= nall;
|
||||
|
||||
delx = xtmp - x[j][0];
|
||||
dely = ytmp - x[j][1];
|
||||
delz = ztmp - x[j][2];
|
||||
rsq = delx*delx + dely*dely + delz*delz;
|
||||
if (rsq < cutsq) {
|
||||
distsq[n] = rsq;
|
||||
nearest[n++] = j;
|
||||
}
|
||||
}
|
||||
|
||||
// if not 12 neighbors, centro = 0.0
|
||||
|
||||
if (n < 12) {
|
||||
centro[i] = 0.0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// store 12 nearest neighs in 1st 12 locations of distsq and nearest
|
||||
|
||||
select2(12,n,distsq,nearest);
|
||||
|
||||
// R = Ri + Rj for each of 66 i,j pairs among 12 neighbors
|
||||
// pairs = squared length of each R
|
||||
|
||||
n = 0;
|
||||
for (j = 0; j < 12; j++) {
|
||||
jj = nearest[j];
|
||||
for (k = j+1; k < 12; k++) {
|
||||
kk = nearest[k];
|
||||
delx = x[jj][0] + x[kk][0] - 2.0*xtmp;
|
||||
dely = x[jj][1] + x[kk][1] - 2.0*ytmp;
|
||||
delz = x[jj][2] + x[kk][2] - 2.0*ztmp;
|
||||
pairs[n++] = delx*delx + dely*dely + delz*delz;
|
||||
}
|
||||
}
|
||||
|
||||
// store 6 smallest pair distances in 1st 6 locations of pairs
|
||||
|
||||
select(6,66,pairs);
|
||||
|
||||
// centrosymmetry = sum of 6 smallest squared values
|
||||
|
||||
value = 0.0;
|
||||
for (j = 0; j < 6; j++) value += pairs[j];
|
||||
centro[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
2 select routines from Numerical Recipes (slightly modified)
|
||||
find k smallest values in array of length n
|
||||
2nd routine sorts auxiliary array at same time
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#define SWAP(a,b) tmp = a; a = b; b = tmp;
|
||||
#define ISWAP(a,b) itmp = a; a = b; b = itmp;
|
||||
|
||||
void ComputeCentroAtom::select(int k, int n, double *arr)
|
||||
{
|
||||
int i,ir,j,l,mid;
|
||||
double a,tmp;
|
||||
|
||||
arr--;
|
||||
l = 1;
|
||||
ir = n;
|
||||
for (;;) {
|
||||
if (ir <= l+1) {
|
||||
if (ir == l+1 && arr[ir] < arr[l]) {
|
||||
SWAP(arr[l],arr[ir])
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
mid=(l+ir) >> 1;
|
||||
SWAP(arr[mid],arr[l+1])
|
||||
if (arr[l] > arr[ir]) {
|
||||
SWAP(arr[l],arr[ir])
|
||||
}
|
||||
if (arr[l+1] > arr[ir]) {
|
||||
SWAP(arr[l+1],arr[ir])
|
||||
}
|
||||
if (arr[l] > arr[l+1]) {
|
||||
SWAP(arr[l],arr[l+1])
|
||||
}
|
||||
i = l+1;
|
||||
j = ir;
|
||||
a = arr[l+1];
|
||||
for (;;) {
|
||||
do i++; while (arr[i] < a);
|
||||
do j--; while (arr[j] > a);
|
||||
if (j < i) break;
|
||||
SWAP(arr[i],arr[j])
|
||||
}
|
||||
arr[l+1] = arr[j];
|
||||
arr[j] = a;
|
||||
if (j >= k) ir = j-1;
|
||||
if (j <= k) l = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeCentroAtom::select2(int k, int n, double *arr, int *iarr)
|
||||
{
|
||||
int i,ir,j,l,mid,ia,itmp;
|
||||
double a,tmp;
|
||||
|
||||
arr--;
|
||||
iarr--;
|
||||
l = 1;
|
||||
ir = n;
|
||||
for (;;) {
|
||||
if (ir <= l+1) {
|
||||
if (ir == l+1 && arr[ir] < arr[l]) {
|
||||
SWAP(arr[l],arr[ir])
|
||||
ISWAP(iarr[l],iarr[ir])
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
mid=(l+ir) >> 1;
|
||||
SWAP(arr[mid],arr[l+1])
|
||||
ISWAP(iarr[mid],iarr[l+1])
|
||||
if (arr[l] > arr[ir]) {
|
||||
SWAP(arr[l],arr[ir])
|
||||
ISWAP(iarr[l],iarr[ir])
|
||||
}
|
||||
if (arr[l+1] > arr[ir]) {
|
||||
SWAP(arr[l+1],arr[ir])
|
||||
ISWAP(iarr[l+1],iarr[ir])
|
||||
}
|
||||
if (arr[l] > arr[l+1]) {
|
||||
SWAP(arr[l],arr[l+1])
|
||||
ISWAP(iarr[l],iarr[l+1])
|
||||
}
|
||||
i = l+1;
|
||||
j = ir;
|
||||
a = arr[l+1];
|
||||
ia = iarr[l+1];
|
||||
for (;;) {
|
||||
do i++; while (arr[i] < a);
|
||||
do j--; while (arr[j] > a);
|
||||
if (j < i) break;
|
||||
SWAP(arr[i],arr[j])
|
||||
ISWAP(iarr[i],iarr[j])
|
||||
}
|
||||
arr[l+1] = arr[j];
|
||||
arr[j] = a;
|
||||
iarr[l+1] = iarr[j];
|
||||
iarr[j] = ia;
|
||||
if (j >= k) ir = j-1;
|
||||
if (j <= k) l = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based array
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ComputeCentroAtom::memory_usage()
|
||||
{
|
||||
int bytes = nmax * sizeof(double);
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_CENTRO_ATOM_H
|
||||
#define COMPUTE_CENTRO_ATOM_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeCentroAtom : public Compute {
|
||||
public:
|
||||
ComputeCentroAtom(class LAMMPS *, int, char **);
|
||||
~ComputeCentroAtom();
|
||||
void init();
|
||||
void compute_peratom();
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int nmax,maxneigh;
|
||||
double *distsq;
|
||||
int *nearest;
|
||||
double *centro;
|
||||
|
||||
void select(int, int, double *);
|
||||
void select2(int, int, double *, int *);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,203 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "compute_epair_atom.h"
|
||||
#include "atom.h"
|
||||
#include "neighbor.h"
|
||||
#include "modify.h"
|
||||
#include "comm.h"
|
||||
#include "update.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeEpairAtom::ComputeEpairAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute epair/atom command");
|
||||
|
||||
peratom_flag = 1;
|
||||
size_peratom = 0;
|
||||
comm_reverse = 1;
|
||||
neigh_half_once = 1;
|
||||
|
||||
nmax = 0;
|
||||
energy = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeEpairAtom::~ComputeEpairAtom()
|
||||
{
|
||||
memory->sfree(energy);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeEpairAtom::init()
|
||||
{
|
||||
if (force->pair == NULL || force->pair->single_enable == 0)
|
||||
error->all("Pair style does not support computing per-atom energy");
|
||||
|
||||
if (force->pair_match("eam")) eamstyle = 1;
|
||||
else eamstyle = 0;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < modify->ncompute; i++)
|
||||
if (strcmp(modify->compute[i]->style,"epair/atom") == 0) count++;
|
||||
if (count > 1 && comm->me == 0)
|
||||
error->warning("More than one compute epair/atom defined");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeEpairAtom::compute_peratom()
|
||||
{
|
||||
int i,j,k,n,itype,jtype,numneigh;
|
||||
double xtmp,ytmp,ztmp,delx,dely,delz,rsq;
|
||||
double factor_coul,factor_lj,e;
|
||||
int *neighs;
|
||||
|
||||
// grow energy array if necessary
|
||||
|
||||
if (atom->nmax > nmax) {
|
||||
memory->sfree(energy);
|
||||
nmax = atom->nmax;
|
||||
energy = (double *)
|
||||
memory->smalloc(nmax*sizeof(double),"compute/epair/atom:energy");
|
||||
scalar_atom = energy;
|
||||
}
|
||||
|
||||
// clear energy array
|
||||
// n includes ghosts only if newton_pair flag is set
|
||||
|
||||
if (force->newton_pair) n = atom->nlocal + atom->nghost;
|
||||
else n = atom->nlocal;
|
||||
|
||||
for (i = 0; i < n; i++) energy[i] = 0.0;
|
||||
|
||||
// if needed, build a half neighbor list
|
||||
|
||||
if (!neighbor->half_every) neighbor->build_half();
|
||||
|
||||
// compute pairwise energy for all atoms via pair->single()
|
||||
// ignore compute group, since using half neighbor list
|
||||
|
||||
double *special_coul = force->special_coul;
|
||||
double *special_lj = force->special_lj;
|
||||
double **cutsq = force->pair->cutsq;
|
||||
|
||||
double **x = atom->x;
|
||||
int *type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
|
||||
Pair::One one;
|
||||
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
xtmp = x[i][0];
|
||||
ytmp = x[i][1];
|
||||
ztmp = x[i][2];
|
||||
itype = type[i];
|
||||
neighs = neighbor->firstneigh[i];
|
||||
numneigh = neighbor->numneigh[i];
|
||||
|
||||
for (k = 0; k < numneigh; k++) {
|
||||
j = neighs[k];
|
||||
|
||||
if (j < nall) factor_coul = factor_lj = 1.0;
|
||||
else {
|
||||
factor_coul = special_coul[j/nall];
|
||||
factor_lj = special_lj[j/nall];
|
||||
j %= nall;
|
||||
}
|
||||
|
||||
delx = xtmp - x[j][0];
|
||||
dely = ytmp - x[j][1];
|
||||
delz = ztmp - x[j][2];
|
||||
rsq = delx*delx + dely*dely + delz*delz;
|
||||
jtype = type[j];
|
||||
|
||||
if (rsq < cutsq[itype][jtype]) {
|
||||
force->pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,1,one);
|
||||
e = one.eng_coul + one.eng_vdwl;
|
||||
energy[i] += e;
|
||||
energy[j] += e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// communicate energy between neigchbor procs
|
||||
|
||||
if (force->newton_pair) comm->reverse_comm_compute(this);
|
||||
|
||||
// remove double counting of per-atom energy
|
||||
|
||||
for (i = 0; i < nlocal; i++) energy[i] *= 0.5;
|
||||
|
||||
// for EAM, include embedding function contribution to energy
|
||||
|
||||
if (eamstyle) {
|
||||
int *type = atom->type;
|
||||
double etmp = 0.0;
|
||||
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
force->pair->single_embed(i,type[i],etmp);
|
||||
energy[i] += etmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int ComputeEpairAtom::pack_reverse_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) buf[m++] = energy[i];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeEpairAtom::unpack_reverse_comm(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
energy[j] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based array
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ComputeEpairAtom::memory_usage()
|
||||
{
|
||||
int bytes = nmax * sizeof(double);
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_EPAIR_ATOM_H
|
||||
#define COMPUTE_EPAIR_ATOM_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeEpairAtom : public Compute {
|
||||
public:
|
||||
ComputeEpairAtom(class LAMMPS *, int, char **);
|
||||
~ComputeEpairAtom();
|
||||
void init();
|
||||
void compute_peratom();
|
||||
int pack_reverse_comm(int, int, double *);
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int nmax,eamstyle;
|
||||
double *energy;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,124 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "compute_etotal_atom.h"
|
||||
#include "atom.h"
|
||||
#include "modify.h"
|
||||
#include "force.h"
|
||||
#include "comm.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeEtotalAtom::ComputeEtotalAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 4) error->all("Illegal compute etotal/atom command");
|
||||
|
||||
// store epair ID used by energy computation
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_pre = new char[n];
|
||||
strcpy(id_pre,arg[3]);
|
||||
|
||||
peratom_flag = 1;
|
||||
size_peratom = 0;
|
||||
|
||||
nmax = 0;
|
||||
etotal = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeEtotalAtom::~ComputeEtotalAtom()
|
||||
{
|
||||
delete [] id_pre;
|
||||
memory->sfree(etotal);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeEtotalAtom::init()
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < modify->ncompute; i++)
|
||||
if (strcmp(modify->compute[i]->style,"etotal/atom") == 0) count++;
|
||||
if (count > 1 && comm->me == 0)
|
||||
error->warning("More than one compute etotal/atom defined");
|
||||
|
||||
// set epair Compute used by this compute
|
||||
|
||||
int icompute = modify->find_compute(id_pre);
|
||||
if (icompute < 0)
|
||||
error->all("Could not find compute etotal/atom pre-compute ID");
|
||||
compute_epair = modify->compute[icompute];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeEtotalAtom::compute_peratom()
|
||||
{
|
||||
// grow etotal array if necessary
|
||||
|
||||
if (atom->nlocal > nmax) {
|
||||
memory->sfree(etotal);
|
||||
nmax = atom->nmax;
|
||||
etotal = (double *)
|
||||
memory->smalloc(nmax*sizeof(double),"compute/etotal/atom:etotal");
|
||||
scalar_atom = etotal;
|
||||
}
|
||||
|
||||
// compute total energy for each atom in group
|
||||
|
||||
double *epair = compute_epair->scalar_atom;
|
||||
double mvv2e = force->mvv2e;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *mask = atom->mask;
|
||||
int *type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double ke;
|
||||
|
||||
if (mass)
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
ke = 0.5 * mvv2e * mass[type[i]] *
|
||||
(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
|
||||
etotal[i] = ke + epair[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
ke = 0.5 * mvv2e * rmass[i] *
|
||||
(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
|
||||
etotal[i] = ke + epair[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based array
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ComputeEtotalAtom::memory_usage()
|
||||
{
|
||||
int bytes = nmax * sizeof(double);
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_ETOTAL_ATOM_H
|
||||
#define COMPUTE_ETOTAL_ATOM_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeEtotalAtom : public Compute {
|
||||
public:
|
||||
ComputeEtotalAtom(class LAMMPS *, int, char **);
|
||||
~ComputeEtotalAtom();
|
||||
void init();
|
||||
void compute_peratom();
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int nmax;
|
||||
double *etotal;
|
||||
Compute *compute_epair;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,104 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "compute_ke_atom.h"
|
||||
#include "atom.h"
|
||||
#include "modify.h"
|
||||
#include "comm.h"
|
||||
#include "force.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeKEAtom::ComputeKEAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute ke/atom command");
|
||||
|
||||
peratom_flag = 1;
|
||||
size_peratom = 0;
|
||||
|
||||
nmax = 0;
|
||||
ke = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeKEAtom::~ComputeKEAtom()
|
||||
{
|
||||
memory->sfree(ke);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeKEAtom::init()
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < modify->ncompute; i++)
|
||||
if (strcmp(modify->compute[i]->style,"ke/atom") == 0) count++;
|
||||
if (count > 1 && comm->me == 0)
|
||||
error->warning("More than one compute ke/atom defined");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeKEAtom::compute_peratom()
|
||||
{
|
||||
// grow ke array if necessary
|
||||
|
||||
if (atom->nlocal > nmax) {
|
||||
memory->sfree(ke);
|
||||
nmax = atom->nmax;
|
||||
ke = (double *) memory->smalloc(nmax*sizeof(double),"compute/ke/atom:ke");
|
||||
scalar_atom = ke;
|
||||
}
|
||||
|
||||
// compute kinetic energy for each atom in group
|
||||
|
||||
double mvv2e = force->mvv2e;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *mask = atom->mask;
|
||||
int *type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (mass)
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
ke[i] = 0.5 * mvv2e * mass[type[i]] *
|
||||
(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
ke[i] = 0.5 * mvv2e * rmass[i] *
|
||||
(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based array
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ComputeKEAtom::memory_usage()
|
||||
{
|
||||
int bytes = nmax * sizeof(double);
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_KE_ATOM_H
|
||||
#define COMPUTE_KE_ATOM_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeKEAtom : public Compute {
|
||||
public:
|
||||
ComputeKEAtom(class LAMMPS *, int, char **);
|
||||
~ComputeKEAtom();
|
||||
void init();
|
||||
void compute_peratom();
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int nmax;
|
||||
double *ke;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,210 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include "compute_pressure.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "bond.h"
|
||||
#include "angle.h"
|
||||
#include "dihedral.h"
|
||||
#include "improper.h"
|
||||
#include "kspace.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 4) error->all("Illegal compute pressure command");
|
||||
|
||||
if (igroup) error->all("Compute pressure must use group all");
|
||||
|
||||
// store temperature ID used by pressure computation
|
||||
// insure it is valid for temperature computation
|
||||
|
||||
int n = strlen(arg[3]) + 1;
|
||||
id_pre = new char[n];
|
||||
strcpy(id_pre,arg[3]);
|
||||
|
||||
int icompute = modify->find_compute(id_pre);
|
||||
|
||||
if (icompute < 0) error->all("Could not find compute pressure temp ID");
|
||||
if (modify->compute[icompute]->tempflag == 0)
|
||||
error->all("Compute pressure temp ID does not compute temperature");
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
extensive = 0;
|
||||
pressflag = 1;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputePressure::~ComputePressure()
|
||||
{
|
||||
delete [] id_pre;
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputePressure::init()
|
||||
{
|
||||
boltz = force->boltz;
|
||||
nktv2p = force->nktv2p;
|
||||
|
||||
// set temperature used by pressure
|
||||
|
||||
int icompute = modify->find_compute(id_pre);
|
||||
if (icompute < 0) error->all("Could not find compute pressure temp ID");
|
||||
temperature = modify->compute[icompute];
|
||||
|
||||
// set flags/ptrs for all contributions to virial
|
||||
|
||||
pairflag = bondflag = angleflag = dihedralflag = improperflag = 0;
|
||||
kspaceflag = 0;
|
||||
shakeflag = bodyflag = rigidflag = poemsflag = 0;
|
||||
|
||||
if (force->pair) {
|
||||
pairflag = 1;
|
||||
pair_virial = force->pair->virial;
|
||||
}
|
||||
if (atom->molecular) {
|
||||
if (force->bond) {
|
||||
bondflag = 1;
|
||||
bond_virial = force->bond->virial;
|
||||
}
|
||||
if (force->angle) {
|
||||
angleflag = 1;
|
||||
angle_virial = force->angle->virial;
|
||||
}
|
||||
if (force->dihedral) {
|
||||
dihedralflag = 1;
|
||||
dihedral_virial = force->dihedral->virial;
|
||||
}
|
||||
if (force->improper) {
|
||||
improperflag = 1;
|
||||
improper_virial = force->improper->virial;
|
||||
}
|
||||
}
|
||||
|
||||
if (force->kspace) {
|
||||
kspaceflag = 1;
|
||||
kspace_virial = force->kspace->virial;
|
||||
}
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++) {
|
||||
if (strcmp(modify->fix[i]->style,"shake") == 0) {
|
||||
shakeflag = 1;
|
||||
shake_virial = modify->fix[i]->virial;
|
||||
}
|
||||
if (strcmp(modify->fix[i]->style,"rigid") == 0 ||
|
||||
strcmp(modify->fix[i]->style,"poems") == 0) {
|
||||
bodyflag = 1;
|
||||
if (strcmp(modify->fix[i]->style,"rigid") == 0) {
|
||||
rigidflag = 1;
|
||||
rigid_virial = modify->fix[i]->virial;
|
||||
} else {
|
||||
poemsflag = 1;
|
||||
poems_virial = modify->fix[i]->virial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute total pressure, averaged over Pxx, Pyy, Pzz
|
||||
assume temperature has already been computed
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double ComputePressure::compute_scalar()
|
||||
{
|
||||
inv_volume = 1.0 / (domain->xprd * domain->yprd * domain->zprd);
|
||||
virial_compute(3);
|
||||
scalar = (temperature->dof * boltz * temperature->scalar +
|
||||
virial[0] + virial[1] + virial[2]) / 3.0 * inv_volume * nktv2p;
|
||||
return scalar;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute pressure tensor
|
||||
assume KE tensor has already been computed
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputePressure::compute_vector()
|
||||
{
|
||||
inv_volume = 1.0 / (domain->xprd * domain->yprd * domain->zprd);
|
||||
virial_compute(6);
|
||||
double *ke_tensor = temperature->vector;
|
||||
for (int i = 0; i < 6; i++)
|
||||
vector[i] = (ke_tensor[i] + virial[i]) * inv_volume * nktv2p;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputePressure::virial_compute(int n)
|
||||
{
|
||||
int i;
|
||||
double v[6];
|
||||
|
||||
for (i = 0; i < n; i++) v[i] = 0.0;
|
||||
|
||||
// sum contributions to virial from various forces and fixes
|
||||
|
||||
if (pairflag)
|
||||
for (i = 0; i < n; i++) v[i] += pair_virial[i];
|
||||
|
||||
if (atom->molecular) {
|
||||
if (bondflag)
|
||||
for (i = 0; i < n; i++) v[i] += bond_virial[i];
|
||||
if (angleflag)
|
||||
for (i = 0; i < n; i++) v[i] += angle_virial[i];
|
||||
if (dihedralflag)
|
||||
for (i = 0; i < n; i++) v[i] += dihedral_virial[i];
|
||||
if (improperflag)
|
||||
for (i = 0; i < n; i++) v[i] += improper_virial[i];
|
||||
if (shakeflag)
|
||||
for (i = 0; i < n; i++) v[i] += shake_virial[i];
|
||||
}
|
||||
|
||||
if (bodyflag) {
|
||||
if (rigidflag) for (i = 0; i < n; i++) v[i] += rigid_virial[i];
|
||||
if (poemsflag) for (i = 0; i < n; i++) v[i] += poems_virial[i];
|
||||
}
|
||||
|
||||
// sum virial across procs
|
||||
|
||||
MPI_Allreduce(v,virial,n,MPI_DOUBLE,MPI_SUM,world);
|
||||
|
||||
// KSpace virial contribution is already summed across procs
|
||||
|
||||
if (force->kspace)
|
||||
for (i = 0; i < n; i++) virial[i] += kspace_virial[i];
|
||||
|
||||
// LJ long-range tail correction
|
||||
|
||||
if (force->pair && force->pair->tail_flag)
|
||||
for (i = 0; i < n; i++) virial[i] += force->pair->ptail * inv_volume;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_PRESSURE_H
|
||||
#define COMPUTE_PRESSURE_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputePressure : public Compute {
|
||||
public:
|
||||
ComputePressure(class LAMMPS *, int, char **);
|
||||
~ComputePressure();
|
||||
void init();
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
private:
|
||||
double boltz,nktv2p,inv_volume;
|
||||
double *pair_virial,*bond_virial,*angle_virial;
|
||||
double *dihedral_virial,*improper_virial,*kspace_virial;
|
||||
double *shake_virial,*rigid_virial,*poems_virial;
|
||||
int pairflag,bondflag,angleflag,dihedralflag,improperflag,kspaceflag;
|
||||
int shakeflag,bodyflag,rigidflag,poemsflag;
|
||||
Compute *temperature;
|
||||
double virial[6];
|
||||
|
||||
void virial_compute(int);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,95 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "compute_rotate_dipole.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "group.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define INERTIA3D 0.4 // moments of inertia for sphere and disk
|
||||
#define INERTIA2D 0.5
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeRotateDipole::ComputeRotateDipole(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute rotate/dipole command");
|
||||
|
||||
if (atom->check_style("dipole") == 0)
|
||||
error->all("Must use atom style dipole with compute rotate/dipole");
|
||||
|
||||
scalar_flag = 1;
|
||||
extensive = 1;
|
||||
|
||||
inertia = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeRotateDipole::~ComputeRotateDipole()
|
||||
{
|
||||
delete [] inertia;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeRotateDipole::init()
|
||||
{
|
||||
delete [] inertia;
|
||||
inertia = new double[atom->ntypes+1];
|
||||
double *mass = atom->mass;
|
||||
|
||||
// insure use of dipole pair_style
|
||||
// set sigma to Pair's sigma
|
||||
|
||||
Pair *pair = force->pair_match("dipole");
|
||||
if (pair == NULL)
|
||||
error->all("Pair style is incompatible with compute rotate/dipole");
|
||||
double **sigma;
|
||||
pair->extract_dipole(&sigma);
|
||||
|
||||
if (force->dimension == 3)
|
||||
for (int i = 1; i <= atom->ntypes; i++)
|
||||
inertia[i] = INERTIA3D * mass[i] * 0.25*sigma[i][i]*sigma[i][i];
|
||||
else
|
||||
for (int i = 1; i <= atom->ntypes; i++)
|
||||
inertia[i] = INERTIA2D * mass[i] * 0.25*sigma[i][i]*sigma[i][i];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeRotateDipole::compute_scalar()
|
||||
{
|
||||
double *dipole = atom->dipole;
|
||||
double **omega = atom->omega;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double erot = 0.0;
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit && dipole[type[i]] > 0.0)
|
||||
erot += inertia[type[i]] *
|
||||
(omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] +
|
||||
omega[i][2]*omega[i][2]);
|
||||
|
||||
MPI_Allreduce(&erot,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
scalar *= 0.5;
|
||||
return scalar;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_ROTATE_DIPOLE_H
|
||||
#define COMPUTE_ROTATE_DIPOLE_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeRotateDipole : public Compute {
|
||||
public:
|
||||
ComputeRotateDipole(class LAMMPS *, int, char **);
|
||||
~ComputeRotateDipole();
|
||||
void init();
|
||||
double compute_scalar();
|
||||
|
||||
private:
|
||||
double *inertia;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,68 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "compute_rotate_gran.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "group.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define INERTIA3D 0.4 // moments of inertia for sphere and disk
|
||||
#define INERTIA2D 0.5
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeRotateGran::ComputeRotateGran(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute rotate/gran command");
|
||||
|
||||
if (atom->check_style("granular") == 0)
|
||||
error->all("Must use atom style granular with compute rotate/gran");
|
||||
|
||||
scalar_flag = 1;
|
||||
extensive = 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeRotateGran::init()
|
||||
{
|
||||
if (force->dimension == 3) pfactor = 0.5 * force->mvv2e * INERTIA3D;
|
||||
else pfactor = 0.5 * force->mvv2e * INERTIA2D;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeRotateGran::compute_scalar()
|
||||
{
|
||||
double **phiv = atom->phiv;
|
||||
double *radius = atom->radius;
|
||||
double *rmass = atom->rmass;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double erot = 0.0;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
erot += (phiv[i][0]*phiv[i][0] + phiv[i][1]*phiv[i][1] +
|
||||
phiv[i][2]*phiv[i][2]) * radius[i]*radius[i]*rmass[i];
|
||||
|
||||
MPI_Allreduce(&erot,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
scalar *= pfactor;
|
||||
return scalar;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_ROTATE_GRAN_H
|
||||
#define COMPUTE_ROTATE_GRAN_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeRotateGran : public Compute {
|
||||
public:
|
||||
ComputeRotateGran(class LAMMPS *, int, char **);
|
||||
void init();
|
||||
double compute_scalar();
|
||||
|
||||
private:
|
||||
double pfactor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,255 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "compute_stress_atom.h"
|
||||
#include "atom.h"
|
||||
#include "neighbor.h"
|
||||
#include "modify.h"
|
||||
#include "comm.h"
|
||||
#include "update.h"
|
||||
#include "force.h"
|
||||
#include "pair.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute stress/atom command");
|
||||
|
||||
peratom_flag = 1;
|
||||
size_peratom = 6;
|
||||
comm_reverse = 6;
|
||||
neigh_half_once = 1;
|
||||
|
||||
nmax = 0;
|
||||
stress = NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeStressAtom::~ComputeStressAtom()
|
||||
{
|
||||
memory->destroy_2d_double_array(stress);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeStressAtom::init()
|
||||
{
|
||||
if (force->pair == NULL || force->pair->single_enable == 0)
|
||||
error->all("Pair style does not support computing per-atom stress");
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < modify->ncompute; i++)
|
||||
if (strcmp(modify->compute[i]->style,"stress/atom") == 0) count++;
|
||||
if (count > 1 && comm->me == 0)
|
||||
error->warning("More than one compute stress/atom defined");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeStressAtom::compute_peratom()
|
||||
{
|
||||
int i,j,k,n,itype,jtype,numneigh;
|
||||
double xtmp,ytmp,ztmp,delx,dely,delz,rsq;
|
||||
double factor_coul,factor_lj,fforce,rmass;
|
||||
int *neighs;
|
||||
Pair::One one;
|
||||
|
||||
// grow stress array if necessary
|
||||
|
||||
if (atom->nmax > nmax) {
|
||||
memory->destroy_2d_double_array(stress);
|
||||
nmax = atom->nmax;
|
||||
stress =
|
||||
memory->create_2d_double_array(nmax,6,"compute/stress/atom:stress");
|
||||
vector_atom = stress;
|
||||
}
|
||||
|
||||
// clear stress array
|
||||
// n includes ghosts only if newton_pair flag is set
|
||||
|
||||
if (force->newton_pair) n = atom->nlocal + atom->nghost;
|
||||
else n = atom->nlocal;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
stress[i][0] = 0.0;
|
||||
stress[i][1] = 0.0;
|
||||
stress[i][2] = 0.0;
|
||||
stress[i][3] = 0.0;
|
||||
stress[i][4] = 0.0;
|
||||
stress[i][5] = 0.0;
|
||||
}
|
||||
|
||||
// if needed, build a half neighbor list
|
||||
|
||||
if (!neighbor->half_every) neighbor->build_half();
|
||||
|
||||
// compute pairwise stress for all atoms via pair->single()
|
||||
// use half neighbor list
|
||||
|
||||
double *special_coul = force->special_coul;
|
||||
double *special_lj = force->special_lj;
|
||||
double **cutsq = force->pair->cutsq;
|
||||
|
||||
double **x = atom->x;
|
||||
int *type = atom->type;
|
||||
int nlocal = atom->nlocal;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
xtmp = x[i][0];
|
||||
ytmp = x[i][1];
|
||||
ztmp = x[i][2];
|
||||
itype = type[i];
|
||||
neighs = neighbor->firstneigh[i];
|
||||
numneigh = neighbor->numneigh[i];
|
||||
|
||||
for (k = 0; k < numneigh; k++) {
|
||||
j = neighs[k];
|
||||
|
||||
if (j < nall) factor_coul = factor_lj = 1.0;
|
||||
else {
|
||||
factor_coul = special_coul[j/nall];
|
||||
factor_lj = special_lj[j/nall];
|
||||
j %= nall;
|
||||
}
|
||||
|
||||
delx = xtmp - x[j][0];
|
||||
dely = ytmp - x[j][1];
|
||||
delz = ztmp - x[j][2];
|
||||
rsq = delx*delx + dely*dely + delz*delz;
|
||||
jtype = type[j];
|
||||
|
||||
if (rsq < cutsq[itype][jtype]) {
|
||||
force->pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,0,one);
|
||||
fforce = one.fforce;
|
||||
|
||||
stress[i][0] -= delx*delx*fforce;
|
||||
stress[i][1] -= dely*dely*fforce;
|
||||
stress[i][2] -= delz*delz*fforce;
|
||||
stress[i][3] -= delx*dely*fforce;
|
||||
stress[i][4] -= delx*delz*fforce;
|
||||
stress[i][5] -= dely*delz*fforce;
|
||||
if (force->newton_pair || j < nlocal) {
|
||||
stress[j][0] -= delx*delx*fforce;
|
||||
stress[j][1] -= dely*dely*fforce;
|
||||
stress[j][2] -= delz*delz*fforce;
|
||||
stress[j][3] -= delx*dely*fforce;
|
||||
stress[j][4] -= delx*delz*fforce;
|
||||
stress[j][5] -= dely*delz*fforce;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// communicate stress between neighbor procs
|
||||
|
||||
if (force->newton_pair) comm->reverse_comm_compute(this);
|
||||
|
||||
// remove double counting of per-atom stress
|
||||
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
stress[i][0] *= 0.5;
|
||||
stress[i][1] *= 0.5;
|
||||
stress[i][2] *= 0.5;
|
||||
stress[i][3] *= 0.5;
|
||||
stress[i][4] *= 0.5;
|
||||
stress[i][5] *= 0.5;
|
||||
}
|
||||
|
||||
// include kinetic energy term for each atom
|
||||
// mvv2e converts mv^2 to energy
|
||||
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double mvv2e = force->mvv2e;
|
||||
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
rmass = mvv2e * mass[type[i]];
|
||||
stress[i][0] -= rmass*v[i][0]*v[i][0];
|
||||
stress[i][1] -= rmass*v[i][1]*v[i][1];
|
||||
stress[i][2] -= rmass*v[i][2]*v[i][2];
|
||||
stress[i][3] -= rmass*v[i][0]*v[i][1];
|
||||
stress[i][4] -= rmass*v[i][0]*v[i][2];
|
||||
stress[i][5] -= rmass*v[i][1]*v[i][2];
|
||||
}
|
||||
|
||||
// convert to pressure units (actually stress/volume = pressure)
|
||||
|
||||
double nktv2p = force->nktv2p;
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
stress[i][0] *= nktv2p;
|
||||
stress[i][1] *= nktv2p;
|
||||
stress[i][2] *= nktv2p;
|
||||
stress[i][3] *= nktv2p;
|
||||
stress[i][4] *= nktv2p;
|
||||
stress[i][5] *= nktv2p;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int ComputeStressAtom::pack_reverse_comm(int n, int first, double *buf)
|
||||
{
|
||||
int i,m,last;
|
||||
|
||||
m = 0;
|
||||
last = first + n;
|
||||
for (i = first; i < last; i++) {
|
||||
buf[m++] = stress[i][0];
|
||||
buf[m++] = stress[i][1];
|
||||
buf[m++] = stress[i][2];
|
||||
buf[m++] = stress[i][3];
|
||||
buf[m++] = stress[i][4];
|
||||
buf[m++] = stress[i][5];
|
||||
}
|
||||
return 6;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeStressAtom::unpack_reverse_comm(int n, int *list, double *buf)
|
||||
{
|
||||
int i,j,m;
|
||||
|
||||
m = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
j = list[i];
|
||||
stress[j][0] += buf[m++];
|
||||
stress[j][1] += buf[m++];
|
||||
stress[j][2] += buf[m++];
|
||||
stress[j][3] += buf[m++];
|
||||
stress[j][4] += buf[m++];
|
||||
stress[j][5] += buf[m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based array
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ComputeStressAtom::memory_usage()
|
||||
{
|
||||
int bytes = nmax*6 * sizeof(double);
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_STRESS_ATOM_H
|
||||
#define COMPUTE_STRESS_ATOM_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeStressAtom : public Compute {
|
||||
|
||||
public:
|
||||
ComputeStressAtom(class LAMMPS *, int, char **);
|
||||
~ComputeStressAtom();
|
||||
void init();
|
||||
void compute_peratom();
|
||||
int pack_reverse_comm(int, int, double *);
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
int memory_usage();
|
||||
|
||||
private:
|
||||
int nmax;
|
||||
double **stress;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,128 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "compute_temp.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "group.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTemp::ComputeTemp(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 3) error->all("Illegal compute temp command");
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
extensive = 0;
|
||||
tempflag = 1;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTemp::~ComputeTemp()
|
||||
{
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTemp::init()
|
||||
{
|
||||
fix_dof = 0;
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
recount();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTemp::recount()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = force->dimension * natoms;
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeTemp::compute_scalar()
|
||||
{
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double t = 0.0;
|
||||
|
||||
if (mass) {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) *
|
||||
mass[type[i]];
|
||||
} else {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
if (dynamic) recount();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTemp::compute_vector()
|
||||
{
|
||||
int i;
|
||||
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double massone,t[6];
|
||||
for (i = 0; i < 6; i++) t[i] = 0.0;
|
||||
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
if (mass) massone = mass[type[i]];
|
||||
else massone = rmass[i];
|
||||
t[0] += massone * v[i][0]*v[i][0];
|
||||
t[1] += massone * v[i][1]*v[i][1];
|
||||
t[2] += massone * v[i][2]*v[i][2];
|
||||
t[3] += massone * v[i][0]*v[i][1];
|
||||
t[4] += massone * v[i][0]*v[i][2];
|
||||
t[5] += massone * v[i][1]*v[i][2];
|
||||
}
|
||||
|
||||
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_TEMP_H
|
||||
#define COMPUTE_TEMP_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeTemp : public Compute {
|
||||
public:
|
||||
ComputeTemp(class LAMMPS *, int, char **);
|
||||
~ComputeTemp();
|
||||
void init();
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
private:
|
||||
int fix_dof;
|
||||
double tfactor;
|
||||
|
||||
void recount();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,134 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "stdlib.h"
|
||||
#include "compute_temp_partial.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "group.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTempPartial::ComputeTempPartial(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 6) error->all("Illegal compute temp/partial command");
|
||||
|
||||
xflag = atoi(arg[3]);
|
||||
yflag = atoi(arg[4]);
|
||||
zflag = atoi(arg[5]);
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
extensive = 0;
|
||||
tempflag = 1;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTempPartial::~ComputeTempPartial()
|
||||
{
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempPartial::init()
|
||||
{
|
||||
fix_dof = 0;
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
recount();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempPartial::recount()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = (xflag+yflag+zflag) * natoms;
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeTempPartial::compute_scalar()
|
||||
{
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double t = 0.0;
|
||||
|
||||
if (mass) {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
t += (xflag*v[i][0]*v[i][0] + yflag*v[i][1]*v[i][1] +
|
||||
zflag*v[i][2]*v[i][2]) * mass[type[i]];
|
||||
} else {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit)
|
||||
t += (xflag*v[i][0]*v[i][0] + yflag*v[i][1]*v[i][1] +
|
||||
zflag*v[i][2]*v[i][2]) * rmass[i];
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
if (dynamic) recount();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempPartial::compute_vector()
|
||||
{
|
||||
int i;
|
||||
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double massone,t[6];
|
||||
for (i = 0; i < 6; i++) t[i] = 0.0;
|
||||
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
if (mass) massone = mass[type[i]];
|
||||
else massone = rmass[i];
|
||||
t[0] += massone * xflag*v[i][0]*v[i][0];
|
||||
t[1] += massone * yflag*v[i][1]*v[i][1];
|
||||
t[2] += massone * zflag*v[i][2]*v[i][2];
|
||||
t[3] += massone * xflag*yflag*v[i][0]*v[i][1];
|
||||
t[4] += massone * xflag*zflag*v[i][0]*v[i][2];
|
||||
t[5] += massone * yflag*zflag*v[i][1]*v[i][2];
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_TEMP_PARTIAL_H
|
||||
#define COMPUTE_TEMP_PARTIAL_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeTempPartial : public Compute {
|
||||
public:
|
||||
ComputeTempPartial(class LAMMPS *, int, char **);
|
||||
~ComputeTempPartial();
|
||||
void init();
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
private:
|
||||
int xflag,yflag,zflag;
|
||||
int fix_dof;
|
||||
double tfactor;
|
||||
|
||||
void recount();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,213 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "compute_temp_ramp.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "group.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
#include "domain.h"
|
||||
#include "lattice.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MIN(A,B) ((A) < (B)) ? (A) : (B)
|
||||
#define MAX(A,B) ((A) > (B)) ? (A) : (B)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTempRamp::ComputeTempRamp(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 9) error->all("Illegal compute temp command");
|
||||
|
||||
if (strcmp(arg[3],"vx") == 0) v_dim = 0;
|
||||
else if (strcmp(arg[3],"vy") == 0) v_dim = 1;
|
||||
else if (strcmp(arg[3],"vz") == 0) v_dim = 2;
|
||||
else error->all("Illegal compute temp/ramp command");
|
||||
|
||||
if (v_dim == 0) {
|
||||
v_lo = xscale*atof(arg[4]);
|
||||
v_hi = xscale*atof(arg[5]);
|
||||
} else if (v_dim == 1) {
|
||||
v_lo = yscale*atof(arg[4]);
|
||||
v_hi = yscale*atof(arg[5]);
|
||||
} else if (v_dim == 0) {
|
||||
v_lo = zscale*atof(arg[4]);
|
||||
v_hi = zscale*atof(arg[5]);
|
||||
}
|
||||
|
||||
if (strcmp(arg[6],"x") == 0) coord_dim = 0;
|
||||
else if (strcmp(arg[6],"y") == 0) coord_dim = 1;
|
||||
else if (strcmp(arg[6],"z") == 0) coord_dim = 2;
|
||||
else error->all("Illegal compute temp/ramp command");
|
||||
|
||||
if (coord_dim == 0) {
|
||||
coord_lo = xscale*atof(arg[7]);
|
||||
coord_hi = xscale*atof(arg[8]);
|
||||
} else if (coord_dim == 1) {
|
||||
coord_lo = yscale*atof(arg[7]);
|
||||
coord_hi = yscale*atof(arg[8]);
|
||||
} else if (coord_dim == 2) {
|
||||
coord_lo = zscale*atof(arg[7]);
|
||||
coord_hi = zscale*atof(arg[8]);
|
||||
}
|
||||
|
||||
// parse optional args
|
||||
|
||||
scaleflag = 1;
|
||||
|
||||
int iarg = 9;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"units") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal compute temp/ramp command");
|
||||
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
||||
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
|
||||
else error->all("Illegal compute temp/ramp command");
|
||||
iarg += 2;
|
||||
} else error->all("Illegal compute temp/ramp command");
|
||||
}
|
||||
|
||||
// setup scaling
|
||||
|
||||
if (scaleflag && domain->lattice == NULL)
|
||||
error->all("Use of compute temp/ramp with undefined lattice");
|
||||
|
||||
if (scaleflag) {
|
||||
xscale = domain->lattice->xlattice;
|
||||
yscale = domain->lattice->ylattice;
|
||||
zscale = domain->lattice->zlattice;
|
||||
}
|
||||
else xscale = yscale = zscale = 1.0;
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
extensive = 0;
|
||||
tempflag = 1;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTempRamp::~ComputeTempRamp()
|
||||
{
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempRamp::init()
|
||||
{
|
||||
fix_dof = 0;
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
fix_dof += modify->fix[i]->dof(igroup);
|
||||
recount();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempRamp::recount()
|
||||
{
|
||||
double natoms = group->count(igroup);
|
||||
dof = force->dimension * natoms;
|
||||
dof -= extra_dof + fix_dof;
|
||||
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
|
||||
else tfactor = 0.0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeTempRamp::compute_scalar()
|
||||
{
|
||||
double fraction,vramp,vtmp[3];
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double t = 0.0;
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
fraction = (x[i][coord_dim] - coord_lo) / (coord_hi - coord_lo);
|
||||
fraction = MAX(fraction,0.0);
|
||||
fraction = MIN(fraction,1.0);
|
||||
vramp = v_lo + fraction*(v_hi - v_lo);
|
||||
vtmp[0] = v[i][0];
|
||||
vtmp[1] = v[i][1];
|
||||
vtmp[2] = v[i][2];
|
||||
vtmp[v_dim] -= vramp;
|
||||
if (mass)
|
||||
t += (vtmp[0]*vtmp[0] + vtmp[1]*vtmp[1] + vtmp[2]*vtmp[2]) *
|
||||
mass[type[i]];
|
||||
else
|
||||
t += (vtmp[0]*vtmp[0] + vtmp[1]*vtmp[1] + vtmp[2]*vtmp[2]) * rmass[i];
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
|
||||
if (dynamic) recount();
|
||||
scalar *= tfactor;
|
||||
return scalar;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempRamp::compute_vector()
|
||||
{
|
||||
int i;
|
||||
double fraction,vramp,vtmp[3];
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double massone,t[6];
|
||||
for (i = 0; i < 6; i++) t[i] = 0.0;
|
||||
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
fraction = (x[i][coord_dim] - coord_lo) / (coord_hi - coord_lo);
|
||||
fraction = MAX(fraction,0.0);
|
||||
fraction = MIN(fraction,1.0);
|
||||
vramp = v_lo + fraction*(v_hi - v_lo);
|
||||
vtmp[0] = v[i][0];
|
||||
vtmp[1] = v[i][1];
|
||||
vtmp[2] = v[i][2];
|
||||
vtmp[v_dim] -= vramp;
|
||||
|
||||
if (mass) massone = mass[type[i]];
|
||||
else massone = rmass[i];
|
||||
t[0] += massone * vtmp[0]*vtmp[0];
|
||||
t[1] += massone * vtmp[1]*vtmp[1];
|
||||
t[2] += massone * vtmp[2]*vtmp[2];
|
||||
t[3] += massone * vtmp[0]*vtmp[1];
|
||||
t[4] += massone * vtmp[0]*vtmp[2];
|
||||
t[5] += massone * vtmp[1]*vtmp[2];
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_TEMP_RAMP_H
|
||||
#define COMPUTE_TEMP_RAMP_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeTempRamp : public Compute {
|
||||
public:
|
||||
ComputeTempRamp(class LAMMPS *, int, char **);
|
||||
~ComputeTempRamp();
|
||||
void init();
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
private:
|
||||
int coord_dim;
|
||||
double coord_lo,coord_hi;
|
||||
int v_dim;
|
||||
double v_lo,v_hi;
|
||||
int scaleflag,fix_dof;
|
||||
double tfactor,xscale,yscale,zscale;
|
||||
|
||||
void recount();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,133 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "mpi.h"
|
||||
#include "string.h"
|
||||
#include "compute_temp_region.h"
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "domain.h"
|
||||
#include "region.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg)
|
||||
{
|
||||
if (narg != 4) error->all("Illegal compute temp/region command");
|
||||
|
||||
for (iregion = 0; iregion < domain->nregion; iregion++)
|
||||
if (strcmp(arg[3],domain->regions[iregion]->id) == 0) break;
|
||||
if (iregion == domain->nregion)
|
||||
error->all("Temperature region ID does not exist");
|
||||
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
extensive = 0;
|
||||
tempflag = 1;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeTempRegion::~ComputeTempRegion()
|
||||
{
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempRegion::init()
|
||||
{
|
||||
dof = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
double ComputeTempRegion::compute_scalar()
|
||||
{
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
int count = 0;
|
||||
double t = 0.0;
|
||||
|
||||
if (mass) {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit &&
|
||||
domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
|
||||
count++;
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) *
|
||||
mass[type[i]];
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit &&
|
||||
domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
|
||||
count++;
|
||||
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
|
||||
}
|
||||
}
|
||||
|
||||
double tarray[2],tarray_all[2];
|
||||
tarray[0] = count;
|
||||
tarray[1] = t;
|
||||
MPI_Allreduce(tarray,tarray_all,2,MPI_DOUBLE,MPI_SUM,world);
|
||||
dof = force->dimension * tarray_all[0] - extra_dof;
|
||||
if (dof > 0) scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
|
||||
else scalar = 0.0;
|
||||
return scalar;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeTempRegion::compute_vector()
|
||||
{
|
||||
int i;
|
||||
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
double massone,t[6];
|
||||
for (i = 0; i < 6; i++) t[i] = 0.0;
|
||||
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit &&
|
||||
domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
|
||||
if (mass) massone = mass[type[i]];
|
||||
else massone = rmass[i];
|
||||
t[0] += massone * v[i][0]*v[i][0];
|
||||
t[1] += massone * v[i][1]*v[i][1];
|
||||
t[2] += massone * v[i][2]*v[i][2];
|
||||
t[3] += massone * v[i][0]*v[i][1];
|
||||
t[4] += massone * v[i][0]*v[i][2];
|
||||
t[5] += massone * v[i][1]*v[i][2];
|
||||
}
|
||||
|
||||
MPI_Allreduce(&t,&vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef COMPUTE_TEMP_REGION_H
|
||||
#define COMPUTE_TEMP_REGION_H
|
||||
|
||||
#include "compute.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ComputeTempRegion : public Compute {
|
||||
public:
|
||||
ComputeTempRegion(class LAMMPS *, int, char **);
|
||||
~ComputeTempRegion();
|
||||
void init();
|
||||
double compute_scalar();
|
||||
void compute_vector();
|
||||
|
||||
private:
|
||||
int iregion;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,284 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "fix_shear_history.h"
|
||||
#include "atom.h"
|
||||
#include "neighbor.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAXTOUCH 15
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixShearHistory::FixShearHistory(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg)
|
||||
{
|
||||
restart_peratom = 1;
|
||||
|
||||
// perform initial allocation of atom-based arrays
|
||||
// register with atom class
|
||||
|
||||
npartner = NULL;
|
||||
partner = NULL;
|
||||
shearpartner = NULL;
|
||||
grow_arrays(atom->nmax);
|
||||
atom->add_callback(0);
|
||||
atom->add_callback(1);
|
||||
|
||||
// initialize npartner to 0 so neighbor list creation is OK the 1st time
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
for (int i = 0; i < nlocal; i++) npartner[i] = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixShearHistory::~FixShearHistory()
|
||||
{
|
||||
// unregister this fix so atom class doesn't invoke it any more
|
||||
|
||||
atom->delete_callback(id,0);
|
||||
atom->delete_callback(id,1);
|
||||
|
||||
// delete locally stored arrays
|
||||
|
||||
memory->sfree(npartner);
|
||||
memory->destroy_2d_int_array(partner);
|
||||
memory->destroy_3d_double_array(shearpartner);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int FixShearHistory::setmask()
|
||||
{
|
||||
int mask = 0;
|
||||
mask |= PRE_EXCHANGE;
|
||||
return mask;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void FixShearHistory::init()
|
||||
{
|
||||
if (atom->tag_enable == 0)
|
||||
error->all("Pair style granular with history requires atoms have IDs");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy shear partner info from neighbor lists to atom arrays
|
||||
so can be exchanged with atoms
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixShearHistory::pre_exchange()
|
||||
{
|
||||
int i,j,k,m;
|
||||
|
||||
// zero npartners for all current atoms
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
for (i = 0; i < nlocal; i++) npartner[i] = 0;
|
||||
|
||||
// copy shear info from neighbor list atoms to atom arrays
|
||||
// nlocal = nlocal_neighbor = nlocal when neighbor list last built,
|
||||
// which might be pre-insert on this step
|
||||
|
||||
int numneigh;
|
||||
int *neighs,*touch;
|
||||
double *firstshear,*shear;
|
||||
int *tag = atom->tag;
|
||||
nlocal = neighbor->nlocal_neighbor;
|
||||
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
neighs = neighbor->firstneigh[i];
|
||||
touch = neighbor->firsttouch[i];
|
||||
firstshear = neighbor->firstshear[i];
|
||||
numneigh = neighbor->numneigh[i];
|
||||
for (k = 0; k < numneigh; k++) {
|
||||
if (touch[k]) {
|
||||
shear = &firstshear[3*k];
|
||||
j = neighs[k];
|
||||
if (npartner[i] < MAXTOUCH) {
|
||||
m = npartner[i];
|
||||
partner[i][m] = tag[j];
|
||||
shearpartner[i][m][0] = shear[0];
|
||||
shearpartner[i][m][1] = shear[1];
|
||||
shearpartner[i][m][2] = shear[2];
|
||||
}
|
||||
npartner[i]++;
|
||||
if (j < nlocal) {
|
||||
if (npartner[j] < MAXTOUCH) {
|
||||
m = npartner[j];
|
||||
partner[j][m] = tag[i];
|
||||
shearpartner[j][m][0] = -shear[0];
|
||||
shearpartner[j][m][1] = -shear[1];
|
||||
shearpartner[j][m][2] = -shear[2];
|
||||
}
|
||||
npartner[j]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test for too many touching neighbors
|
||||
|
||||
int flag = 0;
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (npartner[i] >= MAXTOUCH) flag = 1;
|
||||
int flag_all;
|
||||
MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world);
|
||||
if (flag_all) error->all("Too many touching neighbors - boost MAXTOUCH");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
memory usage of local atom-based arrays
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixShearHistory::memory_usage()
|
||||
{
|
||||
int nmax = atom->nmax;
|
||||
int bytes = nmax * sizeof(int);
|
||||
bytes += nmax*MAXTOUCH * sizeof(int);
|
||||
bytes += nmax*MAXTOUCH*3 * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
allocate local atom-based arrays
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixShearHistory::grow_arrays(int nmax)
|
||||
{
|
||||
npartner = (int *) memory->srealloc(npartner,nmax*sizeof(int),
|
||||
"shear_history:npartner");
|
||||
partner = memory->grow_2d_int_array(partner,nmax,MAXTOUCH,
|
||||
"shear_history:partner");
|
||||
shearpartner =
|
||||
memory->grow_3d_double_array(shearpartner,nmax,MAXTOUCH,3,
|
||||
"shear_history:shearpartner");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy values within local atom-based arrays
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixShearHistory::copy_arrays(int i, int j)
|
||||
{
|
||||
npartner[j] = npartner[i];
|
||||
for (int m = 0; m < npartner[j]; m++) {
|
||||
partner[j][m] = partner[i][m];
|
||||
shearpartner[j][m][0] = shearpartner[i][m][0];
|
||||
shearpartner[j][m][1] = shearpartner[i][m][1];
|
||||
shearpartner[j][m][2] = shearpartner[i][m][2];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack values in local atom-based arrays for exchange with another proc
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixShearHistory::pack_exchange(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
buf[m++] = npartner[i];
|
||||
for (int n = 0; n < npartner[i]; n++) {
|
||||
buf[m++] = partner[i][n];
|
||||
buf[m++] = shearpartner[i][n][0];
|
||||
buf[m++] = shearpartner[i][n][1];
|
||||
buf[m++] = shearpartner[i][n][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack values in local atom-based arrays from exchange with another proc
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixShearHistory::unpack_exchange(int nlocal, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
npartner[nlocal] = static_cast<int> (buf[m++]);
|
||||
for (int n = 0; n < npartner[nlocal]; n++) {
|
||||
partner[nlocal][n] = static_cast<int> (buf[m++]);
|
||||
shearpartner[nlocal][n][0] = buf[m++];
|
||||
shearpartner[nlocal][n][1] = buf[m++];
|
||||
shearpartner[nlocal][n][2] = buf[m++];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
pack values in local atom-based arrays for restart file
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixShearHistory::pack_restart(int i, double *buf)
|
||||
{
|
||||
int m = 0;
|
||||
buf[m++] = 4*npartner[i] + 2;
|
||||
buf[m++] = npartner[i];
|
||||
for (int n = 0; n < npartner[i]; n++) {
|
||||
buf[m++] = partner[i][n];
|
||||
buf[m++] = shearpartner[i][n][0];
|
||||
buf[m++] = shearpartner[i][n][1];
|
||||
buf[m++] = shearpartner[i][n][2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
unpack values from atom->extra array to restart the fix
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixShearHistory::unpack_restart(int nlocal, int nth)
|
||||
{
|
||||
double **extra = atom->extra;
|
||||
|
||||
// skip to Nth set of extra values
|
||||
|
||||
int m = 0;
|
||||
for (int i = 0; i < nth; i++) m += static_cast<int> (extra[nlocal][m]);
|
||||
m++;
|
||||
|
||||
npartner[nlocal] = static_cast<int> (extra[nlocal][m++]);
|
||||
for (int n = 0; n < npartner[nlocal]; n++) {
|
||||
partner[nlocal][n] = static_cast<int> (extra[nlocal][m++]);
|
||||
shearpartner[nlocal][n][0] = extra[nlocal][m++];
|
||||
shearpartner[nlocal][n][1] = extra[nlocal][m++];
|
||||
shearpartner[nlocal][n][2] = extra[nlocal][m++];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
maxsize of any atom's restart data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixShearHistory::maxsize_restart()
|
||||
{
|
||||
return 4*MAXTOUCH + 2;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
size of atom nlocal's restart data
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int FixShearHistory::size_restart(int nlocal)
|
||||
{
|
||||
return 4*npartner[nlocal] + 2;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,304 @@
|
|||
Ni function (universal 3)
|
||||
28 58.710 3.5200 FCC
|
||||
500 5.0100200400801306e-04 500 9.6969696969697039e-03 4.8000000000000114e+00
|
||||
0. -5.0517016048996766e-01 -7.9317853848267106e-01 -1.0217438587039425e+00 -1.2174805690269395e+00
|
||||
-1.3915708504375530e+00 -1.5499932328286121e+00 -1.6963954974188340e+00 -1.8332004716104038e+00 -1.9621160791940611e+00
|
||||
-2.0843760483513876e+00 -2.1992938880209749e+00 -2.3093396176347341e+00 -2.4151048342909860e+00 -2.5170730411782927e+00
|
||||
-2.6156455313181937e+00 -2.7111597934241303e+00 -2.8039029250035838e+00 -2.8941216165036252e+00 -2.9820297219149694e+00
|
||||
-3.0678140937243796e+00 -3.1516391457178798e+00 -3.2336504675375721e+00 -3.3139777215379382e+00 -3.3927369891350594e+00
|
||||
-3.4700326894515854e+00 -3.5459591620359561e+00 -3.6206019830134863e+00 -3.6940390674917722e+00 -3.7663415995091469e+00
|
||||
-3.8375748211898610e+00 -3.9077987065080180e+00 -3.9770685396213423e+00 -4.0454354138360316e+00 -4.1129466641100976e+00
|
||||
-4.1796462436871593e+00 -4.2455750533765979e+00 -4.3107712306517953e+00 -4.3752704043257609e+00 -4.4391059197901370e+00
|
||||
-4.5023090387655884e+00 -4.5649091171416387e+00 -4.6269337636658463e+00 -4.6884089819903636e+00 -4.7493592982170298e+00
|
||||
-4.8098078755955100e+00 -4.8697766180438862e+00 -4.9292862637278461e+00 -4.9883564698644989e+00 -5.0470058897358570e+00
|
||||
-5.1052522427840188e+00 -5.1623072179650649e+00 -5.2189018510607639e+00 -5.2751350144308446e+00 -5.3310209820086811e+00
|
||||
-5.3865733770414863e+00 -5.4418052123181724e+00 -5.4967289272545088e+00 -5.5513564221275828e+00 -5.6056990897199057e+00
|
||||
-5.6597678446140094e+00 -5.7135731503426257e+00 -5.7671250445876296e+00 -5.8204331625956058e+00 -5.8735067589604455e+00
|
||||
-5.9263547279134343e+00 -5.9789856222417370e+00 -6.0314076709491928e+00 -6.0836287957580453e+00 -6.1356566265451704e+00
|
||||
-6.1874985157960793e+00 -6.2391615521814003e+00 -6.2906525731472414e+00 -6.3419781770271015e+00 -6.3931447341185503e+00
|
||||
-6.4441583972792955e+00 -6.4950251118515041e+00 -6.5457506250122037e+00 -6.5963404945961486e+00 -6.6468000974149675e+00
|
||||
-6.6971346371185234e+00 -6.7473491516179536e+00 -6.7974485201119705e+00 -6.8474374697293854e+00 -6.8973205818230383e+00
|
||||
-6.9471022979348334e+00 -6.9967869254475659e+00 -7.0463786429507991e+00 -7.0958815053338640e+00 -7.1452994486230068e+00
|
||||
-7.1946362945806470e+00 -7.2438957550783698e+00 -7.2930814362578644e+00 -7.3421968424935073e+00 -7.3912453801662821e+00
|
||||
-7.4402303612538390e+00 -7.4891550067840740e+00 -7.5380224500758857e+00 -7.5868357398816215e+00 -7.6355978434033887e+00
|
||||
-7.6843116489928320e+00 -7.7329799690993184e+00 -7.7816055427344679e+00 -7.8301910379813648e+00 -7.8787390543927813e+00
|
||||
-7.9272521252767660e+00 -7.9757327198801704e+00 -8.0241832454879045e+00 -8.0726060494311014e+00 -8.1210034210155300e+00
|
||||
-8.1693775933707116e+00 -8.2177307452265609e+00 -8.2660650026147664e+00 -8.3143824405092914e+00 -8.3626850843966167e+00
|
||||
-8.4109749117892534e+00 -8.4592538536799680e+00 -8.5075237959315473e+00 -8.5557865806474069e+00 -8.6040440074316393e+00
|
||||
-8.6522978346561672e+00 -8.7005497806599692e+00 -8.7488015249013529e+00 -8.7970547090747573e+00 -8.8453109381845820e+00
|
||||
-8.8935717815805901e+00 -8.9417402661794085e+00 -8.9898383368729355e+00 -9.0379436351492473e+00 -9.0860575781817374e+00
|
||||
-9.1341815522981733e+00 -9.1823169138104959e+00 -9.2304649898246680e+00 -9.2786270790152230e+00 -9.3268044523757681e+00
|
||||
-9.3749983539491382e+00 -9.4232100015290143e+00 -9.4714405873368719e+00 -9.5196912786851726e+00 -9.5679632186102026e+00
|
||||
-9.6162575264887096e+00 -9.6645752986381694e+00 -9.7129176088877784e+00 -9.7612855091464326e+00 -9.8096800299389315e+00
|
||||
-9.8581021809341678e+00 -9.9065529514548416e+00 -9.9550333109705207e+00 -1.0003544209576205e+01 -1.0052086578458329e+01
|
||||
-1.0100661330345247e+01 -1.0149269359941854e+01 -1.0197911544358305e+01 -1.0246588743517407e+01 -1.0295301800557468e+01
|
||||
-1.0344051542219859e+01 -1.0392838779225485e+01 -1.0441664306641712e+01 -1.0490528904236726e+01 -1.0539433336827699e+01
|
||||
-1.0588378354614804e+01 -1.0637364693509198e+01 -1.0686393075449359e+01 -1.0735464208710937e+01 -1.0784578788206602e+01
|
||||
-1.0833737495777086e+01 -1.0882941000477615e+01 -1.0932189958852859e+01 -1.0981485015205521e+01 -1.1030826801860144e+01
|
||||
-1.1080215939416007e+01 -1.1129653036995705e+01 -1.1179138692487811e+01 -1.1228673492782434e+01 -1.1278258013997231e+01
|
||||
-1.1327892821704779e+01 -1.1377578471149377e+01 -1.1427315507456228e+01 -1.1477104465839943e+01 -1.1526945871807015e+01
|
||||
-1.1576840241350737e+01 -1.1626788081143559e+01 -1.1676789888720691e+01 -1.1726846152666326e+01 -1.1776957352790021e+01
|
||||
-1.1827123960296717e+01 -1.1877346437960568e+01 -1.1927625240283987e+01 -1.1977960813666357e+01 -1.2028353596557736e+01
|
||||
-1.2078804019606196e+01 -1.2129312505807263e+01 -1.2179879470659557e+01 -1.2230505322233341e+01 -1.2281190461588324e+01
|
||||
-1.2331935282489439e+01 -1.2382740171822832e+01 -1.2433605509650079e+01 -1.2484531669341038e+01 -1.2535519017690660e+01
|
||||
-1.2586567915048647e+01 -1.2637678715430582e+01 -1.2688851766635594e+01 -1.2740087410360104e+01 -1.2791385982309691e+01
|
||||
-1.2842747812302150e+01 -1.2894173224380381e+01 -1.2945662536907093e+01 -1.2997216062675022e+01 -1.3048834108996232e+01
|
||||
-1.3100516977805853e+01 -1.3152264965755137e+01 -1.3204078364302120e+01 -1.3255957459800982e+01 -1.3307902533596177e+01
|
||||
-1.3359913862102815e+01 -1.3411991716894249e+01 -1.3464136364786839e+01 -1.3516348067917022e+01 -1.3568627083826016e+01
|
||||
-1.3620973665531096e+01 -1.3673388061610183e+01 -1.3725870516267150e+01 -1.3778421269413343e+01 -1.3831040556733626e+01
|
||||
-1.3883728609760851e+01 -1.3936485655939009e+01 -1.3989311918697354e+01 -1.4042207617510314e+01 -1.4095172967964288e+01
|
||||
-1.4148208181825794e+01 -1.4201313467092689e+01 -1.4254489028066530e+01 -1.4307735065404927e+01 -1.4360825840962775e+01
|
||||
-1.4413978799379436e+01 -1.4467200637720680e+01 -1.4520491531087600e+01 -1.4573851651247821e+01 -1.4627281166688022e+01
|
||||
-1.4680780242682715e+01 -1.4734349041210180e+01 -1.4787987721378727e+01 -1.4841696438965585e+01 -1.4895475346811168e+01
|
||||
-1.4949324594764903e+01 -1.5003244329738379e+01 -1.5057234695747354e+01 -1.5111295833957456e+01 -1.5165427882730739e+01
|
||||
-1.5219630977660984e+01 -1.5273905251625195e+01 -1.5328250834816970e+01 -1.5382667854791293e+01 -1.5437156436504551e+01
|
||||
-1.5491716702349208e+01 -1.5546348772196666e+01 -1.5601052763435575e+01 -1.5655828791002250e+01 -1.5710676967424547e+01
|
||||
-1.5765597402851995e+01 -1.5820590205094163e+01 -1.5875655479554666e+01 -1.5930793329658627e+01 -1.5986003856268781e+01
|
||||
-1.6041287158172963e+01 -1.6096643331986456e+01 -1.6152072472167561e+01 -1.6207574671060911e+01 -1.6263150018929764e+01
|
||||
-1.6318798603984646e+01 -1.6374520512410413e+01 -1.6430315828395351e+01 -1.6486184634163351e+01 -1.6542127009998921e+01
|
||||
-1.6598143034272539e+01 -1.6654232783472025e+01 -1.6710396332224377e+01 -1.6766633753325436e+01 -1.6822945117765585e+01
|
||||
-1.6879330494748046e+01 -1.6935789951724587e+01 -1.6992323554410177e+01 -1.7048931366811757e+01 -1.7105613451248814e+01
|
||||
-1.7162369868381802e+01 -1.7219200677228514e+01 -1.7276105935188525e+01 -1.7333085698066157e+01 -1.7390140020095373e+01
|
||||
-1.7447268953950697e+01 -1.7504472550780861e+01 -1.7561750860218694e+01 -1.7619103930409892e+01 -1.7676531808023810e+01
|
||||
-1.7734034538283254e+01 -1.7791612164975845e+01 -1.7849264730476307e+01 -1.7906992275765219e+01 -1.7964794840444824e+01
|
||||
-1.8022672462761875e+01 -1.8080625179621734e+01 -1.8138653026605425e+01 -1.8196756037990440e+01 -1.8254934246764151e+01
|
||||
-1.8313187684642116e+01 -1.8371516382082859e+01 -1.8429920368310263e+01 -1.8488399671318348e+01 -1.8546954317899235e+01
|
||||
-1.8605584333649176e+01 -1.8664289742987989e+01 -1.8723070569174411e+01 -1.8781926834319393e+01 -1.8840858559402477e+01
|
||||
-1.8899865764282822e+01 -1.8958948467713867e+01 -1.9018106687365503e+01 -1.9077340439822024e+01 -1.9136649740611233e+01
|
||||
-1.9196034604209103e+01 -1.9255495044051372e+01 -1.9315031072554348e+01 -1.9374642701124799e+01 -1.9434329940162570e+01
|
||||
-1.9494092799088207e+01 -1.9553931286346369e+01 -1.9613845409416626e+01 -1.9673835174834608e+01 -1.9733900588187907e+01
|
||||
-1.9794041654145190e+01 -1.9854258376453799e+01 -1.9914550757959887e+01 -1.9974918800611590e+01 -2.0035362505476201e+01
|
||||
-2.0095881872749146e+01 -2.0156476901763995e+01 -2.0217147590998366e+01 -2.0277893938093484e+01 -2.0338715939858389e+01
|
||||
-2.0399613592277888e+01 -2.0460586890529044e+01 -2.0521635828982994e+01 -2.0582760401222004e+01 -2.0643960600042533e+01
|
||||
-2.0705236417468427e+01 -2.0766587844759101e+01 -2.0828014872417498e+01 -2.0889517490199864e+01 -2.0951095687123598e+01
|
||||
-2.1012749451479294e+01 -2.1074478770834048e+01 -2.1136283632044297e+01 -2.1198164021260027e+01 -2.1260119923935804e+01
|
||||
-2.1322151324842025e+01 -2.1384258208059805e+01 -2.1446440557008827e+01 -2.1508698354438025e+01 -2.1571031582440582e+01
|
||||
-2.1633440222459740e+01 -2.1695924255298678e+01 -2.1758483661130299e+01 -2.1821118419499157e+01 -2.1883828509315435e+01
|
||||
-2.1946613908883251e+01 -2.2009474595907591e+01 -2.2072410547490904e+01 -2.2135421740141624e+01 -2.2198508149625354e+01
|
||||
-2.2261669751600152e+01 -2.2324906520680884e+01 -2.2388218431072119e+01 -2.2451605456420339e+01 -2.2515067569818370e+01
|
||||
-2.2578604743809933e+01 -2.2642216950395323e+01 -2.2705904161046874e+01 -2.2769666346698159e+01 -2.2833503477769341e+01
|
||||
-2.2897415524152620e+01 -2.2961402455235202e+01 -2.3025464239895996e+01 -2.3089600846513576e+01 -2.3153812242971071e+01
|
||||
-2.3218098396659570e+01 -2.3282459274490293e+01 -2.3346894842892652e+01 -2.3411405067819828e+01 -2.3475989914765478e+01
|
||||
-2.3540649348746115e+01 -2.3605383334332714e+01 -2.3670191835634910e+01 -2.3735074816317024e+01 -2.3800032239597726e+01
|
||||
-2.3865064068258562e+01 -2.3930170264648723e+01 -2.3995350790681982e+01 -2.4060605607854882e+01 -2.4125934677236842e+01
|
||||
-2.4191337959488578e+01 -2.4256815414853463e+01 -2.4322367003169916e+01 -2.4387992683878451e+01 -2.4453692416015087e+01
|
||||
-2.4519466158226919e+01 -2.4585313868769163e+01 -2.4651235505509703e+01 -2.4717231025938531e+01 -2.4783300387171153e+01
|
||||
-2.4849443545942677e+01 -2.4915660458622597e+01 -2.4981951081215925e+01 -2.5048315369364445e+01 -2.5114753278356716e+01
|
||||
-2.5181264763122385e+01 -2.5247849778241061e+01 -2.5314508277950381e+01 -2.5381240216142828e+01 -2.5448045546370622e+01
|
||||
-2.5514924221854017e+01 -2.5581876195479936e+01 -2.5648901419802769e+01 -2.5715999847061425e+01 -2.5783171429163417e+01
|
||||
-2.5850416117703276e+01 -2.5917733863959484e+01 -2.5985124618898908e+01 -2.6052588333183735e+01 -2.6120124957166922e+01
|
||||
-2.6187734440899703e+01 -2.6255416734137384e+01 -2.6323171786339913e+01 -2.6390999546672560e+01 -2.6458899964009333e+01
|
||||
-2.6526872986945250e+01 -2.6594918563787246e+01 -2.6663036642560087e+01 -2.6731227171017508e+01 -2.6799490096630279e+01
|
||||
-2.6867825366607576e+01 -2.6936232927879701e+01 -2.7004712727119340e+01 -2.7073264710729632e+01 -2.7141888824860530e+01
|
||||
-2.7210585015393917e+01 -2.7279353227967249e+01 -2.7348193407960821e+01 -2.7417105500503567e+01 -2.7486089450479881e+01
|
||||
-2.7555145202530412e+01 -2.7624272701049790e+01 -2.7693471890195497e+01 -2.7762742713890816e+01 -2.7832085115820746e+01
|
||||
-2.7901499039439045e+01 -2.7970984427971530e+01 -2.8040541224415165e+01 -2.8110169371542838e+01 -2.8179868811902452e+01
|
||||
-2.8249639487825789e+01 -2.8319481341422943e+01 -2.8389394314591641e+01 -2.8459378349013832e+01 -2.8529433386177288e+01
|
||||
-2.8599559367335587e+01 -2.8669756233536873e+01 -2.8740023925633068e+01 -2.8810362384271002e+01 -2.8880771549902647e+01
|
||||
-2.8951251362561607e+01 -2.9021801762731002e+01 -2.9092422690058129e+01 -2.9163114084212566e+01 -2.9233875884670852e+01
|
||||
-2.9304708030721031e+01 -2.9375610461472206e+01 -2.9446583115842486e+01 -2.9517625932568308e+01 -2.9588738850209438e+01
|
||||
-2.9659921807143974e+01 -2.9731174741575614e+01 -2.9802497591530710e+01 -2.9873890294866897e+01 -2.9945352789269464e+01
|
||||
-3.0016885012252033e+01 -3.0088486901162696e+01 -3.0160158393185156e+01 -3.0231899425338497e+01 -3.0303709934482413e+01
|
||||
-3.0375589857305158e+01 -3.0447539130352652e+01 -3.0519557690005286e+01 -3.0591645472488608e+01 -3.0663802413871281e+01
|
||||
-3.0736028450080539e+01 -3.0808323516880364e+01 -3.0880687549896038e+01 -3.0953120484603915e+01 -3.1025622256328688e+01
|
||||
1.0000000000000000e+01 9.8993242032246371e+00 9.8057191085309796e+00 9.7122900702135553e+00 9.6190607944140538e+00
|
||||
9.5260540818798063e+00 9.4332918527874199e+00 9.3407951709670556e+00 9.2485842675412187e+00 9.1566785639921022e+00
|
||||
9.0650966946685685e+00 8.9738565287487972e+00 8.8829751916672990e+00 8.7924690860197643e+00 8.7023539119586530e+00
|
||||
8.6126446870900395e+00 8.5233557658822292e+00 8.4345008585987102e+00 8.3460930497666368e+00 8.2581448161884055e+00
|
||||
8.1706680445109328e+00 8.0836740483591711e+00 7.9971735850459709e+00 7.9111768718671556e+00 7.8256936019907357e+00
|
||||
7.7407329599515151e+00 7.6563036367581105e+00 7.5724138446213090e+00 7.4890713313149035e+00 7.4062833941746078e+00
|
||||
7.3240568937442561e+00 7.2423982670791531e+00 7.1613135407112622e+00 7.0808083432878277e+00 7.0008879178868995e+00
|
||||
6.9215571340211000e+00 6.8428204993344366e+00 6.7646821709996345e+00 6.6871459668244597e+00 6.6102153760714941e+00
|
||||
6.5338935699995488e+00 6.4581834121337636e+00 6.3830874682686840e+00 6.3086080162124460e+00 6.2347470552773245e+00
|
||||
6.1615063155225300e+00 6.0888872667561031e+00 6.0168911272995160e+00 5.9455188725228254e+00 5.8747712431541856e+00
|
||||
5.8046487533705715e+00 5.7351516986726381e+00 5.6662801635515905e+00 5.5980340289504795e+00 5.5304129795266590e+00
|
||||
5.4634165107192416e+00 5.3970439356263000e+00 5.3312943916964741e+00 5.2661668472395320e+00 5.2016601077597215e+00
|
||||
5.1377728221172276e+00 5.0745034885205484e+00 5.0118504603546512e+00 4.9498119518489432e+00 4.8883860435884969e+00
|
||||
4.8275706878724520e+00 4.7673637139236007e+00 4.7077628329525680e+00 4.6487656430795710e+00 4.5903696341183604e+00
|
||||
4.5325721922252171e+00 4.4753706044153034e+00 4.4187620629512878e+00 4.3627436696064308e+00 4.3073124398053722e+00
|
||||
4.2524653066454619e+00 4.1981991248019028e+00 4.1445106743194629e+00 4.0913966642936259e+00 4.0388537364436559e+00
|
||||
3.9868784685803007e+00 3.9354673779716904e+00 3.8846169246080535e+00 3.8343235143699275e+00 3.7845835021006451e+00
|
||||
3.7353931945865924e+00 3.6867488534464030e+00 3.6386466979333392e+00 3.5910829076501329e+00 3.5440536251817321e+00
|
||||
3.4975549586455656e+00 3.4515829841626982e+00 3.4061337482512926e+00 3.3612032701449550e+00 3.3167875440371120e+00
|
||||
3.2728825412544325e+00 3.2294842123596226e+00 3.1865884891868035e+00 3.1441912868105533e+00 3.1022885054503888e+00
|
||||
3.0608760323122084e+00 3.0199497433692102e+00 2.9795055050822441e+00 2.9395391760631071e+00 2.9000466086804977e+00
|
||||
2.8610236506118696e+00 2.8224661463407159e+00 2.7843699386024952e+00 2.7467308697794124e+00 2.7095447832462014e+00
|
||||
2.6728075246672347e+00 2.6365149432474198e+00 2.6006628929371232e+00 2.5652472335932828e+00 2.5302638320970061e+00
|
||||
2.4957085634295453e+00 2.4615773117070177e+00 2.4278659711761890e+00 2.3945704471710769e+00 2.3616866570323651e+00
|
||||
2.3292105309901103e+00 2.2971380130111925e+00 2.2654650616121756e+00 2.2341876506386598e+00 2.2033017700121320e+00
|
||||
2.1728034264450997e+00 2.1426886441253288e+00 2.1129534653705520e+00 2.0835939512536754e+00 2.0546061822001747e+00
|
||||
2.0259862585579214e+00 1.9977303011403791e+00 1.9698344517436936e+00 1.9422948736395682e+00 1.9151077520426867e+00
|
||||
1.8882692945553075e+00 1.8617757315883168e+00 1.8356233167606177e+00 1.8098083272764001e+00 1.7843270642818041e+00
|
||||
1.7591758532008299e+00 1.7343510440521328e+00 1.7098490117462504e+00 1.6856661563643627e+00 1.6617989034191183e+00
|
||||
1.6382437040983007e+00 1.6149970354911076e+00 1.5920554007986354e+00 1.5694153295280060e+00 1.5470733776717225e+00
|
||||
1.5250261278715769e+00 1.5032701895688163e+00 1.4818021991397359e+00 1.4606188200184036e+00 1.4397167428059703e+00
|
||||
1.4190926853676089e+00 1.3987433929171260e+00 1.3786656380898776e+00 1.3588562210043307e+00 1.3393119693125612e+00
|
||||
1.3200297382401516e+00 1.3010064106158339e+00 1.2822388968913216e+00 1.2637241351513353e+00 1.2454590911147605e+00
|
||||
1.2274407581266260e+00 1.2096661571415410e+00 1.1921323366990961e+00 1.1748363728909510e+00 1.1577753693205821e+00
|
||||
1.1409464570554135e+00 1.1243467945718493e+00 1.1079735676937119e+00 1.0918239895238244e+00 1.0758953003693179e+00
|
||||
1.0601847676609850e+00 1.0446896858667927e+00 1.0294073763996394e+00 1.0143351875199400e+00 9.9947049423283119e-01
|
||||
9.8481069818076961e-01 9.7035322753107422e-01 9.5609553685923743e-01 9.4203510702756788e-01 9.2816944506015275e-01
|
||||
9.1449608401352123e-01 9.0101258284363794e-01 8.8771652626940778e-01 8.7460552463267049e-01 8.6167721375499085e-01
|
||||
8.4892925479136494e-01 8.3635933408090324e-01 8.2396516299494493e-01 8.1174447778230174e-01 7.9969503941215692e-01
|
||||
7.8781463341458746e-01 7.7610106971892279e-01 7.6455218248987933e-01 7.5316582996180870e-01 7.4193989427123341e-01
|
||||
7.3087228128747483e-01 7.1996092044178539e-01 7.0920376455494605e-01 6.9859878966352440e-01 6.8814399484488220e-01
|
||||
6.7783740204091103e-01 6.6767705588071991e-01 6.5766102350242051e-01 6.4778739437393895e-01 6.3805428011308152e-01
|
||||
6.2845981430683651e-01 6.1900215233006151e-01 6.0967947116362708e-01 6.0048996921213060e-01 5.9143186612108778e-01
|
||||
5.8250340259395017e-01 5.7370284020878159e-01 5.6502846123474981e-01 5.5647856844851162e-01 5.4805148495055178e-01
|
||||
5.3974555398145085e-01 5.3155913873843019e-01 5.2349062219165532e-01 5.1553840690106156e-01 5.0770091483322233e-01
|
||||
4.9997658717849447e-01 4.9236388416861310e-01 4.8486128489444091e-01 4.7746728712437303e-01 4.7018040712309350e-01
|
||||
4.6299917947073332e-01 4.5592215688277093e-01 4.4894791003037327e-01 4.4207502736140292e-01 4.3530211492211102e-01
|
||||
4.2862779617936830e-01 4.2205071184386433e-01 4.1556951969380762e-01 4.0918289439959388e-01 4.0288952734917061e-01
|
||||
3.9668812647427920e-01 3.9057741607756924e-01 3.8455613666061161e-01 3.7862304475270037e-01 3.7277691274081626e-01
|
||||
3.6701652870034884e-01 3.6134069622685772e-01 3.5574823426883739e-01 3.5023797696151959e-01 3.4480877346164718e-01
|
||||
3.3945948778332813e-01 3.3418899863496421e-01 3.2899619925721169e-01 3.2387999726210026e-01 3.1883931447318403e-01
|
||||
3.1387308676685954e-01 3.0898026391477451e-01 3.0415980942741427e-01 2.9941070039879136e-01 2.9473192735234299e-01
|
||||
2.9012249408790858e-01 2.8558141753001287e-01 2.8110772757715452e-01 2.7670046695245354e-01 2.7235869105539834e-01
|
||||
2.6808146781476161e-01 2.6386787754278096e-01 2.5971701279057946e-01 2.5562797820463778e-01 2.5159989038467856e-01
|
||||
2.4763187774259166e-01 2.4372308036269530e-01 2.3987264986319179e-01 2.3607974925875652e-01 2.3234355282446906e-01
|
||||
2.2866324596092369e-01 2.2503802506048665e-01 2.2146709737491133e-01 2.1794968088402022e-01 2.1448500416573690e-01
|
||||
2.1107230626729301e-01 2.0771083657756151e-01 2.0439985470075150e-01 2.0113863033121149e-01 1.9792644312946006e-01
|
||||
1.9476258259946633e-01 1.9164634796702718e-01 1.8857704805947506e-01 1.8555400118649334e-01 1.8257653502209870e-01
|
||||
1.7964398648790514e-01 1.7675570163748855e-01 1.7391103554195020e-01 1.7110935217664736e-01 1.6835002430910073e-01
|
||||
1.6563243338803524e-01 1.6295596943364199e-01 1.6032003092885994e-01 1.5772402471195601e-01 1.5516736587011604e-01
|
||||
1.5264947763423642e-01 1.5016979127480834e-01 1.4772774599894145e-01 1.4532278884846228e-01 1.4295437459917348e-01
|
||||
1.4062196566113006e-01 1.3832503198009682e-01 1.3606305094001581e-01 1.3383550726658733e-01 1.3164189293190898e-01
|
||||
1.2948170706017503e-01 1.2735445583442129e-01 1.2525965240434545e-01 1.2319681679512406e-01 1.2116547581730508e-01
|
||||
1.1916516297767910e-01 1.1719541839120495e-01 1.1525578869391095e-01 1.1334582695682949e-01 1.1146509260089488e-01
|
||||
1.0961315131283333e-01 1.0778957496203434e-01 1.0599394151839725e-01 1.0422583497111182e-01 1.0248484524841883e-01
|
||||
1.0077056813830154e-01 9.9082605210113250e-02 9.7420563737128152e-02 9.5784056620032310e-02 9.4172702311299705e-02
|
||||
9.2586124740488884e-02 9.1023953240430000e-02 8.9485822474299592e-02 8.7971372363576883e-02 8.6480248016858940e-02
|
||||
8.5012099659556473e-02 8.3566582564446712e-02 8.2143356983039428e-02 8.0742088077824459e-02 7.9362445855320374e-02
|
||||
7.8004105099968690e-02 7.6666745308809237e-02 7.5350050627007725e-02 7.4053709784148491e-02 7.2777416031309272e-02
|
||||
7.1520867078974870e-02 7.0283765035655144e-02 6.9065816347314346e-02 6.7866731737558084e-02 6.6686226148542804e-02
|
||||
6.5524018682673990e-02 6.4379832544994464e-02 6.3253394986330314e-02 6.2144437247152684e-02 6.1052694502150562e-02
|
||||
5.9977905805502552e-02 5.8919814036857865e-02 5.7878165848002538e-02 5.6852711610213102e-02 5.5843205362281267e-02
|
||||
5.4849404759204079e-02 5.3871071021555084e-02 5.2907968885476775e-02 5.1959866553358269e-02 5.1026535645117388e-02
|
||||
5.0107751150135327e-02 4.9203291379825043e-02 4.8312937920789834e-02 4.7436475588615856e-02 4.6573692382274823e-02
|
||||
4.5724379439095575e-02 4.4888330990358272e-02 4.4065344317457900e-02 4.3255219708641324e-02 4.2457760416331647e-02
|
||||
4.1672772615001907e-02 4.0900065359606330e-02 4.0139450544587119e-02 3.9390742863385508e-02 3.8653759768535023e-02
|
||||
3.7928321432253886e-02 3.7214250707576557e-02 3.6511373090018173e-02 3.5819516679722607e-02 3.5138512144143652e-02
|
||||
3.4468192681223808e-02 3.3808393983053797e-02 3.3158954200040336e-02 3.2519713905552639e-02 3.1890516061029439e-02
|
||||
3.1271205981592498e-02 3.0661631302092207e-02 3.0061641943631479e-02 2.9471090080552376e-02 2.8889830107845960e-02
|
||||
2.8317718609035092e-02 2.7754614324478899e-02 2.7200378120111335e-02 2.6654872956618725e-02 2.6117963859025206e-02
|
||||
2.5589517886701607e-02 2.5069404103800874e-02 2.4557493550066090e-02 2.4053659212077361e-02 2.3557775994875407e-02
|
||||
2.3069720693975837e-02 2.2589371967784877e-02 2.2116610310377816e-02 2.1651318024671573e-02 2.1193379195963979e-02
|
||||
2.0742679665830766e-02 2.0299107006404360e-02 1.9862550494997966e-02 1.9432901089081245e-02 1.9010051401619821e-02
|
||||
1.8593895676740635e-02 1.8184329765760343e-02 1.7781251103520468e-02 1.7384558685080709e-02 1.6994153042732330e-02
|
||||
1.6609936223318855e-02 1.6231811765900273e-02 1.5859684679716324e-02 1.5493461422459553e-02 1.5133049878863769e-02
|
||||
1.4778359339593705e-02 1.4429300480422236e-02 1.4085785341715229e-02 1.3747727308204616e-02 1.3415041089038238e-02
|
||||
1.3087642698128565e-02 1.2765449434765652e-02 1.2448379864521963e-02 1.2136353800409783e-02 1.1829292284323834e-02
|
||||
1.1527117568744027e-02 1.1229753098690343e-02 1.0937123493950818e-02 1.0649154531552685e-02 1.0365773128486300e-02
|
||||
1.0086907324682204e-02 9.8124862662264389e-03 9.5424401888180022e-03 9.2767004014673304e-03 9.0151992704248229e-03
|
||||
8.7578702033437317e-03 8.5046476336718135e-03 8.2554670052626400e-03 8.0102647572203867e-03 7.7689783089454623e-03
|
||||
7.5315460454166705e-03 7.2979073026746000e-03 7.0680023535117376e-03 6.8417723933825170e-03 6.6191595265108760e-03
|
||||
6.4001067521917143e-03 6.1845579513078452e-03 5.9724578730325772e-03 5.7637521217223098e-03 5.5583871440119115e-03
|
||||
5.3563102160883447e-03 5.1574694311534164e-03 4.9618136870692719e-03 4.7692926741860209e-03 4.5798568633435566e-03
|
||||
4.3934574940516224e-03 4.2100465628429617e-03 4.0295768117985520e-03 3.8520017172329890e-03 3.6772754785580619e-03
|
||||
3.5053530073032024e-03 3.3361899162928088e-03 3.1697425089940445e-03 3.0059677690114639e-03 2.8448233497412878e-03
|
||||
2.6862675641767808e-03 2.5302593748634528e-03 2.3767583840036965e-03 2.2257248237074201e-03 2.0771195463848979e-03
|
||||
1.9309040152846180e-03 1.7870402951681297e-03 1.6454910431250580e-03 1.5062194995254519e-03 1.3691894790999193e-03
|
||||
1.2343653621603723e-03 1.1017120859476148e-03 9.7119513610272046e-04 8.4278053827493982e-04 7.1643484984554306e-04
|
||||
5.9212515177992087e-04 4.6981904059889557e-04 3.4948462047074136e-04 2.3109049541980564e-04 1.1460576165300829e-04
|
||||
0. 0. 0. 0. 0.
|
||||
0. 5.9010126319814817e-05 9.5123001765930887e-04 4.3610102840051235e-03 1.2418760266605156e-02
|
||||
2.7296776919998988e-02 5.0949808246058437e-02 8.4958617911537360e-02 1.3044948432187731e-01 1.8806835258921506e-01
|
||||
2.5799305640066805e-01 3.3997082530515677e-01 4.3337134797535981e-01 5.3724810475810614e-01 6.5040262300578888e-01
|
||||
7.7144783782308224e-01 8.9886793518261499e-01 1.0310729771528742e+00 1.1664473126750252e+00 1.3033913052230872e+00
|
||||
1.4403562964417773e+00 1.5758730017291569e+00 1.7085737236354248e+00 1.8372088913430460e+00 1.9606585051503700e+00
|
||||
2.0779390964991507e+00 2.1882068168517321e+00 2.2907572507149467e+00 2.3850225157235485e+00 2.4705661709060394e+00
|
||||
2.5470764069287242e+00 2.6143579421585343e+00 2.6723229980107988e+00 2.7209816778323130e+00 2.7604320266538878e+00
|
||||
2.7908500052743079e+00 2.8124795717793063e+00 2.8256230270044398e+00 2.8306317476844498e+00 2.8278974020662275e+00
|
||||
2.8178437174311881e+00 2.8009188471197035e+00 2.7775883659789145e+00 2.7483289074652220e+00 2.7136224425962325e+00
|
||||
2.6739511903254396e+00 2.6297931404181583e+00 2.5816181632919921e+00 2.5298846763057838e+00 2.4750368324058769e+00
|
||||
2.4175021946711297e+00 2.3576898589451218e+00 2.2959889862334961e+00 2.2327677067340232e+00 2.1683723581147518e+00
|
||||
2.1031270218484224e+00 2.0373333229482995e+00 1.9712704602410369e+00 1.9051954362820354e+00 1.8393434581054251e+00
|
||||
1.7739284821481149e+00 1.7091438788567075e+00 1.6451631946320333e+00 1.5821409908724249e+00 1.5202137419055788e+00
|
||||
1.4595007755506515e+00 1.4001052418942663e+00 1.3421150976051877e+00 1.2856040947366125e+00 1.2306327644709114e+00
|
||||
1.1772493876521040e+00 1.1254909452253727e+00 1.0753840428599872e+00 1.0269458050837557e+00 9.8018473519940130e-01
|
||||
9.3510153809833696e-01 8.9168990383690883e-01 8.4993725050077984e-01 8.0982542546483316e-01 7.7133136465729990e-01
|
||||
7.3442770987267991e-01 6.9908338454677477e-01 6.6526412872113738e-01 6.3293299418218751e-01 6.0205080097434305e-01
|
||||
5.7257655665637230e-01 5.4446783980309021e-01 5.1768114935412513e-01 4.9217222148221218e-01 4.6789631569801671e-01
|
||||
4.4480847193145756e-01 4.2286374033358065e-01 4.0201738552994115e-01 3.8222506703151460e-01 3.6344299747029751e-01
|
||||
3.4562808028171510e-01 3.2873802840042821e-01 3.1273146547670727e-01 2.9756801105628305e-01 2.8320835109841447e-01
|
||||
2.6961429513751689e-01 2.5674882132317656e-01 2.4457611050121031e-01 2.3306157042885722e-01 2.2217185114615656e-01
|
||||
2.1187485245800097e-01 2.0213972441401395e-01 1.9293686160916401e-01 1.8423789206599128e-01 1.7601566139938463e-01
|
||||
1.6824421290823288e-01 1.6089876418413329e-01 1.5395568077589861e-01 1.4739244740058677e-01 1.4118763714583071e-01
|
||||
1.3532087906606094e-01 1.2977282453457750e-01 1.2452511267704969e-01 1.1956033517667564e-01 1.1486200070957642e-01
|
||||
1.1041449923916735e-01 1.0620306637086507e-01 1.0221374794353455e-01 9.8433365010703433e-02 9.4849479343793064e-02
|
||||
9.1450359570144357e-02 8.8224948041312423e-02 8.5162828511148092e-02 8.2254194688911930e-02 7.9489819719782862e-02
|
||||
7.6861026633556762e-02 7.4359659791945365e-02 7.1978057355755354e-02 6.9709024785019391e-02 6.7545809377936639e-02
|
||||
6.5482075848213306e-02 6.3511882934839115e-02 6.1629661033566707e-02 5.9830190835290065e-02 5.8108582952962173e-02
|
||||
5.6460258515815376e-02 5.4880930707118747e-02 5.3366587219797479e-02 5.1913473602555715e-02 5.0518077467937905e-02
|
||||
4.9177113532858696e-02 4.7887509461463251e-02 4.6646392479786414e-02 4.5451076731534812e-02 4.4299051344329321e-02
|
||||
4.3187969175906726e-02 4.2115636210163343e-02 4.1080001573322589e-02 4.0079148141122012e-02 3.9111283708509692e-02
|
||||
3.8174732694119751e-02 3.7267928352499924e-02 3.6389405467974978e-02 3.5537793504821114e-02 3.4711810189337999e-02
|
||||
3.3910255500315678e-02 3.3132006045311968e-02 3.2376009801025063e-02 3.1641281197056115e-02 3.0926896523147174e-02
|
||||
3.0231989640976842e-02 2.9555747982425329e-02 2.8897408817098458e-02 2.8256255772741601e-02 2.7631615592998982e-02
|
||||
2.7022855117770250e-02 2.6429378472184961e-02 2.5850624450970416e-02 2.5286064085690785e-02 2.4735198383046275e-02
|
||||
2.4197556223065408e-02 2.3672692406680351e-02 2.3160185842761583e-02 2.2659637865279025e-02 2.2170670671835202e-02
|
||||
2.1692925875283153e-02 2.1226063160710629e-02 2.0769759040521030e-02 2.0323705700767247e-02 1.9887609932384143e-02
|
||||
1.9461192141316586e-02 1.9044185431947969e-02 1.8636334758602713e-02 1.8237396140230899e-02 1.7847135933689695e-02
|
||||
1.7465330161385073e-02 1.7091763889272138e-02 1.6726230651524898e-02 1.6368531918402485e-02 1.6018476604117482e-02
|
||||
1.5675880611694337e-02 1.5340566412041456e-02 1.5012362654659439e-02 1.4691103807558503e-02 1.4376629824175480e-02
|
||||
1.4068785835212261e-02 1.3767421863463636e-02 1.3472392559873647e-02 1.3183556959150522e-02 1.2900778253428224e-02
|
||||
1.2623923582545604e-02 1.2352863839649619e-02 1.2087473490903944e-02 1.1827630408180745e-02 1.1573215713719498e-02
|
||||
1.1324113635776012e-02 1.1080211374406845e-02 1.0841398976555172e-02 1.0607569219707735e-02 1.0378617503423171e-02
|
||||
1.0154441748097653e-02 9.9349423003910475e-03 9.7200218447674458e-03 9.5095853206588199e-03 9.3035398448000906e-03
|
||||
9.1017946383145087e-03 8.9042609581665988e-03 8.7108520326330541e-03 8.5214830004667341e-03 8.3360708534563344e-03
|
||||
8.1545343821158855e-03 7.9767941242498419e-03 7.8027723161667450e-03 7.6323928463390700e-03 7.4655812113108566e-03
|
||||
7.3022644736793763e-03 7.1423712220031466e-03 6.9858315324717313e-03 6.8325769322190866e-03 6.6825403641552206e-03
|
||||
6.5356561531992319e-03 6.3918599738218562e-03 6.2510888187975733e-03 6.1132809690869205e-03 5.9783759647687174e-03
|
||||
5.8463145769541147e-03 5.7170387806181611e-03 5.5904917282912081e-03 5.4666177245562830e-03 5.3453622013025781e-03
|
||||
5.2266716936939239e-03 5.1104938168121949e-03 4.9967772429345414e-03 4.8854716794144715e-03 4.7765278471371131e-03
|
||||
4.6698974595187626e-03 4.5655332020223260e-03 4.4633887121737770e-03 4.3634185600484876e-03 4.2655782292140842e-03
|
||||
4.1698240981107859e-03 4.0761134218494921e-03 3.9844043144161567e-03 3.8946557312677932e-03 3.8068274523043177e-03
|
||||
3.7208800652058643e-03 3.6367749491276330e-03 3.5544742587341888e-03 3.4739409085721706e-03 3.3951385577662696e-03
|
||||
3.3180315950305517e-03 3.2425851239922809e-03 3.1687649488125469e-03 3.0965375601038209e-03 3.0258701211323263e-03
|
||||
2.9567304543036133e-03 2.8890870279202896e-03 2.8229089432085241e-03 2.7581659216093096e-03 2.6948282923243694e-03
|
||||
2.6328669801167909e-03 2.5722534933561303e-03 2.5129599123076413e-03 2.4549588776574399e-03 2.3982235792709000e-03
|
||||
2.3427277451791295e-03 2.2884456307876860e-03 2.2353520083073786e-03 2.1834221563960809e-03 2.1326318500153457e-03
|
||||
2.0829573504910909e-03 2.0343753957773325e-03 1.9868631909199103e-03 1.9403983987140230e-03 1.8949591305523622e-03
|
||||
1.8505239374625310e-03 1.8070718013256451e-03 1.7645821262764899e-03 1.7230347302798696e-03 1.6824098368790896e-03
|
||||
1.6426880671145255e-03 1.6038504316082877e-03 1.5658783228106390e-03 1.5287535074066244e-03 1.4924581188781386e-03
|
||||
1.4569746502193157e-03 1.4222859468012855e-03 1.3883751993830559e-03 1.3552259372668837e-03 1.3228220215934505e-03
|
||||
1.2911476387746715e-03 1.2601872940613337e-03 1.2299258052420187e-03 1.2003482964717746e-03 1.1714401922264736e-03
|
||||
1.1431872113803060e-03 1.1155753614053091e-03 1.0885909326878856e-03 1.0622204929616186e-03 1.0364508818534041e-03
|
||||
1.0112692055400316e-03 9.8666283151283701e-04 9.6261938344921819e-04 9.3912673618656156e-04 9.1617301079857313e-04
|
||||
8.9374656977029426e-04 8.7183601227025162e-04 8.5043016951734385e-04 8.2951810024052205e-04 8.0908908622959533e-04
|
||||
7.8913262797420530e-04 7.6963844039006427e-04 7.5059644863021552e-04 7.3199678397861331e-04 7.1382977982614032e-04
|
||||
6.9608596772510398e-04 6.7875607352167050e-04 6.6183101356499102e-04 6.4530189098998408e-04 6.2915999207315693e-04
|
||||
6.1339678265999453e-04 5.9800390466146700e-04 5.8297317261902029e-04 5.6829657033648229e-04 5.5396624757679883e-04
|
||||
5.3997451682300662e-04 5.2631385010162846e-04 5.1297687586741511e-04 4.9995637594766468e-04 4.8724528254567509e-04
|
||||
4.7483667530116673e-04 4.6272377840723272e-04 4.5089995778220364e-04 4.3935871829548813e-04 4.2809370104602770e-04
|
||||
4.1709868069276027e-04 4.0636756283551206e-04 3.9589438144539517e-04 3.8567329634417967e-04 3.7569859073094576e-04
|
||||
3.6596466875535652e-04 3.5646605313704831e-04 3.4719738282937979e-04 3.3815341072727413e-04 3.2932900141820903e-04
|
||||
3.2071912897517658e-04 3.1231887479109613e-04 3.0412342545394974e-04 2.9612807066136011e-04 2.8832820117438013e-04
|
||||
2.8071930680946024e-04 2.7329697446802463e-04 2.6605688620252518e-04 2.5899481731896101e-04 2.5210663451460773e-04
|
||||
2.4538829405039951e-04 2.3883583995754076e-04 2.3244540227755281e-04 2.2621319533494815e-04 2.2013551604236053e-04
|
||||
2.1420874223712898e-04 2.0842933104886149e-04 2.0279381729763207e-04 1.9729881192189717e-04 1.9194100043584596e-04
|
||||
1.8671714141556012e-04 1.8162406501339226e-04 1.7665867150027260e-04 1.7181792983513803e-04 1.6709887626118174e-04
|
||||
1.6249861292849666e-04 1.5801430654247602e-04 1.5364318703756877e-04 1.4938254627607905e-04 1.4522973677123623e-04
|
||||
1.4118217043452164e-04 1.3723731734648428e-04 1.3339270455082000e-04 1.2964591487125629e-04 1.2599458575065798e-04
|
||||
1.2243640811247618e-04 1.1896912524339207e-04 1.1559053169753544e-04 1.1229847222142672e-04 1.0909084069933963e-04
|
||||
1.0596557911894027e-04 1.0292067655662610e-04 9.9954168182353649e-05 9.7064134283507061e-05 9.4248699307630801e-05
|
||||
9.1506030923423857e-05 8.8834339100102040e-05 8.6231875204344742e-05 8.3696931114819219e-05 8.1227838353902480e-05
|
||||
7.8822967236273373e-05 7.6480726034077341e-05 7.4199560158407993e-05 7.1977951356812751e-05 6.9814416926499475e-05
|
||||
6.7707508943029831e-05 6.5655813504213612e-05 6.3657949988866168e-05 6.1712570330282358e-05 5.9818358304071853e-05
|
||||
5.7974028830165385e-05 5.6178327288702694e-05 5.4430028849589227e-05 5.2727937815392426e-05 5.1070886977526431e-05
|
||||
4.9457736985278073e-05 4.7887375727560756e-05 4.6358717727160289e-05 4.4870703547245875e-05 4.3422299209859138e-05
|
||||
4.2012495626317673e-05 4.0640308039126966e-05 3.9304775475375526e-05 3.8004960211247439e-05 3.6739947247565801e-05
|
||||
3.5508843796142400e-05 3.4310778776663886e-05 3.3144902324029873e-05 3.2010385305857383e-05 3.0906418850064473e-05
|
||||
2.9832213882209505e-05 2.8787000672575664e-05 2.7770028392667219e-05 2.6780564681032955e-05 2.5817895218209702e-05
|
||||
2.4881323310664734e-05 2.3970169483444534e-05 2.3083771081538595e-05 2.2221481879665080e-05 2.1382671700350851e-05
|
||||
2.0566726040181392e-05 1.9773045704053120e-05 1.9001046447230654e-05 1.8250158625112214e-05 1.7519826850580754e-05
|
||||
1.6809509658667816e-05 1.6118679178557115e-05 1.5446820812670342e-05 1.4793432922725696e-05 1.4158026522648345e-05
|
||||
1.3540124978214771e-05 1.2939263713231488e-05 1.2354989922202923e-05 1.1786862289310442e-05 1.1234450713584233e-05
|
||||
1.0697336040167097e-05 1.0175109797512299e-05 9.6673739404608315e-06 9.1737405989803780e-06 8.6938318325755241e-06
|
||||
8.2272793901403372e-06 7.7737244752313066e-06 7.3328175165903700e-06 6.9042179438641416e-06 6.4875939683566573e-06
|
||||
6.0826223687688533e-06 5.6889882817751591e-06 5.3063849973837519e-06 4.9345137589397459e-06 4.5730835677019240e-06
|
||||
4.2218109918944072e-06 3.8804199801278200e-06 3.5486416791253358e-06 3.2262142556238214e-06 2.9128827224128399e-06
|
||||
2.6083987683696969e-06 2.3125205924632631e-06 2.0250127415929456e-06 1.7456459522151562e-06 1.4741969956554718e-06
|
||||
1.2104485270563944e-06 9.5418893783608431e-07 7.0521221163838584e-07 4.6331778365889687e-07 2.2831040328782914e-07
|
||||
0. 0. 0. 0. 0.
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, 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.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
// Pointers class contains ptrs to master copy of
|
||||
// fundamental and top-level LAMMPS class ptrs stored in lammps.h
|
||||
// every LAMMPS class inherits from Pointers to get access to lammps.h ptrs
|
||||
// these variables are auto-initialized by Pointer class constructor
|
||||
// *& variables are really pointers to the pointers in lammps.h
|
||||
// & enables them to be used in any class as error->all()
|
||||
|
||||
#ifndef POINTERS_H
|
||||
#define POINTERS_H
|
||||
|
||||
#include "mpi.h"
|
||||
#include "lammps.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class Pointers {
|
||||
public:
|
||||
Pointers(LAMMPS *ptr) :
|
||||
lmp(ptr),
|
||||
memory(ptr->memory),
|
||||
error(ptr->error),
|
||||
universe(ptr->universe),
|
||||
input(ptr->input),
|
||||
atom(ptr->atom),
|
||||
update(ptr->update),
|
||||
neighbor(ptr->neighbor),
|
||||
comm(ptr->comm),
|
||||
domain(ptr->domain),
|
||||
force(ptr->force),
|
||||
modify(ptr->modify),
|
||||
group(ptr->group),
|
||||
output(ptr->output),
|
||||
timer(ptr->timer),
|
||||
world(ptr->world),
|
||||
infile(ptr->infile),
|
||||
screen(ptr->screen),
|
||||
logfile(ptr->logfile) {}
|
||||
virtual ~Pointers() {}
|
||||
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
Memory *&memory;
|
||||
Error *&error;
|
||||
Universe *&universe;
|
||||
Input *&input;
|
||||
|
||||
Atom *&atom;
|
||||
Update *&update;
|
||||
Neighbor *&neighbor;
|
||||
Comm *&comm;
|
||||
Domain *&domain;
|
||||
Force *&force;
|
||||
Modify *&modify;
|
||||
Group *&group;
|
||||
Output *&output;
|
||||
Timer *&timer;
|
||||
|
||||
MPI_Comm &world;
|
||||
FILE *&infile;
|
||||
FILE *&screen;
|
||||
FILE *&logfile;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue