From c3e04bcab6f15b80e3976fcda9b7d045004c8798 Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Wed, 17 Apr 2024 09:09:14 +0200 Subject: [PATCH] add workflow example --- examples/06_workflow_pyiron.ipynb | 770 ++++++++++++++++++++++++++++++ 1 file changed, 770 insertions(+) create mode 100644 examples/06_workflow_pyiron.ipynb diff --git a/examples/06_workflow_pyiron.ipynb b/examples/06_workflow_pyiron.ipynb new file mode 100644 index 0000000..4c9e529 --- /dev/null +++ b/examples/06_workflow_pyiron.ipynb @@ -0,0 +1,770 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "05f9d6ba-0d79-4f5b-b1ac-b185491ee9e3", + "metadata": {}, + "source": [ + "# Annotating workflows" + ] + }, + { + "cell_type": "markdown", + "id": "9a4831f2-6ce8-431b-8a21-67e8d442fb50", + "metadata": {}, + "source": [ + "Annotating workflows with pyiron as example. Note that `pyiron_atomistics` needs to be installed for this notebook." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "7af3b5ba-493c-4689-aee5-99c9de36601d", + "metadata": {}, + "outputs": [], + "source": [ + "%config IPCompleter.evaluation='unsafe'" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "136f88af-af89-44d6-a9f6-7ad1d458e625", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/menon/miniconda3/envs/workflow-rdf-v0.2/lib/python3.11/site-packages/numpy/core/getlimits.py:542: UserWarning: Signature b'\\x00\\xd0\\xcc\\xcc\\xcc\\xcc\\xcc\\xcc\\xfb\\xbf\\x00\\x00\\x00\\x00\\x00\\x00' for does not match any known type: falling back to type probe function.\n", + "This warnings indicates broken support for the dtype!\n", + " machar = _get_machar(dtype)\n", + "2024-04-16 18:35:17,228 - pyiron_log - WARNING - pyiron found a 'templates' folder in the /home/menon/pyiron/resources resource directory. These are no longer supported in pyiron_base >=0.7.0. They are replaced by Project.create_job_class() and Project.wrap_python_function().\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "569131161c9642049116b50ce92ca869", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from pyiron_atomistics import Project\n", + "from atomrdf import KnowledgeGraph, System, Workflow\n", + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "c274b896-e491-401b-a1a4-5610544537f3", + "metadata": {}, + "outputs": [], + "source": [ + "pr = Project('wf9')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "66c3020b-9515-4f41-872a-4ca799a16fcb", + "metadata": {}, + "outputs": [], + "source": [ + "kg = KnowledgeGraph(store=pr)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "68afbc43-b458-4cce-9055-2c6710f839bb", + "metadata": {}, + "outputs": [], + "source": [ + "wf = Workflow(kg, environment='pyiron')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "db033de3-b2e6-4c56-800e-b2fa0383a88c", + "metadata": {}, + "outputs": [], + "source": [ + "structure = pr.create.structure.annotated_structure.bulk('Cu', cubic=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "f647313a-6522-473f-a8ea-b5ec89057516", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "sample_0394fcda-2d6a-470a-a72a-1b98ac5ce1a3\n", + "\n", + "sample_0394fcda-2d6a-470a-a72a-1b98ac5ce1a3\n", + "\n", + "\n", + "\n", + "Entity\n", + "\n", + "Entity\n", + "\n", + "\n", + "\n", + "sample_0394fcda-2d6a-470a-a72a-1b98ac5ce1a3->Entity\n", + "\n", + "\n", + "type\n", + "\n", + "\n", + "\n", + "sample_cc0c55d8-fa4c-43ff-8a18-2e1d9e077ca7\n", + "\n", + "sample_cc0c55d8-fa4c-43ff-8a18-2e1d9e077ca7\n", + "\n", + "\n", + "\n", + "sample_cc0c55d8-fa4c-43ff-8a18-2e1d9e077ca7->sample_0394fcda-2d6a-470a-a72a-1b98ac5ce1a3\n", + "\n", + "\n", + "wasDerivedFrom\n", + "\n", + "\n", + "\n", + "sample_cc0c55d8-fa4c-43ff-8a18-2e1d9e077ca7->Entity\n", + "\n", + "\n", + "type\n", + "\n", + "\n", + "\n", + "sample_2c3e9210-84b2-45dd-a7a2-3569907a9d97\n", + "\n", + "sample_2c3e9210-84b2-45dd-a7a2-3569907a9d97\n", + "\n", + "\n", + "\n", + "sample_2c3e9210-84b2-45dd-a7a2-3569907a9d97->Entity\n", + "\n", + "\n", + "type\n", + "\n", + "\n", + "\n", + "sample_51aeb661-2cb8-4036-8e76-27a97fb0f467\n", + "\n", + "sample_51aeb661-2cb8-4036-8e76-27a97fb0f467\n", + "\n", + "\n", + "\n", + "sample_51aeb661-2cb8-4036-8e76-27a97fb0f467->Entity\n", + "\n", + "\n", + "type\n", + "\n", + "\n", + "\n", + "sample_51aeb661-2cb8-4036-8e76-27a97fb0f467->sample_2c3e9210-84b2-45dd-a7a2-3569907a9d97\n", + "\n", + "\n", + "wasDerivedFrom\n", + "\n", + "\n", + "\n", + "sample_3d96246d-ddc5-449c-9a3e-c76411879498\n", + "\n", + "sample_3d96246d-ddc5-449c-9a3e-c76411879498\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kg.visualise(workflow_view=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "f137392d-c504-4ab7-8473-cbf7f9145089", + "metadata": {}, + "outputs": [], + "source": [ + "job = pr.create.job.Lammps('j1', delete_existing_job=True, delete_aborted_job=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "a26b4d91-ea71-4125-8c7a-26194473f843", + "metadata": {}, + "outputs": [], + "source": [ + "job.structure = structure" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "877a65dd-3386-4c6d-b6ef-5fe60bda5627", + "metadata": {}, + "outputs": [], + "source": [ + "job.potential = '2001--Mishin-Y--Cu-1--LAMMPS--ipr1'" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "502ecfcd-2817-4a66-8384-b10176d36899", + "metadata": {}, + "outputs": [], + "source": [ + "job.calc_md(pressure=0, temperature=500)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "eb3ab16b-c127-44fb-80e4-9b1b2174d51e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The job j1 was saved and received the ID: 8173\n" + ] + } + ], + "source": [ + "job.run()" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "af64675d-2630-4e83-9b54-d83aa92f0df0", + "metadata": {}, + "outputs": [], + "source": [ + "wf.to_graph(job)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "899beab8-f4c8-4bb1-9d15-0f96231ddfb6", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "sample_0394fcda-2d6a-470a-a72a-1b98ac5ce1a3\n", + "\n", + "sample_0394fcda-2d6a-470a-a72a-1b98ac5ce1a3\n", + "\n", + "\n", + "\n", + "sample_cc0c55d8-fa4c-43ff-8a18-2e1d9e077ca7\n", + "\n", + "sample_cc0c55d8-fa4c-43ff-8a18-2e1d9e077ca7\n", + "\n", + "\n", + "\n", + "sample_cc0c55d8-fa4c-43ff-8a18-2e1d9e077ca7->sample_0394fcda-2d6a-470a-a72a-1b98ac5ce1a3\n", + "\n", + "\n", + "wasDerivedFrom\n", + "\n", + "\n", + "\n", + "sample_2c3e9210-84b2-45dd-a7a2-3569907a9d97\n", + "\n", + "sample_2c3e9210-84b2-45dd-a7a2-3569907a9d97\n", + "\n", + "\n", + "\n", + "sample_51aeb661-2cb8-4036-8e76-27a97fb0f467\n", + "\n", + "sample_51aeb661-2cb8-4036-8e76-27a97fb0f467\n", + "\n", + "\n", + "\n", + "sample_51aeb661-2cb8-4036-8e76-27a97fb0f467->sample_2c3e9210-84b2-45dd-a7a2-3569907a9d97\n", + "\n", + "\n", + "wasDerivedFrom\n", + "\n", + "\n", + "\n", + "sample_3d96246d-ddc5-449c-9a3e-c76411879498\n", + "\n", + "sample_3d96246d-ddc5-449c-9a3e-c76411879498\n", + "\n", + "\n", + "\n", + "sample_97a194be-0485-4135-817e-7a587adae82c\n", + "\n", + "sample_97a194be-0485-4135-817e-7a587adae82c\n", + "\n", + "\n", + "\n", + "sample_97a194be-0485-4135-817e-7a587adae82c->sample_3d96246d-ddc5-449c-9a3e-c76411879498\n", + "\n", + "\n", + "wasDerivedFrom\n", + "\n", + "\n", + "\n", + "activity_8173\n", + "\n", + "activity_8173\n", + "\n", + "\n", + "\n", + "sample_97a194be-0485-4135-817e-7a587adae82c->activity_8173\n", + "\n", + "\n", + "wasGeneratedBy\n", + "\n", + "\n", + "\n", + "8173_TotalEnergy\n", + "\n", + "8173_TotalEnergy\n", + "\n", + "\n", + "\n", + "sample_97a194be-0485-4135-817e-7a587adae82c->8173_TotalEnergy\n", + "\n", + "\n", + "cmso.hasCalculatedProperty\n", + "\n", + "\n", + "\n", + "8173_TotalVolume\n", + "\n", + "8173_TotalVolume\n", + "\n", + "\n", + "\n", + "sample_97a194be-0485-4135-817e-7a587adae82c->8173_TotalVolume\n", + "\n", + "\n", + "cmso.hasCalculatedProperty\n", + "\n", + "\n", + "\n", + "method_8173\n", + "\n", + "method_8173\n", + "\n", + "\n", + "\n", + "activity_8173->method_8173\n", + "\n", + "\n", + "asmo.hasComputationalMethod\n", + "\n", + "\n", + "\n", + "asmo.AtomicPosition\n", + "\n", + "asmo.AtomicPosition\n", + "\n", + "\n", + "\n", + "activity_8173->asmo.AtomicPosition\n", + "\n", + "\n", + "asmo.hasRelaxationDOF\n", + "\n", + "\n", + "\n", + "asmo.CellVolume\n", + "\n", + "asmo.CellVolume\n", + "\n", + "\n", + "\n", + "activity_8173->asmo.CellVolume\n", + "\n", + "\n", + "asmo.hasRelaxationDOF\n", + "\n", + "\n", + "\n", + "temperature_8173\n", + "\n", + "temperature_8173\n", + "\n", + "\n", + "\n", + "activity_8173->temperature_8173\n", + "\n", + "\n", + "asmo.hasInputParameter\n", + "\n", + "\n", + "\n", + "pressure_8173\n", + "\n", + "pressure_8173\n", + "\n", + "\n", + "\n", + "activity_8173->pressure_8173\n", + "\n", + "\n", + "asmo.hasInputParameter\n", + "\n", + "\n", + "\n", + "asmo.Isothermal–isobaricEnsemble\n", + "\n", + "asmo.Isothermal–isobaricEnsemble\n", + "\n", + "\n", + "\n", + "method_8173->asmo.Isothermal–isobaricEnsemble\n", + "\n", + "\n", + "asmo.hasStatisticalEnsemble\n", + "\n", + "\n", + "\n", + "potential_8173\n", + "\n", + "potential_8173\n", + "\n", + "\n", + "\n", + "method_8173->potential_8173\n", + "\n", + "\n", + "asmo.hasInteratomicPotential\n", + "\n", + "\n", + "\n", + "matwerk.E457491\n", + "\n", + "matwerk.E457491\n", + "\n", + "\n", + "\n", + "method_8173->matwerk.E457491\n", + "\n", + "\n", + "wasAssociatedWith\n", + "\n", + "\n", + "\n", + "unit.K\n", + "\n", + "unit.K\n", + "\n", + "\n", + "\n", + "temperature_8173->unit.K\n", + "\n", + "\n", + "asmo.hasUnit\n", + "\n", + "\n", + "\n", + "33893be5-082f-457c-a724-2d78ba35c377\n", + "\n", + "Temperature\n", + "\n", + "\n", + "\n", + "temperature_8173->33893be5-082f-457c-a724-2d78ba35c377\n", + "\n", + "\n", + "label\n", + "\n", + "\n", + "\n", + "c7172178-e65a-451d-a26e-78211ce3d9e4\n", + "\n", + "500.0\n", + "\n", + "\n", + "\n", + "temperature_8173->c7172178-e65a-451d-a26e-78211ce3d9e4\n", + "\n", + "\n", + "asmo.hasValue\n", + "\n", + "\n", + "\n", + "unit.GigaPA\n", + "\n", + "unit.GigaPA\n", + "\n", + "\n", + "\n", + "pressure_8173->unit.GigaPA\n", + "\n", + "\n", + "asmo.hasUnit\n", + "\n", + "\n", + "\n", + "f230d3cb-7144-414d-8b45-7e3d3d5e1022\n", + "\n", + "Pressure\n", + "\n", + "\n", + "\n", + "pressure_8173->f230d3cb-7144-414d-8b45-7e3d3d5e1022\n", + "\n", + "\n", + "label\n", + "\n", + "\n", + "\n", + "9c649324-bb8c-4b5a-a27c-5992e0af8c39\n", + "\n", + "0.0\n", + "\n", + "\n", + "\n", + "pressure_8173->9c649324-bb8c-4b5a-a27c-5992e0af8c39\n", + "\n", + "\n", + "asmo.hasValue\n", + "\n", + "\n", + "\n", + "e6481ff8-7f93-4aed-9b58-9e7550a74af9\n", + "\n", + "2001--Mishin-Y--Cu-1--Lammps--Ipr1\n", + "\n", + "\n", + "\n", + "potential_8173->e6481ff8-7f93-4aed-9b58-9e7550a74af9\n", + "\n", + "\n", + "label\n", + "\n", + "\n", + "\n", + "matwerk.E447986\n", + "\n", + "matwerk.E447986\n", + "\n", + "\n", + "\n", + "matwerk.E457491->matwerk.E447986\n", + "\n", + "\n", + "actedOnBehalfOf\n", + "\n", + "\n", + "\n", + "12548f54-03d7-4501-8c43-9f0ad08fe88d\n", + "\n", + "Pyiron\n", + "\n", + "\n", + "\n", + "matwerk.E457491->12548f54-03d7-4501-8c43-9f0ad08fe88d\n", + "\n", + "\n", + "label\n", + "\n", + "\n", + "\n", + "04b8fe58-e7f8-475a-b86b-eb91a6360617\n", + "\n", + "Lammps\n", + "\n", + "\n", + "\n", + "matwerk.E447986->04b8fe58-e7f8-475a-b86b-eb91a6360617\n", + "\n", + "\n", + "label\n", + "\n", + "\n", + "\n", + "8173_TotalEnergy->activity_8173\n", + "\n", + "\n", + "asmo.wasCalculatedBy\n", + "\n", + "\n", + "\n", + "unit.EV\n", + "\n", + "unit.EV\n", + "\n", + "\n", + "\n", + "8173_TotalEnergy->unit.EV\n", + "\n", + "\n", + "asmo.hasUnit\n", + "\n", + "\n", + "\n", + "79389594-1584-4763-a243-5d35ca8ccf10\n", + "\n", + "Totalenergy\n", + "\n", + "\n", + "\n", + "8173_TotalEnergy->79389594-1584-4763-a243-5d35ca8ccf10\n", + "\n", + "\n", + "label\n", + "\n", + "\n", + "\n", + "eec92a85-1911-49ce-a483-b3d892942b01\n", + "\n", + "-13.7346\n", + "\n", + "\n", + "\n", + "8173_TotalEnergy->eec92a85-1911-49ce-a483-b3d892942b01\n", + "\n", + "\n", + "asmo.hasValue\n", + "\n", + "\n", + "\n", + "8173_TotalVolume->activity_8173\n", + "\n", + "\n", + "asmo.wasCalculatedBy\n", + "\n", + "\n", + "\n", + "unit.ANGSTROM3\n", + "\n", + "unit.ANGSTROM3\n", + "\n", + "\n", + "\n", + "8173_TotalVolume->unit.ANGSTROM3\n", + "\n", + "\n", + "asmo.hasUnit\n", + "\n", + "\n", + "\n", + "8a700e67-6e09-4d19-861f-6c423d9c28f7\n", + "\n", + "Totalvolume\n", + "\n", + "\n", + "\n", + "8173_TotalVolume->8a700e67-6e09-4d19-861f-6c423d9c28f7\n", + "\n", + "\n", + "label\n", + "\n", + "\n", + "\n", + "fad73c39-653b-4764-a6ae-43e8e1b051ad\n", + "\n", + "48.2558\n", + "\n", + "\n", + "\n", + "8173_TotalVolume->fad73c39-653b-4764-a6ae-43e8e1b051ad\n", + "\n", + "\n", + "asmo.hasValue\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kg.visualise(workflow_view=True, hide_types=True, size=(15,15), layout='dot')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.11.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}