{ "cells": [ { "cell_type": "markdown", "id": "26023df2-77a5-45be-bd6b-ac4eb028591f", "metadata": {}, "source": [ "## Requirements\n", "\n", "The package m3net can be installed with `amspackages`" ] }, { "cell_type": "markdown", "id": "4163a004-6028-483d-b2ee-d15f711c3ec1", "metadata": {}, "source": [ "## Purpose\n", "\n", "Use the M3GNet ML potential with AMS." ] }, { "cell_type": "markdown", "id": "8f9a4166-86d0-4763-abf3-2485f8489d18", "metadata": {}, "source": [ "## Initialization" ] }, { "cell_type": "code", "execution_count": 4, "id": "ed35131e-0bd6-4d85-8119-08f21182f0d3", "metadata": {}, "outputs": [], "source": [ "from scm.plams import *\n", "\n", "# this line is not required in AMS2025+\n", "init()" ] }, { "cell_type": "markdown", "id": "da4bdbf6-5ef1-451c-9024-7112141e5b46", "metadata": {}, "source": [ "## Setup and run job" ] }, { "cell_type": "code", "execution_count": 5, "id": "d36d8e41-4b34-427a-8059-1cdd36edbb83", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[04.03|15:36:21] JOB ams_with_m3gnet STARTED\n", "[04.03|15:36:21] Renaming job ams_with_m3gnet to ams_with_m3gnet.002\n", "[04.03|15:36:21] Job ams_with_m3gnet.002 previously run as ams_with_m3gnet, using old results\n", "[04.03|15:36:21] JOB ams_with_m3gnet.002 COPIED\n", "M3GNet: final energy -14.077 eV\n" ] } ], "source": [ "mol = from_smiles(\"O\")\n", "mol.lattice = [\n", " [\n", " 3.0,\n", " 0.0,\n", " 0.0,\n", " ],\n", " [0.0, 3.0, 0.0],\n", " [0.0, 0.0, 3.0],\n", "]\n", "\n", "s = Settings()\n", "s.runscript.nproc = 1\n", "s.input.ams.task = \"GeometryOptimization\"\n", "s.input.ams.GeometryOptimization.Convergence.Gradients = 0.01 # hartree/ang\n", "\n", "s.input.MLPotential.Model = \"M3GNet-UP-2022\"\n", "# If you have trained a custom M3GNet model yourself, you can use:\n", "# s.input.MLPotential.Model = 'Custom'\n", "# s.input.MLPotential.Backend = 'm3gnet'\n", "# s.input.MLPotential.ParameterDir = ''\n", "\n", "job = AMSJob(settings=s, molecule=mol, name=\"ams_with_m3gnet\")\n", "job.run()\n", "\n", "energy = job.results.get_energy(unit=\"eV\")\n", "print(f\"M3GNet: final energy {energy:.3f} eV\")" ] }, { "cell_type": "code", "execution_count": null, "id": "8c709008-c714-4763-86f2-2eaeadc445c4", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12" } }, "nbformat": 4, "nbformat_minor": 5 }