Kohn–Sham energy decomposition for molecules in a magnetic field