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.3.7. Per-atom properties — LAMMPS documentation

2.3.7. Per-atom properties

Similar to what is described in Per-atom properties, the instances of lammps can be used to extract atom quantities and modify some of them.

In some cases the data returned is a direct reference to the original data inside LAMMPS cast to ctypes pointers. Where possible, the wrappers will determine the ctypes data type and cast pointers accordingly. If numpy is installed arrays can also be extracted as numpy arrays, which will access the C arrays directly and have the correct dimensions to protect against invalid accesses.

Warning

When accessing per-atom data, please note that this data is the per-processor local data and indexed accordingly. These arrays can change sizes and order at every neighbor list rebuild and atom sort event as atoms are migrating between subdomains.

from lammps import lammps

lmp = lammps()
lmp.file("in.sysinit")


# Read/Write access via ctypes
nlocal = lmp.extract_global("nlocal")
x = lmp.extract_atom("x")

for i in range(nlocal):
   print("(x,y,z) = (", x[i][0], x[i][1], x[i][2], ")")

# Read/Write access via NumPy arrays
atom_id = L.numpy.extract_atom("id")
atom_type = L.numpy.extract_atom("type")
x = L.numpy.extract_atom("x")
v = L.numpy.extract_atom("v")
f = L.numpy.extract_atom("f")

# set position in 2D simulation
x[0] = (1.0, 0.0)

# set position in 3D simulation
x[0] = (1.0, 0.0, 1.)

lmp.close()

Methods:

  • extract_atom(): extract a per-atom quantity

Numpy Methods:

  • numpy.extract_atom(): extract a per-atom quantity as numpy array

Version release
LAMMPS Branch:
develop
stable
release
Downloads:
PDF
Source
Git Info:
13Nov2026
You are visitor 01402792 — 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.