Merge pull request #2429 from rbberger/python_docs

Minor updates to the Python docs
This commit is contained in:
Axel Kohlmeyer
2020-10-20 21:12:44 -04:00
committed by GitHub
4 changed files with 59 additions and 49 deletions

View File

@ -10,45 +10,41 @@ things that are possible when Python wraps LAMMPS. If you create your
own scripts, send them to us and we can include them in the LAMMPS own scripts, send them to us and we can include them in the LAMMPS
distribution. distribution.
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| trivial.py | read/run a LAMMPS input script through Python | | ``trivial.py`` | read/run a LAMMPS input script through Python |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| demo.py | invoke various LAMMPS library interface routines | | ``demo.py`` | invoke various LAMMPS library interface routines |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| simple.py | run in parallel | | ``simple.py`` | run in parallel, similar to ``examples/COUPLE/simple/simple.cpp`` |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| similar to examples/COUPLE/simple/simple.cpp | split.py | | ``split.py`` | same as ``simple.py`` but running in parallel on a subset of procs |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| same as simple.py but running in parallel on a subset of procs | gui.py | | ``gui.py`` | GUI go/stop/temperature-slider to control LAMMPS |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| GUI go/stop/temperature-slider to control LAMMPS | plot.py | | ``plot.py`` | real-time temperature plot with GnuPlot via Pizza.py |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| real-time temperature plot with GnuPlot via Pizza.py | viz_tool.py | | ``viz_TOOL.py`` | real-time viz via some viz package |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| real-time viz via some viz package | vizplotgui_tool.py | | ``vizplotgui_TOOL.py`` | combination of ``viz_TOOL.py`` and ``plot.py`` and ``gui.py`` |
+----------------------------------------------------------------+--------------------------------------------------+ +------------------------+--------------------------------------------------------------------+
| combination of viz_tool.py and plot.py and gui.py | |
+----------------------------------------------------------------+--------------------------------------------------+
---------- For the ``viz_TOOL.py`` and ``vizplotgui_TOOL.py`` commands, replace ``TOOL``
with ``gl`` or ``atomeye`` or ``pymol`` or ``vmd``, depending on what
For the ``viz_tool.py`` and ``vizplotgui_tool.py`` commands, replace "tool"
with "gl" or "atomeye" or "pymol" or "vmd", depending on what
visualization package you have installed. visualization package you have installed.
Note that for GL, you need to be able to run the Pizza.py GL tool, Note that for GL, you need to be able to run the Pizza.py GL tool,
which is included in the pizza sub-directory. See the `Pizza.py doc pages <pizza_>`_ for more info: which is included in the pizza sub-directory. See the Pizza.py doc pages for more info:
* `https://pizza.sandia.gov <pizza_>`_
.. _pizza: https://pizza.sandia.gov .. _pizza: https://pizza.sandia.gov
Note that for AtomEye, you need version 3, and there is a line in the Note that for AtomEye, you need version 3, and there is a line in the
scripts that specifies the path and name of the executable. See the scripts that specifies the path and name of the executable. See the
AtomEye WWW pages `here <atomeye_>`_ or `here <atomeye3_>`_ for more details: AtomEye web pages for more details:
.. parsed-literal:: * `http://li.mit.edu/Archive/Graphics/A/ <atomeye_>`_
* `http://li.mit.edu/Archive/Graphics/A3/A3.html <atomeye3_>`_
http://li.mit.edu/Archive/Graphics/A/
http://li.mit.edu/Archive/Graphics/A3/A3.html
.. _atomeye: http://li.mit.edu/Archive/Graphics/A/ .. _atomeye: http://li.mit.edu/Archive/Graphics/A/
@ -59,13 +55,10 @@ capability needed by these Python scripts.
Note that for PyMol, you need to have built and installed the Note that for PyMol, you need to have built and installed the
open-source version of PyMol in your Python, so that you can import it open-source version of PyMol in your Python, so that you can import it
from a Python script. See the PyMol WWW pages `here <pymolhome_>`_ or from a Python script. See the PyMol web pages for more details:
`here <pymolopen_>`_ for more details:
.. parsed-literal:: * `https://www.pymol.org <pymolhome_>`_
* `https://github.com/schrodinger/pymol-open-source <pymolopen_>`_
https://www.pymol.org
https://github.com/schrodinger/pymol-open-source
.. _pymolhome: https://www.pymol.org .. _pymolhome: https://www.pymol.org
@ -74,15 +67,15 @@ from a Python script. See the PyMol WWW pages `here <pymolhome_>`_ or
The latter link is to the open-source version. The latter link is to the open-source version.
Note that for VMD, you need a fairly current version (1.8.7 works for Note that for VMD, you need a fairly current version (1.8.7 works for
me) and there are some lines in the pizza/vmd.py script for 4 PIZZA me) and there are some lines in the ``pizza/vmd.py`` script for 4 PIZZA
variables that have to match the VMD installation on your system. variables that have to match the VMD installation on your system.
---------- ----------
See the python/README file for instructions on how to run them and the See the ``python/README`` file for instructions on how to run them and the
source code for individual scripts for comments about what they do. source code for individual scripts for comments about what they do.
Here are screenshots of the vizplotgui_tool.py script in action for Here are screenshots of the ``vizplotgui_tool.py`` script in action for
different visualization package options: different visualization package options:
.. |pyex1| image:: img/screenshot_gl.jpg .. |pyex1| image:: img/screenshot_gl.jpg

View File

@ -57,34 +57,45 @@ it is possible to "compute" what the next LAMMPS command should be.
region box block 0 10 0 5 -0.5 0.5 region box block 0 10 0 5 -0.5 0.5
can be executed using with the lammps AI with the following Python code if *L* is an can be executed using with the lammps API with the following Python code if ``lmp`` is an
instance of :py:class:`lammps <lammps.lammps>`: instance of :py:class:`lammps <lammps.lammps>`:
.. code-block:: Python .. code-block:: Python
L.command("region box block 0 10 0 5 -0.5 0.5") from lammps import lammps
lmp = lammps()
lmp.command("region box block 0 10 0 5 -0.5 0.5")
With the PyLammps interface, any LAMMPS command can be split up into arbitrary parts. With the PyLammps interface, any LAMMPS command can be split up into arbitrary parts.
These parts are then passed to a member function with the name of the command. These parts are then passed to a member function with the name of the :doc:`command <Commands_all>`.
For the ``region`` command that means the :code:`region()` method can be called. For the :doc:`region <region>` command that means the :code:`region()` method can be called.
The arguments of the command can be passed as one string, or The arguments of the command can be passed as one string, or
individually. individually.
.. code-block:: Python .. code-block:: Python
from lammps import PyLammps
L = PyLammps()
# pass command parameters as one string
L.region("box block 0 10 0 5 -0.5 0.5")
# OR pass them individually
L.region("box block", 0, 10, 0, 5, -0.5, 0.5) L.region("box block", 0, 10, 0, 5, -0.5, 0.5)
In this example all parameters except the first are Python floating-point literals. The In the latter example, all parameters except the first are Python floating-point literals. The
PyLammps interface takes the entire parameter list and transparently member function takes the entire parameter list and transparently merges it to a single command
merges it to a single command string. string.
The benefit of this approach is avoiding redundant command calls and easier The benefit of this approach is avoiding redundant command calls and easier
parameterization. In the original interface parameterization this needed to be done parameterization. In the lammps API parameterization needed to be done
manually by creating formatted strings. manually by creating formatted command strings.
.. code-block:: Python .. code-block:: Python
L.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi)) lmp.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi))
In contrast, methods of PyLammps accept parameters directly and will convert In contrast, methods of PyLammps accept parameters directly and will convert
them automatically to a final command string. them automatically to a final command string.

View File

@ -56,7 +56,7 @@ and you should see the same output as if you had typed
Note that without the mpi4py specific lines from ``test.py`` Note that without the mpi4py specific lines from ``test.py``
.. code-block:: .. code-block:: Python
from lammps import lammps from lammps import lammps
lmp = lammps() lmp = lammps()

View File

@ -13,6 +13,12 @@ what functionality is available and give some examples how to use it.
:maxdepth: 1 :maxdepth: 1
Python_launch Python_launch
------
.. toctree::
:maxdepth: 1
Python_create Python_create
Python_execute Python_execute
Python_properties Python_properties