LAMMPS + DeePMD-kit
Use this skill when the user wants to run molecular dynamics in LAMMPS with a DeePMD-kit potential, prepare or explain an input.lammps file, or switch between common ensembles such as NVE, NVT, and NPT.
Agent responsibilities
- Confirm the available execution mode:
- Online mode: if internet access is available and
uv is installed, prefer
uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp ...
- Offline mode: do not guess the executable. Ask the user which LAMMPS command, module, or container should be used.
- Confirm the minimum simulation inputs:
- structure/data file (for example
data.system)
- DeePMD model file (for example
graph.pb or compressed model)
- atom type to element mapping, including required per-type masses if the data file does not define them
- target ensemble (NVE, NVT, NPT, or another explicitly requested setup)
- temperature, pressure if applicable, timestep, and total number of steps
- Write the LAMMPS input script yourself instead of asking the user to hand-write it.
- Keep the example readable and fully explained. If you include an example input script, explain what every command does.
- When possible, validate command availability against the LAMMPS docs or local
lmp -h output before execution.
- Report clearly which command was run, which files were used, and where outputs were written.
Decide the execution mode
Online mode (preferred when internet access is available)
Use:
uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -in input.lammps
If you need to inspect the local command-line help:
uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -h | tee /dev/tty
Notes:
- This is the preferred path because it can provision LAMMPS and DeePMD-kit on demand.
- The
gpu,torch,lmp extras match the requested runtime pattern from the user.
- If the environment is slow or the packages are large, warn the user that the first run may take time.
Offline mode
If internet access is unavailable or the user explicitly wants a site-installed binary, ask a concrete question such as:
- "Which LAMMPS executable should I use, for example
lmp, lmp_mpi, mpirun -np 8 lmp, or an HPC module command?"
- "Do you already have a DeePMD-enabled LAMMPS build on this machine or cluster?"
Do not invent a binary name or module name.
Minimal information to collect
Ask only for what is missing:
- DeePMD model path
- LAMMPS data file path
- ensemble
- target temperature
- target pressure if using NPT
- timestep
- run length in steps
- whether velocities should be generated from scratch
- preferred execution command if offline
Recommended workflow
- Inspect available files in the working directory.
- Draft
input.lammps.
- Explain the script to the user if they asked for an explanation or if the script is nontrivial.
- Run a short smoke test first when reasonable.
- Run the full simulation.
- Summarize outputs such as
log.lammps, dump trajectories, restart files, and thermodynamic data.
Example: annotated NVT input
The following example is adapted from the user-provided tutorial pattern and slightly generalized. See also assets/input.nvt.lammps.
variable NSTEPS equal 1000000
variable THERMO_FREQ equal 1000
variable DUMP_FREQ equal 1000
variable TEMP equal 300.0
variable TAU_T equal 0.1
units metal
boundary p p p
atom_style atomic
neighbor 1.0 bin
read_data data.system
mass 1 28.0855
mass 2 15.999
pair_style deepmd graph_compressed.pb
pair_coeff * *
thermo_style custom step temp pe ke etotal press vol lx ly lz xy xz yz
thermo ${THERMO_FREQ}
dump 1 all custom ${DUMP_FREQ} traj.lammpstrj id type x y z
velocity all create ${TEMP} 743574
fix 1 all nvt temp ${TEMP} ${TEMP} ${TAU_T}
timestep 0.0005
run ${NSTEPS}
What every command means
variable NSTEPS equal 1000000
- Defines a numeric variable called
NSTEPS with value 1000000.
- Used later by
run ${NSTEPS} so the run length is easy to modify in one place.
variable THERMO_FREQ equal 1000
- Defines how often LAMMPS prints thermodynamic information.
- Used by
thermo ${THERMO_FREQ}.
variable DUMP_FREQ equal 1000
- Defines how often coordinates are written to the trajectory dump.
variable TEMP equal 300.0
- Sets the target temperature in the current unit system.
- Because
units metal is used below, this temperature is interpreted in kelvin.
variable TAU_T equal 0.1
- Sets the thermostat damping parameter used by the NVT fix.
- In
metal units this is in picoseconds.
units metal
- Selects the LAMMPS
metal unit system.
- This determines the physical meaning of timestep, temperature, pressure, energy, distance, and time.
- In this unit system, distances are in angstrom, time is in picoseconds, and the timestep should be chosen accordingly.
boundary p p p
- Applies periodic boundary conditions in x, y, and z.
- Suitable for bulk condensed-phase simulations.
atom_style atomic
- Uses the
atomic atom style, appropriate when atoms have no explicit bonds, angles, or molecular topology in the force field description.
- Common for DeePMD simulations of condensed phases when the structure is provided as atoms in a box.
neighbor 1.0 bin
- Sets the neighbor-list skin distance to
1.0 in the current distance unit.
- Uses the
bin neighbor-building method.
- Neighbor lists help LAMMPS efficiently find nearby atoms for force evaluation.
read_data data.system
- Reads the initial atomic structure, atom types, simulation box, and related information from the LAMMPS data file
data.system.
- Replace this filename with the actual user file.
mass 1 28.0855, mass 2 15.999
- Defines per-type atomic masses when the data file does not contain a
Masses section.
- These example values correspond to a two-type Si/O mapping; adjust them to the actual atom type to element mapping. LAMMPS velocity creation and thermostats require masses; without them, runs can fail with
Not all per-type masses are set.
pair_style deepmd graph_compressed.pb
- Selects the DeePMD pair style.
- Loads the DeePMD model from
graph_compressed.pb.
- Replace the model filename with the actual model path, for example
graph.pb, graph-compress.pb, or another supported exported model.
pair_coeff * *
- Activates the previously selected pair style for all atom types.
- For DeePMD this often takes the simple form
* * because the mapping is embedded in the model workflow rather than through conventional pairwise parameters.
thermo_style custom step temp pe ke etotal press vol lx ly lz xy xz yz
- Chooses exactly which thermodynamic quantities to print.
step: timestep index.
temp: instantaneous temperature.
pe: potential energy.
ke: kinetic energy.
etotal: total energy.
press: pressure.
vol: box volume.
lx ly lz: box lengths.
xy xz yz: triclinic tilt factors, which are harmless to print even for an orthogonal box.
thermo ${THERMO_FREQ}
- Prints the thermo block every
THERMO_FREQ timesteps.
dump 1 all custom ${DUMP_FREQ} traj.lammpstrj id type x y z
- Creates dump ID
1.
- Dumps atoms from group
all.
- Uses the
custom dump format.
- Writes every
DUMP_FREQ steps.
- Saves to
traj.lammpstrj.
- Outputs per-atom columns
id type x y z.
velocity all create ${TEMP} 743574
- Assigns random initial velocities to all atoms.
- The target temperature is
TEMP.
743574 is the random seed.
- Use this when starting a fresh MD trajectory. If restarting from a previous equilibrated state, this command may be unnecessary.
fix 1 all nvt temp ${TEMP} ${TEMP} ${TAU_T}
- Creates fix ID
1 on group all.
- Applies the Nose-Hoover NVT thermostat.
- The target temperature is ramped from
${TEMP} to ${TEMP}, meaning constant temperature here.
${TAU_T} is the thermostat damping constant.
timestep 0.0005
- Sets the MD timestep.
- In
metal units, 0.0005 means 0.0005 ps = 0.5 fs.
- The safe choice depends on the system and model quality.
run ${NSTEPS}
- Runs molecular dynamics for
NSTEPS timesteps.
Common ensemble modifications
NVE
Replace the NVT thermostat line with:
fix 1 all nve
Meaning:
- integrates Newton's equations in the microcanonical ensemble
- no thermostat or barostat is applied
- useful for short stability checks or production runs after equilibration
NPT
A typical isotropic NPT alternative is:
variable PRESS equal 1.0
variable TAU_P equal 1.0
fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRESS} ${PRESS} ${TAU_P}
Meaning:
PRESS is the target pressure
TAU_P is the barostat damping constant
iso applies isotropic pressure control to the simulation box
- this simultaneously thermostats and barostats the system
When using NPT, it is often useful to keep vol, lx, ly, and lz in the thermo output.
Execution templates
Online run
uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -in input.lammps
Online help
uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -h | tee /dev/tty
Offline run
Only after the user specifies the executable, use a command such as one of these exact patterns:
lmp -in input.lammps
mpirun -np 8 lmp_mpi -in input.lammps
srun lmp -in input.lammps
The agent must not choose one of these on its own without user guidance in offline mode.
Output checklist
After a run, report at least:
- executed command
- input script path
- data file path
- model path
- main log path
- trajectory path if any
- whether the run completed successfully
- any obvious warnings or errors from the log
References
1---2name: lammps-deepmd3description: A tool and knowledge base for running molecular dynamics (MD) simulations in LAMMPS with the DeePMD-kit plugin. It handles input script preparation, ensemble selection (NVE/NVT/NPT), and job execution via `uv` or offline binaries. USE WHEN you need to set up, write, explain, or execute a LAMMPS molecular dynamics simulation using a DeePMD machine learning potential (e.g., `graph.pb`).4license: LGPL-3.0-or-later5---6
7# LAMMPS + DeePMD-kit
8
9Use this skill when the user wants to run molecular dynamics in LAMMPS with a DeePMD-kit potential, prepare or explain an `input.lammps` file, or switch between common ensembles such as NVE, NVT, and NPT.
10
11## Agent responsibilities
12
131. Confirm the available execution mode:
14 - **Online mode**: if internet access is available and `uv` is installed, prefer
15 `uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp ...`
16 - **Offline mode**: do **not** guess the executable. Ask the user which LAMMPS command, module, or container should be used.
171. Confirm the minimum simulation inputs:
18 - structure/data file (for example `data.system`)
19 - DeePMD model file (for example `graph.pb` or compressed model)
20 - atom type to element mapping, including required per-type masses if the data file does not define them
21 - target ensemble (NVE, NVT, NPT, or another explicitly requested setup)
22 - temperature, pressure if applicable, timestep, and total number of steps
231. Write the LAMMPS input script yourself instead of asking the user to hand-write it.
241. Keep the example readable and fully explained. If you include an example input script, explain what **every command** does.
251. When possible, validate command availability against the LAMMPS docs or local `lmp -h` output before execution.
261. Report clearly which command was run, which files were used, and where outputs were written.
27
28## Decide the execution mode
29
30### Online mode (preferred when internet access is available)
31
32Use:
33
34```bash
35uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -in input.lammps
36```
37
38If you need to inspect the local command-line help:
39
40```bash
41uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -h | tee /dev/tty
42```
43
44Notes:
45
46- This is the preferred path because it can provision LAMMPS and DeePMD-kit on demand.
47- The `gpu,torch,lmp` extras match the requested runtime pattern from the user.
48- If the environment is slow or the packages are large, warn the user that the first run may take time.
49
50### Offline mode
51
52If internet access is unavailable or the user explicitly wants a site-installed binary, ask a concrete question such as:
53
54- "Which LAMMPS executable should I use, for example `lmp`, `lmp_mpi`, `mpirun -np 8 lmp`, or an HPC module command?"
55- "Do you already have a DeePMD-enabled LAMMPS build on this machine or cluster?"
56
57Do not invent a binary name or module name.
58
59## Minimal information to collect
60
61Ask only for what is missing:
62
63- DeePMD model path
64- LAMMPS data file path
65- ensemble
66- target temperature
67- target pressure if using NPT
68- timestep
69- run length in steps
70- whether velocities should be generated from scratch
71- preferred execution command if offline
72
73## Recommended workflow
74
751. Inspect available files in the working directory.
761. Draft `input.lammps`.
771. Explain the script to the user if they asked for an explanation or if the script is nontrivial.
781. Run a short smoke test first when reasonable.
791. Run the full simulation.
801. Summarize outputs such as `log.lammps`, dump trajectories, restart files, and thermodynamic data.
81
82## Example: annotated NVT input
83
84The following example is adapted from the user-provided tutorial pattern and slightly generalized. See also `assets/input.nvt.lammps`.
85
86```lammps
87variable NSTEPS equal 1000000
88variable THERMO_FREQ equal 1000
89variable DUMP_FREQ equal 1000
90variable TEMP equal 300.0
91variable TAU_T equal 0.1
92
93units metal
94boundary p p p
95atom_style atomic
96
97neighbor 1.0 bin
98
99read_data data.system
100mass 1 28.0855
101mass 2 15.999
102pair_style deepmd graph_compressed.pb
103pair_coeff * *
104
105thermo_style custom step temp pe ke etotal press vol lx ly lz xy xz yz
106thermo ${THERMO_FREQ}
107dump 1 all custom ${DUMP_FREQ} traj.lammpstrj id type x y z
108
109velocity all create ${TEMP} 743574
110fix 1 all nvt temp ${TEMP} ${TEMP} ${TAU_T}
111
112timestep 0.0005
113run ${NSTEPS}
114```
115
116### What every command means
117
118- `variable NSTEPS equal 1000000`
119
120 - Defines a numeric variable called `NSTEPS` with value `1000000`.
121 - Used later by `run ${NSTEPS}` so the run length is easy to modify in one place.
122
123- `variable THERMO_FREQ equal 1000`
124
125 - Defines how often LAMMPS prints thermodynamic information.
126 - Used by `thermo ${THERMO_FREQ}`.
127
128- `variable DUMP_FREQ equal 1000`
129
130 - Defines how often coordinates are written to the trajectory dump.
131
132- `variable TEMP equal 300.0`
133
134 - Sets the target temperature in the current unit system.
135 - Because `units metal` is used below, this temperature is interpreted in kelvin.
136
137- `variable TAU_T equal 0.1`
138
139 - Sets the thermostat damping parameter used by the NVT fix.
140 - In `metal` units this is in picoseconds.
141
142- `units metal`
143
144 - Selects the LAMMPS `metal` unit system.
145 - This determines the physical meaning of timestep, temperature, pressure, energy, distance, and time.
146 - In this unit system, distances are in angstrom, time is in picoseconds, and the timestep should be chosen accordingly.
147
148- `boundary p p p`
149
150 - Applies periodic boundary conditions in x, y, and z.
151 - Suitable for bulk condensed-phase simulations.
152
153- `atom_style atomic`
154
155 - Uses the `atomic` atom style, appropriate when atoms have no explicit bonds, angles, or molecular topology in the force field description.
156 - Common for DeePMD simulations of condensed phases when the structure is provided as atoms in a box.
157
158- `neighbor 1.0 bin`
159
160 - Sets the neighbor-list skin distance to `1.0` in the current distance unit.
161 - Uses the `bin` neighbor-building method.
162 - Neighbor lists help LAMMPS efficiently find nearby atoms for force evaluation.
163
164- `read_data data.system`
165
166 - Reads the initial atomic structure, atom types, simulation box, and related information from the LAMMPS data file `data.system`.
167 - Replace this filename with the actual user file.
168
169- `mass 1 28.0855`, `mass 2 15.999`
170
171 - Defines per-type atomic masses when the data file does not contain a `Masses` section.
172 - These example values correspond to a two-type Si/O mapping; adjust them to the actual atom type to element mapping. LAMMPS velocity creation and thermostats require masses; without them, runs can fail with `Not all per-type masses are set`.
173
174- `pair_style deepmd graph_compressed.pb`
175
176 - Selects the DeePMD pair style.
177 - Loads the DeePMD model from `graph_compressed.pb`.
178 - Replace the model filename with the actual model path, for example `graph.pb`, `graph-compress.pb`, or another supported exported model.
179
180- `pair_coeff * *`
181
182 - Activates the previously selected pair style for all atom types.
183 - For DeePMD this often takes the simple form `* *` because the mapping is embedded in the model workflow rather than through conventional pairwise parameters.
184
185- `thermo_style custom step temp pe ke etotal press vol lx ly lz xy xz yz`
186
187 - Chooses exactly which thermodynamic quantities to print.
188 - `step`: timestep index.
189 - `temp`: instantaneous temperature.
190 - `pe`: potential energy.
191 - `ke`: kinetic energy.
192 - `etotal`: total energy.
193 - `press`: pressure.
194 - `vol`: box volume.
195 - `lx ly lz`: box lengths.
196 - `xy xz yz`: triclinic tilt factors, which are harmless to print even for an orthogonal box.
197
198- `thermo ${THERMO_FREQ}`
199
200 - Prints the thermo block every `THERMO_FREQ` timesteps.
201
202- `dump 1 all custom ${DUMP_FREQ} traj.lammpstrj id type x y z`
203
204 - Creates dump ID `1`.
205 - Dumps atoms from group `all`.
206 - Uses the `custom` dump format.
207 - Writes every `DUMP_FREQ` steps.
208 - Saves to `traj.lammpstrj`.
209 - Outputs per-atom columns `id type x y z`.
210
211- `velocity all create ${TEMP} 743574`
212
213 - Assigns random initial velocities to all atoms.
214 - The target temperature is `TEMP`.
215 - `743574` is the random seed.
216 - Use this when starting a fresh MD trajectory. If restarting from a previous equilibrated state, this command may be unnecessary.
217
218- `fix 1 all nvt temp ${TEMP} ${TEMP} ${TAU_T}`
219
220 - Creates fix ID `1` on group `all`.
221 - Applies the Nose-Hoover NVT thermostat.
222 - The target temperature is ramped from `${TEMP}` to `${TEMP}`, meaning constant temperature here.
223 - `${TAU_T}` is the thermostat damping constant.
224
225- `timestep 0.0005`
226
227 - Sets the MD timestep.
228 - In `metal` units, `0.0005` means `0.0005 ps = 0.5 fs`.
229 - The safe choice depends on the system and model quality.
230
231- `run ${NSTEPS}`
232
233 - Runs molecular dynamics for `NSTEPS` timesteps.
234
235## Common ensemble modifications
236
237### NVE
238
239Replace the NVT thermostat line with:
240
241```lammps
242fix 1 all nve
243```
244
245Meaning:
246
247- integrates Newton's equations in the microcanonical ensemble
248- no thermostat or barostat is applied
249- useful for short stability checks or production runs after equilibration
250
251### NPT
252
253A typical isotropic NPT alternative is:
254
255```lammps
256variable PRESS equal 1.0
257variable TAU_P equal 1.0
258fix 1 all npt temp ${TEMP} ${TEMP} ${TAU_T} iso ${PRESS} ${PRESS} ${TAU_P}
259```
260
261Meaning:
262
263- `PRESS` is the target pressure
264- `TAU_P` is the barostat damping constant
265- `iso` applies isotropic pressure control to the simulation box
266- this simultaneously thermostats and barostats the system
267
268When using NPT, it is often useful to keep `vol`, `lx`, `ly`, and `lz` in the thermo output.
269
270## Execution templates
271
272### Online run
273
274```bash
275uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -in input.lammps
276```
277
278### Online help
279
280```bash
281uvx --from lammps --with deepmd-kit[gpu,torch,lmp] lmp -h | tee /dev/tty
282```
283
284### Offline run
285
286Only after the user specifies the executable, use a command such as one of these exact patterns:
287
288```bash
289lmp -in input.lammps
290mpirun -np 8 lmp_mpi -in input.lammps
291srun lmp -in input.lammps
292```
293
294The agent must not choose one of these on its own without user guidance in offline mode.
295
296## Output checklist
297
298After a run, report at least:
299
300- executed command
301- input script path
302- data file path
303- model path
304- main log path
305- trajectory path if any
306- whether the run completed successfully
307- any obvious warnings or errors from the log
308
309## References
310
311- LAMMPS command categories: https://docs.lammps.org/Commands_category.html
312- LAMMPS command index: https://docs.lammps.org/Commands_all.html
313- DeePMD-kit: https://github.com/deepmodeling/deepmd-kit
314- User-provided tutorial reference: https://github.com/tongzhugroup/Chapter13-tutorial/blob/master/input.lammps
315- Detailed notes: `references/commands-and-workflow.md`