pylammpsmpi.wrapper.concurrent module

class pylammpsmpi.wrapper.concurrent.LammpsConcurrent(cores=8, oversubscribe=False, working_directory='.', cmdargs=None)

Bases: object

close()

Close the current lammps object

Parameters:

None

Return type:

None

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, id, type, x, v=None, image=None, shrinkexceed=False)

Create atoms on all procs

Parameters:
  • n (int) – number of atoms

  • id (list of ints, optional) – ids of N atoms that need to be created if not specified, ids from 1 to N are assigned

  • type (list of atom types, optional) – type of N atoms, if not specied, 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

Return type:

None

extract_atom(name)

Extract a property of the atoms

Parameters:

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

Returns:

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

Return type:

array of length n_atoms

Notes

This method only gathers information from the current processor. Rest of the values would be zero.

See also

scatter_atoms

extract_box()

Get the simulation box

Parameters:

None

Returns:

box – of the form [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.

Return type:

list

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)

Extract a fix value

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

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

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

  • i (int, optional) – index to select fix output

  • j (int, optional) – index to select fix output

Returns:

Fix data corresponding to the requested dimensions

Return type:

value

extract_global(name)

Extract value of global simulation parameters

Parameters:

name (string) – see notes for a set of possible options

Notes

The possible options for name are- “dt”, “boxlo”, “boxhi”, “boxxlo”, “boxxhi”, “boxylo”, “boxyhi”, “boxzlo”, “boxzhi”, “periodicity”, “xy”, “xz”, “yz”, “natoms”, “nbonds”, “nangles”, “ndihedrals”, “nimpropers”, “nlocal”, “nghost”, “nmax”, “ntypes”, “ntimestep”, “units”, “triclinic”, “q_flag”, “atime”, “atimestep”

Also global constants defined by units can be accessed- “boltz”, “hplanck”, “mvv2e”, “ftm2v”, “mv2d”, “nktv2p”, “qqr2e”, “qe2f”, “vxmu2f”, “xxt2kmu”, “dielectric”, “qqr2e”, “e_mass”, “hhmrr2e”, “mvh2r”, “angstrom”, “femtosecond”, “qelectron”

extract_setting(*args)
extract_variable(*args)

Extract the value of a variable

Parameters:
  • name (string) – name of the variable

  • group (string) – group id (ignored for equal style variables)

  • flag ({0, 1}) – 0 - equal style variable 1 - atom style variable

Returns:

value of variable depending on the requested dimension

Return type:

data

Notes

Currently only returns the information provided on a single processor

file(inputfile)

Read script from an input file

Parameters:

inputfile (string) – name of inputfile

Return type:

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)

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=None, type=None, x=None, v=None, image=None, shrinkexceed=False)

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

  • type (list of atom types, optional) – type of N atoms, if not specied, 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

Return type:

None

get_natoms()

Get the number of atoms

Parameters:

None

Returns:

natoms – number of atoms

Return type:

int

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

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

property has_ffmpeg_support
property has_gzip_support
property has_jpeg_support
property has_png_support
property installed_packages
property natoms
reset_box(*args)

Reset the simulation box

Parameters:
  • boxlo (array of floats) – lower bound of box in three dimensions

  • boxhi (array of floats) – upper bound of box in three dimensions

  • xy (floats) – box tilts

  • yz (floats) – box tilts

  • xz (floats) – box tilts

scatter_atoms(*args, ids=None)

Scatter atoms for the lammps library

Parameters:

*args

set_fix_external_callback(*args)
set_variable(*args)

Set the value of a string style variable

Parameters:
  • name (string) – name of the variable

  • value (string) – value of the variable

Returns:

flag – 0 if successfull, -1 otherwise

Return type:

int

property version

Get the version of lammps

Parameters:

None

Returns:

version – version string of lammps

Return type:

string

pylammpsmpi.wrapper.concurrent.execute_async(future_queue, cmdargs=None, cores=1, oversubscribe=False, cwd=None)