pylammpsmpi.wrapper.base module

class pylammpsmpi.wrapper.base.LammpsBase(cores: int = 8, oversubscribe: bool = False, working_directory: str = '.', hostname_localhost: bool | None = None, cmdargs: list[Any] | None = None, executor: BaseExecutor | None = None)

Bases: LammpsConcurrent

command(cmd)

Send a command to the lammps object

Parameters:

cmd (string, list of strings) – command to be sent

Return type:

None

create_atoms(n: int, id: list[int], type: list[int], x: list[float], v: list[float] | None = None, image: list[int] | None = None, shrinkexceed: bool = False) None

Create atoms on all procs

Parameters: n : int

number of atoms

idlist of ints, optional

ids of N atoms that need to be created if not specified, ids from 1 to N are assigned

typelist of atom types, optional

type of N atoms, if not specified, all atoms are assigned as type 1

x: list of positions

list of the type [posx, posy, posz] for N atoms

v: list of velocities

list of the type [vx, vy, vz] for N atoms

image: list of ints, optional

if not specified a list of 0s will be used.

shrinkexceed: bool, optional

default False

Returns: None

extract_atom(name: str) list[int] | list[float]

Extract a property of the atoms

Parameters: name : str

the property of atom to be extracted

Returns: val : list of int or float

If the requested name has multiple dimensions, output will be a multi-dimensional list.

extract_box() list[float | list[float] | list[int]]

Get the simulation box

Returns: box : list

list containing the simulation box information [boxlo, boxhi, xy, yz, xz, periodicity, box_change] where boxlo and boxhi are lower and upper bounds of the box in three dimensions, xy, yz, xz are the box tilts, periodicity is an array which shows if the box is periodic in three dimensions, and box_change is a list of booleans indicating if the box dimensions have changed

extract_compute(id, style, type, length=0, width=0)

Extract compute value from the lammps library

Parameters:
  • id (string) – id of the compute

  • style ({0, 1}) – 0 - global data 1 - per atom data

  • type ({0, 1, 2}) – 0 - scalar 1 - vector 2 - array

  • length (int, optional. Default 0) – if style is 0 and type is 1 or 2, then length is the length of vector.

  • width (int, optional. Default 0) – if type is 2, then width is the number of elements in each element along length.

Returns:

data computed by the fix depending on the chosen inputs

Return type:

val

extract_fix(*args) int | float | list[int | float]

Extract a fix value

Parameters: *args: tuple

arguments to specify the fix value to extract

Returns: value: int, float, or list of int or float

extracted fix value corresponding to the requested dimensions

extract_global(name: str) int | float | str

Extract value of global simulation parameters

Parameters: name : str

name of the global parameter to extract

Returns: value: int, float, or str

extracted value of the global parameter

extract_setting(*args) int | float | str

Extract a setting value

Parameters: *args: tuple

arguments to specify the setting to extract

Returns: value: int, float, or str

extracted setting value

extract_variable(*args) int | float | list[int | float]

Extract the value of a variable

Parameters: *args: tuple

arguments to specify the variable to extract

Returns: data: int, float, or list of int or float

value of the variable depending on the requested dimension

file(inputfile: str) None

Read script from an input file

Parameters: inputfile: str

name of inputfile

Returns: None

find_compute_neighlist(*args)

Find neighbor list index of compute neighbor list :param computeid: name of compute :type computeid: string :param request: index of neighbor list request, in case there are more than one, defaults to 0 :type request: int, optional :return: neighbor list index if found, otherwise -1 :rtype: int

find_fix_neighlist(*args)

Find neighbor list index of fix neighbor list :param fixid: name of fix :type fixid: string :param request: index of neighbor list request, in case there are more than one, defaults to 0 :type request: int, optional :return: neighbor list index if found, otherwise -1 :rtype: int

find_pair_neighlist(*args) int

Find neighbor list index of pair style neighbor list Try finding pair instance that matches style. If exact is set, the pair must match style exactly. If exact is 0, style must only be contained. If pair is of style pair/hybrid, style is instead matched the nsub-th hybrid sub-style. Once the pair instance has been identified, multiple neighbor list requests may be found. Every neighbor list is uniquely identified by its request index. Thus, providing this request index ensures that the correct neighbor list index is returned. :param style: name of pair style that should be searched for :type style: string :param exact: controls whether style should match exactly or only must be contained in pair style name, defaults to True :type exact: bool, optional :param nsub: match nsub-th hybrid sub-style, defaults to 0 :type nsub: int, optional :param request: index of neighbor list request, in case there are more than one, defaults to 0 :type request: int, optional :return: neighbor list index if found, otherwise -1 :rtype: int

gather_atoms(*args, concat=False, ids=None)

Gather atom properties

Parameters:
  • name ({'x', 'mass', 'id', 'type', 'mask', 'v', 'f',) – ‘molecule’, ‘q’, ‘mu’, ‘omega’, ‘angmom’, ‘torque’, ‘radius’} the property of atom to be extracted

  • concat (bool, optional. Default False) – If True, gather information from all processors, but not sorted according to Atom ids

  • ids (list, optional. Default None) – If a list of ids are provided, the required information for only those atoms are returned

Returns:

val – If the requested name has multiple dimensions, output will be a multi-dimensional array.

Return type:

array of length n_atoms sorted by atom ids

Notes

This method gathers information from all processors.

See also

extract_atoms

generate_atoms(ids: list[int] | None = None, type: list[int] | None = None, x: list[float] | None = None, v: list[float] | None = None, image: list[int] | None = None, shrinkexceed: bool = False) None

Create atoms on all procs

Parameters: ids : list of ints, optional

ids of N atoms that need to be created if not specified, ids from 1 to N are assigned

typelist of atom types, optional

type of N atoms, if not specified, all atoms are assigned as type 1

x: list of positions

list of the type [posx, posy, posz] for N atoms

v: list of velocities

list of the type [vx, vy, vz] for N atoms

image: list of ints, optional

if not specified a list of 0s will be used.

shrinkexceed: bool, optional

default False

Returns: None

get_natoms() int

Get the number of atoms

Returns: natoms : int

number of atoms

get_neighlist(*args)

Returns an instance of NeighList which wraps access to the neighbor list with the given index :param idx: index of neighbor list :type idx: int :return: an instance of NeighList wrapping access to neighbor list data :rtype: NeighList

get_neighlist_element_neighbors(*args)
get_neighlist_size(*args)

Return the number of elements in neighbor list with the given index :param idx: neighbor list index :type idx: int :return: number of elements in neighbor list with index idx :rtype: int

get_thermo(*args)

Return current value of thermo keyword

Parameters:

name (string) – name of the thermo keyword

Returns:

value of the thermo keyword

Return type:

val

property has_exceptions: bool

Return whether the LAMMPS shared library was compiled with C++ exceptions handling enabled

property has_ffmpeg_support: bool
property has_gzip_support: bool

Return whether the Lammps shared library has gzip support.

Returns:

has_gzip_support – A future object representing whether the Lammps library has gzip support.

Return type:

Future

property has_jpeg_support: bool

Return whether the Lammps shared library has JPEG support.

Returns:

has_jpeg_support – A future object representing whether the Lammps library has JPEG support.

Return type:

Future

property has_png_support: bool

Return whether the Lammps shared library has PNG support.

Returns:

has_png_support – A future object representing whether the Lammps library has PNG support.

Return type:

Future

property installed_packages: list[str]
property natoms: int

Get the number of atoms

Returns: natoms : int

number of atoms

reset_box(*args) None

Reset the simulation box

Parameters: *args: tuple

arguments to specify the new box dimensions

Returns: None

scatter_atoms(*args, ids=None)

Scatter atoms for the lammps library

Parameters:

*args

set_fix_external_callback(*args) None

Follows the signature of LAMMPS’s set_fix_external_callback(fix_id, callback, caller=None). The caller argument is a list of inputs to the callback function, including class instances and, importantly, the LammpsLibrary instance itself. Since LAMMPS’s set_fix_external_callback allows passing to itself a self-reference, we want to keep this feature. Because the LAMMPS instance is unavailable at this stage, we insert a placeholder in its position, which will later be replaced with the actual LAMMPS instance.

set_variable(*args) int

Set the value of a string style variable

Parameters: *args: tuple

arguments to specify the variable and its value

Returns: flag : int

0 if successful, -1 otherwise

property version: str

Get the version of lammps

Returns: version: str

version string of lammps

pylammpsmpi.wrapper.base.get_result(future: Future, cores: int) Any