From 3321477c7f54ba6cf40aee6a4281856f18c7d3db Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 13 Aug 2024 16:30:33 -0600 Subject: [PATCH] misc doc fixes to python section --- doc/src/Python_error.rst | 2 +- doc/src/Python_neighbor.rst | 8 ++++---- doc/src/Python_scatter.rst | 20 ++++++++++---------- python/lammps/core.py | 2 +- python/lammps/numpy_wrapper.py | 16 ++++++++-------- python/lammps/pylammps.py | 8 +++++--- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/doc/src/Python_error.rst b/doc/src/Python_error.rst index bdf69df5b4..b8755d6c04 100644 --- a/doc/src/Python_error.rst +++ b/doc/src/Python_error.rst @@ -16,7 +16,7 @@ can be handled through the Python exception handling mechanism. try: # LAMMPS will normally terminate itself and the running process if an error # 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') except MPIAbortException as ae: diff --git a/doc/src/Python_neighbor.rst b/doc/src/Python_neighbor.rst index 755b83da81..fc4e7a1149 100644 --- a/doc/src/Python_neighbor.rst +++ b/doc/src/Python_neighbor.rst @@ -2,7 +2,7 @@ Neighbor list access ==================== 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 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 @@ -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.find_pair_neighlist() `: Find neighbor list of pair style -* :py:meth:`lammps.find_fix_neighlist() `: Find neighbor list of pair style -* :py:meth:`lammps.find_compute_neighlist() `: Find neighbor list of pair style +* :py:meth:`lammps.find_fix_neighlist() `: Find neighbor list of fix style +* :py:meth:`lammps.find_compute_neighlist() `: Find neighbor list of compute style **NumPy Methods:** * :py:meth:`lammps.numpy.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() `: Get element in neighbor list and its neighbors (as numpy array) +* :py:meth:`lammps.numpy.get_neighlist_element_neighbors() `: Get element in neighbor list and its neighbors (as a numpy array) diff --git a/doc/src/Python_scatter.rst b/doc/src/Python_scatter.rst index e4444fabe7..5db4b5329c 100644 --- a/doc/src/Python_scatter.rst +++ b/doc/src/Python_scatter.rst @@ -23,19 +23,19 @@ passed by all calling processors, to individual atoms, which may be owned by different processors. Note that the data returned by the gather methods, -e.g. gather_atoms("x"), is different from the data structure returned -by extract_atom("x") in four ways. (1) Gather_atoms() returns a -vector which you index as x[i]; extract_atom() returns an array -which you index as x[i][j]. (2) Gather_atoms() orders the atoms -by atom ID while extract_atom() does not. (3) Gather_atoms() returns -a list of all atoms in the simulation; extract_atoms() returns just -the atoms local to each processor. (4) Finally, the gather_atoms() +e.g. :code:`gather_atoms("x")`, is different from the data structure returned +by :code:`extract_atom("x")` in four ways. (1) :code:`gather_atoms()` returns a +vector which you index as x[i]; :code:`extract_atom()` returns an array +which you index as x[i][j]. (2) :code:`gather_atoms()` orders the atoms +by atom ID while :code:`extract_atom()` does not. (3) :code:`gather_atoms()` returns +a list of all atoms in the simulation; :code:`extract_atoms()` returns just +the atoms local to each processor. (4) Finally, the :code:`gather_atoms()` 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 values inside LAMMPS from Python by assigning a new values to the -extract_atom() array. To do this with the gather_atoms() vector, you -need to change values in the vector, then invoke the scatter_atoms() +:code:`extract_atom()` array. To do this with the :code:`gather_atoms()` vector, you +need to change values in the vector, then invoke the :code:`scatter_atoms()` method. For the scatter methods, the array of coordinates passed to must be a diff --git a/python/lammps/core.py b/python/lammps/core.py index 9080dd9c56..4fcda37d5d 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -2067,7 +2067,7 @@ class lammps(object): """ 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` - and :cpp:func`lammps_config_package_name` of the library interface. + and :cpp:func:`lammps_config_package_name` of the library interface. :return """ diff --git a/python/lammps/numpy_wrapper.py b/python/lammps/numpy_wrapper.py index 91042c43c8..9ab7f538de 100644 --- a/python/lammps/numpy_wrapper.py +++ b/python/lammps/numpy_wrapper.py @@ -271,11 +271,11 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def gather_bonds(self): - """Retrieve global list of bonds as NumPy array + """Retrieve global list of bonds as a NumPy array .. versionadded:: 28Jul2021 - This is a wrapper around :py:meth:`lammps.gather_bonds() ` + This is a wrapper around :py:meth:`lammps.gather_bonds() `. It behaves the same as the original method, but returns a NumPy array instead of a ``ctypes`` list. @@ -289,11 +289,11 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def gather_angles(self): - """ Retrieve global list of angles as NumPy array + """ Retrieve global list of angles as a NumPy array .. versionadded:: 8Feb2023 - This is a wrapper around :py:meth:`lammps.gather_angles() ` + This is a wrapper around :py:meth:`lammps.gather_angles() `. It behaves the same as the original method, but returns a NumPy array instead of a ``ctypes`` list. @@ -307,11 +307,11 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def gather_dihedrals(self): - """ Retrieve global list of dihedrals as NumPy array + """ Retrieve global list of dihedrals as a NumPy array .. versionadded:: 8Feb2023 - This is a wrapper around :py:meth:`lammps.gather_dihedrals() ` + This is a wrapper around :py:meth:`lammps.gather_dihedrals() `. It behaves the same as the original method, but returns a NumPy array instead of a ``ctypes`` list. @@ -325,11 +325,11 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def gather_impropers(self): - """ Retrieve global list of impropers as NumPy array + """ Retrieve global list of impropers as a NumPy array .. versionadded:: 8Feb2023 - This is a wrapper around :py:meth:`lammps.gather_impropers() ` + This is a wrapper around :py:meth:`lammps.gather_impropers() `. It behaves the same as the original method, but returns a NumPy array instead of a ``ctypes`` list. diff --git a/python/lammps/pylammps.py b/python/lammps/pylammps.py index 49a2c6cb09..9087305ba3 100644 --- a/python/lammps/pylammps.py +++ b/python/lammps/pylammps.py @@ -358,6 +358,7 @@ class Atom2D(Atom): @property def velocity(self): """Access to velocity of an atom + :getter: Return velocity of atom :setter: Set velocity of atom :type: numpy.array (float, float) @@ -372,6 +373,7 @@ class Atom2D(Atom): @property def force(self): """Access to force of an atom + :getter: Return force of atom :setter: Set force of atom :type: numpy.array (float, float) @@ -418,7 +420,7 @@ class PyLammps(object): """ This is a Python wrapper class around the lower-level :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. 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. 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()`. """ self._cmd_history.append(cmd) @@ -908,7 +910,7 @@ class PyLammps(object): 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 initialized with an existing instance. The arguments are the same of the