add renieigbor option to fix set
This commit is contained in:
@ -216,6 +216,7 @@ OPT.
|
||||
* :doc:`rigid/small (o) <fix_rigid>`
|
||||
* :doc:`rx (k) <fix_rx>`
|
||||
* :doc:`saed/vtk <fix_saed_vtk>`
|
||||
* :doc:`set <fix_set>`
|
||||
* :doc:`setforce (k) <fix_setforce>`
|
||||
* :doc:`setforce/spin <fix_setforce>`
|
||||
* :doc:`sgcmc <fix_sgcmc>`
|
||||
|
||||
@ -8,11 +8,12 @@ Syntax
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
fix ID group-ID set Nfreq set-args
|
||||
fix ID group-ID set Nfreq rnflag set-args
|
||||
|
||||
* ID, group-ID are documented in :doc:`fix <fix>` command
|
||||
* set = style name of this fix command
|
||||
* Nfreq = reset per-atom properties every this many timesteps
|
||||
* rnflag = 1 to reneighbor on next timestep, 0 to not
|
||||
* set-args = identical to args for the :doc:`set <set>` command
|
||||
|
||||
Examples
|
||||
@ -20,8 +21,8 @@ Examples
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
fix 10 all set 1 group all i_dump v_new
|
||||
fix 10 all set 1 group all i_dump v_turnoff
|
||||
fix 10 all set 1 0 group all i_dump v_new
|
||||
fix 10 all set 1 0 group all i_dump v_turnoff
|
||||
|
||||
Description
|
||||
"""""""""""
|
||||
@ -29,11 +30,30 @@ Description
|
||||
Reset one or more properties of one or more atoms once every *Nfreq*
|
||||
steps during a simulation.
|
||||
|
||||
The args following *Nfreq* are identical to those allowed for the
|
||||
:doc:`set <set>` command, as in the examples above and below.
|
||||
If the *rnflag* for reneighboring is set to 1, then a reneighboring
|
||||
will be triggered on the next timestep (since the fix set operation
|
||||
occurs at the end of the current timestep). This is important to do
|
||||
if this command changes per-atom properties that need to be
|
||||
communicated to ghost atoms. If this is not the case, an *rnflag*
|
||||
setting of 0 can be used; reneighboring will only be triggered on
|
||||
subsequent timesteps by the usual neighbor list criteria; see the
|
||||
:doc:`neigh_modify <neigh_modify.html>` command.
|
||||
|
||||
Here are two examples where an *rnflag* setting of 1 are needed. If a
|
||||
custom per-atom property is changed and the :doc:`fix property/atom
|
||||
<fix_property_atom>` command to create the property used the *ghost
|
||||
yes* keyword. Or if per-atom charges are changed, all pair styles
|
||||
which compute Coulombic interactions require charge values for ghost
|
||||
atoms. In both these examples, the re-neighboring will trigger the
|
||||
changes in the owned atom properties to be immediately communicated to
|
||||
ghost atoms.
|
||||
|
||||
The arguments following *Nfreq* and *rnflag* are identical to those
|
||||
allowed for the :doc:`set <set>` command, as in the examples above and
|
||||
below.
|
||||
|
||||
Note that the group-ID setting for this command is ignored. The
|
||||
syntax for the :doc:`set <set>` command allows selection of which
|
||||
syntax for the :doc:`set <set>` arguments allows selection of which
|
||||
atoms have their properties reset.
|
||||
|
||||
This command can only be used to reset an atom property using a
|
||||
@ -68,7 +88,7 @@ be output every step for *twindow* timesteps.
|
||||
#
|
||||
variable start atom "vx > v_vthresh && i_dump == -1"
|
||||
variable new atom ternary(v_start,step,i_dump)
|
||||
fix 3 all set 1 group all i_dump v_new
|
||||
fix 3 all set 1 0 group all i_dump v_new
|
||||
#
|
||||
# dump command with thresh which enforces twindow
|
||||
#
|
||||
@ -112,7 +132,7 @@ longer useful.
|
||||
variable turnon atom ternary(v_start,step,i_dump)
|
||||
variable stop atom "v_turnon >= 0 && (step-v_turnon) < v_twindow"
|
||||
variable turnoff atom ternary(v_stop,v_turnon,-1)
|
||||
fix 3 all set 1 group all i_dump v_turnoff
|
||||
fix 3 all set 1 0 group all i_dump v_turnoff
|
||||
#
|
||||
# dump command with thresh which enforces twindow
|
||||
#
|
||||
|
||||
@ -103,14 +103,16 @@ must be done.
|
||||
|
||||
.. note::
|
||||
|
||||
If your input script changes the system between 2 runs, then the
|
||||
initial setup must be performed to ensure the change is recognized by
|
||||
all parts of the code that are affected. Examples are adding a
|
||||
:doc:`fix <fix>` or :doc:`dump <dump>` or :doc:`compute <compute>`, changing
|
||||
a :doc:`neighbor <neigh_modify>` list parameter, or writing restart file
|
||||
which can migrate atoms between processors. LAMMPS has no easy way to
|
||||
check if this has happened, but it is an error to use the *pre no*
|
||||
option in this case.
|
||||
If your input script "changes" the system between 2 runs, then the
|
||||
initial setup typically needs to be performed to ensure the change
|
||||
is recognized by all parts of the code that are affected. Examples
|
||||
are adding a :doc:`fix <fix>` or :doc:`dump <dump>` or
|
||||
:doc:`compute <compute>`, changing a :doc:`neighbor <neigh_modify>`
|
||||
list parameter, using the :doc:`set <set>` command, or writing a
|
||||
restart file via the :doc:`write_restart <write_restart>` command,
|
||||
which can migrate atoms between processors. LAMMPS has no easy way
|
||||
to check if this has happened, but it is an error to use the *pre
|
||||
no* option in these cases.
|
||||
|
||||
If *post* is specified as "no", the full timing summary is skipped;
|
||||
only a one-line summary timing is printed.
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
#include "set.h"
|
||||
#include "update.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
@ -26,27 +27,25 @@ enum{SETCOMMAND,FIXSET}; // also used in Set class
|
||||
|
||||
FixSet::FixSet(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
|
||||
{
|
||||
if (narg < 7) error->all(FLERR, 1, "Illegal fix set command: need at least four arguments");
|
||||
if (narg < 8) error->all(FLERR, 1, "Illegal fix set command: need at least eight arguments");
|
||||
|
||||
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
|
||||
if (nevery <= 0) error->all(FLERR, "Fix {} Nevery must be > 0", style);
|
||||
|
||||
reneighbor = utils::inumeric(FLERR, arg[4], false, lmp);
|
||||
if (reneighbor = 0 || reneighbor > 1)
|
||||
error->all(FLERR, "Fix {} rnflag must be 0/1", style);
|
||||
|
||||
// create instance of Set class
|
||||
|
||||
set = new Set(lmp);
|
||||
|
||||
// pass remaining args to Set class
|
||||
// only keywords which use per-atom variables are currently allowed
|
||||
// NOTE: could also allow when set style = region, since atoms may move in/out of regions
|
||||
// NOTE: could also allow when set style = region,
|
||||
// since atoms may move in/out of regions
|
||||
|
||||
set->process_args(FIXSET,narg-4,&arg[4]);
|
||||
|
||||
// NOTE: not sure if either of these options for fix set are needed or could be problematic
|
||||
// could add ghost yes keyword/value to trigger
|
||||
// ghost comm, e.g. if atom types are reset
|
||||
// this could require an extract() method in Set to query what value(s) to comm
|
||||
// could add reneigh yes keyword/value to trigger
|
||||
// full reneighbor on next step, e.g. if xyz coords are reset
|
||||
set->process_args(FIXSET,narg-5,&arg[5]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -79,5 +78,9 @@ void FixSet::end_of_step()
|
||||
// loop over list of actions to reset atom attributes
|
||||
|
||||
set->invoke_actions();
|
||||
|
||||
// trigger reneighboring on next timestep if requested
|
||||
|
||||
if (reneighbor) next_reneighbor = update->ntimestep + 1;
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,8 @@ class FixSet : public Fix {
|
||||
void end_of_step() override;
|
||||
|
||||
private:
|
||||
int reneighbor;
|
||||
|
||||
class Set *set;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user