# Power Control and Channel Allocation Algorithm for Energy Harvesting D2D Communications
## 4 Simulation Results and Discussion  
In this section, the simulation results of the proposed optimal joint power control and channel allocation algorithm in MATLAB R2015b are given, and the influence of the distance between D2D pair \(Rd\), the number of D2D users \(N\), and the number of cellular users \(M\) on the total capacity of D2D users is analyzed. In this paper, we denote that channel gain consists of large-scale fading based on path loss and small-scale fading based on Rayleigh fading and is expressed as \(h=\kappa d^{-\alpha}\big{|}g_{0}\big{|}^{2}\)[15], where \(\kappa\) and \(\alpha\) respectively represents path loss constant and path loss exponent, \(d\) is the distance between transmitter and receiver, and \(\big{|}g_{0}\big{|}^{2}\) represents Rayleigh fading that follows the mean value of exponential distribution as 1. After analyzing \(\xi_{m,j}\), \(\xi_{p,j}\), \(\xi_{o,j}\) and \(\xi_{dct,j}\), the simulation diagram in [19] illustrates the relationship between converter efficiency and input power, according to the simulation diagram, we use an expression for energy harvesting efficiency in the simulation is \(\xi_{j}=1/\Big{(}1+\exp\Big{(}-P_{BS}l_{Bj}\big{)}\Big{)}\). Other simulation parameters and their specific values are given in Table 1.  
Figure 3 shows the impact of different distance between D2D pair on the total capacity of D2D users, and the proposed algorithm in this paper is compared with the algorithm in [13] and the equal time allocation (ETA) method. The ETA method uses half the time \(T\) to harvest energy and the other half to transmit information. Without loss of generality, we consider a standardized unit time period [20], that is \(T=1\). In the simulation, it is assumed that there are 10 D2D users and 5 cellular users in the cell. Figure 2: Weighted bipartite graph for optimal matching problem of D2D clusters and cellular users’ channels. The channel gain of the D2D link decreases as the distance between the D2D pair increases, which leads to the decrease of D2D users' total capacity; therefore, the total capacity of D2D users decreases with the increasing distance between D2D pair. Meanwhile, the proposed algorithm is superior to the algorithm in [13] and the ETA method, and the reason is that the proposed algorithm takes both the co-channel interference of D2D users and the limitation of the harvested energy into account with the aim of maximizing the total capacity of the D2D user to get each D2D user's optimal transmission power, then determines energy harvesting time of each D2D transmitters. The [13] assumes that the energy harvesting time of multiple D2D transmitters on a same channel is same, however, the optimal transmission power and energy harvesting time of different D2D transmitters are different. When the ETA method is adopted, the transmission power of D2D users only depends on the harvested energy by the D2D transmitter and energy harvesting time is not optimized. Therefore, the algorithm in this paper can obtain bigger capacity than the algorithm in [13] and ETA method. Figure 4 shows the total capacity of D2D users with the increasing number of D2D users. In the simulation, we assume that the distance between D2D pair is 10 m, and there are 5 cellular users in the cell. As can be seen from Figure 4, with the increasing number of D2D users, the total capacity of D2D users increases. This is because as the number of D2D users increases, more D2D users can reuse the channels of cellular users for communication, which increases the total capacity of D2D users. The complexity of the proposed power control algorithm is \(O(LN)\) in the worst case, and the complexity of the power control algorithm in [13] is \(O\big{(}LKN^{3}\big{)}\) in the worst case, where \(L\) and \(K\) are iteration numbers, the ETA method does not optimize transmission power and energy harvesting time, and its complexity is \(O(1)\).