Calculation of local friction forces in atomic-force microscopy of metal surfaces