replace parsed-literal with code-block where applicable. improve typesetting
This commit is contained in:
@ -50,7 +50,7 @@ Examples
|
|||||||
""""""""
|
""""""""
|
||||||
|
|
||||||
|
|
||||||
.. parsed-literal::
|
.. code-block:: LAMMPS
|
||||||
|
|
||||||
python pForce input 2 v_x 20.0 return v_f format fff file force.py
|
python pForce input 2 v_x 20.0 return v_f format fff file force.py
|
||||||
python pForce invoke
|
python pForce invoke
|
||||||
@ -58,7 +58,7 @@ Examples
|
|||||||
python factorial input 1 myN return v_fac format ii here """
|
python factorial input 1 myN return v_fac format ii here """
|
||||||
def factorial(n):
|
def factorial(n):
|
||||||
if n == 1: return n
|
if n == 1: return n
|
||||||
return n \* factorial(n-1)
|
return n * factorial(n-1)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
python loop input 1 SELF return v_value format pf here """
|
python loop input 1 SELF return v_value format pf here """
|
||||||
@ -69,10 +69,10 @@ Examples
|
|||||||
# loop N times, increasing cutoff each time
|
# loop N times, increasing cutoff each time
|
||||||
|
|
||||||
for i in range(N):
|
for i in range(N):
|
||||||
cut = cut0 + i\*0.1
|
cut = cut0 + i*0.1
|
||||||
lmp.set_variable("cut",cut) # set a variable in LAMMPS
|
lmp.set_variable("cut",cut) # set a variable in LAMMPS
|
||||||
lmp.command("pair_style lj/cut ${cut}") # LAMMPS commands
|
lmp.command("pair_style lj/cut ${cut}") # LAMMPS commands
|
||||||
lmp.command("pair_coeff \* \* 1.0 1.0")
|
lmp.command("pair_coeff * * 1.0 1.0")
|
||||||
lmp.command("run 100")
|
lmp.command("run 100")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ variable. This must match the *func* setting for this command. For
|
|||||||
example these two commands would be self-consistent:
|
example these two commands would be self-consistent:
|
||||||
|
|
||||||
|
|
||||||
.. parsed-literal::
|
.. code-block:: LAMMPS
|
||||||
|
|
||||||
variable foo python myMultiply
|
variable foo python myMultiply
|
||||||
python myMultiply return v_foo format f file funcs.py
|
python myMultiply return v_foo format f file funcs.py
|
||||||
@ -262,7 +262,7 @@ consider this function loaded with two global variables defined
|
|||||||
outside the function:
|
outside the function:
|
||||||
|
|
||||||
|
|
||||||
.. parsed-literal::
|
.. code-block:: python
|
||||||
|
|
||||||
nsteplast = -1
|
nsteplast = -1
|
||||||
nvaluelast = 0
|
nvaluelast = 0
|
||||||
@ -328,7 +328,7 @@ a pointer to LAMMPS. The mechanism for doing this in your
|
|||||||
Python function is as follows:
|
Python function is as follows:
|
||||||
|
|
||||||
|
|
||||||
.. parsed-literal::
|
.. code-block:: python
|
||||||
|
|
||||||
def foo(lmpptr,...):
|
def foo(lmpptr,...):
|
||||||
from lammps import lammps
|
from lammps import lammps
|
||||||
@ -364,7 +364,7 @@ A more interesting example is in the examples/python/in.python script
|
|||||||
which loads and runs the following function from examples/python/funcs.py:
|
which loads and runs the following function from examples/python/funcs.py:
|
||||||
|
|
||||||
|
|
||||||
.. parsed-literal::
|
.. 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
|
||||||
@ -373,13 +373,13 @@ which loads and runs the following function from examples/python/funcs.py:
|
|||||||
natoms = lmp.get_natoms()
|
natoms = lmp.get_natoms()
|
||||||
|
|
||||||
for i in range(N):
|
for i in range(N):
|
||||||
cut = cut0 + i\*0.1
|
cut = cut0 + i*0.1
|
||||||
|
|
||||||
lmp.set_variable("cut",cut) # set a variable in LAMMPS
|
lmp.set_variable("cut",cut) # set a variable in LAMMPS
|
||||||
lmp.command("pair_style lj/cut ${cut}") # LAMMPS command
|
lmp.command("pair_style lj/cut ${cut}") # LAMMPS command
|
||||||
#lmp.command("pair_style lj/cut %d" % cut) # LAMMPS command option
|
#lmp.command("pair_style lj/cut %d" % cut) # LAMMPS command option
|
||||||
|
|
||||||
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
|
||||||
@ -486,7 +486,7 @@ in your Python function is failing, because you have not initialized the
|
|||||||
variable foo:
|
variable foo:
|
||||||
|
|
||||||
|
|
||||||
.. parsed-literal::
|
.. code-block:: python
|
||||||
|
|
||||||
foo += 1
|
foo += 1
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ If you put one (or more) statements inside a "try" statement,
|
|||||||
like this:
|
like this:
|
||||||
|
|
||||||
|
|
||||||
.. parsed-literal::
|
.. code-block:: python
|
||||||
|
|
||||||
import exceptions
|
import exceptions
|
||||||
print "Inside simple function"
|
print "Inside simple function"
|
||||||
|
|||||||
Reference in New Issue
Block a user