Simulation and modeling of the powder diffraction pattern from nanoparticles