|
25 | 25 | "source": [ |
26 | 26 | "## Set up environment (optional)\n", |
27 | 27 | "\n", |
28 | | - "These steps are required for Google Colab, but may work on other systems too:" |
| 28 | + "These steps are required to run this tutorial with Google Colab. To do so, uncomment and run the cell below.\n", |
| 29 | + "\n", |
| 30 | + "This will replace pre-installed versions of `numpy` and `torch` in Colab with versions that are known to be compatible with `janus-core`.\n", |
| 31 | + "\n", |
| 32 | + "It may be possible to skip the steps that uninstall and reinstall `torch`, which will save a considerable amount of time.\n", |
| 33 | + "\n", |
| 34 | + "These instructions but may work for other systems too, but it is typically preferable to prepare a virtual environment separately before running this notebook if possible." |
29 | 35 | ] |
30 | 36 | }, |
31 | 37 | { |
|
39 | 45 | "# import locale\n", |
40 | 46 | "# locale.getpreferredencoding = lambda: \"UTF-8\"\n", |
41 | 47 | "\n", |
42 | | - "# ! pip uninstall torch torchaudio torchvision transformers numpy -y\n", |
43 | | - "# ! uv pip install janus-core[all] data-tutorials torch==2.5.1 --system\n", |
44 | | - "# get_ipython().kernel.do_shutdown(restart=True)" |
| 48 | + "# ! pip uninstall numpy -y # Uninstall pre-installed numpy\n", |
| 49 | + "\n", |
| 50 | + "# ! pip uninstall torch torchaudio torchvision transformers -y # Uninstall pre-installed torch\n", |
| 51 | + "# ! uv pip install torch==2.5.1 # Install pinned version of torch\n", |
| 52 | + "\n", |
| 53 | + "# ! uv pip install janus-core[mace,visualise] data-tutorials --system # Install janus-core with MACE and WeasWidget, and data-tutorials\n", |
| 54 | + "\n", |
| 55 | + "# get_ipython().kernel.do_shutdown(restart=True) # Restart kernel to update libraries. This may warn that your session has crashed." |
| 56 | + ] |
| 57 | + }, |
| 58 | + { |
| 59 | + "cell_type": "markdown", |
| 60 | + "metadata": {}, |
| 61 | + "source": [ |
| 62 | + "To ensure you have the latest version of `janus-core` installed, compare the output of the following cell to the latest version available at https://pypi.org/project/janus-core/" |
| 63 | + ] |
| 64 | + }, |
| 65 | + { |
| 66 | + "cell_type": "code", |
| 67 | + "execution_count": null, |
| 68 | + "metadata": {}, |
| 69 | + "outputs": [], |
| 70 | + "source": [ |
| 71 | + "from janus_core import __version__\n", |
| 72 | + "\n", |
| 73 | + "print(__version__)" |
| 74 | + ] |
| 75 | + }, |
| 76 | + { |
| 77 | + "cell_type": "markdown", |
| 78 | + "metadata": {}, |
| 79 | + "source": [ |
| 80 | + "## Prepare data and modules" |
| 81 | + ] |
| 82 | + }, |
| 83 | + { |
| 84 | + "cell_type": "code", |
| 85 | + "execution_count": null, |
| 86 | + "metadata": {}, |
| 87 | + "outputs": [], |
| 88 | + "source": [ |
| 89 | + "from data_tutorials.data import get_data\n", |
| 90 | + "\n", |
| 91 | + "get_data(\n", |
| 92 | + " url=\"https://raw.githubusercontent.com/stfc/janus-core/main/docs/source/tutorials/data/\",\n", |
| 93 | + " filename=[\"NaCl-1040.extxyz\"],\n", |
| 94 | + " folder=\"../data\",\n", |
| 95 | + ")" |
45 | 96 | ] |
46 | 97 | }, |
47 | 98 | { |
|
52 | 103 | }, |
53 | 104 | "outputs": [], |
54 | 105 | "source": [ |
| 106 | + "from pathlib import Path\n", |
| 107 | + "\n", |
55 | 108 | "from ase.build import bulk\n", |
56 | 109 | "from ase.io import read, write\n", |
| 110 | + "import numpy as np\n", |
| 111 | + "import matplotlib.pyplot as plt\n", |
57 | 112 | "from weas_widget import WeasWidget\n", |
58 | | - "from janus_core.helpers.stats import Stats\n", |
59 | | - "from janus_core.processing import post_process\n", |
60 | 113 | "import yaml\n", |
61 | 114 | "\n", |
62 | | - "import numpy as np\n", |
63 | | - "import matplotlib.pyplot as plt" |
| 115 | + "from janus_core.helpers.stats import Stats\n", |
| 116 | + "from janus_core.processing import post_process" |
64 | 117 | ] |
65 | 118 | }, |
66 | 119 | { |
|
80 | 133 | "metadata": {}, |
81 | 134 | "outputs": [], |
82 | 135 | "source": [ |
| 136 | + "Path(\"../data\").mkdir(exist_ok=True)\n", |
| 137 | + "\n", |
83 | 138 | "NaCl = bulk(\"NaCl\", \"rocksalt\", a=5.63, cubic=True)\n", |
84 | 139 | "NaCl = NaCl * (2, 2, 2)\n", |
85 | 140 | "write(\"../data/NaCl.xyz\", NaCl)\n", |
|
0 commit comments