# How to understand the wavefunction outputed by QE with HDF5 format?

Following the answer to my question: What is the best program to manipulate numerical DFT wavefunctions to calculate custom matrix elements?, I compiled Quantum ESPRESSO with the hdf5 flag on, and now have wfcX.hdf5 output for each K point labeled by X. When I analyze these .hdf5 files in Python, it appears to be an array with 'Miller Indices' and 'evc' values (which are wavefunctions). These evcs are given as an array (row vector with size (1, 10000) for instance). However, this confuses me for two reasons, because:

1. All entries of evc are real numbers. I expected wavefunctions to be complex numbers in general. When I used pw_export.x with an earlier version of Quantum ESPRESSO, I got index.xml, which gives eigenvectors as a list of 2-column rows (columns that I assumed corresponded to the real and imaginary parts of the eigenvector).

2. There are many rows for the wavefunction of a single k point. I expected just one complex-valued wavefunction per k point. When I plotted the 1D array 'evc', I saw something like a highly oscillating function that was peaked at the origin but then looked as if it converged to 0 (as in the picture below). This makes me question whether these are just results of iterations until convergence was reached.

Could anyone clarify for me what's going on? If this evc isn't what I want, how do I get the eigenvector at each k point? Thanks.

• The DATASET "MillerIndices" stores the vectors of reciprocal space, namely $$n_1$$, $$n_2$$, and $$n_3$$ in following equation:

$$\dfrac{1}{\sqrt{V}}e^{i\vec{G}\cdot\vec{r}}=\dfrac{1}{\sqrt{V}}e^{i(n_1 \vec{a}_1+n_2\vec{b}_2+n_3\vec{b}_3)\cdot\vec{r}}$$

I assume that you have $$m$$ plane waves, then the data space should be $$(m,3)$$.

• As you said, the DATASET "evc" stores the wave function.

I further assume you have $$n$$ bands, then the data space should be $$n \times (m \times 2)$$ array. Due to the HDF5 library can't support the type of complex number, then the complex number generated by QE is stored as two neighborhood real numbers.

• The wave function in real space is calculated as follows:

$$\psi_{n\vec{k}}(\vec{r})=\dfrac{1}{\sqrt{V}}\sum_{\vec{G}}c_{n\vec{k}}(\vec{G}) e^{i(\vec{k}+\vec{G})\cdot\vec{r}}$$ in which

• $$\vec{G}=n_1\vec{b}_1+n_2\vec{b}_2+n_3\vec{b}_3$$
• $$\vec{k}=k_1\vec{b}_1+k_2\vec{b}_2+k_3\vec{b}_3$$
• $$\vec{r}=r_1\vec{a}_1+r_2\vec{a}_2+r_3\vec{a}_3$$

May it helps.

## UPDATE from Question Author:

I found the following data structure for output hdf5 files here: https://gitlab.com/QEF/q-e/snippets/1869219. I believe this makes a complete answer.

HDF5 "wfc17.hdf5" {
GROUP "/" {
ATTRIBUTE "gamma_only" {
DATATYPE  H5T_STRING {
STRSIZE 7;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
DATASPACE  SCALAR
DATA {
(0): ".FALSE."
}
}
ATTRIBUTE "igwx" {
DATATYPE  H5T_STD_I32LE
DATASPACE  SCALAR
DATA {
(0): 4572
}
}
ATTRIBUTE "ik" {
DATATYPE  H5T_STD_I32LE
DATASPACE  SCALAR
DATA {
(0): 17
}
}
ATTRIBUTE "ispin" {
DATATYPE  H5T_STD_I32LE
DATASPACE  SCALAR
DATA {
(0): 1
}
}
ATTRIBUTE "nbnd" {
DATATYPE  H5T_STD_I32LE
DATASPACE  SCALAR
DATA {
(0): 36
}
}
ATTRIBUTE "ngw" {
DATATYPE  H5T_STD_I32LE
DATASPACE  SCALAR
DATA {
(0): 4840
}
}
ATTRIBUTE "npol" {
DATATYPE  H5T_STD_I32LE
DATASPACE  SCALAR
DATA {
(0): 1
}
}
ATTRIBUTE "scale_factor" {
DATATYPE  H5T_IEEE_F64LE
DATASPACE  SCALAR
DATA {
(0): 1
}
}
ATTRIBUTE "xk" {
DATATYPE  H5T_ARRAY { [3] H5T_IEEE_F64LE }
DATASPACE  SCALAR
DATA {
(0): [ 0, 0.130217, 0.10252 ]
}
}
DATASET "MillerIndices" {
DATATYPE  H5T_STD_I32LE
DATASPACE  SIMPLE { ( 4572, 3 ) / ( 4572, 3 ) }
ATTRIBUTE "bg1" {
DATATYPE  H5T_ARRAY { [3] H5T_IEEE_F64LE }
DATASPACE  SCALAR
DATA {
(0): [ 0.67663, 0.390652, -0 ]
}
}
ATTRIBUTE "bg2" {
DATATYPE  H5T_ARRAY { [3] H5T_IEEE_F64LE }
DATASPACE  SCALAR
DATA {
(0): [ 0, 0.781305, 0 ]
}
}
ATTRIBUTE "bg3" {
DATATYPE  H5T_ARRAY { [3] H5T_IEEE_F64LE }
DATASPACE  SCALAR
DATA {
(0): [ 0, -0, 0.615118 ]
}
}
ATTRIBUTE "doc" {
DATATYPE  H5T_STRING {
STRSIZE 77;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
DATASPACE  SCALAR
DATA {
(0): "Miller Indices of the wave-vectors, same ordering as wave-function components"
}
}
}
DATASET "evc" {
DATATYPE  H5T_IEEE_F64LE
DATASPACE  SIMPLE { ( 36, 9144 ) / ( 36, 9144 ) }
ATTRIBUTE "doc:" {
DATATYPE  H5T_STRING {
STRSIZE 145;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
DATASPACE  SCALAR
DATA {
(0): "Wave Functions, (npwx,nbnd), each contiguous line represents a wave function,  each complex coefficient is given by a couple of contiguous floats"
}
}
}
}

• Thank you for your answer. I found some resources here: mail-archive.com/[email protected]/msg36186.html and I will update your answer accordingly and accept it. Commented Feb 3, 2021 at 19:04
• If I sum all complex plane-wave functions, am I guaranteed to get a correct energy eigenstate? Commented Feb 3, 2021 at 22:54
• I think the answer is YES.
– Jack
Commented Feb 3, 2021 at 23:50