To improve fundamental understanding of thermal transport and materials design, the accurate prediction of thermal transport coefficients is critical. Addressing the need for an efficient and general quantum simulation framework for thermal properties of materials, we developed a new method for the calculation of thermal conductivity in homogeneous solids and fluids. This method can efficiently compute the thermal conductivity using either classical, first principle or Neural-Network Molecular Dynamics. We show the application of this method in the calculation of the thermal conductivity of solid crystalline and nanocrystalline MgO and liquid water. To show the performance of our approach we computed the thermal conductivity of MgO from first principle and the thermal conductivity of water at extreme temperature and pressure using a Neural Network potential trained on first principle data.