Quantum mechanical state preparation II-The statistical ensemble as a thermostat