please execute the cell below before starting the tutorial by selecting it and pressing Ctrl+Enter

%load_ext autoreload
%autoreload 2
# imports correct environment
from aiida import load_profile
load_profile()

# imports load_node() 
from aiida.orm import load_node
from pprint import pprint

AiiDA-Fleur input file

Introduction

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.

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.

FleurinpData

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:

from aiida.plugins import DataFactory
FleurinpData = DataFactory('fleur.fleurinp') 

or importing it directly:

from aiida_fleur.data.fleurinp import FleurinpData

FleurinpData can be initialized with an absolute path to an inp.xml file or a FolderData node containing inp.xml. Other files can also be added to a FleurinpData object that will be copied to the calculation folder.

# you need to modify this - replace /path/to/inp.xml
inpxmlfile = '../files/Si/inp.xml'
fleurinp = FleurinpData(files = [inpxmlfile])
print(fleurinp)   # not stored

fleurinp.store() # to store the node in the database
print('The PK of stored FleurinpData is {}'.format(fleurinp.pk))
print('The FleurinpData contains a list of files: {}.'.format(fleurinp.files))

FleurinpData stores the files in the repository and saves the input parameters of the inp.xml file of FLEUR in the database as a python dictionary which can be accessed via:

fleurinp.inp_dict

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:

# The _ncf methods will not keep the provenance for the operation and will return a yet unstored node
kpoints = fleurinp.get_kpointsdata_ncf()
kpoints
kpoints['default_1'].get_kpoints()
# Notice that this keeps the provenance and returns an already stored node.
structure = fleurinp.get_structuredata()
structure
para_dict = fleurinp.get_parameterdata()
print(para_dict)
pprint(para_dict.get_dict())

Remember, most attributes of AiiDA nodes can not be changed after they had been stored in the database! Therefore, we can not change stored FleurinpData in-place. One has to use the FleurinpModifier class and its methods to change something in the inp.xml file. We will learn how to do it in next tutorial.