GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • 1. Introduction
  • 2. Install LAMMPS
  • 3. Build LAMMPS
  • 4. Run LAMMPS
  • 5. Errors
  • 6. Commands
  • 7. Accelerate performance
  • 8. Optional packages
  • 9. Auxiliary tools
  • 10. Howto discussions
  • 11. Example scripts
  • 1. LAMMPS Library Interfaces
  • 2. Use Python with LAMMPS
  • 2.1. Overview

This view

  • Original page
  • New address

GeezerVison is showing docs.lammps.org — 2.10. Handling LAMMPS errors — LAMMPS documentation

2.10. Handling LAMMPS errors

LAMMPS and the LAMMPS library are compiled with C++ exception support to provide a better error handling experience. LAMMPS errors trigger throwing a C++ exception. These exceptions allow capturing errors on the C++ side and rethrowing them on the Python side. This way LAMMPS errors can be handled through the Python exception handling mechanism.

from lammps import lammps, MPIAbortException

lmp = lammps()

try:
   # LAMMPS will normally terminate itself and the running process if an error
   # occurs. This would kill the Python interpreter.  The library wrapper will
   # detect that an error has occurred and throw a Python exception

   lmp.command('unknown')
except MPIAbortException as ae:
   # Single MPI process got killed. This would normally be handled by an MPI abort
   pass
except Exception as e:
   # All (MPI) processes have reached this error
   pass

Warning

Capturing a LAMMPS exception in Python can still mean that the current LAMMPS process is in an illegal state and must be terminated. It is advised to save your data and terminate the Python instance as quickly as possible when running in parallel with MPI.

Version release
LAMMPS Branch:
develop
stable
release
Downloads:
PDF
Source
Git Info:
13Nov2026
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.