Guide · VASP · LAMMPS · SLURM · 14 min read
How do I spot a molecular dynamics run that has gone wrong, and stop it?
Checked against the docs · VASP wiki and LAMMPS stable release 30 Sep 2026 and SLURM 26.05 · Last checked 11 November 2026 · Spot a mistake? Tell us
Short answer
Watch four things from the first steps on. The temperature should fluctuate around the thermostat's target; the conserved energy should not drift; the pressure and volume should not blow up; and no atom should be lost or turn into NaN. VASP writes them to OSZICAR and OUTCAR, LAMMPS to the thermo lines of log.lammps. If the run has gone wrong, stop it rather than spend the walltime: a STOPCAR with LSTOP = .TRUE. ends VASP cleanly at the next step, and scancel with the job id ends any job on a SLURM cluster. Then fix the cause, usually the starting structure or the time step.
What does "gone wrong" mean for a dynamics run?
A molecular dynamics (MD) run moves atoms through time, one time step at a time, and writes a few numbers about the whole system every so often: the temperature, the energies, the pressure. Those numbers are how you tell a healthy run from a broken one long before you look at any result.
A run can go wrong in two ways:
- It breaks. The numbers run away: the energy climbs, the temperature shoots up, atoms fly out of the box, values become
NaN(not a number). The usual causes are too long a time step, two atoms that started too close, or forces that are not good enough (poorly converged DFT in VASP, a potential used outside its range in LAMMPS). - It runs, but not the run you meant. Nothing crashes, yet the thermostat is not acting, the temperature is not the one you asked for, or the cell is slowly deforming. These are easy to miss because the job finishes normally.
When does it matter most?
In the first few hundred steps. A bad start shows early: the LAMMPS manual notes that its "simulation unstable" error is more likely during equilibration, and the VASP wiki's guide to MD says to begin "with a short trajectory" and examine it "before committing to a long run".
In ab initio MD. When VASP computes the forces from DFT at every step, each step is expensive. A run that broke at step 200 and kept going until the walltime ran out has spent most of its allocation on nothing.
With anything new. A new structure, a new potential, a new temperature, a new thermostat: each is a chance for one of the problems below.
What should I watch while it runs?
| Watch | A healthy run | A run gone wrong | Where to read it |
|---|---|---|---|
| Temperature | Fluctuates around the thermostat's target (constant-temperature runs) | A steady drift away from the target, or a sudden jump | VASP: T= in OSZICAR. LAMMPS: the Temp column |
| Conserved energy | No systematic drift; only fluctuations | A steady climb or fall; sudden steps | VASP: E= in OSZICAR. LAMMPS: etotal with no thermostat, econserve with one |
| Pressure and volume | Fluctuate about a steady value | Grow without bound; in a variable-cell run, a cell that keeps distorting | VASP: OUTCAR. LAMMPS: the Press and vol columns |
| The atoms | All present, moving by small amounts | Lost atoms, NaN values, atoms far from where they should be | VASP: XDATCAR, CONTCAR. LAMMPS: the error message, a dump file |
| Electronic convergence (VASP) | Each MD step's electronic loop converges | Repeated electronic steps that hit the limit | The electronic-step lines in OSZICAR |
The VASP wiki lists the same warning signs: "repeated electronic nonconvergence, large force spikes, a steady temperature drift away from the target in NVT, strong total energy drift in NVE, and rapidly growing cell distortions in variable-cell runs." Here NVE is a run with no thermostat (constant number of atoms N, volume V and energy E) and NVT one with a thermostat at constant temperature T.
The size of a normal fluctuation shrinks as the system grows: a cell of 64 atoms swings by much more than one of 6400. That is why a trend matters more than any single value.
How do I read OSZICAR during a VASP run?
VASP writes OSZICAR as it goes. For molecular dynamics (IBRION = 0), each step ends with one line like this one from the VASP wiki:
29 T= 339. E= -.40079922E+02 F= -.40328692E+02 E0= -.40329272E+02 EK= 0.30631E+00 SP= -.62E-01 SK= 0.41E-02In order: the step number; T, the temperature in kelvin; E, the total energy of the extended system (the electrons and ions, the ions' kinetic energy and the thermostat's energy), in eV; F, the free energy of the electrons and ions; E0, that energy extrapolated to zero smearing; EK, the ions' kinetic energy; SP and SK, the Nosé thermostat's potential and kinetic energy.
To see the latest steps:
grep "T=" OSZICAR | tail -5Watch E. The wiki: in NVE and in deterministic thermostats such as Nosé-Hoover, it "should not show a systematic drift"; with stochastic thermostats (Andersen, Langevin, CSVR) it is not strictly conserved, so "focus on unexplained long-term drift". It adds that a sudden change can be a numerical problem or a real event, such as a phase transition, so look at the structure before you decide.
Watch the electronic steps. The lines above each MD line (each starting with the algorithm's name, such as RMM:) are that step's electronic iterations. If step after step runs to the limit NELM (60 by default) without converging, the forces are not converged, and the wiki calls poor electronic convergence something that "directly corrupts the forces".
OUTCAR has the same energies spelled out per step, with the forces, the stress and the external pressure. XDATCAR holds the trajectory, the positions every NBLOCK steps, and is where you look for atoms doing something unphysical.
How do I read the thermo output in log.lammps?
LAMMPS prints a line of thermodynamic output ("thermo") to the screen and to log.lammps every N steps. Two defaults catch people:
thermodefaults to 0, which prints only the first and last step. Without athermoline you will see nothing while the run goes. Set one, such asthermo 100.- The default columns (
thermo_style one) areStep Temp E_pair E_mol TotEng Press: the step, the temperature, the pair and molecular potential energies, the total energy and the pressure. For dynamics with a thermostat, add the conserved quantity:
thermo_style custom step temp pe ke etotal econserve press vol
thermo 100
thermo_modify flush yesetotal is potential plus kinetic energy, conserved with fix nve. econserve adds the energy a thermostat or barostat has taken out; the manual says it "should remain constant over time" in NVT, NPH and NPT runs. thermo_modify flush yes makes LAMMPS write each line out at once, so you can watch the log grow (tail -f log.lammps) and keep the lines if the run stops early.
Look at the job's screen output too. The manual notes that a warning raised in the middle of a run is printed only to the screen, not to the log file. On a SLURM cluster, the screen goes to the job's output file, slurm-<jobid>.out by default (the sbatch page).
What does too long a time step look like?
The total energy drifts in a run with no thermostat, the temperature runs away from the thermostat's target, atoms move unrealistically far per step and, in VASP, the electronic loop becomes erratic. The VASP wiki's first remedy for any of its warning signs is to reduce POTIM. In LAMMPS, a step far too long ends in lost atoms. How to choose the step and test it is in What time step should I use for molecular dynamics?
What does it look like when atoms fly apart?
In LAMMPS, a run whose atoms fly apart usually stops with one of these errors, each explained in the manual's Errors details page:
| Error | What it means |
|---|---|
Lost atoms: original N current M | Fewer atoms than at the start. LAMMPS checks every time it writes thermo output; lost atoms "usually indicate bad dynamics, e.g. atoms have been blown far out of the simulation box". |
Out of range atoms - cannot compute ... | With long-range electrostatics (PPPM), atoms moved too fast for the charge grid, usually "a system with very high forces". |
Bond atoms missing (and angle, dihedral) | The atoms of a bond are too far apart; possibly "unstable dynamics which caused the atoms to blow apart". |
Non-numeric atom coords or pressure or box dimensions - simulation unstable | Positions or the pressure became NaN or infinite. |
Domain too large for neighbor bins | An atom has been blown a long way out of the box, or a barostat has grown the box too far. |
The manual's cures: avoid close contacts when you build the system (or remove them with delete_atoms overlap), minimize before the dynamics, shorten the time step, and ease the system in before switching to "more aggressive settings". With a barostat, run with only a thermostat until the potential energy settles. The page on the lost-atoms error goes through them one by one.
Do not silence the error. thermo_modify lost ignore stops LAMMPS checking, and the manual is clear that it should be used "only when atoms should leave the system" (sputtering, evaporation): "ignoring a problem does not solve it".
In VASP, look for the signs in the numbers (force spikes in OUTCAR, an energy that jumps, an electronic loop that stops converging) and in the structure (XDATCAR and CONTCAR showing atoms in unphysical places). The wiki's advice is to check XDATCAR or CONTCAR "for obviously unphysical atomic motion" in a short test run.
How do I know my run is healthy before I let it run long?
Run it short first. The VASP wiki's procedure: run a short trajectory, then check the temperature and energy in OSZICAR, the forces, stress and electronic convergence in OUTCAR, and the motion in XDATCAR. Make sure "the thermostat drives the system toward the intended temperature, that no atom leaves the physically meaningful structure, and that the SCF cycle remains stable". The same order works for LAMMPS with the thermo columns above. Only then continue from CONTCAR (VASP) or a restart file (LAMMPS) for the long run.
Check the thermostat is really on. Several setups run without one and say nothing:
- In VASP,
MDALGO = 2(Nosé-Hoover) with noSMASSusesSMASS = -3, the default, which the wiki lists as a microcanonical (NVE) run.MDALGO = 1(Andersen) with noANDERSEN_PROBuses 0, which is the wiki's recipe for NVE. Look at the temperature: in NVE nothing holds it at your target. - In VASP,
TEBEGdefaults to 0 K; ifPOSCARhas no velocities, they are drawn atTEBEG. - In LAMMPS,
fix nvt's damping time matters: the manual warns that if it is too small "the temperature can fluctuate wildly", and if it is too large it "will take a very long time to equilibrate". A good choice for many models is about 100 time steps.
Know what pressure to expect. At constant volume, nothing controls the pressure: the wiki's NVT page says its average "will therefore depend on the initial lattice". A large, steady pressure in an NVT run points to the starting cell, not to broken dynamics; the wiki's remedy is to equilibrate the lattice first, with an NpT run or a volume relaxation.
When should I stop a run, and how?
Stop it when it cannot recover: atoms lost or overlapping, values gone to NaN, an energy or pressure that has run away by orders of magnitude, an electronic loop that no longer converges. Stop it, too, when the setup is not what you meant (the wrong thermostat, the wrong temperature): every further step is spent on a run you will not use. A drift alone can be real physics, such as a phase transition, so look at the structure before you decide.
VASP: ask it to stop at the next step. In the run's directory, create a file called STOPCAR:
echo "LSTOP = .TRUE." > STOPCARVASP then "stops at the next ionic step", which for MD is the next time step. LABORT = .TRUE. stops at the next electronic step instead, and the wiki warns that WAVECAR and CHGCAR may then hold unconverged results; it recommends LSTOP where possible. CONTCAR is written after every ionic step, so the last structure (with velocities, in MD) is there to inspect or continue from.
LAMMPS: plan the stop in the script. fix halt ends a run when a condition is met, checked every N steps. The manual's own example stops when a file named EXIT appears in the run directory:
variable exit equal is_file(EXIT)
fix 10 all halt 100 v_exit != 0 error softWith error soft, LAMMPS leaves the current run but still carries out the commands after it (skipping further run commands), so a write_restart or write_dump after the run saves the state. To stop, touch EXIT in the run directory. The condition can also be a quantity, such as an equal-style variable built from the temperature.
Any code, on SLURM: cancel the job. Find its job id with squeue --me, then:
scancel 1234567(1234567 is an example id.) scancel without a signal option sends SIGCONT and SIGTERM, waits the cluster's KillWait time, then sends SIGKILL, which "gives time for the running job/step(s) to clean up". Canceling ends the processes; the files already written to disk stay in the run directory, which is why LAMMPS's thermo_modify flush yes is worth having. See the scancel page for the options.
Then fix the cause before you rerun. Rerunning the same input gives the same failure. Most broken runs trace back to the start (atoms too close, a cell far from its equilibrium volume) or to the time step.
What goes wrong when watching and stopping MD?
| Mistake | What you would see | What to do |
|---|---|---|
No thermo line in a LAMMPS script | A log with only the first and last step, so nothing to watch. | Set thermo 100 (or another interval) and thermo_modify flush yes. |
thermo_modify lost ignore to get past the error | The run continues with atoms missing, and every number after it is wrong. | Find the cause: close contacts, the time step, the potential. |
Judging etotal in a thermostatted LAMMPS run | An energy that moves although nothing is wrong. | Watch econserve. |
MDALGO = 2 without SMASS in VASP | A run with no thermostat: the temperature wanders instead of holding at TEBEG. | Set SMASS (0 or more for Nosé-Hoover). |
Reading only log.lammps | Warnings raised during the run are missing; they went to the screen. | Read the job's SLURM output file too. |
| Killing a VASP run that only needed to stop | The run ends at once; with LABORT or a hard kill, WAVECAR and CHGCAR may hold unconverged results. | Use STOPCAR with LSTOP = .TRUE. when you can wait one step. |
| Continuing a stopped VASP run in a different ensemble | The new run crashes at the start. | The wiki's CONTCAR page: remove the predictor-corrector block from the file before switching ensemble. |
| Rerunning a broken input unchanged | The same failure at about the same step. | Minimize first, shorten the time step, check the closest pair of atoms. |
Monitor follows your job on a connected cluster or on the practice cluster, and its glance draws the temperature or energy as the output arrives, beside the latest frame. While the job runs, Verlet points out what looks wrong, with the number behind it, and recognizes the usual errors in the output and says what they mean; it never stops a job on its own.