# How to calculate the d-band from pdos data?

I am trying to find the d-band center of pdos data generated using quantum espresso 6.8. I'm aware that this maybe calculated by the formula:

$$\frac{\int_{-\infty}^\infty E \cdot \textrm{pdos}(E)dE}{\int_{-\infty}^\infty \textrm{pdos}(E)dE} \tag{1}$$

I tried XMgrace as suggested here but was not able to do it. Is there a way to use this formula using MatLab, or any other software to integrate the pdos curve (maybe a piece of code)? Any help would be appreciated :)

• if you have E and pdos(E) data, you can use trapz function in matlab to integrate numerator and denominator of equation. mathworks.com/help/matlab/ref/trapz.html Feb 5 at 15:26
• That worked. Thank you @pranavkumar Feb 6 at 3:05
• @pranavkumar Can you turn that into an answer? Mar 2 at 19:17
• @pranavkumar Nike has a good point. If you can provide even a little more detail about this process, an answer is much more visible for future users (and much less likely to disappear than a comment).
– Tyberius
Mar 2 at 20:07

Numerical integration for evenly-spaced data can be performed using trapz function in MATLAB. Here infinite integration can assumed to integrate between extrema of data.
d_center=trapz(E,P)/trapz(E)

$$\int_{a}^{b}f(x)dx=\frac{b-a}{2N}( f(x_{1})+2f(x_{2})...+2f(x_{n})+f(x_{n+1}))$$