Simulations of the magnesium anode used (16 × 16) Mg(0001), (16 × 8) Mg(1010)A and (16×8) Mg(1011) periodic surface model systems with 60 layers for 1 ns ( = 4 000 000 iterations with 0.25 fs time step). On each side of the surface slab was a vacuum of 2000 Å thickness filled with 5504 O 2 molecules whose atomic configurations were generated using the PACK-MOL software. We calculated the number of O 2 molecules using the ideal gas law at 300 K at ten times atmospheric pressure (10 atm). The initial velocities of all atoms followed a Maxwell-Boltzmann distribution for 300 K. Furthermore, we applied a weakly coupled NHC thermostat (τ = 1000 fs) to the ten innermost Mg layers at 300 K to provide a heat sink for the reaction heat generated at the surface. The choice to use a heat sink region constitutes a compromise: in simulations without a thermostat, the Mg surface heated far beyond its melting temperature due to the strongly exothermic oxidation reaction taking place and evaporation was observed. The number of surface layers required to serve as a heat sink to compensate for this effect is computationally inefficient. In contrast, applying the thermostat to all atoms quenches the surface reactions altogether. With the thermostat layer used here, the surface heats up to several 1000 K for a short time upon first contact of the bare Mg surface with oxygen but the surface remains intact. An illustration of the cell setup and the simulation settings used are given in Figure .