Quantum theory of real materials