Mechanism and kinetics for both thermal and electrochemical reduction of N2 catalysed by Ru(0001) based on quantum mechanics.