We have investigated the effect of scan velocity on atomic friction force in a Prandtl–Tomlinson model at finite temperature. We use a nonsinusoidal substrate potential with variable shape to capture surface features. The velocity dependence of atomic friction force is classified into two regimes: thermal and athermal regimes. We numerically find turning velocity between these two regimes, and its shape parameter dependence is determined. Furthermore, we have studied the torsional oscillation effect on a cantilever. We show that friction force can be reduced by controlling the frequency and the amplitude of the superimposed torsional oscillation at low scan velocity. The numerical calculations have shown that the substrate shape strongly affects the occurrence of resonances, so the torsional resonance frequency dependence of the shape parameter is established.