From 8af4507b06ba902b158d43faa34eddf6024d8752 Mon Sep 17 00:00:00 2001 From: BowenD-UCB <84425382+BowenD-UCB@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:31:17 -0800 Subject: [PATCH] update example with ase install --- examples/basics.ipynb | 58 ++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/examples/basics.ipynb b/examples/basics.ipynb index 030f091a..dc4a9dcf 100644 --- a/examples/basics.ipynb +++ b/examples/basics.ipynb @@ -19,7 +19,8 @@ " from chgnet.model import CHGNet\n", "except ImportError:\n", " # install CHGNet (only needed on Google Colab or if you didn't install CHGNet yet)\n", - " !pip install chgnet" + " !pip install chgnet\n", + " !pip install git+https://gitlab.com/ase/ase" ] }, { @@ -75,6 +76,14 @@ " 6 O2- 0.5 0 0.901486\n", " 7 O2- 0 0.5 0.639176\n" ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/bowendeng/PackagesforReseach/pymatgen-private/pymatgen/io/cif.py:1186: UserWarning: The default value of primitive was changed from True to False in https://github.com/materialsproject/pymatgen/pull/3419. CifParser now returns the cell in the CIF file as is. If you want the primitive cell, please set primitive=True explicitly.\n", + " warnings.warn(\n" + ] } ], "source": [ @@ -110,7 +119,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CHGNet v0.3.0 initialized with 412,525 parameters\n" + "CHGNet v0.3.0 initialized with 412,525 parameters\n", + "CHGNet will run on cpu\n" ] } ], @@ -144,25 +154,25 @@ "output_type": "stream", "text": [ "CHGNet-predicted energy (eV/atom):\n", - "-7.371591567993164\n", + "-7.367691516876221\n", "\n", "CHGNet-predicted forces (eV/A):\n", - "[[ 0. -0. 0.0241]\n", - " [ 0. -0. -0.0241]\n", - " [-0. 0. 0.0254]\n", - " [-0. -0. -0.0254]\n", - " [-0. 0. -0.0217]\n", - " [ 0. -0. 0.0096]\n", - " [-0. 0. -0.0096]\n", - " [-0. -0. 0.0217]]\n", + "[[ 0. -0. 0.0238]\n", + " [ 0. 0. -0.0238]\n", + " [ 0. -0. 0.0926]\n", + " [-0. -0. -0.0926]\n", + " [ 0. 0. -0.0024]\n", + " [-0. -0. -0.0131]\n", + " [ 0. 0. 0.0131]\n", + " [-0. 0. 0.0024]]\n", "\n", "CHGNet-predicted stress (GPa):\n", - "[[ 0.3368 -0. -0. ]\n", - " [ 0. 0.2468 0. ]\n", - " [-0. 0. 0.0403]]\n", + "[[-0.3037 -0. 0. ]\n", + " [-0. 0.2231 -0. ]\n", + " [ 0. -0. -0.1074]]\n", "\n", "CHGNet-predicted magmom (mu_B):\n", - "[0.0052 0.0052 3.8573 3.8573 0.0254 0.0371 0.0371 0.0254]\n", + "[0.003 0.003 3.8694 3.8694 0.0441 0.0386 0.0386 0.0441]\n", "\n" ] } @@ -260,12 +270,14 @@ } ], "source": [ + "# Perturb the structure\n", "structure.perturb(0.1)\n", - "for ase_filter in (\"FrechetCellFilter\", \"ExpCellFilter\"):\n", - " result = relaxer.relax(structure, verbose=False, ase_filter=ase_filter)\n", - " n_steps = len(result[\"trajectory\"])\n", - " print(f\"\\n{ase_filter} took {n_steps} steps. Relaxed structure:\\n\")\n", - " print(result[\"final_structure\"])" + "\n", + "# Relax the pur\n", + "result = relaxer.relax(structure, verbose=False, ase_filter=ase_filter)\n", + "n_steps = len(result[\"trajectory\"])\n", + "print(f\"\\n{ase_filter} took {n_steps} steps. Relaxed structure:\\n\")\n", + "print(result[\"final_structure\"])" ] }, { @@ -1848,9 +1860,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python (tf)", "language": "python", - "name": "python3" + "name": "myenv" }, "language_info": { "codemirror_mode": { @@ -1862,7 +1874,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.9.10" } }, "nbformat": 4,