Due to the excellent performance of the CdTe solar cells, research is ongoing to increase the efficiency of these cells. The first purpose of this study is to increase the accuracy of the physical parameters of a solar cell in the electron ̶hole production rate equation. In previous studies, this section was neglected because of using only ready-made software. Simulations were performed using a one-dimensional diffusion model in MATLAB and Maple software. Then, in theory, we simulated cadmium telluride-based layered solar cells for the first time without using ready-made software and with coding in MATLAB and Maple software. We designed and optimized the thickness of the layers in solar cells in detail. Then we studied the effect of layer thickness on the short-circuit current (Jsc), open-circuit voltage (Voc), filling factor (FF), and its efficiency. It is found that the efficiency of solar cells layered with TCO/SnO2/CdS/CdTe layers is as follows: the thickness of the TCO layer is 0.1 μm, that of the SnO2 layer is equal to 0.1 μm, that of the CdS layer as the window layer is 0.1 μm and the thickness of the CdTe layer as the absorber layer is 3.9 μm. The efficiency of the solar cell with the TCO/SnO2/CdS/CdTe structure increases significantly and reaches a maximum value of more than 20%.