Skip to content

Commit

Permalink
update example with ase install
Browse files Browse the repository at this point in the history
  • Loading branch information
bowen-bd committed Feb 21, 2024
1 parent 3f1c722 commit 8af4507
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions examples/basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
]
}
],
Expand Down Expand Up @@ -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"
]
}
Expand Down Expand Up @@ -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\"])"
]
},
{
Expand Down Expand Up @@ -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": {
Expand All @@ -1862,7 +1874,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.9.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8af4507

Please sign in to comment.