A prompt gamma neutron activation analysis (PGNAA) system based on a deuterium-deuterium (D-D) sealed neutron generator was designed using the MOCA code for explosive detection. The system is mainly composed of four parts: D-D sealed neutron generator, moderator, shielding, and Lutetium Yttrium OxyorthoSilicate (LYSO) scintillation detectors. Polyethylene (PE) was selected as the moderator and the optimal thickness was 7cm. Lead, PE, and boron-containing polyethylene were used as shielding materials. In the optimized model, the LYSO detector is used to measure eighteen materials, such as wood, melamine, glucose, and nylon, and so on. Firstly, the nitrogen characteristic peak of 10.8 MeV was analyzed to determine whether the material contained nitrogen. Then, the ratio of characteristic peak counts of C/O and O/N were calculated to distinguish explosives from nitrogen containing materials. Finally, dinitrobenzene, nitroglycerin, TNT, and ammonium nitrate can be separated from nitrogenous substances by a discriminant algorithm. The final device can be used to detect the chemical composition of the threat substances, and the maximum dose rate of the system meets the limits of international protection standards.