forked from lijiext/lammps
Merge pull request #1889 from lammps/change-box-error-check
delay change_box error check with existing per-atom restart data
This commit is contained in:
commit
e7cce60777
|
@ -142,24 +142,40 @@ new owning processors.
|
|||
|
||||
.. note::
|
||||
|
||||
The simulation box size/shape can be changed by arbitrarily
|
||||
large amounts by this command. This is not a problem, except that the
|
||||
The simulation box size/shape can be changed by arbitrarily large
|
||||
amounts by this command. This is not a problem, except that the
|
||||
mapping of processors to the simulation box is not changed from its
|
||||
initial 3d configuration; see the :doc:`processors <processors>`
|
||||
command. Thus, if the box size/shape changes dramatically, the
|
||||
mapping of processors to the simulation box may not end up as optimal
|
||||
as the initial mapping attempted to be.
|
||||
mapping of processors to the simulation box may not end up as
|
||||
optimal as the initial mapping attempted to be. You may wish to
|
||||
re-balance the atoms by using the :doc:`balance <balance>` command
|
||||
if that is the case.
|
||||
|
||||
.. note::
|
||||
|
||||
Because the keywords used in this command are applied one at a
|
||||
time to the simulation box and the atoms in it, care must be taken
|
||||
with triclinic cells to avoid exceeding the limits on skew after each
|
||||
transformation in the sequence. If skew is exceeded before the final
|
||||
transformation this can be avoided by changing the order of the
|
||||
sequence, or breaking the transformation into two or more smaller
|
||||
transformations. For more information on the allowed limits for box
|
||||
skew see the discussion on triclinic boxes on :doc:`Howto triclinic <Howto_triclinic>` doc page.
|
||||
You cannot use this command after reading a restart file (and
|
||||
before a run is performed) if the restart file stored per-atom
|
||||
information from a fix and any of the specified keywords change the
|
||||
box size or shape or boundary conditions. This is because atoms
|
||||
may be moved to new processors and the restart info will not
|
||||
migrate with them. LAMMPS will generate an error if this could
|
||||
happen. Only the *ortho* and *triclinic* keywords do not trigger
|
||||
this error. One solution is to perform a "run 0" command before
|
||||
using the change_box command. This clears the per-atom restart
|
||||
data, whether it has been re-assigned to a new fix or not.
|
||||
|
||||
.. note::
|
||||
|
||||
Because the keywords used in this command are applied one at a time
|
||||
to the simulation box and the atoms in it, care must be taken with
|
||||
triclinic cells to avoid exceeding the limits on skew after each
|
||||
transformation in the sequence. If skew is exceeded before the
|
||||
final transformation this can be avoided by changing the order of
|
||||
the sequence, or breaking the transformation into two or more
|
||||
smaller transformations. For more information on the allowed
|
||||
limits for box skew see the discussion on triclinic boxes on
|
||||
:doc:`Howto triclinic <Howto_triclinic>` doc page.
|
||||
|
||||
----------
|
||||
|
||||
|
|
|
@ -46,9 +46,6 @@ void ChangeBox::command(int narg, char **arg)
|
|||
if (domain->box_exist == 0)
|
||||
error->all(FLERR,"Change_box command before simulation box is defined");
|
||||
if (narg < 2) error->all(FLERR,"Illegal change_box command");
|
||||
if (modify->nfix_restart_peratom)
|
||||
error->all(FLERR,"Cannot change_box after "
|
||||
"reading restart file with per-atom info");
|
||||
|
||||
if (comm->me == 0 && screen) fprintf(screen,"Changing box ...\n");
|
||||
|
||||
|
@ -174,6 +171,21 @@ void ChangeBox::command(int narg, char **arg)
|
|||
|
||||
if (nops == 0) error->all(FLERR,"Illegal change_box command");
|
||||
|
||||
// move_atoms = 1 if need to move atoms to new procs after box changes
|
||||
// anything other than ORTHO or TRICLINIC may cause atom movement
|
||||
|
||||
int move_atoms = 0;
|
||||
for (int m = 0; m < nops; m++) {
|
||||
if (ops[m].style != ORTHO || ops[m].style != TRICLINIC) move_atoms = 1;
|
||||
}
|
||||
|
||||
// error if moving atoms and there is stored per-atom restart state
|
||||
// disallowed b/c restart per-atom fix info will not move with atoms
|
||||
|
||||
if (move_atoms && modify->nfix_restart_peratom)
|
||||
error->all(FLERR,"Change_box parameter not allowed after "
|
||||
"reading restart file with per-atom info");
|
||||
|
||||
// read options from end of input line
|
||||
|
||||
options(narg-iarg,&arg[iarg]);
|
||||
|
@ -350,6 +362,10 @@ void ChangeBox::command(int narg, char **arg)
|
|||
if (domain->triclinic) domain->lamda2x(atom->nlocal);
|
||||
}
|
||||
|
||||
// done if don't need to move atoms
|
||||
|
||||
if (!move_atoms) return;
|
||||
|
||||
// move atoms back inside simulation box and to new processors
|
||||
// use remap() instead of pbc()
|
||||
// in case box moved a long distance relative to atoms
|
||||
|
|
Loading…
Reference in New Issue