import numpy as np import matplotlib.pyplot as plt from ase.io import read traj = read("dump.lammpstrj", format="lammps-dump-text", index=":") n = len(traj) # Number of timesteps nleft = np.zeros(n) vxmean = np.zeros(n) # Find size of simulation box firstframe = traj[0] cellshape = firstframe.get_cell() halfsize = cellshape[0][0]*0.5 # Count number of particles on left side for each timestep it = 0 for frame in traj: x = frame.get_positions() # positions of atoms xi = x[:,0] # x-coordinates of atoms nleft[it] = np.sum(xi