The effect of X (X = O, Se, N, P, F, Cl) doping on the adsorption of Zn atoms by WS2 was investigated based on first principles. The electronic structure and optical properties of the adsorbed system after atomic doping were calculated. It is found that the Zn atom adsorbed on the W top (Tw) site has the most stable structure. When an S atom is replaced with an X atom based on the adsorption system, where the adsorption energy decreases after doping of O, P, F, and Cl atoms compared to the undoped system, it means that each system is more stable after doping of these atoms; charge transfer shows that the adsorption system after P-atom doping the system around the Zn atom loses electrons while S-atom gains electrons, which indicates that P-atom doping is favorable for the adsorption of Zn by WS2, N, P-atom is introduced as p-type doping and F, Cl-atom is introduced undoped by n-type doping, and the band gap of the doped system is less than that of the undoped one. With the introduction of different dopant atoms, certain impurity energy levels are introduced into the adsorption system. The prohibited bandwidth around the Fermi energy level reduces the density of states, causing the doped system's density of states to shift to lower energies, among which the shifts of N, P, F, and Cl are more pronounced. The P-doped adsorption system shows a new peak near the energy of - 11 eV. In addition, the study of optical properties showed that the peak reflections of both doped and non-doped systems adsorbing Zn atoms appeared in the ultraviolet region; the absorbance coefficient of the doped system is moved in the lower energy direction and red-shifted after atom doping; in addition, the absorption coefficients and reflectance of the P, Se doped systems are enhanced in the wavelength range of 200-300 nm compared with that before doping, the dielectric function and CBM and VBM positions were also calculated further indicating the potential of Se-doped systems in improving photocatalytic efficiency. In this paper, the structure optimization of X (X = O, Se, N, P, F, Cl) doping on WS2 adsorbed Zn atom model is performed based on the CASTEP module in Materials-Studio software under the first principles using GGA and PBE generalized function. The corresponding binding energies, bond lengths, bond angles, charge densities, energy band structures, densities of states, and optical properties were also analyzed. The Monkhorst-Pack particular K-point sampling method is used in the calculations; the K-point grid is 6 × 6 × 1, and the cutoff energy for the plane wave expansion is 500 eV. After geometric optimization, the iterative accuracy converges to a value of less than 1 × 10-5 eV/atom for the total energy of each atom and less than 0.03 eV/Å for all atomic forces. The thickness of the vacuum layer was set to 20 Å to avoid the effect of interlayer interaction forces. In this paper, 27 atoms were used to form a 3 × 3 × 1 supercellular tungsten disulfide system consisting of 18 S atoms and 9 W atoms.