A two-dimensional device simulator for designing laser diodes has been developed. The wave equation and the rate equation for photons, as well as Poisson's equation and the current-continuity equations for electrons and holes, are solved numerically. The letter can reveal precisely the operation mechanism of laser diodes.