{
"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"
],
"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
}