  The standard equilibrium Green-Kubo and nonequilibrium molecular dynamics
(MD) methods for computing thermal transport coefficients in solids typically
require relatively long simulation times and large system sizes. To this end,
we revisit here the homogeneous nonequilibrium MD method by Evans [Phys. Lett.
A \textbf{91}, 457 (1982)] and generalize it to many-body potentials that are
required for more realistic materials modeling. We also propose a method for
obtaining spectral conductivity and phonon mean free path from the simulation
data. This spectral decomposition method does not require lattice dynamics
calculations and can find important applications in spatially complex
structures. We benchmark the method by calculating thermal conductivities of
three-dimensional silicon, two-dimensional graphene, and a
quasi-one-dimensional carbon nanotube and show that the method is about one to
two orders of magnitude more efficient than the Green-Kubo method. We apply the
spectral decomposition method to examine the long-standing dispute over thermal
conductivity convergence vs divergence in carbon nanotubes.
