support for other vector fields in read_data

This commit is contained in:
Steve Plimpton
2023-09-13 09:29:56 -06:00
parent e20e3972d2
commit dec245c67b
16 changed files with 110 additions and 32 deletions

View File

@ -7883,12 +7883,6 @@ keyword to allow for additional bonds to be formed
Fix poems cannot (yet) work with coupled bodies whose joints connect Fix poems cannot (yet) work with coupled bodies whose joints connect
the bodies in a tree structure. the bodies in a tree structure.
*Triclinic box skew is too large*
The displacement in a skewed direction must be less than half the box
length in that dimension. E.g. the xy tilt must be between -half and
+half of the x box length. This constraint can be relaxed by using
the box tilt command.
*Tried to convert a double to int, but input_double > INT_MAX* *Tried to convert a double to int, but input_double > INT_MAX*
Self-explanatory. Self-explanatory.

View File

@ -752,13 +752,6 @@ This will most likely cause errors in kinetic fluctuations.
More than the maximum # of neighbors was found multiple times. This More than the maximum # of neighbors was found multiple times. This
was unexpected. was unexpected.
*Triclinic box skew is large*
The displacement in a skewed direction is normally required to be less
than half the box length in that dimension. E.g. the xy tilt must be
between -half and +half of the x box length. You have relaxed the
constraint using the box tilt command, but the warning means that a
LAMMPS simulation may be inefficient as a result.
*Use special bonds = 0,1,1 with bond style fene* *Use special bonds = 0,1,1 with bond style fene*
Most FENE models need this setting for the special_bonds command. Most FENE models need this setting for the special_bonds command.

View File

@ -15,6 +15,7 @@
#include "atom.h" #include "atom.h"
#include "citeme.h" #include "citeme.h"
#include "domain.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "pair.h" #include "pair.h"
@ -187,6 +188,20 @@ void AtomVecDielectric::data_atom_post(int ilocal)
mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]); mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]);
} }
/* ----------------------------------------------------------------------
convert read_data file info from general to restricted triclinic
parent class operates on data from Velocities section of data file
child class operates on dipole moment mu
------------------------------------------------------------------------- */
void AtomVecDielectric::data_general_to_restricted(int nlocal_previous, int nlocal)
{
AtomVec::data_general_to_restricted(nlocal_previous, nlocal);
for (int i = nlocal_previous; i < nlocal; i++)
domain->general_to_restricted_vector(mu[i]);
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
initialize other atom quantities after AtomVec::unpack_restart() initialize other atom quantities after AtomVec::unpack_restart()
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -35,6 +35,7 @@ class AtomVecDielectric : virtual public AtomVec {
void grow_pointers() override; void grow_pointers() override;
void create_atom_post(int) override; void create_atom_post(int) override;
void data_atom_post(int) override; void data_atom_post(int) override;
void data_general_to_restricted(int, int);
void unpack_restart_init(int) override; void unpack_restart_init(int) override;
int property_atom(const std::string &) override; int property_atom(const std::string &) override;
void pack_property_atom(int, double *, int, int) override; void pack_property_atom(int, double *, int, int) override;

View File

@ -14,6 +14,7 @@
#include "atom_vec_dipole.h" #include "atom_vec_dipole.h"
#include "atom.h" #include "atom.h"
#include "domain.h"
#include <cmath> #include <cmath>
@ -68,3 +69,17 @@ void AtomVecDipole::data_atom_post(int ilocal)
double *mu_one = mu[ilocal]; double *mu_one = mu[ilocal];
mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]); mu_one[3] = sqrt(mu_one[0] * mu_one[0] + mu_one[1] * mu_one[1] + mu_one[2] * mu_one[2]);
} }
/* ----------------------------------------------------------------------
convert read_data file info from general to restricted triclinic
parent class operates on data from Velocities section of data file
child class operates on mu
------------------------------------------------------------------------- */
void AtomVecDipole::data_general_to_restricted(int nlocal_previous, int nlocal)
{
AtomVec::data_general_to_restricted(nlocal_previous, nlocal);
for (int i = nlocal_previous; i < nlocal; i++)
domain->general_to_restricted_vector(mu[i]);
}

View File

@ -30,6 +30,7 @@ class AtomVecDipole : virtual public AtomVec {
void grow_pointers() override; void grow_pointers() override;
void data_atom_post(int) override; void data_atom_post(int) override;
void data_general_to_restricted(int, int);
protected: protected:
double **mu; double **mu;

View File

@ -156,6 +156,13 @@ void AtomVecSMD::create_atom_post(int ilocal)
void AtomVecSMD::data_atom_post(int ilocal) void AtomVecSMD::data_atom_post(int ilocal)
{ {
esph[ilocal] = 0.0; esph[ilocal] = 0.0;
// x and x0 are in Atoms section of data file
// reset x0 b/c x may have been modified in Atom::data_atoms()
// for PBC, shift, etc
// this also means no need for data_general_to_restricted() method
// to rotate x0 for general triclinic
x0[ilocal][0] = x[ilocal][0]; x0[ilocal][0] = x[ilocal][0];
x0[ilocal][1] = x[ilocal][1]; x0[ilocal][1] = x[ilocal][1];
x0[ilocal][2] = x[ilocal][2]; x0[ilocal][2] = x[ilocal][2];

View File

@ -1,5 +1,4 @@
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
LAMMPS development team: developers@lammps.org LAMMPS development team: developers@lammps.org
@ -10,7 +9,6 @@
the GNU General Public License. the GNU General Public License.
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
@ -26,6 +24,7 @@
#include "atom_vec_spin.h" #include "atom_vec_spin.h"
#include "atom.h" #include "atom.h"
#include "domain.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
@ -100,3 +99,17 @@ void AtomVecSpin::data_atom_post(int ilocal)
sp_one[1] *= norm; sp_one[1] *= norm;
sp_one[2] *= norm; sp_one[2] *= norm;
} }
/* ----------------------------------------------------------------------
convert read_data file info from general to restricted triclinic
parent class operates on data from Velocities section of data file
child class operates on spin vector sp
------------------------------------------------------------------------- */
void AtomVecSpin::data_general_to_restricted(int nlocal_previous, int nlocal)
{
AtomVec::data_general_to_restricted(nlocal_previous, nlocal);
for (int i = nlocal_previous; i < nlocal; i++)
domain->general_to_restricted_vector(sp[i]);
}

View File

@ -31,6 +31,7 @@ class AtomVecSpin : virtual public AtomVec {
void grow_pointers() override; void grow_pointers() override;
void force_clear(int, size_t) override; void force_clear(int, size_t) override;
void data_atom_post(int) override; void data_atom_post(int) override;
void data_general_to_restricted(int, int);
protected: protected:
double **sp, **fm, **fm_long; double **sp, **fm, **fm_long;

View File

@ -1039,12 +1039,12 @@ void Atom::deallocate_topology()
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack N lines from Atom section of data file unpack N lines from Atom section of data file
call style-specific routine to parse line call style-specific routine to parse line
triclinic_general = 1 if data file defines a general triclinic box
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset, void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
int type_offset, int triclinic_general, int type_offset, int shiftflag, double *shift,
int shiftflag, double *shift, int labelflag, int *ilabel, int triclinic_general)
int labelflag, int *ilabel)
{ {
int xptr,iptr; int xptr,iptr;
imageint imagedata; imageint imagedata;
@ -1181,8 +1181,8 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
xdata[1] = utils::numeric(FLERR,values[xptr+1],false,lmp); xdata[1] = utils::numeric(FLERR,values[xptr+1],false,lmp);
xdata[2] = utils::numeric(FLERR,values[xptr+2],false,lmp); xdata[2] = utils::numeric(FLERR,values[xptr+2],false,lmp);
// for 2d simulation, check if z coord is within EPS_ZCOORD of zero // for 2d simulation:
// then set to zero // check if z coord is within EPS_ZCOORD of zero and set to zero
if (dimension == 2) { if (dimension == 2) {
if (fabs(xdata[2]) > EPS_ZCOORD) if (fabs(xdata[2]) > EPS_ZCOORD)
@ -1255,8 +1255,8 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack N lines from Velocity section of data file unpack N lines from Velocity section of data file
check that atom IDs are > 0 and <= map_tag_max check that atom IDs are > 0 and <= map_tag_max
call style-specific routine to parse line call style-specific routine to parse line-
------------------------------------------------------------------------- */ ------------------------------------------------------------------------ */
void Atom::data_vels(int n, char *buf, tagint id_offset) void Atom::data_vels(int n, char *buf, tagint id_offset)
{ {

View File

@ -328,8 +328,7 @@ class Atom : protected Pointers {
void deallocate_topology(); void deallocate_topology();
void data_atoms(int, char *, tagint, tagint, int, int, void data_atoms(int, char *, tagint, tagint, int, int, double *, int, int *, int);
int, double *, int, int *);
void data_vels(int, char *, tagint); void data_vels(int, char *, tagint);
void data_bonds(int, char *, int *, tagint, int, int, int *); void data_bonds(int, char *, int *, tagint, int, int, int *);
void data_angles(int, char *, int *, tagint, int, int, int *); void data_angles(int, char *, int *, tagint, int, int, int *);

View File

@ -1656,6 +1656,7 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, const std::vector<std:
{ {
int m, n, datatype, cols; int m, n, datatype, cols;
void *pdata; void *pdata;
double vector[3];
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -1684,7 +1685,7 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, const std::vector<std:
ivalue += cols; ivalue += cols;
continue; continue;
} }
for (m = 0; m < cols; m++) for (m = 0; m < cols; m++) \
array[nlocal][m] = utils::numeric(FLERR, values[ivalue++], true, lmp); array[nlocal][m] = utils::numeric(FLERR, values[ivalue++], true, lmp);
} }
} else if (datatype == Atom::INT) { } else if (datatype == Atom::INT) {
@ -2221,6 +2222,35 @@ void AtomVec::write_improper(FILE *fp, int n, tagint **buf, int index)
} }
} }
/* ----------------------------------------------------------------------
convert read_data file info from general to restricted triclinic
parent class only operates on data from Velocities section of data file
child classes operate on all other data: Atoms, Ellipsoids, Lines, Triangles, etc
------------------------------------------------------------------------- */
void AtomVec::data_general_to_restricted(int nlocal_previous, int nlocal)
{
int datatype, cols;
void *pdata;
for (int n = 1; n < ndata_vel; n++) {
pdata = mdata_vel.pdata[n];
datatype = mdata_vel.datatype[n];
cols = mdata_vel.cols[n];
// operate on v, omega, angmom
// no other read_data atom fields are Nx3 double arrays
if (datatype == Atom::DOUBLE) {
if (cols == 3) {
double **array = *((double ***) pdata);
for (int i = nlocal_previous; i < nlocal; i++)
domain->general_to_restricted_vector(array[i]);
}
}
}
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return # of bytes of allocated memory return # of bytes of allocated memory
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -123,7 +123,8 @@ class AtomVec : protected Pointers {
virtual void create_atom(int, double *); virtual void create_atom(int, double *);
virtual void create_atom_post(int) {} virtual void create_atom_post(int) {}
virtual void data_atom(double *, imageint, const std::vector<std::string> &, std::string &); virtual void data_atom(double *, imageint, const std::vector<std::string> &,
std::string &);
virtual void data_atom_post(int) {} virtual void data_atom_post(int) {}
virtual void data_atom_bonus(int, const std::vector<std::string> &) {} virtual void data_atom_bonus(int, const std::vector<std::string> &) {}
virtual void data_body(int, int, int, int *, double *) {} virtual void data_body(int, int, int, int *, double *) {}
@ -151,6 +152,8 @@ class AtomVec : protected Pointers {
virtual int pack_data_bonus(double *, int) { return 0; } virtual int pack_data_bonus(double *, int) { return 0; }
virtual void write_data_bonus(FILE *, int, double *, int) {} virtual void write_data_bonus(FILE *, int, double *, int) {}
virtual void data_general_to_restricted(int, int);
virtual int property_atom(const std::string &) { return -1; } virtual int property_atom(const std::string &) { return -1; }
virtual void pack_property_atom(int, double *, int, int) {} virtual void pack_property_atom(int, double *, int, int) {}

View File

@ -1376,8 +1376,8 @@ void CreateAtoms::loop_lattice(int action)
domain->lattice->lattice2box(x[0], x[1], x[2]); domain->lattice->lattice2box(x[0], x[1], x[2]);
// convert from general to restricted triclinic coords // convert from general to restricted triclinic coords
// for 2d simulation, check if z coord is within EPS_ZCOORD of zero // for 2d simulation:
// then set to zero // check if z coord is within EPS_ZCOORD of zero and set to zero
if (triclinic_general) { if (triclinic_general) {
domain->general_to_restricted_coords(x); domain->general_to_restricted_coords(x);

View File

@ -29,7 +29,6 @@ enum{VERSION,SMALLINT,TAGINT,BIGINT,
NDIHEDRALS,NDIHEDRALTYPES,DIHEDRAL_PER_ATOM, NDIHEDRALS,NDIHEDRALTYPES,DIHEDRAL_PER_ATOM,
NIMPROPERS,NIMPROPERTYPES,IMPROPER_PER_ATOM, NIMPROPERS,NIMPROPERTYPES,IMPROPER_PER_ATOM,
TRICLINIC,BOXLO,BOXHI,XY,XZ,YZ, TRICLINIC,BOXLO,BOXHI,XY,XZ,YZ,
TRICLINIC_GENERAL,ROTATE_G2R,ROTATE_R2G,
SPECIAL_LJ,SPECIAL_COUL, SPECIAL_LJ,SPECIAL_COUL,
MASS,PAIR,BOND,ANGLE,DIHEDRAL,IMPROPER, MASS,PAIR,BOND,ANGLE,DIHEDRAL,IMPROPER,
MULTIPROC,MPIIO,PROCSPERFILE,PERPROC, MULTIPROC,MPIIO,PROCSPERFILE,PERPROC,
@ -38,7 +37,8 @@ enum{VERSION,SMALLINT,TAGINT,BIGINT,
COMM_MODE,COMM_CUTOFF,COMM_VEL,NO_PAIR, COMM_MODE,COMM_CUTOFF,COMM_VEL,NO_PAIR,
EXTRA_BOND_PER_ATOM,EXTRA_ANGLE_PER_ATOM,EXTRA_DIHEDRAL_PER_ATOM, EXTRA_BOND_PER_ATOM,EXTRA_ANGLE_PER_ATOM,EXTRA_DIHEDRAL_PER_ATOM,
EXTRA_IMPROPER_PER_ATOM,EXTRA_SPECIAL_PER_ATOM,ATOM_MAXSPECIAL, EXTRA_IMPROPER_PER_ATOM,EXTRA_SPECIAL_PER_ATOM,ATOM_MAXSPECIAL,
NELLIPSOIDS,NLINES,NTRIS,NBODIES,ATIME,ATIMESTEP,LABELMAP}; NELLIPSOIDS,NLINES,NTRIS,NBODIES,ATIME,ATIMESTEP,LABELMAP,
TRICLINIC_GENERAL,ROTATE_G2R,ROTATE_R2G};
#define LB_FACTOR 1.1 #define LB_FACTOR 1.1

View File

@ -1062,6 +1062,12 @@ void ReadData::command(int narg, char **arg)
atom->avec->grow(atom->nmax); atom->avec->grow(atom->nmax);
} }
// if general triclinic, perform general to restricted rotation operation
// on any quantities read from data file which require it
if (triclinic_general)
atom->avec->data_general_to_restricted(nlocal_previous, atom->nlocal);
// init per-atom fix/compute/variable values for created atoms // init per-atom fix/compute/variable values for created atoms
atom->data_fix_compute_variable(nlocal_previous, atom->nlocal); atom->data_fix_compute_variable(nlocal_previous, atom->nlocal);
@ -1518,8 +1524,8 @@ void ReadData::atoms()
if (eof) error->all(FLERR, "Unexpected end of data file"); if (eof) error->all(FLERR, "Unexpected end of data file");
if (tlabelflag && !lmap->is_complete(Atom::ATOM)) if (tlabelflag && !lmap->is_complete(Atom::ATOM))
error->all(FLERR, "Label map is incomplete: all types must be assigned a unique type label"); error->all(FLERR, "Label map is incomplete: all types must be assigned a unique type label");
atom->data_atoms(nchunk, buffer, id_offset, mol_offset, toffset, triclinic_general, atom->data_atoms(nchunk, buffer, id_offset, mol_offset, toffset,
shiftflag, shift, tlabelflag, lmap->lmap2lmap.atom); shiftflag, shift, tlabelflag, lmap->lmap2lmap.atom, triclinic_general);
nread += nchunk; nread += nchunk;
} }