Theoretical simulation of atomic-scale friction in atomic force microscopy