diff --git a/doc/src/Errors_messages.rst b/doc/src/Errors_messages.rst index bfdba4f6a1..2a146a9184 100644 --- a/doc/src/Errors_messages.rst +++ b/doc/src/Errors_messages.rst @@ -7883,12 +7883,6 @@ keyword to allow for additional bonds to be formed Fix poems cannot (yet) work with coupled bodies whose joints connect 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* Self-explanatory. diff --git a/doc/src/Errors_warnings.rst b/doc/src/Errors_warnings.rst index b0fa2e2173..d244818cc9 100644 --- a/doc/src/Errors_warnings.rst +++ b/doc/src/Errors_warnings.rst @@ -752,13 +752,6 @@ This will most likely cause errors in kinetic fluctuations. More than the maximum # of neighbors was found multiple times. This 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* Most FENE models need this setting for the special_bonds command. diff --git a/src/DIELECTRIC/atom_vec_dielectric.cpp b/src/DIELECTRIC/atom_vec_dielectric.cpp index 3b25ad4e17..a06b4d599b 100644 --- a/src/DIELECTRIC/atom_vec_dielectric.cpp +++ b/src/DIELECTRIC/atom_vec_dielectric.cpp @@ -15,6 +15,7 @@ #include "atom.h" #include "citeme.h" +#include "domain.h" #include "error.h" #include "force.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]); } +/* ---------------------------------------------------------------------- + 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() ------------------------------------------------------------------------- */ diff --git a/src/DIELECTRIC/atom_vec_dielectric.h b/src/DIELECTRIC/atom_vec_dielectric.h index 28bf7abb33..fefbc99c4f 100644 --- a/src/DIELECTRIC/atom_vec_dielectric.h +++ b/src/DIELECTRIC/atom_vec_dielectric.h @@ -35,6 +35,7 @@ class AtomVecDielectric : virtual public AtomVec { void grow_pointers() override; void create_atom_post(int) override; void data_atom_post(int) override; + void data_general_to_restricted(int, int); void unpack_restart_init(int) override; int property_atom(const std::string &) override; void pack_property_atom(int, double *, int, int) override; diff --git a/src/DIPOLE/atom_vec_dipole.cpp b/src/DIPOLE/atom_vec_dipole.cpp index 3f160787b2..5323e33f17 100644 --- a/src/DIPOLE/atom_vec_dipole.cpp +++ b/src/DIPOLE/atom_vec_dipole.cpp @@ -14,6 +14,7 @@ #include "atom_vec_dipole.h" #include "atom.h" +#include "domain.h" #include @@ -68,3 +69,17 @@ void AtomVecDipole::data_atom_post(int 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]); } + +/* ---------------------------------------------------------------------- + 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]); +} diff --git a/src/DIPOLE/atom_vec_dipole.h b/src/DIPOLE/atom_vec_dipole.h index d2f5746462..d688fd98dd 100644 --- a/src/DIPOLE/atom_vec_dipole.h +++ b/src/DIPOLE/atom_vec_dipole.h @@ -30,6 +30,7 @@ class AtomVecDipole : virtual public AtomVec { void grow_pointers() override; void data_atom_post(int) override; + void data_general_to_restricted(int, int); protected: double **mu; diff --git a/src/MACHDYN/atom_vec_smd.cpp b/src/MACHDYN/atom_vec_smd.cpp index d1bae9ecb7..0f5e7f82f0 100644 --- a/src/MACHDYN/atom_vec_smd.cpp +++ b/src/MACHDYN/atom_vec_smd.cpp @@ -156,6 +156,13 @@ void AtomVecSMD::create_atom_post(int ilocal) void AtomVecSMD::data_atom_post(int ilocal) { 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][1] = x[ilocal][1]; x0[ilocal][2] = x[ilocal][2]; diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index 9a7e4c6aac..1ea57516f6 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -1,5 +1,4 @@ /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories LAMMPS development team: developers@lammps.org @@ -10,7 +9,6 @@ the GNU General Public License. See the README file in the top-level LAMMPS directory. - ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ @@ -26,6 +24,7 @@ #include "atom_vec_spin.h" #include "atom.h" +#include "domain.h" #include #include @@ -100,3 +99,17 @@ void AtomVecSpin::data_atom_post(int ilocal) sp_one[1] *= 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]); +} diff --git a/src/SPIN/atom_vec_spin.h b/src/SPIN/atom_vec_spin.h index bf11d5856e..effbe232f4 100644 --- a/src/SPIN/atom_vec_spin.h +++ b/src/SPIN/atom_vec_spin.h @@ -31,6 +31,7 @@ class AtomVecSpin : virtual public AtomVec { void grow_pointers() override; void force_clear(int, size_t) override; void data_atom_post(int) override; + void data_general_to_restricted(int, int); protected: double **sp, **fm, **fm_long; diff --git a/src/atom.cpp b/src/atom.cpp index fb444e3e79..4674ded045 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1039,12 +1039,12 @@ void Atom::deallocate_topology() /* ---------------------------------------------------------------------- unpack N lines from Atom section of data file 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, - int type_offset, int triclinic_general, - int shiftflag, double *shift, - int labelflag, int *ilabel) + int type_offset, int shiftflag, double *shift, + int labelflag, int *ilabel, int triclinic_general) { int xptr,iptr; 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[2] = utils::numeric(FLERR,values[xptr+2],false,lmp); - // for 2d simulation, check if z coord is within EPS_ZCOORD of zero - // then set to zero + // for 2d simulation: + // check if z coord is within EPS_ZCOORD of zero and set to zero if (dimension == 2) { 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 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) { diff --git a/src/atom.h b/src/atom.h index cf5fa10814..5c4ad80e62 100644 --- a/src/atom.h +++ b/src/atom.h @@ -328,8 +328,7 @@ class Atom : protected Pointers { void deallocate_topology(); - void data_atoms(int, char *, tagint, tagint, int, int, - int, double *, int, int *); + void data_atoms(int, char *, tagint, tagint, int, int, double *, int, int *, int); void data_vels(int, char *, tagint); void data_bonds(int, char *, int *, tagint, int, int, int *); void data_angles(int, char *, int *, tagint, int, int, int *); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index bfda951823..d8684aaf94 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -1656,6 +1656,7 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, const std::vectornlocal; if (nlocal == nmax) grow(0); @@ -1684,7 +1685,7 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, const std::vectorgeneral_to_restricted_vector(array[i]); + } + } + } +} + /* ---------------------------------------------------------------------- return # of bytes of allocated memory ------------------------------------------------------------------------- */ diff --git a/src/atom_vec.h b/src/atom_vec.h index a4db054752..b0c77635f8 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -123,7 +123,8 @@ class AtomVec : protected Pointers { virtual void create_atom(int, double *); virtual void create_atom_post(int) {} - virtual void data_atom(double *, imageint, const std::vector &, std::string &); + virtual void data_atom(double *, imageint, const std::vector &, + std::string &); virtual void data_atom_post(int) {} virtual void data_atom_bonus(int, const std::vector &) {} 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 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 void pack_property_atom(int, double *, int, int) {} diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 0a8c462688..fb9b83413f 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -1376,8 +1376,8 @@ void CreateAtoms::loop_lattice(int action) domain->lattice->lattice2box(x[0], x[1], x[2]); // convert from general to restricted triclinic coords - // for 2d simulation, check if z coord is within EPS_ZCOORD of zero - // then set to zero + // for 2d simulation: + // check if z coord is within EPS_ZCOORD of zero and set to zero if (triclinic_general) { domain->general_to_restricted_coords(x); diff --git a/src/lmprestart.h b/src/lmprestart.h index b3982ac8c1..2ed1d7db11 100644 --- a/src/lmprestart.h +++ b/src/lmprestart.h @@ -29,7 +29,6 @@ enum{VERSION,SMALLINT,TAGINT,BIGINT, NDIHEDRALS,NDIHEDRALTYPES,DIHEDRAL_PER_ATOM, NIMPROPERS,NIMPROPERTYPES,IMPROPER_PER_ATOM, TRICLINIC,BOXLO,BOXHI,XY,XZ,YZ, - TRICLINIC_GENERAL,ROTATE_G2R,ROTATE_R2G, SPECIAL_LJ,SPECIAL_COUL, MASS,PAIR,BOND,ANGLE,DIHEDRAL,IMPROPER, MULTIPROC,MPIIO,PROCSPERFILE,PERPROC, @@ -38,7 +37,8 @@ enum{VERSION,SMALLINT,TAGINT,BIGINT, COMM_MODE,COMM_CUTOFF,COMM_VEL,NO_PAIR, EXTRA_BOND_PER_ATOM,EXTRA_ANGLE_PER_ATOM,EXTRA_DIHEDRAL_PER_ATOM, 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 diff --git a/src/read_data.cpp b/src/read_data.cpp index c59bec7476..219a361584 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -1062,6 +1062,12 @@ void ReadData::command(int narg, char **arg) 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 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 (tlabelflag && !lmap->is_complete(Atom::ATOM)) 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, - shiftflag, shift, tlabelflag, lmap->lmap2lmap.atom); + atom->data_atoms(nchunk, buffer, id_offset, mol_offset, toffset, + shiftflag, shift, tlabelflag, lmap->lmap2lmap.atom, triclinic_general); nread += nchunk; }