Theoretical Foundations of Nanoscale Quantum Devices