Unverified Commit 6d7a591d authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1762 from rbberger/doc_lammps_lexer

Add LAMMPSLexer for LAMMPS code-blocks in docs
parents bb18adc7 d2da55f5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ one line at a time and each command takes effect when it is read.
Thus this sequence of commands:


.. parsed-literal::
.. code-block:: LAMMPS

   timestep 0.5
   run      100
@@ -26,7 +26,7 @@ Thus this sequence of commands:
does something different than this sequence:


.. parsed-literal::
.. code-block:: LAMMPS

   run      100
   timestep 0.5
+9 −5
Original line number Diff line number Diff line
@@ -22,6 +22,10 @@ comment after a trailing "&" character will prevent the command from
continuing on the next line.  Also note that for multi-line commands a
single leading "#" will comment out the entire command.

.. code-block:: LAMMPS

   # this is a comment

(3) The line is searched repeatedly for $ characters, which indicate
variables that are replaced with a text string.  See an exception in
(6).
@@ -47,7 +51,7 @@ to use numeric formulas in an input script without having to assign
them to variable names.  For example, these 3 input script lines:


.. parsed-literal::
.. code-block:: LAMMPS

   variable X equal (xlo+xhi)/2+sqrt(v_area)
   region 1 block $X 2 INF INF EDGE EDGE
@@ -56,7 +60,7 @@ them to variable names. For example, these 3 input script lines:
can be replaced by


.. parsed-literal::
.. code-block:: LAMMPS

   region 1 block $((xlo+xhi)/2+sqrt(v_area)) 2 INF INF EDGE EDGE

@@ -72,7 +76,7 @@ specified a high-precision "%.20g" is used as the default.
This can be useful for formatting print output to a desired precision:


.. parsed-literal::
.. code-block:: LAMMPS

   print "Final energy per atom: $(pe/atoms:%10.3f) eV/atom"

@@ -81,7 +85,7 @@ contain nested $ characters for other variables to substitute for.
Thus you cannot do this:


.. parsed-literal::
.. code-block:: LAMMPS

   variable        a equal 2
   variable        b2 equal 4
@@ -113,7 +117,7 @@ can be enclosed in triple quotes, in which case "&" characters are not
needed.  For example:


.. parsed-literal::
.. code-block:: LAMMPS

   print "Volume = $v"
   print 'Volume = $v'
+29 −29
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ output support enabled.
Step 1a: For the CMake based build system, the steps are:


.. parsed-literal::
.. code-block:: bash

   mkdir $LAMMPS_DIR/build-shared
   cd  $LAMMPS_DIR/build-shared
@@ -69,7 +69,7 @@ Step 1a: For the CMake based build system, the steps are:
Step 1b: For the legacy, make based build system, the steps are:


.. parsed-literal::
.. code-block:: bash

   cd $LAMMPS_DIR/src

@@ -86,7 +86,7 @@ PyLammps is part of the lammps Python package. To install it simply install
that package into your current Python installation with:


.. parsed-literal::
.. code-block:: bash

   make install-python

@@ -111,7 +111,7 @@ Benefits of using a virtualenv
**Prerequisite (e.g. on Ubuntu)**


.. parsed-literal::
.. code-block:: bash

   apt-get install python-virtualenv

@@ -119,7 +119,7 @@ Creating a virtualenv with lammps installed
"""""""""""""""""""""""""""""""""""""""""""


.. parsed-literal::
.. code-block:: bash

   # create virtualenv named 'testing'
   virtualenv $HOME/python/testing
@@ -133,7 +133,7 @@ need to re-run CMake to update the location of the python executable
to the location in the virtual environment with:


.. parsed-literal::
.. code-block:: bash

   cmake . -DPYTHON_EXECUTABLE=$(which python)

@@ -155,7 +155,7 @@ 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.


.. parsed-literal::
.. code-block:: Python

   from lammps import PyLammps
   L = PyLammps()
@@ -163,7 +163,7 @@ module. By using the default constructor, a new *lammps* instance is created.
You can also initialize PyLammps on top of this existing *lammps* object:


.. parsed-literal::
.. code-block:: Python

   from lammps import lammps, PyLammps
   lmp = lammps()
@@ -178,7 +178,7 @@ the command method of the lammps object instance.
For instance, let's take the following LAMMPS command:


.. parsed-literal::
.. code-block:: LAMMPS

   region box block 0 10 0 5 -0.5 0.5

@@ -186,7 +186,7 @@ In the original interface this command can be executed with the following
Python code if *L* was a lammps instance:


.. parsed-literal::
.. code-block:: Python

   L.command("region box block 0 10 0 5 -0.5 0.5")

@@ -194,7 +194,7 @@ 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.


.. parsed-literal::
.. code-block:: Python

   L.region("box block", 0, 10, 0, 5, -0.5, 0.5)

@@ -207,7 +207,7 @@ parameterization. In the original interface parameterization needed to be done
manually by creating formatted strings.


.. parsed-literal::
.. code-block:: Python

   L.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi))

@@ -215,7 +215,7 @@ In contrast, methods of PyLammps accept parameters directly and will convert
them automatically to a final command string.


.. parsed-literal::
.. code-block:: Python

   L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi)

@@ -270,7 +270,7 @@ LAMMPS variables can be both defined and accessed via the PyLammps interface.
To define a variable you can use the :doc:`variable <variable>` command:


.. parsed-literal::
.. code-block:: Python

   L.variable("a index 2")

@@ -280,7 +280,7 @@ you can access an individual variable by retrieving a variable object from the
L.variables dictionary by name


.. parsed-literal::
.. code-block:: Python

   a = L.variables['a']

@@ -288,7 +288,7 @@ The variable value can then be easily read and written by accessing the value
property of this object.


.. parsed-literal::
.. code-block:: Python

   print(a.value)
   a.value = 4
@@ -301,7 +301,7 @@ passed string parameter can be any expression containing global thermo values,
variables, compute or fix data.


.. parsed-literal::
.. code-block:: Python

   result = L.eval("ke") # kinetic energy
   result = L.eval("pe") # potential energy
@@ -316,7 +316,7 @@ Each element of this list is an object which exposes its properties (id, type,
position, velocity, force, etc.).


.. parsed-literal::
.. code-block:: Python

   # access first atom
   L.atoms[0].id
@@ -330,7 +330,7 @@ position, velocity, force, etc.).
Some properties can also be used to set:


.. parsed-literal::
.. code-block:: Python

   # set position in 2D simulation
   L.atoms[0].position = (1.0, 0.0)
@@ -348,7 +348,7 @@ The first element is the output of the first run, the second element that of
the second run.


.. parsed-literal::
.. code-block:: Python

   L.run(1000)
   L.runs[0] # data of first 1000 time steps
@@ -360,7 +360,7 @@ Each run contains a dictionary of all trajectories. Each trajectory is
accessible through its thermo name:


.. parsed-literal::
.. code-block:: Python

   L.runs[0].step # list of time steps in first run
   L.runs[0].ke   # list of kinetic energy values in first run
@@ -370,7 +370,7 @@ Together with matplotlib plotting data out of LAMMPS becomes simple:
import matplotlib.plot as plt


.. parsed-literal::
.. code-block:: Python

   steps = L.runs[0].step
   ke    = L.runs[0].ke
@@ -408,7 +408,7 @@ To launch an instance of Jupyter simply run the following command inside your
Python environment (this assumes you followed the Quick Start instructions):


.. parsed-literal::
.. code-block:: bash

   jupyter notebook

@@ -431,7 +431,7 @@ them using a datafile. Then one of the atoms is rotated along the central axis b
setting its position from Python, which changes the dihedral angle.


.. parsed-literal::
.. code-block:: Python

   phi = [d \* math.pi / 180 for d in range(360)]

@@ -465,7 +465,7 @@ Initially, a 2D system is created in a state with minimal energy.
It is then disordered by moving each atom by a random delta.


.. parsed-literal::
.. code-block:: Python

   random.seed(27848)
   deltaperturb = 0.2
@@ -485,7 +485,7 @@ Finally, the Monte Carlo algorithm is implemented in Python. It continuously
moves random atoms by a random delta and only accepts certain moves.


.. parsed-literal::
.. code-block:: Python

   estart = L.eval("pe")
   elast = estart
@@ -538,7 +538,7 @@ Using PyLammps and mpi4py (Experimental)
PyLammps can be run in parallel using mpi4py. This python package can be installed using


.. parsed-literal::
.. code-block:: bash

   pip install mpi4py

@@ -546,7 +546,7 @@ The following is a short example which reads in an existing LAMMPS input file an
executes it in parallel.  You can find in.melt in the examples/melt folder.


.. parsed-literal::
.. code-block:: Python

   from mpi4py import MPI
   from lammps import PyLammps
@@ -563,7 +563,7 @@ To run this script (melt.py) in parallel using 4 MPI processes we invoke the
following mpirun command:


.. parsed-literal::
.. code-block:: bash

   mpirun -np 4 python melt.py

+17 −41
Original line number Diff line number Diff line
@@ -20,29 +20,21 @@ directories and files should be included.

If you downloaded LAMMPS from the public SVN or Git repositories, then
the HTML and PDF files are not included.  Instead you need to create
them, in one of three ways:
them, in one of two ways:

(a) You can "fetch" the current HTML and PDF files from the LAMMPS web
site.  Just type "make fetch".  This should create a html\_www dir and
Manual\_www.pdf/Developer\_www.pdf files.  Note that if new LAMMPS
features have been added more recently than the date of your version,
the fetched documentation will include those changes (but your source
code will not, unless you update your local repository).
a. You can "fetch" the current HTML and PDF files from the LAMMPS web site.
   Just type "make fetch".  This should create a html\_www dir and
   Manual\_www.pdf/Developer\_www.pdf files.  Note that if new LAMMPS features
   have been added more recently than the date of your version, the fetched
   documentation will include those changes (but your source code will not, unless
   you update your local repository).

(b) You can build the HTML and PDF files yourself, by typing "make
b. You can build the HTML and PDF files yourself, by typing "make
   html" followed by "make pdf".  Note that the PDF make requires the
   HTML files already exist.  This requires various tools including
   Sphinx, which the build process will attempt to download and install
   on your system, if not already available.  See more details below.

(c) You can generate an older, simpler, less-fancy style of HTML
documentation by typing "make old".  This will create an "old"
directory.  This can be useful if (b) does not work on your box for
some reason, or you want to quickly view the HTML version of a doc
page you have created or edited yourself within the src directory.
E.g. if you are planning to submit a new feature to LAMMPS.


----------


@@ -50,14 +42,13 @@ The generation of all documentation is managed by the Makefile in
the doc dir.


.. parsed-literal::
.. code-block:: bash

   Documentation Build Options:

   make html         # generate HTML in html dir using Sphinx
   make pdf          # generate 2 PDF files (Manual.pdf,Developer.pdf)
                     #   in doc dir via htmldoc and pdflatex
   make old          # generate old-style HTML pages in old dir via txt2html
   make fetch        # fetch HTML doc pages and 2 PDF files from web site
                     #   as a tarball and unpack into html dir and 2 PDFs
   make epub         # generate LAMMPS.epub in ePUB format using Sphinx
@@ -82,7 +73,7 @@ Ubuntu
------


.. parsed-literal::
.. code-block:: bash

   sudo apt-get install python-virtualenv

@@ -90,7 +81,7 @@ Fedora (up to version 21) and Red Hat Enterprise Linux or CentOS (up to version
------------------------------------------------------------------------------------


.. parsed-literal::
.. code-block:: bash

   sudo yum install python3-virtualenv

@@ -98,7 +89,7 @@ Fedora (since version 22)
-------------------------


.. parsed-literal::
.. code-block:: bash

   sudo dnf install python3-virtualenv

@@ -119,7 +110,7 @@ virtualenv
Once Python 3 is installed, open a Terminal and type


.. parsed-literal::
.. code-block:: bash

   pip3 install virtualenv

@@ -129,21 +120,6 @@ This will install virtualenv from the Python Package Index.
----------


Installing prerequisites for PDF build

Building the PDF manual requires a working C++ compiler (to
compile the txt2html tool and a working installation of
`HTMLDOC <https://www.msweet.org/htmldoc/>`_
HTMLDOC has its own list of prerequisites, but in most cases
you can install a binary package of it either through your
Linux package manager or MacOS (dmg) and Windows installer
(msi) packages from its
`GitHub releases page at <https://github.com/michaelrsweet/htmldoc/releases>`_


----------


Installing prerequisites for epub build
=======================================

doc/txt/Commands_input.txt

deleted100644 → 0
+0 −60
Original line number Diff line number Diff line
"Higher level section"_Commands.html - "LAMMPS WWW Site"_lws - "LAMMPS
Documentation"_ld - "LAMMPS Commands"_lc :c

:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Commands_all.html)

:line

LAMMPS input scripts :h3

LAMMPS executes by reading commands from a input script (text file),
one line at a time.  When the input script ends, LAMMPS exits.  Each
command causes LAMMPS to take some action.  It may set an internal
variable, read in a file, or run a simulation.  Most commands have
default settings, which means you only need to use the command if you
wish to change the default.

In many cases, the ordering of commands in an input script is not
important.  However the following rules apply:

(1) LAMMPS does not read your entire input script and then perform a
simulation with all the settings.  Rather, the input script is read
one line at a time and each command takes effect when it is read.
Thus this sequence of commands:

timestep 0.5
run      100
run      100 :pre

does something different than this sequence:

run      100
timestep 0.5
run      100 :pre

In the first case, the specified timestep (0.5 fs) is used for two
simulations of 100 timesteps each.  In the 2nd case, the default
timestep (1.0 fs) is used for the 1st 100 step simulation and a 0.5 fs
timestep is used for the 2nd one.

(2) Some commands are only valid when they follow other commands.  For
example you cannot set the temperature of a group of atoms until atoms
have been defined and a group command is used to define which atoms
belong to the group.

(3) Sometimes command B will use values that can be set by command A.
This means command A must precede command B in the input script if it
is to have the desired effect.  For example, the
"read_data"_read_data.html command initializes the system by setting
up the simulation box and assigning atoms to processors.  If default
values are not desired, the "processors"_processors.html and
"boundary"_boundary.html commands need to be used before read_data to
tell LAMMPS how to map processors to the simulation box.

Many input script errors are detected by LAMMPS and an ERROR or
WARNING message is printed.  The "Errors"_Errors.html doc page gives
more information on what errors mean.  The documentation for each
command lists restrictions on how the command can be used.
Loading