lammps_utils

Collection of useful functions for working with LAMMPS.

extract_compute_np(lmp, name, compute_type, result_type, array_shape=None, use_fp64=False)[source]

Convert a lammps compute to a numpy array.

Assumes the compute returns floating point numbers. Note that the result is a view into the original memory. If the result type is 0 (scalar) then conversion to numpy is skipped and a python float is returned.

Parameters:
  • lmp (lammps.lammps) – The LAMMPS object from which data is supposed to be extracted.

  • name (string) – Name of the LAMMPS calculation.

  • compute_type – Compute type of the LAMMPS calculation.

  • result_type – Result type of the LAMMPS calculation.

  • array_shape – Array shape of the LAMMPS calculation.

  • use_fp64 (bool) – If True, return the array with double precision. If False (default), the array will be processed with single precision. Only has an effect if result_type equals 2.

set_cmdlinevars(cmdargs, argdict)[source]

Add a dicitionary of LAMMPS arguments in a command line argument string.

Parameters:
  • cmdargs (list) – Command line argument string. Will be mutated by this function.

  • argdict (dict) – Dictionary to be added to LAMMPS command line argument string.

Returns:

cmdargs – New command line argument string.

Return type:

list