The paper considers a mathematical model of potentials optimal distribution in a crystalline semiconductor. This model is based on the problem of optimal control of weak generalized solutions of the mathematical model of the potential distribution in a crystalline semiconductor with the Showalter–Sidorov condition. The theoretical results obtained by us earlier made it possible to develop an algorithm for a numerical method for finding an approximate one by solutions of the optimal control problem for the problem under study, based on the methods of decomposition, Ritz, penalty and Galerkin’s projection method. The results of a computational experiment are presented.