{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "(props_workflow)=\n", "\n", "# Properties Workflow" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The {py:class}`~.aiida_crystal17.workflows.crystal_props.base.CryPropertiesWorkChain` can be used to compute multiple properties,\n", "using an existing ``fort.9`` file or by running an initial SCF {py:class}`~aiida_crystal17.calculations.cry_main.CryMainCalculation`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[31m\u001b[1mInputs\u001b[0m\n", " check_remote: optional Bool If a RemoteData wf_folder is input, check it contains the wavefunction file ...\u001b[0m\n", " clean_workdir: optional Bool If `True`, work directories of all called calculation will be cleaned at th ...\u001b[0m\n", " doss: optional \u001b[0m\n", " ech3: optional \u001b[0m\n", " metadata: optional \u001b[0m\n", " scf: optional \u001b[0m\n", " test_run: optional Bool break off the workchain before submitting a calculation\u001b[0m\n", " wf_folder: optional FolderData, RemoteData, SinglefileData the folder containing the wavefunction fort.9 file\u001b[0m\n", "\u001b[31m\u001b[1mOutputs\u001b[0m\n", " doss: optional \u001b[0m\n", " ech3: optional \u001b[0m\n", "\u001b[31m\u001b[1mExit codes\u001b[0m\n", " 1: The process has failed with an unspecified error.\u001b[0m\n", " 2: The process failed with legacy failure mode.\u001b[0m\n", " 10: The process returned an invalid output.\u001b[0m\n", " 11: The process did not register a required output.\u001b[0m\n", " 200: Workchain ended before submitting calculation.\u001b[0m\n", " 201: Neither a wf_folder nor scf calculation was supplied.\u001b[0m\n", " 202: No property calculation inputs were supplied.\u001b[0m\n", " 203: The supplied folder does contain the wavefunction file.\u001b[0m\n", " 210: The scf calculation submission failed.\u001b[0m\n", " 301: The scf calculation failed.\u001b[0m\n", " 302: One or more property calculations failed.\u001b[0m\n" ] } ], "source": [ "!verdi plugin list aiida.workflows crystal17.properties" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'test_crystal17'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from aiida import engine, load_profile, orm, plugins\n", "from aiida.tools.visualization import Graph\n", "from aiida_crystal17.common import recursive_round\n", "from aiida_crystal17.data.basis_set import BasisSetData\n", "from aiida_crystal17.data.input_params import CryInputParamsData\n", "from aiida_crystal17.tests.utils import (\n", " get_or_create_local_computer, get_or_create_code,\n", " get_default_metadata)\n", "from aiida_crystal17.tests import (\n", " get_test_structure_and_symm, resource_context)\n", "profile = load_profile()\n", "profile.name" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "wc_builder = plugins.WorkflowFactory('crystal17.properties').get_builder()\n", "computer = get_or_create_local_computer('work_directory', 'localhost')\n", "\n", "wc_builder.scf.code = get_or_create_code('crystal17.main',\n", " computer, 'mock_crystal17')\n", "structure, symmetry = get_test_structure_and_symm('MgO')\n", "wc_builder.scf.structure = structure\n", "wc_builder.scf.symmetry = symmetry\n", "wc_builder.scf.parameters = CryInputParamsData(data={\n", " 'title': 'MgO Bulk',\n", " 'scf': {\n", " 'k_points': [8, 8],\n", " 'post_scf': ['PPAN']\n", " },\n", " })\n", "with resource_context('basis_sets', 'sto3g') as path:\n", " BasisSetData.upload_basisset_family(\n", " path, \"sto3g\", \"group of sto3g basis sets\",\n", " extension=\".basis\", stop_if_existing=False)\n", "wc_builder.scf.basissets = BasisSetData.get_basissets_from_structure(\n", " structure, \"sto3g\")\n", "wc_builder.scf.metadata = get_default_metadata()\n", "\n", "wc_builder.doss.code = get_or_create_code('crystal17.doss',\n", " computer, 'mock_properties17')\n", "wc_builder.doss.parameters = orm.Dict(dict={\n", " 'k_points': [18, 36],\n", " 'npoints': 100,\n", " 'band_minimum': -10,\n", " 'band_maximum': 10,\n", " 'band_units': 'eV'\n", " })\n", "wc_builder.doss.metadata = get_default_metadata()\n", "\n", "wc_builder.ech3.code = get_or_create_code('crystal17.ech3',\n", " computer, 'mock_properties17')\n", "wc_builder.ech3.parameters = orm.Dict(dict={\n", " 'npoints': 20\n", " })\n", "wc_builder.ech3.metadata = get_default_metadata()\n", "\n", "wc_builder.clean_workdir = True" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "outputs, wc_node = engine.run_get_node(wc_builder)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[22m2019-09-24 17:02:37 [61 | REPORT]: [997|CryPropertiesWorkChain|check_wf_folder]: No 'wf_folder' supplied, running SCF Calculation...\n", "2019-09-24 17:02:38 [62 | REPORT]: [997|CryPropertiesWorkChain|submit_scf_calculation]: launched SCF calculation: uuid: 80c1d604-504c-46e3-abe3-3cba696dd09d (pk: 998) (aiida.calculations:crystal17.main)\n", "2019-09-24 17:02:52 [63 | REPORT]: [997|CryPropertiesWorkChain|check_scf_calculation]: uuid: 80c1d604-504c-46e3-abe3-3cba696dd09d (pk: 998) (aiida.calculations:crystal17.main) finished successfully\n", "2019-09-24 17:02:52 [64 | REPORT]: [997|CryPropertiesWorkChain|submit_prop_calculations]: launched doss calculation uuid: fc38e33a-2786-4e2d-b154-ec03df427b1e (pk: 1002) (aiida.calculations:crystal17.doss)\n", "2019-09-24 17:02:52 [65 | REPORT]: [997|CryPropertiesWorkChain|submit_prop_calculations]: launched ech3 calculation uuid: a7ec5251-c94d-47e2-9f79-7491c7d239ec (pk: 1003) (aiida.calculations:crystal17.ech3)\n", "2019-09-24 17:03:03 [66 | REPORT]: [997|CryPropertiesWorkChain|check_prop_calculations]: calc_doss; uuid: fc38e33a-2786-4e2d-b154-ec03df427b1e (pk: 1002) (aiida.calculations:crystal17.doss) finished successfully\n", "2019-09-24 17:03:03 [67 | REPORT]: [997|CryPropertiesWorkChain|check_prop_calculations]: calc_ech3; uuid: a7ec5251-c94d-47e2-9f79-7491c7d239ec (pk: 1003) (aiida.calculations:crystal17.ech3) finished successfully\n", "2019-09-24 17:03:03 [68 | REPORT]: [997|CryPropertiesWorkChain|on_terminated]: cleaned remote folders of calculations: 1003 1002 998\u001b[0m\n" ] } ], "source": [ "!verdi process report {wc_node.pk}" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[22mProperty Value\n", "------------- ------------------------------------\n", "type WorkChainNode\n", "pk 997\n", "uuid 00f27214-1aad-405e-bc73-0151bab4f873\n", "label\n", "description\n", "ctime 2019-09-24 17:02:37.060297+00:00\n", "mtime 2019-09-24 17:03:03.295586+00:00\n", "process state Finished\n", "exit status 0\n", "computer [1] localhost\n", "\n", "Inputs PK Type\n", "-------------- ---- ------------------\n", "doss\n", " parameters 994 Dict\n", " code 881 Code\n", "ech3\n", " parameters 995 Dict\n", " code 971 Code\n", "scf\n", " parameters 993 CryInputParamsData\n", " symmetry 992 SymmetryData\n", " structure 990 StructureData\n", " code 445 Code\n", " basissets\n", " O 44 BasisSetData\n", " Mg 704 BasisSetData\n", "clean_workdir 996 Bool\n", "\n", "Outputs PK Type\n", "----------------- ---- ------------\n", "doss\n", " remote_folder 1004 RemoteData\n", " retrieved 1006 FolderData\n", " results 1008 Dict\n", " arrays 1009 ArrayData\n", "ech3\n", " remote_folder 1005 RemoteData\n", " retrieved 1007 FolderData\n", " results 1010 Dict\n", " charge 1011 GaussianCube\n", "\n", "Called PK Type\n", "--------- ---- -----------\n", "calc_ech3 1003 CalcJobNode\n", "calc_doss 1002 CalcJobNode\n", "calc_scf 998 CalcJobNode\n", "\n", "Log messages\n", "---------------------------------------------\n", "There are 8 log messages for this calculation\n", "Run 'verdi process report 997' to see them\u001b[0m\n" ] } ], "source": [ "!verdi process show {wc_node.pk}" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "ipub": { "figure": { "caption": "`crystal17.properties` workflow provenance graph." } } }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", "\n", "\n", "\n", "%3\n", "\n", "\n", "\n", "N997\n", "\n", "CryPropertiesWorkChain (997)\n", "State: finished\n", "Exit Code: 0\n", "\n", "\n", "\n", "N1005\n", "\n", "RemoteData (1005)\n", "@localhost\n", "\n", "\n", "\n", "N997->N1005\n", "\n", "\n", "RETURN\n", "ech3__remote_folder\n", "\n", "\n", "\n", "N1007\n", "\n", "FolderData (1007)\n", "\n", "\n", "\n", "N997->N1007\n", "\n", "\n", "RETURN\n", "ech3__retrieved\n", "\n", "\n", "\n", "N1010\n", "\n", "Dict (1010)\n", "\n", "\n", "\n", "N997->N1010\n", "\n", "\n", "RETURN\n", "ech3__results\n", "\n", "\n", "\n", "N1011\n", "\n", "GaussianCube (1011)\n", "\n", "\n", "\n", "N997->N1011\n", "\n", "\n", "RETURN\n", "ech3__charge\n", "\n", "\n", "\n", "N1004\n", "\n", "RemoteData (1004)\n", "@localhost\n", "\n", "\n", "\n", "N997->N1004\n", "\n", "\n", "RETURN\n", "doss__remote_folder\n", "\n", "\n", "\n", "N1006\n", "\n", "FolderData (1006)\n", "\n", "\n", "\n", "N997->N1006\n", "\n", "\n", "RETURN\n", "doss__retrieved\n", "\n", "\n", "\n", "N1008\n", "\n", "Dict (1008)\n", "\n", "\n", "\n", "N997->N1008\n", "\n", "\n", "RETURN\n", "doss__results\n", "\n", "\n", "\n", "N1009\n", "\n", "ArrayData (1009)\n", "\n", "\n", "\n", "N997->N1009\n", "\n", "\n", "RETURN\n", "doss__arrays\n", "\n", "\n", "\n", "N1003\n", "\n", "CryEch3Calculation (1003)\n", "State: finished\n", "Exit Code: 0\n", "\n", "\n", "\n", "N997->N1003\n", "\n", "\n", "CALL_CALC\n", "calc_ech3\n", "\n", "\n", "\n", "N1002\n", "\n", "CryDossCalculation (1002)\n", "State: finished\n", "Exit Code: 0\n", "\n", "\n", "\n", "N997->N1002\n", "\n", "\n", "CALL_CALC\n", "calc_doss\n", "\n", "\n", "\n", "N998\n", "\n", "CryMainCalculation (998)\n", "State: finished\n", "Exit Code: 0\n", "\n", "\n", "\n", "N997->N998\n", "\n", "\n", "CALL_CALC\n", "calc_scf\n", "\n", "\n", "\n", "N996\n", "\n", "Bool (996)\n", "True\n", "\n", "\n", "\n", "N996->N997\n", "\n", "\n", "INPUT_WORK\n", "clean_workdir\n", "\n", "\n", "\n", "N995\n", "\n", "Dict (995)\n", "\n", "\n", "\n", "N995->N997\n", "\n", "\n", "INPUT_WORK\n", "ech3__parameters\n", "\n", "\n", "\n", "N995->N1003\n", "\n", "\n", "INPUT_CALC\n", "parameters\n", "\n", "\n", "\n", "N971\n", "\n", "Code (971)\n", "mock_properties17@localhost\n", "\n", "\n", "\n", "N971->N997\n", "\n", "\n", "INPUT_WORK\n", "ech3__code\n", "\n", "\n", "\n", "N971->N1003\n", "\n", "\n", "INPUT_CALC\n", "code\n", "\n", "\n", "\n", "N994\n", "\n", "Dict (994)\n", "\n", "\n", "\n", "N994->N997\n", "\n", "\n", "INPUT_WORK\n", "doss__parameters\n", "\n", "\n", "\n", "N994->N1002\n", "\n", "\n", "INPUT_CALC\n", "parameters\n", "\n", "\n", "\n", "N881\n", "\n", "Code (881)\n", "mock_properties17@localhost\n", "\n", "\n", "\n", "N881->N997\n", "\n", "\n", "INPUT_WORK\n", "doss__code\n", "\n", "\n", "\n", "N881->N1002\n", "\n", "\n", "INPUT_CALC\n", "code\n", "\n", "\n", "\n", "N993\n", "\n", "CryInputParamsData (993)\n", "\n", "\n", "\n", "N993->N997\n", "\n", "\n", "INPUT_WORK\n", "scf__parameters\n", "\n", "\n", "\n", "N993->N998\n", "\n", "\n", "INPUT_CALC\n", "parameters\n", "\n", "\n", "\n", "N992\n", "\n", "SymmetryData (992)\n", "hall_number: 523\n", "symmops: 48\n", "\n", "\n", "\n", "N992->N997\n", "\n", "\n", "INPUT_WORK\n", "scf__symmetry\n", "\n", "\n", "\n", "N992->N998\n", "\n", "\n", "INPUT_CALC\n", "symmetry\n", "\n", "\n", "\n", "N990\n", "\n", "StructureData (990)\n", "MgO\n", "\n", "\n", "\n", "N990->N997\n", "\n", "\n", "INPUT_WORK\n", "scf__structure\n", "\n", "\n", "\n", "N990->N998\n", "\n", "\n", "INPUT_CALC\n", "structure\n", "\n", "\n", "\n", "N445\n", "\n", "Code (445)\n", "mock_crystal17@localhost\n", "\n", "\n", "\n", "N445->N997\n", "\n", "\n", "INPUT_WORK\n", "scf__code\n", "\n", "\n", "\n", "N445->N998\n", "\n", "\n", "INPUT_CALC\n", "code\n", "\n", "\n", "\n", "N44\n", "\n", "BasisSetData (44)\n", "\n", "\n", "\n", "N44->N997\n", "\n", "\n", "INPUT_WORK\n", "scf__basissets__O\n", "\n", "\n", "\n", "N44->N998\n", "\n", "\n", "INPUT_CALC\n", "basissets__O\n", "\n", "\n", "\n", "N704\n", "\n", "BasisSetData (704)\n", "\n", "\n", "\n", "N704->N997\n", "\n", "\n", "INPUT_WORK\n", "scf__basissets__Mg\n", "\n", "\n", "\n", "N704->N998\n", "\n", "\n", "INPUT_CALC\n", "basissets__Mg\n", "\n", "\n", "\n", "N1003->N1005\n", "\n", "\n", "CREATE\n", "remote_folder\n", "\n", "\n", "\n", "N1003->N1007\n", "\n", "\n", "CREATE\n", "retrieved\n", "\n", "\n", "\n", "N1003->N1010\n", "\n", "\n", "CREATE\n", "results\n", "\n", "\n", "\n", "N1003->N1011\n", "\n", "\n", "CREATE\n", "charge\n", "\n", "\n", "\n", "N1002->N1004\n", "\n", "\n", "CREATE\n", "remote_folder\n", "\n", "\n", "\n", "N1002->N1006\n", "\n", "\n", "CREATE\n", "retrieved\n", "\n", "\n", "\n", "N1002->N1008\n", "\n", "\n", "CREATE\n", "results\n", "\n", "\n", "\n", "N1002->N1009\n", "\n", "\n", "CREATE\n", "arrays\n", "\n", "\n", "\n", "N999\n", "\n", "RemoteData (999)\n", "@localhost\n", "\n", "\n", "\n", "N998->N999\n", "\n", "\n", "CREATE\n", "remote_folder\n", "\n", "\n", "\n", "N1001\n", "\n", "Dict (1001)\n", "\n", "\n", "\n", "N998->N1001\n", "\n", "\n", "CREATE\n", "results\n", "\n", "\n", "\n", "N1000\n", "\n", "FolderData (1000)\n", "\n", "\n", "\n", "N998->N1000\n", "\n", "\n", "CREATE\n", "retrieved\n", "\n", "\n", "\n", "N999->N1003\n", "\n", "\n", "INPUT_CALC\n", "wf_folder\n", "\n", "\n", "\n", "N999->N1002\n", "\n", "\n", "INPUT_CALC\n", "wf_folder\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "graph = Graph(graph_attr={'size': \"8,6!\", \"rankdir\": \"LR\"})\n", "graph.recurse_ancestors(\n", " wc_node,\n", " depth=1,\n", " include_process_outputs=False,\n", " annotate_links=\"both\")\n", "graph.recurse_descendants(\n", " wc_node,\n", " depth=None,\n", " include_process_inputs=True,\n", " annotate_links=\"both\")\n", "graph.graphviz" ] } ], "metadata": { "celltoolbar": "Edit Metadata", "hide_input": false, "jupytext": { "formats": "ipynb,md:myst" }, "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.6.7" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }