collapse multiple empty lines into a single empty line
This commit is contained in:
@ -56,7 +56,6 @@ output support enabled.
|
||||
|
||||
Step 1a: For the CMake based build system, the steps are:
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
mkdir $LAMMPS_DIR/build-shared
|
||||
@ -68,7 +67,6 @@ Step 1a: For the CMake based build system, the steps are:
|
||||
|
||||
Step 1b: For the legacy, make based build system, the steps are:
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd $LAMMPS_DIR/src
|
||||
@ -85,7 +83,6 @@ Step 2: Installing the LAMMPS Python package
|
||||
PyLammps is part of the lammps Python package. To install it simply install
|
||||
that package into your current Python installation with:
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make install-python
|
||||
@ -110,7 +107,6 @@ Benefits of using a virtualenv
|
||||
|
||||
**Prerequisite (e.g. on Ubuntu)**
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
apt-get install python-virtualenv
|
||||
@ -118,7 +114,6 @@ Benefits of using a virtualenv
|
||||
Creating a virtualenv with lammps installed
|
||||
"""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# create virtualenv named 'testing'
|
||||
@ -132,7 +127,6 @@ When using CMake and the shared library has already been build, you
|
||||
need to re-run CMake to update the location of the python executable
|
||||
to the location in the virtual environment with:
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cmake . -DPYTHON_EXECUTABLE=$(which python)
|
||||
@ -154,7 +148,6 @@ Creating a new instance of PyLammps
|
||||
To create a PyLammps object you need to first import the class from the lammps
|
||||
module. By using the default constructor, a new *lammps* instance is created.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
from lammps import PyLammps
|
||||
@ -162,7 +155,6 @@ module. By using the default constructor, a new *lammps* instance is created.
|
||||
|
||||
You can also initialize PyLammps on top of this existing *lammps* object:
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
from lammps import lammps, PyLammps
|
||||
@ -177,7 +169,6 @@ the command method of the lammps object instance.
|
||||
|
||||
For instance, let's take the following LAMMPS command:
|
||||
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
region box block 0 10 0 5 -0.5 0.5
|
||||
@ -185,7 +176,6 @@ For instance, let's take the following LAMMPS command:
|
||||
In the original interface this command can be executed with the following
|
||||
Python code if *L* was a lammps instance:
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
L.command("region box block 0 10 0 5 -0.5 0.5")
|
||||
@ -193,7 +183,6 @@ Python code if *L* was a lammps instance:
|
||||
With the PyLammps interface, any command can be split up into arbitrary parts
|
||||
separated by white-space, passed as individual arguments to a region method.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
L.region("box block", 0, 10, 0, 5, -0.5, 0.5)
|
||||
@ -206,7 +195,6 @@ The benefit of this approach is avoiding redundant command calls and easier
|
||||
parameterization. In the original interface parameterization needed to be done
|
||||
manually by creating formatted strings.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
L.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi))
|
||||
@ -214,7 +202,6 @@ manually by creating formatted strings.
|
||||
In contrast, methods of PyLammps accept parameters directly and will convert
|
||||
them automatically to a final command string.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi)
|
||||
@ -225,8 +212,6 @@ System state
|
||||
In addition to dispatching commands directly through the PyLammps object, it
|
||||
also provides several properties which allow you to query the system state.
|
||||
|
||||
|
||||
|
||||
L.system
|
||||
Is a dictionary describing the system such as the bounding box or number of atoms
|
||||
|
||||
@ -260,8 +245,6 @@ L.dump
|
||||
L.groups
|
||||
List of groups present in the current system
|
||||
|
||||
|
||||
|
||||
Working with LAMMPS variables
|
||||
-----------------------------
|
||||
|
||||
@ -269,7 +252,6 @@ LAMMPS variables can be both defined and accessed via the PyLammps interface.
|
||||
|
||||
To define a variable you can use the :doc:`variable <variable>` command:
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
L.variable("a index 2")
|
||||
@ -279,7 +261,6 @@ A dictionary of all variables is returned by L.variables
|
||||
you can access an individual variable by retrieving a variable object from the
|
||||
L.variables dictionary by name
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
a = L.variables['a']
|
||||
@ -287,7 +268,6 @@ L.variables dictionary by name
|
||||
The variable value can then be easily read and written by accessing the value
|
||||
property of this object.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
print(a.value)
|
||||
@ -300,7 +280,6 @@ LAMMPS expressions can be immediately evaluated by using the eval method. The
|
||||
passed string parameter can be any expression containing global thermo values,
|
||||
variables, compute or fix data.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
result = L.eval("ke") # kinetic energy
|
||||
@ -315,7 +294,6 @@ All atoms in the current simulation can be accessed by using the L.atoms list.
|
||||
Each element of this list is an object which exposes its properties (id, type,
|
||||
position, velocity, force, etc.).
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
# access first atom
|
||||
@ -329,7 +307,6 @@ position, velocity, force, etc.).
|
||||
|
||||
Some properties can also be used to set:
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
# set position in 2D simulation
|
||||
@ -347,7 +324,6 @@ after a run via the L.runs list. This list contains a growing list of run data.
|
||||
The first element is the output of the first run, the second element that of
|
||||
the second run.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
L.run(1000)
|
||||
@ -359,7 +335,6 @@ the second run.
|
||||
Each run contains a dictionary of all trajectories. Each trajectory is
|
||||
accessible through its thermo name:
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
L.runs[0].thermo.Step # list of time steps in first run
|
||||
@ -367,7 +342,6 @@ accessible through its thermo name:
|
||||
|
||||
Together with matplotlib plotting data out of LAMMPS becomes simple:
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
import matplotlib.plot as plt
|
||||
@ -406,7 +380,6 @@ tutorials and showcasing your latest research.
|
||||
To launch an instance of Jupyter simply run the following command inside your
|
||||
Python environment (this assumes you followed the Quick Start instructions):
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
jupyter notebook
|
||||
@ -429,7 +402,6 @@ Four atoms are placed in the simulation and the dihedral potential is applied on
|
||||
them using a datafile. Then one of the atoms is rotated along the central axis by
|
||||
setting its position from Python, which changes the dihedral angle.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
phi = [d \* math.pi / 180 for d in range(360)]
|
||||
@ -463,7 +435,6 @@ Initially, a 2D system is created in a state with minimal energy.
|
||||
|
||||
It is then disordered by moving each atom by a random delta.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
random.seed(27848)
|
||||
@ -483,7 +454,6 @@ It is then disordered by moving each atom by a random delta.
|
||||
Finally, the Monte Carlo algorithm is implemented in Python. It continuously
|
||||
moves random atoms by a random delta and only accepts certain moves.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
estart = L.eval("pe")
|
||||
@ -536,7 +506,6 @@ Using PyLammps and mpi4py (Experimental)
|
||||
|
||||
PyLammps can be run in parallel using mpi4py. This python package can be installed using
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install mpi4py
|
||||
@ -544,7 +513,6 @@ PyLammps can be run in parallel using mpi4py. This python package can be install
|
||||
The following is a short example which reads in an existing LAMMPS input file and
|
||||
executes it in parallel. You can find in.melt in the examples/melt folder.
|
||||
|
||||
|
||||
.. code-block:: Python
|
||||
|
||||
from mpi4py import MPI
|
||||
@ -561,7 +529,6 @@ executes it in parallel. You can find in.melt in the examples/melt folder.
|
||||
To run this script (melt.py) in parallel using 4 MPI processes we invoke the
|
||||
following mpirun command:
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
mpirun -np 4 python melt.py
|
||||
|
||||
Reference in New Issue
Block a user