A computational model is proposed to analyze the nanoscale self-assembling phenomenon of monolayers on heterogeneous surfaces. Morse potential is used to describe the pairpotential between molecules or atoms. Minimization of free energy is used to regulate different phases and lattices to form optimized heterogeneous structures of different sizes with periodical patterns. A representative volume element (RVE) is first defined and an optimization algorithm is developed to adjust the positions of particles in it to reduce its potential until global equilibrium is reached. The pair-potential distribution in the monolayer and the substrate layers are studied. It is interesting to observe that the pair-potential distribution in the substrate layers resumes uniformity just a few layers away from the interfacial boundary.