misc doc fixes to python section

This commit is contained in:
jtclemm
2024-08-13 16:30:33 -06:00
parent aa0b6c47c2
commit 3321477c7f
6 changed files with 29 additions and 27 deletions

View File

@ -16,7 +16,7 @@ can be handled through the Python exception handling mechanism.
try: try:
# LAMMPS will normally terminate itself and the running process if an error # LAMMPS will normally terminate itself and the running process if an error
# occurs. This would kill the Python interpreter. The library wrapper will # occurs. This would kill the Python interpreter. The library wrapper will
# detect that an error has occured and throw a Python exception # detect that an error has occurred and throw a Python exception
lmp.command('unknown') lmp.command('unknown')
except MPIAbortException as ae: except MPIAbortException as ae:

View File

@ -2,7 +2,7 @@ Neighbor list access
==================== ====================
Access to neighbor lists is handled through a couple of wrapper classes Access to neighbor lists is handled through a couple of wrapper classes
that allows to treat it like either a python list or a NumPy array. The that allows one to treat it like either a python list or a NumPy array. The
access procedure is similar to that of the C-library interface: use one access procedure is similar to that of the C-library interface: use one
of the "find" functions to look up the index of the neighbor list in the of the "find" functions to look up the index of the neighbor list in the
global table of neighbor lists and then get access to the neighbor list global table of neighbor lists and then get access to the neighbor list
@ -79,11 +79,11 @@ potential is shown below.
* :py:meth:`lammps.get_neighlist_element_neighbors()`: Get element in neighbor list and its neighbors * :py:meth:`lammps.get_neighlist_element_neighbors()`: Get element in neighbor list and its neighbors
* :py:meth:`lammps.find_pair_neighlist() <lammps.lammps.find_pair_neighlist()>`: Find neighbor list of pair style * :py:meth:`lammps.find_pair_neighlist() <lammps.lammps.find_pair_neighlist()>`: Find neighbor list of pair style
* :py:meth:`lammps.find_fix_neighlist() <lammps.lammps.find_pair_neighlist()>`: Find neighbor list of pair style * :py:meth:`lammps.find_fix_neighlist() <lammps.lammps.find_pair_neighlist()>`: Find neighbor list of fix style
* :py:meth:`lammps.find_compute_neighlist() <lammps.lammps.find_pair_neighlist()>`: Find neighbor list of pair style * :py:meth:`lammps.find_compute_neighlist() <lammps.lammps.find_pair_neighlist()>`: Find neighbor list of compute style
**NumPy Methods:** **NumPy Methods:**
* :py:meth:`lammps.numpy.get_neighlist() <lammps.numpy_wrapper.numpy_wrapper.get_neighlist()>`: Get neighbor list for given index, which uses NumPy arrays for its element neighbor arrays * :py:meth:`lammps.numpy.get_neighlist() <lammps.numpy_wrapper.numpy_wrapper.get_neighlist()>`: Get neighbor list for given index, which uses NumPy arrays for its element neighbor arrays
* :py:meth:`lammps.numpy.get_neighlist_element_neighbors() <lammps.numpy_wrapper.numpy_wrapper.get_neighlist_element_neighbors()>`: Get element in neighbor list and its neighbors (as numpy array) * :py:meth:`lammps.numpy.get_neighlist_element_neighbors() <lammps.numpy_wrapper.numpy_wrapper.get_neighlist_element_neighbors()>`: Get element in neighbor list and its neighbors (as a numpy array)

View File

@ -23,19 +23,19 @@ passed by all calling processors, to individual atoms, which may be
owned by different processors. owned by different processors.
Note that the data returned by the gather methods, Note that the data returned by the gather methods,
e.g. gather_atoms("x"), is different from the data structure returned e.g. :code:`gather_atoms("x")`, is different from the data structure returned
by extract_atom("x") in four ways. (1) Gather_atoms() returns a by :code:`extract_atom("x")` in four ways. (1) :code:`gather_atoms()` returns a
vector which you index as x[i]; extract_atom() returns an array vector which you index as x[i]; :code:`extract_atom()` returns an array
which you index as x[i][j]. (2) Gather_atoms() orders the atoms which you index as x[i][j]. (2) :code:`gather_atoms()` orders the atoms
by atom ID while extract_atom() does not. (3) Gather_atoms() returns by atom ID while :code:`extract_atom()` does not. (3) :code:`gather_atoms()` returns
a list of all atoms in the simulation; extract_atoms() returns just a list of all atoms in the simulation; :code:`extract_atoms()` returns just
the atoms local to each processor. (4) Finally, the gather_atoms() the atoms local to each processor. (4) Finally, the :code:`gather_atoms()`
data structure is a copy of the atom coords stored internally in data structure is a copy of the atom coords stored internally in
LAMMPS, whereas extract_atom() returns an array that effectively LAMMPS, whereas :code:`extract_atom()` returns an array that effectively
points directly to the internal data. This means you can change points directly to the internal data. This means you can change
values inside LAMMPS from Python by assigning a new values to the values inside LAMMPS from Python by assigning a new values to the
extract_atom() array. To do this with the gather_atoms() vector, you :code:`extract_atom()` array. To do this with the :code:`gather_atoms()` vector, you
need to change values in the vector, then invoke the scatter_atoms() need to change values in the vector, then invoke the :code:`scatter_atoms()`
method. method.
For the scatter methods, the array of coordinates passed to must be a For the scatter methods, the array of coordinates passed to must be a

View File

@ -2067,7 +2067,7 @@ class lammps(object):
""" List of the names of enabled packages in the LAMMPS shared library """ List of the names of enabled packages in the LAMMPS shared library
This is a wrapper around the functions :cpp:func:`lammps_config_package_count` This is a wrapper around the functions :cpp:func:`lammps_config_package_count`
and :cpp:func`lammps_config_package_name` of the library interface. and :cpp:func:`lammps_config_package_name` of the library interface.
:return :return
""" """

View File

@ -271,11 +271,11 @@ class numpy_wrapper:
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
def gather_bonds(self): def gather_bonds(self):
"""Retrieve global list of bonds as NumPy array """Retrieve global list of bonds as a NumPy array
.. versionadded:: 28Jul2021 .. versionadded:: 28Jul2021
This is a wrapper around :py:meth:`lammps.gather_bonds() <lammps.lammps.gather_bonds()>` This is a wrapper around :py:meth:`lammps.gather_bonds() <lammps.lammps.gather_bonds()>`.
It behaves the same as the original method, but returns a NumPy array instead It behaves the same as the original method, but returns a NumPy array instead
of a ``ctypes`` list. of a ``ctypes`` list.
@ -289,11 +289,11 @@ class numpy_wrapper:
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
def gather_angles(self): def gather_angles(self):
""" Retrieve global list of angles as NumPy array """ Retrieve global list of angles as a NumPy array
.. versionadded:: 8Feb2023 .. versionadded:: 8Feb2023
This is a wrapper around :py:meth:`lammps.gather_angles() <lammps.lammps.gather_angles()>` This is a wrapper around :py:meth:`lammps.gather_angles() <lammps.lammps.gather_angles()>`.
It behaves the same as the original method, but returns a NumPy array instead It behaves the same as the original method, but returns a NumPy array instead
of a ``ctypes`` list. of a ``ctypes`` list.
@ -307,11 +307,11 @@ class numpy_wrapper:
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
def gather_dihedrals(self): def gather_dihedrals(self):
""" Retrieve global list of dihedrals as NumPy array """ Retrieve global list of dihedrals as a NumPy array
.. versionadded:: 8Feb2023 .. versionadded:: 8Feb2023
This is a wrapper around :py:meth:`lammps.gather_dihedrals() <lammps.lammps.gather_dihedrals()>` This is a wrapper around :py:meth:`lammps.gather_dihedrals() <lammps.lammps.gather_dihedrals()>`.
It behaves the same as the original method, but returns a NumPy array instead It behaves the same as the original method, but returns a NumPy array instead
of a ``ctypes`` list. of a ``ctypes`` list.
@ -325,11 +325,11 @@ class numpy_wrapper:
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
def gather_impropers(self): def gather_impropers(self):
""" Retrieve global list of impropers as NumPy array """ Retrieve global list of impropers as a NumPy array
.. versionadded:: 8Feb2023 .. versionadded:: 8Feb2023
This is a wrapper around :py:meth:`lammps.gather_impropers() <lammps.lammps.gather_impropers()>` This is a wrapper around :py:meth:`lammps.gather_impropers() <lammps.lammps.gather_impropers()>`.
It behaves the same as the original method, but returns a NumPy array instead It behaves the same as the original method, but returns a NumPy array instead
of a ``ctypes`` list. of a ``ctypes`` list.

View File

@ -358,6 +358,7 @@ class Atom2D(Atom):
@property @property
def velocity(self): def velocity(self):
"""Access to velocity of an atom """Access to velocity of an atom
:getter: Return velocity of atom :getter: Return velocity of atom
:setter: Set velocity of atom :setter: Set velocity of atom
:type: numpy.array (float, float) :type: numpy.array (float, float)
@ -372,6 +373,7 @@ class Atom2D(Atom):
@property @property
def force(self): def force(self):
"""Access to force of an atom """Access to force of an atom
:getter: Return force of atom :getter: Return force of atom
:setter: Set force of atom :setter: Set force of atom
:type: numpy.array (float, float) :type: numpy.array (float, float)
@ -418,7 +420,7 @@ class PyLammps(object):
""" """
This is a Python wrapper class around the lower-level This is a Python wrapper class around the lower-level
:py:class:`lammps` class, exposing a more Python-like, :py:class:`lammps` class, exposing a more Python-like,
object-oriented interface for prototyping system inside of IPython and object-oriented interface for prototyping systems inside of IPython and
Jupyter notebooks. Jupyter notebooks.
It either creates its own instance of :py:class:`lammps` or can be It either creates its own instance of :py:class:`lammps` or can be
@ -556,7 +558,7 @@ class PyLammps(object):
Commands will be added to the command history but not executed. Commands will be added to the command history but not executed.
Add `commands` only to the command history, but do not execute them, so that you can Add `commands` only to the command history, but do not execute them, so that you can
conveniently create Lammps input files, using conveniently create LAMMPS input files, using
:py:meth:`PyLammps.write_script()`. :py:meth:`PyLammps.write_script()`.
""" """
self._cmd_history.append(cmd) self._cmd_history.append(cmd)
@ -908,7 +910,7 @@ class PyLammps(object):
class IPyLammps(PyLammps): class IPyLammps(PyLammps):
""" """
IPython wrapper for LAMMPS which adds embedded graphics capabilities to PyLammmps interface IPython wrapper for LAMMPS which adds embedded graphics capabilities to PyLammps interface
It either creates its own instance of :py:class:`lammps` or can be It either creates its own instance of :py:class:`lammps` or can be
initialized with an existing instance. The arguments are the same of the initialized with an existing instance. The arguments are the same of the