XML file from Quantum Espresso

In this post I will deep dive into the xml file from pw.x calculation, there are so much information that we can get from the xml file. Also the xml file can be used as the input in the next stages of our simulation.

Installation

In order to get the information from the qe-xml file, we need a python package called qeschema.

QEF/qeschema
Contribute to QEF/qeschema development by creating an account on GitHub.

dict_data['qes:espresso']

After the installation, we could use the following code to generate the information (in python dictionary, in which we can process later):

import qeschema

pw_document = qeschema.PwDocument()
pw_document.read('./aiida.xml')

dict_data = pw_document.to_dict()

Then we could look at the content in dict_data:

dict_data.keys()

The output is:

dict_keys(['qes:espresso'])

Then we print the keys in dict_data['qes:espresso'], then we can get:

>>> dict_data['qes:espresso'].keys()
>>> dict_keys(['@xmlns:xsi', '@xmlns:qes', '@xsi:schemaLocation', '@Units', 'general_info', 'parallel_info', 'input', 'step', 'output', 'status', 'timing_info', 'closed'])

The most important keys are:

  • parallel_info: shows the information about the parallelization
  • input: shows the input file
  • step: a python list, which contains all the steps of atomic relaxation and electronic scf calculations, really useful
  • output: the output file of your simulation
  • status: determine whether your simulation is finished OK (0) or not
  • timing_info: the timing of your simulation (how much time does it take)

output

Now we should first look into the output, which contains all the information that we need in order to process our data:

>>> dict_data['qes:espresso']['output']['convergence_info']
>>> dict_keys(['convergence_info', 'algorithmic_info', 'atomic_species', 'atomic_structure', 'symmetries', 'basis_set', 'dft', 'magnetization', 'total_energy', 'band_structure', 'forces', 'stress'])

Let's learn these keys one by one (because all of them are really important):

convergence_info

In convergence_info we can get the convergence information of our simulation, to see whether our simulation has converged or not.

A typical output is shown in below:

>>> dict_data['qes:espresso']['output']['convergence_info']
>>> 
{'scf_conv': {'convergence_achieved': True,
  'n_scf_steps': 149,
  'scf_error': 4.412198869447713e-09},
 'opt_conv': {'convergence_achieved': True,
  'n_opt_steps': 77,
  'grad_norm': 0.05120316772735826}}

Where scf_conv shows the scf step; and opt_conv shows the relaxation convergence. In this case we can see both of them are converged.

algorithmic_info

In algorithmic_info we can check the algorithm used in the pw.x:

>>> dict_data['qes:espresso']['output']['algorithmic_info']
>>> {'real_space_q': False, 'real_space_beta': False, 'uspp': True, 'paw': False}

This shows that in this simulation we are using the uspp (Ultra-Soft Pseudopotential)

atomic_species

In atomic_species we can see all the types of atoms we have in our system and the corresponding pseudopotentials that we used.

>>> dict_data['qes:espresso']['output']['atomic_species']
>>> 
{'@ntyp': 4,
 '@pseudo_dir': './pseudo/',
 'species': [{'@name': 'Fe',
   'mass': 58.6934,
   'pseudo_file': 'Fe.uspp.pbe.VDB.UPF',
   'starting_magnetization': -0.08401577400982042},
  {'@name': 'H',
   'mass': 1.008,
   'pseudo_file': 'H.pbe-van_bm.UPF',
   'starting_magnetization': 0.005037586351737685},
  {'@name': 'Ni',
   'mass': 58.6934,
   'pseudo_file': 'Ni.pbe.uspp.VDB.UPF',
   'starting_magnetization': 0.1454593086170182},
  {'@name': 'O',
   'mass': 15.999,
   'pseudo_file': 'O.uspp.pbe.UPF',
   'starting_magnetization': 0.02291090336123523}]}

atomic_structure

The atomic_structure will represent the optimized structure of our system, this is so important for our later simulations, because lots of properties (PDOS, DOS, etc.) are based on optimized structures.

>>> dict_data['qes:espresso']['output']['atomic_structure']
>>>
{'@nat': 64,
 '@alat': 10.96854227739,
 'atomic_positions': {'atom': [{'@name': 'Ni',
    '@index': 1,
    '$': [-2.753971530871385, 21.13716096599403, 8.020474824821578]},
   {'@name': 'Ni',
    '@index': 2,
    '$': [5.346523160030826, 6.664565821035703, 8.30101482981721]},
   {'@name': 'O',
    '@index': 3,
    '$': [-0.01598896219289322, 3.091416772923155, 1.543582911534848]},
   {'@name': 'O',
    '@index': 4,
    '$': [-2.805085359006213, 8.237817389827617, 1.783261411495191]},
   {'@name': 'O',
    '@index': 5,
    '$': [-0.05670045571537367, 3.271189810788649, 6.273341037304396]},
   {'@name': 'O',
    '@index': 6,
    '$': [-2.856224453957867, 8.336740914955229, 6.528374080743689]},
   {'@name': 'H',
    '@index': 7,
    '$': [0.02729013267886097, 3.139318997531369, 4.299095357765525]},
   {'@name': 'H',
    '@index': 8,
    '$': [-2.883032697213061, 8.354552868706868, 3.758448888878352]},
   {'@name': 'Ni',
    '@index': 9,
    '$': [-8.305283806697762, 21.11667229517019, 7.99734845316339]},
   {'@name': 'Ni',
    '@index': 10,
    '$': [-0.1862142151671258, 6.647537724880522, 8.265292486815706]},
   {'@name': 'O',
    '@index': 11,
    '$': [5.744840313636344, 3.084742620309016, 1.642993759168402]},
   {'@name': 'O',
    '@index': 12,
    '$': [2.705734812998368, 8.119985114279409, 1.777230415499783]},
   {'@name': 'O',
    '@index': 13,
    '$': [5.504967509528367, 3.405556199536604, 6.349052743055291]},
   {'@name': 'O',
    '@index': 14,
    '$': [2.481542571090582, 8.33627644489776, 6.519688330059797]},
   {'@name': 'H',
    '@index': 15,
    '$': [5.675890104024421, 3.259379628480058, 4.364702582606874]},
   {'@name': 'H',
    '@index': 16,
    '$': [2.525901789720345, 8.197853764040657, 3.756722605702716]},
   {'@name': 'Fe',
    '@index': 17,
    '$': [2.642058519428041, 11.47325896830832, 8.21959281566832]},
   {'@name': 'Ni',
    '@index': 18,
    '$': [-0.05757112594245171, 16.2201169771266, 8.128400362844998]},
   {'@name': 'O',
    '@index': 19,
    '$': [-5.340202647506548, 12.85272054272661, 1.391420299111586]},
   {'@name': 'O',
    '@index': 20,
    '$': [-7.969372086196088, 17.93985513954917, 1.539764426247003]},
   {'@name': 'O',
    '@index': 21,
    '$': [-5.69748923312235, 12.79557065571962, 6.185678296079502]},
   {'@name': 'O',
    '@index': 22,
    '$': [-8.245544489237474, 17.96141061724618, 6.245936854238048]},
   {'@name': 'H',
    '@index': 23,
    '$': [-5.590089942631859, 12.72117712836625, 4.221533439376117]},
   {'@name': 'H',
    '@index': 24,
    '$': [-8.054793717382832, 18.04016342120861, 4.219434967788191]},
   {'@name': 'Ni',
    '@index': 25,
    '$': [-2.916613336886357, 11.45111646616479, 8.190791081096073]},
   {'@name': 'Ni',
    '@index': 26,
    '$': [-5.620561170690955, 16.22907967956963, 8.085578862356968]},
   {'@name': 'O',
    '@index': 27,
    '$': [0.2821967778332864, 12.85429894923019, 1.448595692929271]},
   {'@name': 'O',
    '@index': 28,
    '$': [-2.730632692698876, 17.630498396179, 1.595705091584898]},
   {'@name': 'O',
    '@index': 29,
    '$': [0.03638887721796269, 12.9049751191081, 6.221546914871396]},
   {'@name': 'O',
    '@index': 30,
    '$': [-2.955829782312242, 17.96117921061406, 6.283085500838348]},
   {'@name': 'H',
    '@index': 31,
    '$': [0.2008620240603259, 12.83365055876618, 4.26204181787535]},
   {'@name': 'H',
    '@index': 32,
    '$': [-2.981209205673988, 17.88373216776455, 4.245555218084934]},
   {'@name': 'Ni',
    '@index': 33,
    '$': [-5.878807142385197, 22.89702762138912, 16.42867256896495]},
   {'@name': 'Ni',
    '@index': 34,
    '$': [2.211460683604727, 8.494158280357476, 16.65122177349388]},
   {'@name': 'O',
    '@index': 35,
    '$': [-2.863723396342093, 4.948534701888565, 10.00250609140918]},
   {'@name': 'O',
    '@index': 36,
    '$': [-5.868431265426858, 9.93304073788776, 10.13355316804045]},
   {'@name': 'O',
    '@index': 37,
    '$': [-3.152862770627408, 5.174676844901358, 14.67363020615957]},
   {'@name': 'O',
    '@index': 38,
    '$': [-6.237114243267514, 10.18638718608891, 14.84374651643926]},
   {'@name': 'H',
    '@index': 39,
    '$': [-2.933298364133369, 5.049181884859178, 12.66391829709219]},
   {'@name': 'H',
    '@index': 40,
    '$': [-6.072113605484608, 10.04126327104134, 12.11085654255438]},
   {'@name': 'Ni',
    '@index': 41,
    '$': [-11.42526282515651, 22.87930150039537, 16.37791440876595]},
   {'@name': 'Ni',
    '@index': 42,
    '$': [-3.327419763099309, 8.490052413069261, 16.58375550679831]},
   {'@name': 'O',
    '@index': 43,
    '$': [2.461771909773785, 4.939372842582904, 10.05451447158573]},
   {'@name': 'O',
    '@index': 44,
    '$': [-0.1174963527736981, 10.10483134364778, 10.16166922450553]},
   {'@name': 'O',
    '@index': 45,
    '$': [2.142827237366711, 4.950200796087722, 14.75586901759933]},
   {'@name': 'O',
    '@index': 46,
    '$': [-0.4353945055586605, 10.1807790909915, 14.89278511756802]},
   {'@name': 'H',
    '@index': 47,
    '$': [2.208467563565312, 4.827374607200515, 12.72912705166768]},
   {'@name': 'H',
    '@index': 48,
    '$': [-0.2051233351877594, 10.22572029239386, 12.13270313227373]},
   {'@name': 'Ni',
    '@index': 49,
    '$': [-0.4680546148472501, 13.35278907464944, 16.55041746478138]},
   {'@name': 'Ni',
    '@index': 50,
    '$': [-3.17205454372733, 18.14046462156462, 16.47082001984631]},
   {'@name': 'O',
    '@index': 51,
    '$': [-8.250811283544534, 14.55959546472252, 9.878420984233875]},
   {'@name': 'O',
    '@index': 52,
    '$': [-11.32219170204362, 19.56977864321104, 9.908669926519222]},
   {'@name': 'O',
    '@index': 53,
    '$': [-8.570108116458835, 14.97052696762282, 14.54968484645359]},
   {'@name': 'O',
    '@index': 54,
    '$': [-11.52134679440729, 19.76052423489615, 14.70009049848895]},
   {'@name': 'H',
    '@index': 55,
    '$': [-8.347849975207026, 14.81329515045267, 12.51817045052062]},
   {'@name': 'H',
    '@index': 56,
    '$': [-11.47648474227266, 19.72897776253405, 11.85404782717183]},
   {'@name': 'Ni',
    '@index': 57,
    '$': [-6.046275289968052, 13.36049781910645, 16.51726914029955]},
   {'@name': 'Fe',
    '@index': 58,
    '$': [-8.743418815673976, 18.1606800713907, 16.45606036569388]},
   {'@name': 'O',
    '@index': 59,
    '$': [-3.009614759927872, 14.54836298162636, 9.86494331346711]},
   {'@name': 'O',
    '@index': 60,
    '$': [-5.746661712610252, 19.66766882953775, 10.00172389941143]},
   {'@name': 'O',
    '@index': 61,
    '$': [-3.055035098033748, 14.74837448237939, 14.53161622872944]},
   {'@name': 'O',
    '@index': 62,
    '$': [-5.918954224378527, 19.76492231820684, 14.79883680886914]},
   {'@name': 'H',
    '@index': 63,
    '$': [-3.013961515428232, 14.58896675567225, 12.49323346086344]},
   {'@name': 'H',
    '@index': 64,
    '$': [-5.871333743980075, 19.7869813607191, 11.95854750011383]}]},
 'cell': {'a1': [11.1067454171422, 0.01553834554722472, 0.06627757441389587],
  'a2': [-10.80428005181602, 19.27979865633355, -0.2787821680712856],
  'a3': [-6.2019355886473, 3.66825948913474, 16.7262822639897]}}

We can see that we have two important information: atomic_positions and cell, by using both information, we can create the optimized structure as the input file.

magnetization

If we want to calculate magnetic material (e.g. with Ni or Fe), the magnetization is really really important.

In the magnetization key, we have:

>>> dict_data['qes:espresso']['output']['magnetization']
>>>
{'lsda': True,
 'noncolin': False,
 'spinorbit': False,
 'total': 16.0000000001087,
 'absolute': 21.37843243579283,
 'do_magnetization': False}

But if we use DFT+U method with spin polarization, we will have more information in dft key.

dft

>>> dict_data['qes:espresso']['output']['dft']
>>> 
{'functional': 'PBESOL',
 'dftU': {'lda_plus_u_kind': 0,
  'Hubbard_U': [{'@specie': 'Fe', '@label': '3d', '$': 0.3674932217565494},
   {'@specie': 'Ni', '@label': '3d', '$': 0.3674932217565494}],
  'starting_ns': [{'@specie': 'Fe',
    '@label': '3d',
    '@spin': 1,
    '@size': 7,
    '$': [1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]},
   {'@specie': 'Ni',
    '@label': '3d',
    '@spin': 1,
    '@size': 7,
    '$': [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0]},
   {'@specie': 'Fe',
    '@label': '3d',
    '@spin': 2,
    '@size': 7,
    '$': [1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]},
   {'@specie': 'Ni',
    '@label': '3d',
    '@spin': 2,
    '@size': 7,
    '$': [1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]}],
  'Hubbard_ns': [{'@specie': 'Ni',
    '@label': '3d',
    '@spin': 1,
    '@index': 1,
    '@rank': 2,
    '@dims': [5, 5],
    '@order': 'F',
    '$': [0.995727543190972,
     0.007196361447609894,
     -0.01507944450053442,
     -0.01084480360318141,
     0.008299325281752134,
     0.007196361447609894,
     0.9480958231298999,
     0.07546835323477848,
     0.05358245278887454,
     -0.04470890706231537,
     -0.01507944450053442,
     0.07546835323477848,
     0.8591339019527473,
     -0.09830165981891956,
     0.06900529319416676,
     -0.01084480360318141,
     0.05358245278887454,
     -0.09830165981891956,
     0.9272044891248711,
     0.04982898054850455,
     0.008299325281752134,
     -0.04470890706231537,
     0.06900529319416676,
     0.04982898054850455,
     0.9544063983154782]},
   {'@specie': 'Ni',
    '@label': '3d',
    '@spin': 2,
    '@index': 2,
    '@rank': 2,
    '@dims': [5, 5],
    '@order': 'F',
    '$': [0.9903597492803397,
     0.003180700563630973,
     -0.02536279655488269,
     -0.02050468562453097,
     0.009297813327286936,
     0.003180700563630973,
     0.5741633042067797,
     -0.03291833799231249,
     -0.07988799657509521,
     -0.2648147850019928,
     -0.02536279655488269,
     -0.03291833799231249,
     0.6885481268761381,
     -0.2540957971453488,
     0.02005344085732418,
     -0.02050468562453097,
     -0.07988799657509521,
     -0.2540957971453488,
     0.7766228426108466,
     -0.01483168201991642,
     0.009297813327286936,
     -0.2648147850019928,
     0.02005344085732418,
     -0.01483168201991642,
     0.817682489309011]},

Because of the space, I don't show all the content, but you can see that we have the occupation of d-state in Ni and Fe atoms. These information is really really useful for our analysis.

There are more informations in the xml file, and you could explore it yourself.

Happy coding, and happy research!

Best,

ZDH

Subscribe to He Zhengda

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe