{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Using ACE as a ASE calculator" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Install pyjulip from https://github.com/casv2/pyjulip\n", "\n", "This requires pyjulia to be set up properly first: https://github.com/JuliaPy/pyjulia" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pyjulip\n", "from ase.build import bulk\n", "import time" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "at = bulk(\"Al\") * (2,2,2)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "calc = pyjulip.ACE(\"./ACE_Al.json\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "at.rattle(0.01)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "at.set_calculator(calc)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[-0.00014092, -0.02436524, -0.04762882],\n", " [-0.042433 , 0.02391434, -0.02832742],\n", " [-0.01745242, -0.05401593, 0.02261669],\n", " [-0.00415915, 0.01636964, 0.05024348],\n", " [ 0.00684032, 0.07615094, 0.04716693],\n", " [-0.00229448, -0.02161298, -0.00072229],\n", " [ 0.03770642, 0.04145959, -0.06849356],\n", " [ 0.02193323, -0.05790036, 0.02514498]])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "at.get_forces()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-878.3044107083637" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "at.get_potential_energy()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "def get_forces(at):\n", " at.rattle(0.01)\n", " return at.get_forces()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Timing (ms/atom)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "FORCE CALL/ATOM [ms]: 1.214248538017273\n" ] } ], "source": [ "N = 100\n", "\n", "t1 = time.time()\n", "for i in range(N):\n", " get_forces(at)\n", "t2 = time.time()\n", "\n", "print(\"FORCE CALL/ATOM [ms]:\", ((t2-t1)/N)/len(at) * 1E3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "@webio": { "lastCommId": null, "lastKernelId": null }, "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.2" } }, "nbformat": 4, "nbformat_minor": 2 }