File: README.md

package info (click to toggle)
lammps 20251210%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 465,808 kB
  • sloc: cpp: 1,031,565; python: 26,771; ansic: 8,808; f90: 7,302; sh: 5,316; perl: 4,171; fortran: 2,442; xml: 1,613; makefile: 1,119; objc: 238; lisp: 188; yacc: 58; csh: 16; awk: 14; tcl: 6; javascript: 2
file content (89 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# IPython and Jupyter Notebooks

This folder contains examples showcasing the usage of the LAMMPS Python
interface and Jupyter notebooks. To use this you will need LAMMPS compiled as
a shared library and the LAMMPS Python package installed.

An extensive guide on how to achieve this is documented in the [LAMMPS manual](https://docs.lammps.org/Python_install.html). There is also a [LAMMPS Python tutorial](https://docs.lammps.org/Howto_python.html).

The following will show one way of creating a Python virtual environment
which has both LAMMPS and its Python package installed:

1. Clone the LAMMPS source code

   ```shell
   $ git clone -b stable https://github.com/lammps/lammps.git
   $ cd lammps
   ```

2. Create a build folder

   ```shell
   $ mkdir build
   $ cd build
   ```

3. Create a virtual environment for Python

   ```shell
   $ python3 -m venv myenv
   ```

4. Extend `LD_LIBRARY_PATH` (Unix/Linux) or `DYLD_LIBRARY_PATH` (MacOS)

   On Unix/Linux:
   ```shell
   $ echo 'export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$LD_LIBRARY_PATH' >> myenv/bin/activate
   ```

   On MacOS:
   ```shell
   echo 'export DYLD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$DYLD_LIBRARY_PATH' >> myenv/bin/activate
   ```

5. Activate the virtual environment

   ```shell
   $ source myenv/bin/activate
   (myenv)$
   ```

6. Configure LAMMPS compilation (CMake)

   ```shell
   (myenv)$ cmake -C ../cmake/presets/basic.cmake \
                  -D BUILD_SHARED_LIBS=on \
                  -D PKG_PYTHON=on \
                  -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV \
                  ../cmake
   ```

7. Compile LAMMPS

   ```shell
   (myenv)$ cmake --build .
   ```

8. Install LAMMPS and Python package into virtual environment

   ```shell
   (myenv)$ make install-python
   ```

9. Install other Python packages into virtual environment

   ```shell
   (myenv)$ pip install jupyter matplotlib pandas mpi4py
   ```

10. Navigate to ipython examples folder

    ```shell
    (myenv)$ cd ../python/examples/ipython
    ```

11. Launch Jupyter and work inside browser

    ```shell
    (myenv)$ jupyter notebook
    ```