LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

### fix external command

Syntax:

    fix ID group-ID external

- ID, group-ID are documented in fix command
- external = style name of this fix command

Examples:

    fix 1 all external

Description:

This fix makes a callback each timestep or minimization iteration to an external driver program that is using LAMMPS as a library. This is a way to let another program compute forces on atoms which LAMMPS will include in its dynamics performed by the run command or its iterations performed by the minimize command

The callback function "foo" will be invoked every timestep or iteration as:

    foo(ptr,timestep,nlocal,ids,x,fexternal);

which has this prototype:

void foo(void *, int, int, int *, double **, double **);

The arguments are as follows:

- ptr = pointer provided by and simply passed back to external driver
- timestep = current LAMMPS timestep
- nlocal = # of atoms on this processor
- ids = list of atom IDs on this processor
- x = coordinates of atoms on this processor
- fexternal = forces on atoms on this processor

Fexternal are the forces returned by the driver program, which LAMMPS adds to the current force on each atom.

See the couple/lammps_quest/lmpqst.cpp file in the LAMMPS distribution for an example of a coupling application that uses this fix, and how it makes a call to the fix to specify what function the fix should callback to. The sample application performs classical MD using quantum forces computed by a density functional code Quest.

Restart, fix_modify, output, run start/stop, minimize info:

No information about this fix is written to binary restart files. None of the fix_modify options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various output commands. No parameter of this fix can be used with the start/stop keywords of the run command.

The forces due to this fix are imposed during an energy minimization, invoked by the minimize command. However, LAMMPS knows nothing about the energy associated with these forces. So you should perform the minimization based on a force tolerance, not an energy tolerance.

Restrictions: none

Related commands: none

Default: none