Abstract-Nonlinearity in p-i-n photodetectors leads to power generation at harmonics of the input frequency, limiting the performance of RF-photonic systems. We use one-dimensional and two-dimensional simulations of the drift-diffusion equations to determine the physical origin of the saturation in a simple heterojunction p-i-n photodetector at room temperature. Incomplete ionization, external loading, impact ionization, and the Franz-Keldysh effect are all included in the model. Impact ionization is the main source of nonlinearity at large reverse bias (>10 V in the device that we simulated). The electron and hole current contributions to the second harmonic power were calculated. We find that impact ionization has a greater effect on the electrons than it does on the holes. We also find that the hole velocity saturates slowly with increasing reverse bias, and the hole current makes a large contribution to the harmonic power at 10 V. This result implies that decreasing the hole injection will decrease the harmonic power.Index Terms-2D simulation, impact ionization, nonlinearity, p-i-n photodetector.