Update Python docs

This commit is contained in:
Richard Berger
2020-10-05 15:07:57 -04:00
parent 8f808a5e6e
commit c06348c507
2 changed files with 9 additions and 6 deletions

View File

@ -356,6 +356,9 @@ against invalid accesses.
Retrieving or setting properties of LAMMPS objects Retrieving or setting properties of LAMMPS objects
************************************************** **************************************************
This section documents accessing or modifying data from objects like
computes, fixes, or variables in LAMMPS using the :py:mod:`lammps` module.
.. tabs:: .. tabs::
.. tab:: lammps API .. tab:: lammps API

View File

@ -350,7 +350,7 @@ which loads and runs the following function from examples/python/funcs.py:
.. code-block:: python .. code-block:: python
def loop(N,cut0,thresh,lmpptr): def loop(N,cut0,thresh,lmpptr):
print "LOOP ARGS",N,cut0,thresh,lmpptr print("LOOP ARGS", N, cut0, thresh, lmpptr)
from lammps import lammps from lammps import lammps
lmp = lammps(ptr=lmpptr) lmp = lammps(ptr=lmpptr)
natoms = lmp.get_natoms() natoms = lmp.get_natoms()
@ -365,12 +365,12 @@ which loads and runs the following function from examples/python/funcs.py:
lmp.command("pair_coeff * * 1.0 1.0") # ditto lmp.command("pair_coeff * * 1.0 1.0") # ditto
lmp.command("run 10") # ditto lmp.command("run 10") # ditto
pe = lmp.extract_compute("thermo_pe",0,0) # extract total PE from LAMMPS pe = lmp.extract_compute("thermo_pe",0,0) # extract total PE from LAMMPS
print "PE",pe/natoms,thresh print("PE", pe/natoms, thresh)
if pe/natoms < thresh: return if pe/natoms < thresh: return
with these input script commands: with these input script commands:
.. parsed-literal:: .. code-block:: LAMMPS
python loop input 4 10 1.0 -4.0 SELF format iffp file funcs.py python loop input 4 10 1.0 -4.0 SELF format iffp file funcs.py
python loop invoke python loop invoke
@ -473,11 +473,11 @@ like this:
.. code-block:: python .. code-block:: python
import exceptions import exceptions
print "Inside simple function" print("Inside simple function")
try: try:
foo += 1 # one or more statements here foo += 1 # one or more statements here
except Exception, e: except Exception as e:
print "FOO error:",e print("FOO error:", e)
then you will get this message printed to the screen: then you will get this message printed to the screen: