We have performed atomic force microscopy (AFM) simulations to understand the microscopic mechanism of an AFM experiment, especially the observed energy dissipation. The oscillation of a cantilever in AFM is described by spring motion, and the atomic interaction between the tip attached on cantilever and surface is calculated by the molecular dynamics (MD) method. In order to couple the spring motion with the atomic dynamics, we use the MD/continuum coupling method which was developed by our group. We propose a simple computational model using Lennard Jones interatomic potential. As the spring approaches the surface, the atomic interaction between the tip and surface increases and it perturbs harmonic oscillation of the spring with the frequency shifted and the amplitude damped. The kinetic energy of the spring is transferred to the atoms on the surface. It is shown that this energy dissipation comes from two atomic processes: irreversible atomic dynamics and atomic thermal fluctuation.