Skip to content

Commit e544529

Browse files
committed
keep updating the tutorials
1 parent db34346 commit e544529

File tree

3 files changed

+121
-152
lines changed

3 files changed

+121
-152
lines changed

docs/sphinx/source/tutorial1/tutorial.rst

Lines changed: 88 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ To run a simulation using LAMMPS, you need to write an input script
55
containing a series of commands for LAMMPS to execute, similar to Python
66
or Bash scripts. For clarity, the input scripts for this tutorial will
77
be divided into five categories, which will be filled out step by step.
8-
To set up this tutorial, navigate to the directory
9-
where you want to store your files. Create a folder if needed and
10-
place the initial input file, **initial.lmp**, into it. Then, open the
11-
file in a text editor of your choice, and copy the following into it:
8+
To set up this tutorial using LAMMPS graphical user interface
9+
(LAMMPS--GUI) :cite:`lammps_gui_docs`, select ``Start LAMMPS Tutorial 1``
10+
from the ``Tutorials`` menu and follow the instructions. This will
11+
select (or create, if needed) a folder, place the initial input
12+
file **initial.lmp** in it, and open the file in the LAMMPS--GUI Editor window:
1213

1314
.. code-block:: lammps
1415
@@ -17,18 +18,15 @@ file in a text editor of your choice, and copy the following into it:
1718
# 2) System definition
1819
# 3) Settings
1920
# 4) Visualization
20-
# 5) Run
21+
# 5) Run
2122
22-
.. admonition:: Optional: follow this tutorial using LAMMPS-GUI
23+
.. admonition:: If you are not using LAMMPS-GUI
2324
:class: gui
2425

25-
This tutorial can also be followed using LAMMPS graphical
26-
user interface (LAMMPS--GUI) :cite:`lammps_gui_docs`.
27-
Select ``Start LAMMPS Tutorial 1`` from
28-
the ``Tutorials`` menu of LAMMPS--GUI, and follow the
29-
instructions. This will select (or create, if needed) a folder, place
30-
the initial input file **initial.lmp** in it, and open the file in
31-
the LAMMPS--GUI Editor window.
26+
All tutorials can be followed without using LAMMPS-GUI. To
27+
do so, create a new folder and add a file named **initial.lmp**
28+
inside it. Open the file in a text editor of your choice and
29+
copy the previous lines into it.
3230

3331
Everything that appears after a hash symbol (#) is a comment
3432
and ignored by LAMMPS. These five categories are not required in every input script an do not
@@ -96,15 +94,11 @@ slab geometries.
9694

9795
Each LAMMPS command is accompanied by extensive online documentation
9896
that details the different options for that command :cite:`lammps_docs`.
99-
100-
.. admonition:: If you are using LAMMPS-GUI
101-
:class: gui
102-
103-
From the LAMMPS--GUI editor buffer, you can access the documentation by
104-
right-clicking on a line containing a command (e.g., ``units lj``)
105-
and selecting ``View Documentation for `units'``. This action
106-
should prompt your web browser to open the corresponding URL for the
107-
online manual.
97+
From the LAMMPS--GUI editor buffer, you can access the documentation by
98+
right-clicking on a line containing a command (e.g., ``units lj``)
99+
and selecting ``View Documentation for `units'``. This action
100+
should prompt your web browser to open the corresponding URL for the
101+
online manual.
108102

109103
The next step is to create the simulation box and populate it with
110104
atoms. Modify the ``System definition`` category of
@@ -220,24 +214,21 @@ You can now run LAMMPS (basic commands for running LAMMPS
220214
are provided in Ref. :cite:`lammps_run_basics`).
221215
The simulation should finish quickly.
222216

223-
.. admonition:: If you are using LAMMPS-GUI
224-
:class: gui
225-
226-
With the default settings, LAMMPS--GUI will open two windows: one
227-
displaying the console output and another with a chart. The ``Output`` window
228-
will display information from the executed commands, including the
229-
total energy and pressure at step 0,
230-
as specified by the thermodynamic data request. Since no actual simulation
231-
steps were performed, the ``Charts`` window will be empty.
232-
233-
**Snapshot image --** At this point, you can create a snapshot image of the current system
234-
using the ``Image Viewer`` window, which can be accessed by
235-
clicking the ``Create Image`` button in the ``Run`` menu. The
236-
image viewer works by instructing LAMMPS to render an image of the
237-
current system using its internal rendering library via the ``dump image``
238-
command. The resulting image is then displayed, with various
239-
buttons available to adjust the view and rendering style. This will always
240-
capture the current state of the system.
217+
With the default settings, LAMMPS--GUI will open two windows: one
218+
displaying the console output and another with a chart. The ``Output`` window
219+
will display information from the executed commands, including the
220+
total energy and pressure at step 0,
221+
as specified by the thermodynamic data request. Since no actual simulation
222+
steps were performed, the ``Charts`` window will be empty.
223+
224+
**Snapshot image --** At this point, you can create a snapshot image of the current system
225+
using the ``Image Viewer`` window, which can be accessed by
226+
clicking the ``Create Image`` button in the ``Run`` menu. The
227+
image viewer works by instructing LAMMPS to render an image of the
228+
current system using its internal rendering library via the ``dump image``
229+
command. The resulting image is then displayed, with various
230+
buttons available to adjust the view and rendering style. This will always
231+
capture the current state of the system.
241232

242233
Energy minimization
243234
-------------------
@@ -259,17 +250,14 @@ as the minimizer algorithm cannot find a way to lower the potential
259250
energy. Note that, except for trivial systems, minimization algorithms will find a
260251
local minimum rather than the global minimum.
261252

262-
.. admonition:: If you are using LAMMPS-GUI
263-
:class: gui
264-
265-
Run the minimization and observe that LAMMPS-GUI captures the output
266-
and updates the chart in real time. This run executes quickly (depending
267-
on your computer's capabilities), but LAMMPS-GUI may fail to capture some
268-
of the thermodynamic data. In that
269-
case, use the ``Preferences`` dialog to reduce the data update
270-
interval and switch to single-threaded, unaccelerated execution in the
271-
``Accelerators`` tab. You can repeat the run; each new attempt will start
272-
fresh, resetting the system and re-executing the script from the beginning.
253+
Run the minimization and observe that LAMMPS-GUI captures the output
254+
and updates the chart in real time. This run executes quickly (depending
255+
on your computer's capabilities), but LAMMPS-GUI may fail to capture some
256+
of the thermodynamic data. In that
257+
case, use the ``Preferences`` dialog to reduce the data update
258+
interval and switch to single-threaded, unaccelerated execution in the
259+
``Accelerators`` tab. You can repeat the run; each new attempt will start
260+
fresh, resetting the system and re-executing the script from the beginning.
273261

274262
Run the minimization. The potential energy, :math:`U`, decreases
275263
from a positive value to a negative value
@@ -286,11 +274,10 @@ decreases - first rapidly - then more gradually, before plateauing at a
286274
negative value. This indicates that the atoms have moved to reasonable
287275
distances from one another.
288276

289-
..
290-
Create and save a snapshot image of the simulation state after the
291-
minimization, and compare it to the initial image. You should observe
292-
that the atoms are *clumping together* as they move toward positions
293-
of lower potential energy.
277+
Create and save a snapshot image of the simulation state after the
278+
minimization, and compare it to the initial image. You should observe
279+
that the atoms are *clumping together* as they move toward positions
280+
of lower potential energy.
294281

295282
Molecular dynamics
296283
------------------
@@ -394,20 +381,17 @@ it reaches a plateau value of about -0.25. The kinetic energy,
394381
increases rapidly during molecular dynamics until it reaches
395382
a plateau value of about 1.5.
396383

397-
.. admonition:: If you are using LAMMPS-GUI
398-
:class: gui
399-
400-
From the information
401-
printed in the ``Output`` window, one can see that the temperature
402-
starts from 0 but rapidly reaches the requested value and
403-
stabilizes itself near :math:`T=1` temperature units. One can also observe that
404-
the potential energy, :math:`U`, rapidly decreases during energy
405-
minimization (see the figure below). After
406-
the molecular dynamics simulation starts, :math:`U` increases until
407-
it reaches a plateau value of about -0.25. The kinetic energy,
408-
:math:`K`, is equal to zero during energy minimization and then
409-
increases rapidly during molecular dynamics until it reaches
410-
a plateau value of about 1.5.
384+
From the information
385+
printed in the ``Output`` window, one can see that the temperature
386+
starts from 0 but rapidly reaches the requested value and
387+
stabilizes itself near :math:`T=1` temperature units. One can also observe that
388+
the potential energy, :math:`U`, rapidly decreases during energy
389+
minimization (see the figure below). After
390+
the molecular dynamics simulation starts, :math:`U` increases until
391+
it reaches a plateau value of about -0.25. The kinetic energy,
392+
:math:`K`, is equal to zero during energy minimization and then
393+
increases rapidly during molecular dynamics until it reaches
394+
a plateau value of about 1.5.
411395

412396
.. figure:: figures/LJ-energy-dm.png
413397
:class: only-dark
@@ -444,42 +428,38 @@ Run the **initial.lmp** file using LAMMPS again. A file named **dump.lammpstrj**
444428
must appear alongside **initial.lmp**. The **.lammpstrj** file can be opened
445429
using VMD :cite:`vmd_home, humphrey1996vmd` or OVITO :cite:`ovito_home, ovito_paper`.
446430

447-
.. admonition:: If you are using LAMMPS-GUI
448-
:class: gui
431+
Use the ``dump image`` command to create snapshot images during the simulation. We
432+
have already explored the ``Image Viewer`` window. Open it again
433+
and adjust the visualization to your liking using the available buttons.
434+
Now you can copy the commands used to create this visualization to the
435+
clipboard by either using the ``Ctrl-D`` keyboard shortcut or
436+
selecting ``Copy dump image command`` from the ``File`` menu.
437+
This text can be pasted into the ``Visualization`` section
438+
of ``PART B`` of the **initial.lmp** file. This may look like
439+
the following:
440+
441+
.. code-block:: lammps
449442
450-
Use the ``dump image``
451-
command to create snapshot images during the simulation. We
452-
have already explored the ``Image Viewer`` window. Open it again
453-
and adjust the visualization to your liking using the available buttons.
454-
Now you can copy the commands used to create this visualization to the
455-
clipboard by either using the ``Ctrl-D`` keyboard shortcut or
456-
selecting ``Copy dump image command`` from the ``File`` menu.
457-
This text can be pasted into the ``Visualization`` section
458-
of ``PART B`` of the **initial.lmp** file. This may look like
459-
the following:
460-
461-
.. code-block:: lammps
462-
463-
dump viz all image 100 myimage-*.ppm type type size 800 800 zoom 1.452 shiny 0.7 fsaa yes &
464-
view 80 10 box yes 0.025 axes no 0.0 0.0 center s 0.483725 0.510373 0.510373
465-
dump_modify viz pad 9 boxcolor royalblue backcolor white adiam 1 1.6 adiam 2 4.8
466-
467-
This command tells LAMMPS to generate NetPBM format images every 100
468-
steps. The two ``type`` keywords are for *color* and
469-
*diameter*, respectively. Run the **initial.lmp** using
470-
LAMMPS again, and a new window named ``Slide Show`` will pop up.
471-
It will show each image created by the ``dump image`` as it is
472-
created. After the simulation is finished (or stopped), the slideshow
473-
viewer allows you to animate the trajectory by cycling through the
474-
images. The window also allows you to export the animation to a movie
475-
(provided the FFMpeg program is installed) and to bulk delete those
476-
image files.
477-
478-
The rendering of the system can be further adjusted using the many
479-
options of the ``dump image`` command. For instance, the value for the
480-
``shiny`` keyword is used to adjust the shininess of the atoms, the
481-
``box`` keyword adds or removes a representation of the box, and
482-
the ``view`` and ``zoom`` keywords adjust the camera (and so on).
443+
dump viz all image 100 myimage-*.ppm type type size 800 800 zoom 1.452 shiny 0.7 fsaa yes &
444+
view 80 10 box yes 0.025 axes no 0.0 0.0 center s 0.483725 0.510373 0.510373
445+
dump_modify viz pad 9 boxcolor royalblue backcolor white adiam 1 1.6 adiam 2 4.8
446+
447+
This command tells LAMMPS to generate NetPBM format images every 100
448+
steps. The two ``type`` keywords are for *color* and
449+
*diameter*, respectively. Run the **initial.lmp** using
450+
LAMMPS again, and a new window named ``Slide Show`` will pop up.
451+
It will show each image created by the ``dump image`` as it is
452+
created. After the simulation is finished (or stopped), the slideshow
453+
viewer allows you to animate the trajectory by cycling through the
454+
images. The window also allows you to export the animation to a movie
455+
(provided the FFMpeg program is installed) and to bulk delete those
456+
image files.
457+
458+
The rendering of the system can be further adjusted using the many
459+
options of the ``dump image`` command. For instance, the value for the
460+
``shiny`` keyword is used to adjust the shininess of the atoms, the
461+
``box`` keyword adds or removes a representation of the box, and
462+
the ``view`` and ``zoom`` keywords adjust the camera (and so on).
483463

484464
Improving the script
485465
====================
@@ -556,12 +536,9 @@ the ``minimize`` command:
556536
Run the **improved.min.lmp** file using LAMMPS--GUI. At the end
557537
of the simulation, a file called **improved.min.data** is created.
558538

559-
.. admonition:: If you are using LAMMPS-GUI
560-
:class: gui
561-
562-
You can view the contents of **improved.min.data** from LAMMPS--GUI, by
563-
right-clicking on the file name in the editor and selecting the entry
564-
``View file improved.min.data``.
539+
You can view the contents of **improved.min.data** from LAMMPS--GUI, by
540+
right-clicking on the file name in the editor and selecting the entry
541+
``View file improved.min.data``.
565542

566543
The created **.data** file contains all the information necessary
567544
to restart the simulation, such as the number of atoms, the box size,

docs/sphinx/source/tutorial2/tutorial.rst

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ by maintaining the relative orientations of neighboring atoms.
1212
The LAMMPS input
1313
----------------
1414

15-
Create a folder if needed and
16-
place the initial input file, **unbreakable.lmp**, into it. Then, open the
17-
file in a text editor of your choice, and copy the following into it:
15+
To begin this tutorial, if you are using LAMMPS--GUI, select
16+
``Start Tutorial 2`` from the ``Tutorials`` menu of LAMMPS-GUI
17+
and follow the instructions. This will select a folder, create one if
18+
necessary, and place several files into it. The initial input file,
19+
set up for a single-point energy calculation, will also be loaded into
20+
the editor under the name **unbreakable.lmp**. Additional files
21+
are a data file containing the CNT topology and geometry, named
22+
**unbreakable.data**, a parameters file named **unbreakable.inc**, as well as
23+
the scripts required for the second part of the tutorial.
1824

1925
.. code-block:: lammps
2026
@@ -34,17 +40,12 @@ file in a text editor of your choice, and copy the following into it:
3440
3541
run 0 post no
3642
37-
.. admonition:: If you are using LAMMPS-GUI
43+
.. admonition:: If you are not using LAMMPS-GUI
3844
:class: gui
3945

40-
Select ``Start Tutorial 2`` from the ``Tutorials``
41-
menu of LAMMPS-GUI and follow the instructions. This will select a folder,
42-
create one if necessary, and place several files into it. The initial
43-
input file, set up for a single-point energy calculation, will also be
44-
loaded into the editor under the name **unbreakable.lmp**. Additional files
45-
are a data file containing the CNT topology and geometry, named
46-
**unbreakable.data**, a parameters file named **unbreakable.inc**, as well as
47-
the scripts required for the second part of the tutorial.
46+
Create a folder if needed and
47+
place the initial input file, **unbreakable.lmp**, into it. Then, open the
48+
file in a text editor of your choice, and copy the previous lines into it.
4849

4950
The chosen unit system is ``real`` (therefore distances are in
5051
Ångströms (Å), times in femtoseconds (fs), and energies in kcal/mol), the
@@ -78,12 +79,6 @@ as well as the identity of the atoms that are linked by ``bonds``, ``angles``,
7879

7980
<a href="../../../../../.dependencies/lammpstutorials-inputs/tutorial2/unbreakable.data" target="_blank">unbreakable.data</a>
8081

81-
.. admonition:: If you are using LAMMPS-GUI
82-
:class: gui
83-
84-
The **unbreakable.data** file that should have been downloaded next
85-
to **unbreakable.lmp** during the tutorial setup.
86-
8782
.. admonition:: Note
8883
:class: non-title-info
8984

@@ -364,28 +359,25 @@ from the typical dependency of bond energy with bond distance,
364359
Importing YAML log file into Python
365360
-----------------------------------
366361

367-
.. admonition:: If you are using LAMMPS-GUI
368-
:class: gui
369-
370-
Let us import the simulation data into Python, and generate a stress-strain curve.
371-
Here, the stress is defined as :math:`F_\text{cnt}/A_\text{cnt}`,
372-
where :math:`A_\text{cnt} = \pi r_\text{cnt}^2` is the surface area of the
373-
CNT, and :math:`r_\text{cnt}=5.2\,\text{Å}` the CNT radius. The strain is defined
374-
as :math:`(L_\text{cnt}-L_\text{cnt-0})/L_\text{cnt-0}`, where :math:`L_\text{cnt-0}` is the initial CNT length.
375-
376-
Right-click inside the ``Output`` window, and select
377-
``Export YAML data to file``. Call the output **unbreakable.yaml**, and save
378-
it within the same folder as the input files, where a Python script named |yaml_reader| should also
379-
be located. When executed using Python, this .py file first imports
380-
the **unbreakable.yaml** file. Then, a certain pattern is
381-
identified and stored as a string character named ``docs``. The string is
382-
then converted into a list, and :math:`F_\text{cnt}` and :math:`L_\text{cnt}`
383-
are extracted. The stress and strain are then calculated, and the result
384-
is saved in a data file named **unbreakable.dat** using
385-
the NumPy ``savetxt`` function. ``thermo[0]`` can be used to access the
386-
information from the first minimization run, and ``thermo[1]`` to access the
387-
information from the second MD run. The data extracted from
388-
the **unbreakable.yaml** file can then be used to plot the stress-strain curve.
362+
Let us import the simulation data into Python, and generate a stress-strain curve.
363+
Here, the stress is defined as :math:`F_\text{cnt}/A_\text{cnt}`,
364+
where :math:`A_\text{cnt} = \pi r_\text{cnt}^2` is the surface area of the
365+
CNT, and :math:`r_\text{cnt}=5.2\,\text{Å}` the CNT radius. The strain is defined
366+
as :math:`(L_\text{cnt}-L_\text{cnt-0})/L_\text{cnt-0}`, where :math:`L_\text{cnt-0}` is the initial CNT length.
367+
368+
Right-click inside the ``Output`` window, and select
369+
``Export YAML data to file``. Call the output **unbreakable.yaml**, and save
370+
it within the same folder as the input files, where a Python script named |yaml_reader| should also
371+
be located. When executed using Python, this .py file first imports
372+
the **unbreakable.yaml** file. Then, a certain pattern is
373+
identified and stored as a string character named ``docs``. The string is
374+
then converted into a list, and :math:`F_\text{cnt}` and :math:`L_\text{cnt}`
375+
are extracted. The stress and strain are then calculated, and the result
376+
is saved in a data file named **unbreakable.dat** using
377+
the NumPy ``savetxt`` function. ``thermo[0]`` can be used to access the
378+
information from the first minimization run, and ``thermo[1]`` to access the
379+
information from the second MD run. The data extracted from
380+
the **unbreakable.yaml** file can then be used to plot the stress-strain curve.
389381

390382
.. |yaml_reader| raw:: html
391383

docs/sphinx/source/tutorial7/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Method 1: Free sampling
1212
=======================
1313

1414
The most direct way to calculate a free energy profile is to extract the
15-
partition function from a classical (i.e.~unbiased) molecular dynamics
15+
partition function from a classical (i.e. unbiased) molecular dynamics
1616
simulation, and then estimate the Gibbs free energy by using
1717

1818
.. math::

0 commit comments

Comments
 (0)