We give a detailed presentation of the theory and numerical implementation of an expression for the adiabatic energy flux in extended systems, derived from density-functional theory. This expression can be used to estimate the heat conductivity from equilibrium ab initio molecular dynamics, using the Green-Kubo linear response theory of transport coefficients. Our expression is implemented in an open-source component of the Quantum ESPRESSO suite of computer codes for quantum mechanical materials modeling, which is being made publicly available. Program title: QEHeat CPC Library link to program files: https://doi.org/10.17632/c6wxkvy4z3.1 Licensing provisions: GPLv3 Programming language: Fortran Nature of problem: The computation of thermal transport coefficients via equilibrium molecular dynamics and the Green-Kubo theory of linear response requires the definition of a heat-flux describing the instantaneous flow of energy. When considering predictive first-principles methods, a definition of the heat-flux compatible with density-functional theory is required [1]. The evaluation of such a heat flux requires an extension of state-of-the-art atomic simulation codes. Solution method: This work describes in detail the numerical implementation of the adiabatic energy current derived in Refs. [1, 2] and makes it available to the users of the Quantum ESPRESSO suite of computer codes [3]. Used in conjunction with the cp.x code, to perform Car-Parrinello ab initio molecular dynamics , and the SPORTRAN post-processing tool for data analysis [4–6], the program allows to estimate heat transport coefficients in extended systems entirely from first principles. The new code provides as well to developers a modular and easily extendable framework to evaluate time derivatives of electronic properties (e.g. electronic densities or potentials) via a finite difference approach. [1] A. Marcolongo, P. Umari, S. Baroni, Nat. Phys. 12 (2016) 80. [2] W. Andreoni, S. Yip (Eds.), in: Handbook of Materials Modeling. Applications: Current and Emerging Materials, 2nd ed., Springer, 2018, Chap. 12-1, https://arxiv.org/abs/1802.08006. [3] P. Giannozzi et al., J. Phys. Condens. Matter 21 (2009) 395502; P. Giannozzi et al., J. Phys. Condens. Matter 29 (2017) 465901; P. Giannozzi et al., J. Chem. Phys. 152 (2020) 154105. [4] L. Ercole, A. Marcolongo, S. Baroni, Sci. Rep. 7 (2017) 15835. [5] R. Bertossa, F. Grasselli, L. Ercole, S. Baroni Phys. Rev. Lett. 122 (2019) 255901. [6] L. Ercole, R. Bertossa, S. Bisacchi, S. Baroni, SporTran: a code to estimate transport coefficients from the cepstral analysis of a multi-variate current stationary time series, https://github.com/lorisercole/sportran , 2017–2021. [ABSTRACT FROM AUTHOR]