First-Principles Method to Study Near-Field Radiative Heat Transfer