forked from Tseplyaev/tutorial_notebooks_2019
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from JuDFTteam/fleur_2021
Add FLEUR 2021 workshop tutorial
- Loading branch information
Showing
32 changed files
with
8,985 additions
and
0 deletions.
There are no files selected for viewing
753 changes: 753 additions & 0 deletions
753
tutorials/aiida_fleur_workshop_2021/A1/1_AiiDA_data_types_and_verdi_commands.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
235 changes: 235 additions & 0 deletions
235
tutorials/aiida_fleur_workshop_2021/A1/2_AiiDA_Fleur_input_file.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"*please execute the cell below before starting the tutorial by selecting it and pressing Ctrl+Enter*" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%load_ext autoreload\n", | ||
"%autoreload 2" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# imports correct environment\n", | ||
"from aiida import load_profile\n", | ||
"load_profile()\n", | ||
"\n", | ||
"# imports load_node() \n", | ||
"from aiida.orm import load_node\n", | ||
"from pprint import pprint" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# AiiDA-Fleur input file" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Introduction" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"In previous tutorial, we learnt about AiiDA data types and found out how files and folders can be stored in the database. It makes sense to extend some of the AiiDA types to represent not a general file - but input files, specific for the Fleur code. There is a special class in AiiDA-Fleur to represent input files for Fleur which is called `FleurinpData`. It represents xml input files needed for a Fleur calculation and also contains some helpful methods to work with them.\n", | ||
"\n", | ||
"**NOTE** : Creation and usage of these data objects via the input generator (`inpgen`) are described in the notebook 4. For this tutorial we assume that we already have an `inp.xml` file." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## FleurinpData" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"`FleurinpData` is an AiiDA datastructure specific to the AiiDA-Fleur plugin. One can access this class using the `DataFactory` class provided by the `aiida.orm` module:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from aiida.plugins import DataFactory\n", | ||
"FleurinpData = DataFactory('fleur.fleurinp') " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"or importing it directly:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from aiida_fleur.data.fleurinp import FleurinpData" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"`FleurinpData` can be initialized with an absolute path to an ``inp.xml`` file or a\n", | ||
"`FolderData` node containing ``inp.xml``.\n", | ||
"Other files can also be added to a `FleurinpData` object that will be copied to the calculation folder." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# you need to modify this - replace /path/to/inp.xml\n", | ||
"inpxmlfile = '../files/Si/inp.xml'\n", | ||
"fleurinp = FleurinpData(files = [inpxmlfile])\n", | ||
"print(fleurinp) # not stored\n", | ||
"\n", | ||
"fleurinp.store() # to store the node in the database\n", | ||
"print('The PK of stored FleurinpData is {}'.format(fleurinp.pk))\n", | ||
"print('The FleurinpData contains a list of files: {}.'.format(fleurinp.files))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"`FleurinpData` stores the files in the repository and saves the input parameters of the\n", | ||
"``inp.xml`` file of FLEUR in the database as a python dictionary which can be accessed via:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fleurinp.inp_dict" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"`FleurinpData` also provides the user with methods to extract some AiiDA object such as `StructureData` and `KpointsData` or a `DictData` node which can be used again for an inpgen calculation from an `inp.xml` file:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# The _ncf methods will not keep the provenance for the operation and will return a yet unstored node\n", | ||
"kpoints = fleurinp.get_kpointsdata_ncf()\n", | ||
"kpoints" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"kpoints.get_kpoints()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Notice that this keeps the provenance and returns an already stored node.\n", | ||
"structure = fleurinp.get_structuredata()\n", | ||
"structure" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"para_dict = fleurinp.get_parameterdata(fleurinp)\n", | ||
"print(para_dict)\n", | ||
"pprint(para_dict.get_dict())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Remember, most attributes of AiiDA nodes can not be changed after they\n", | ||
"had been stored in the database! Therefore, we can not change stored `FleurinpData` in-place. \n", | ||
"One has to use the `FleurinpModifier` class and its\n", | ||
"methods to change something in the ``inp.xml`` file. We will learn how to do it in next tutorial." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"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.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.