Rate equations model for semiconductor lasers with multilongitudinal mode competition and gain dynamics