Update Jupyter notebooks

This commit is contained in:
Richard Berger
2021-03-16 15:18:07 -04:00
parent 32a2ee6dc2
commit 45b01aba0c
4 changed files with 112 additions and 151 deletions

View File

@ -4,72 +4,29 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using LAMMPS with iPython and Jupyter"
"# Example 3: 2D circle of particles inside of box with LJ walls"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"LAMMPS can be run interactively using iPython easily. This tutorial shows how to set this up."
"## Prerequisites\n",
"\n",
"Before running this example, make sure your Python environment can find the LAMMPS shared library (`liblammps.so`) and the LAMMPS Python package is installed. If you followed the [README](README.md) in this folder, this should already be the case. You can also find more information about how to compile LAMMPS and install the LAMMPS Python package in the [LAMMPS manual](https://lammps.sandia.gov/doc/Python_install.html). There is also a dedicated [PyLammps HowTo](https://lammps.sandia.gov/doc/Howto_pylammps.html)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Download the latest version of LAMMPS into a folder (we will calls this `$LAMMPS_DIR` from now on)\n",
"2. Compile LAMMPS as a shared library and enable exceptions and PNG support\n",
" ```bash\n",
" cd $LAMMPS_DIR/src\n",
" make yes-molecule\n",
" make mpi mode=shlib LMP_INC=\"-DLAMMPS_PNG -DLAMMPS_EXCEPTIONS\" JPG_LIB=\"-lpng\"\n",
" ```\n",
"\n",
"3. Create a python virtualenv\n",
" ```bash\n",
" virtualenv testing\n",
" source testing/bin/activate\n",
" ```\n",
"\n",
"4. Inside the virtualenv install the lammps package\n",
" ```\n",
" (testing) cd $LAMMPS_DIR/python\n",
" (testing) python install.py\n",
" (testing) cd # move to your working directory\n",
" ```\n",
"\n",
"5. Install jupyter and ipython in the virtualenv\n",
" ```bash\n",
" (testing) pip install ipython jupyter\n",
" ```\n",
"\n",
"6. Run jupyter notebook\n",
" ```bash\n",
" (testing) jupyter notebook\n",
" ```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example"
"## Setup system"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from lammps import IPyLammps"
@ -135,6 +92,13 @@
"L.fix(3, \"all wall/lj93 ylo 0.0 1 1 2.5 yhi\", y, \"1 1 2.5\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualize initial state"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -144,6 +108,13 @@
"L.image(zoom=1.8)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Run simulation and visualize new state"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -254,9 +225,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"L.variable(\"a index 2\")"
@ -274,9 +243,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"L.variable(\"t equal temp\")"
@ -332,9 +299,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"L.variable(\"b index a b c\")"
@ -370,9 +335,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"L.variable(\"i loop 10\")"
@ -428,7 +391,7 @@
"metadata": {},
"outputs": [],
"source": [
"[x for x in dir(L.atoms[0]) if not x.startswith('__')]"
"dir(L.atoms[0])"
]
},
{
@ -479,9 +442,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": []
}
@ -502,7 +463,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.9.2"
}
},
"nbformat": 4,