pylammpsmpi.wrapper.concurrent module¶
- class pylammpsmpi.wrapper.concurrent.LammpsConcurrent(cores: int = 8, oversubscribe: bool = False, working_directory: str = '.', hostname_localhost: bool | None = None, cmdargs: list[Any] | None = None, executor: BaseExecutor | None = 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) Future¶
Create atoms on all processors.
- Parameters:
n (int) – Number of atoms.
id (list of ints, optional) – IDs of N atoms that need to be created.
type (list of atom types, optional) – Type of N atoms.
x (list of positions) – List of positions for N atoms.
v (list of velocities, optional) – List of velocities for N atoms.
image (list of ints, optional) – List of image flags for N atoms.
shrinkexceed (bool, optional) – Whether to shrink the box if the atoms exceed the box boundaries.
- Return type:
None
- extract_atom(name: str) Future¶
Extract a property of the atoms.
- Parameters:
name (str) – The property of the atom to be extracted.
- Returns:
val – A future object representing the extracted property of the atoms.
- Return type:
Future
- extract_box() Future¶
Get the simulation box.
- Returns:
box – A future object representing the simulation box.
- Return type:
Future
- 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) Future¶
Extract a fix value.
- Parameters:
args (tuple) – Variable number of arguments specifying the fix value to extract.
- Returns:
value – A future object representing the extracted fix value.
- Return type:
Future
- extract_global(name: str) Future¶
Extract value of global simulation parameters.
- Parameters:
name (str) – Name of the global simulation parameter.
- Returns:
value – A future object representing the value of the requested global parameter.
- Return type:
Future
- extract_setting(*args)¶
- extract_variable(*args) Future¶
Extract the value of a variable.
- Parameters:
args (tuple) – Variable number of arguments specifying the variable to extract.
- Returns:
data – A future object representing the value of the variable.
- Return type:
Future
- file(inputfile: str) Future¶
Read script from an input file.
- Parameters:
inputfile (str) – Name of the input file.
- 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) Future¶
Create atoms on all processors.
- Parameters:
ids (list of ints, optional) – IDs of N atoms that need to be created.
type (list of atom types, optional) – Type of N atoms.
x (list of positions) – List of positions for N atoms.
v (list of velocities, optional) – List of velocities for N atoms.
image (list of ints, optional) – List of image flags for N atoms.
shrinkexceed (bool, optional) – Whether to shrink the box if the atoms exceed the box boundaries.
- Return type:
None
- get_natoms() Future¶
Get the number of atoms.
- Returns:
natoms – A future object representing the number of atoms.
- Return type:
Future
- get_neighlist(*args)¶
Returns an instance of
NeighListwhich wraps access to the neighbor list with the given index :param idx: index of neighbor list :type idx: int :return: an instance ofNeighListwrapping 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: Future¶
Return whether the Lammps shared library was compiled with C++ exceptions handling enabled.
- Returns:
has_exceptions – A future object representing whether the Lammps library has exceptions handling enabled.
- Return type:
Future
- property has_ffmpeg_support¶
- property has_gzip_support: Future¶
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: Future¶
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: Future¶
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¶
- property natoms: Future¶
Get the number of atoms.
- Returns:
natoms – A future object representing the number of atoms.
- Return type:
Future
- reset_box(*args) Future¶
Reset the simulation box.
- Parameters:
args (tuple) – Variable number of arguments specifying the box parameters.
- Return type:
None
- scatter_atoms(*args, ids=None)¶
Scatter atoms for the lammps library
- Parameters:
*args
- set_fix_external_callback(*args)¶
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) Future¶
Set the value of a string style variable.
- Parameters:
args (tuple) – Variable number of arguments specifying the variable name and value.
- Returns:
flag – A future object representing the success flag (0 if successful, -1 otherwise).
- Return type:
Future
- property version: Future¶
Get the version of Lammps.
- Returns:
version – A future object representing the version string of Lammps.
- Return type:
Future
- pylammpsmpi.wrapper.concurrent.call_function_lmp(lmp, input_dict)¶
- pylammpsmpi.wrapper.concurrent.init_function()¶
- pylammpsmpi.wrapper.concurrent.shutdown_lmp(lmp)¶
- pylammpsmpi.wrapper.concurrent.start_lmp(lmp, argument_lst)¶