A measurement of the production of ultracold neutrons from velocity-selected cold neutrons on gaseous and solid deuterium targets is reported. The expected energy dependence for two-particle collisions with well defined neutron and Maxwell-Boltzmann distributed molecular velocities is found for the gas target. The solid target data agree in shape with the phonon density-of-states curve and provide strong evidence for the phonon model including multiphonon excitations.