narupa.lammps.LammpsImd module

LAMMPS python integration with Narupa This program can be run as a standalone using mock data or from within LAMMPS using the python_invoke/fix command as demonstrated in the example LAMMPS inputs.

class narupa.lammps.LammpsImd.LammpsImd(port: int = None, address: str = '[::]')

Bases: object

A class that can communicate with the LAMMPS program through its python interpreter. Upon initialisation, MPI is set up along with the Narupa server. The LAMMPS data is collected across all processors using GATHER and SCATTER routines that require mpi4py to respect the internal processor rank of LAMMPS.

The variables that can currently be accessed are x : positions v : velocities f : forces

This code executes as a LAMMPS fix allowing python to be executed after the forces are calculated. The particle positions can be extracted and the forces modified in the lammps ctypes.

The main lammps_hook routine will check if it is being run from within LAMMPS or as a stand alone program and determine if it should use mock variables (manipulate_dummy_arrays) or ones available from within LAMMPS (manipulate_lammps_arrays).

close()

Close ports to prevent blocking

find_unit_type(lammps_class)

Check the unit type collected from LAMMPS against the plank_values list and fid its index :return: The replaced units from the list.

interactions

Returns a shallow copy of the current interactions. This is copied from the ASE example, but reduces the abstracted degree

lammps_hook(lmp=None, comm=None)

lammps_hook is the main routine that is run within LAMMPS MD steps. It checks that the LAMMPS python wrapper is callable and then attempts to extract a 3N matrix of atomic data

Parameters:lmp – LAMMPS object data, only populated when running from within LAMMPS
need_to_collect_topology = True