  While cognitive radio enables spectrum-efficient wireless communication,
radio frequency (RF) energy harvesting from ambient interference is an enabler
for energy-efficient wireless communication. In this paper, we model and
analyze cognitive and energy harvesting-based D2D communication in cellular
networks. The cognitive D2D transmitters harvest energy from ambient
interference and use one of the channels allocated to cellular users (in uplink
or downlink), which is referred to as the D2D channel, to communicate with the
corresponding receivers. We investigate two spectrum access policies for
cellular communication in the uplink or downlink, namely, random spectrum
access (RSA) policy and prioritized spectrum access (PSA) policy. In RSA, any
of the available channels including the channel used by the D2D transmitters
can be selected randomly for cellular communication, while in PSA the D2D
channel is used only when all of the other channels are occupied. A D2D
transmitter can communicate successfully with its receiver only when it
harvests enough energy to perform channel inversion toward the receiver, the
D2D channel is free, and the $\mathsf{SINR}$ at the receiver is above the
required threshold; otherwise, an outage occurs for the D2D communication. We
use tools from stochastic geometry to evaluate the performance of the proposed
communication system model with general path-loss exponent in terms of outage
probability for D2D and cellular users. We show that energy harvesting can be a
reliable alternative to power cognitive D2D transmitters while achieving
acceptable performance. Under the same $\mathsf{SINR}$ outage requirements as
for the non-cognitive case, cognitive channel access improves the outage
probability for D2D users for both the spectrum access policies.
