The numerical method upon which our code is based was developed by Courtier et al. [
6] to solve a simplified model description of a perovskite solar cell in which it was assumed that the transport layers were so highly doped that the potential within them was uniform, thereby reducing the model to equations in the perovskite absorber layer only. In that work, the speed and accuracy of the method are compared against those of two previously used alternatives. It is shown that the method we adopt here is superior to both of these methods for both metrics of performance. Here, we adapt the finite element-based scheme to solve the dimensionless three-layer model set out in the previous section. We do not use the Scharfetter–Gummel scheme [
19], commonly used for the solution of drift–diffusion equations, because it is tailored to deal with issues related to charge carrier transport rather than accurately resolving solutions in narrow Debye layers, which is the main difficulty in the present work.
4.1 Spatial grid
The discretisation is formulated on a computational grid comprised of \(N+N_{\rm E}+N_{\rm H}+1\) non-uniformly positioned grid points which partition the (non-dimensional) domain \(x\in [-w_{\rm E},1+w_{\rm H}]\) into \(N+N_{\rm E}+N_{\rm H}\) subintervals. The perovskite layer (including interfaces) contains \(N+1\) grid points denoted by \(x=x_i\) for \(i=0,\ldots ,N\) with subinterval widths denoted by \(\varDelta _{i+1/2}=x_{i+1}-x_{i}\). The transport layer domains (excluding interfaces) contain \(N_{\rm E}\) and \(N_{\rm H}\) grid points, respectively, with grid points denoted by \(x=x^{E}_i\) for \(i=0,\ldots ,N_{\rm E}-1\) and \(x=x^{H}_i\) for \(i=1,\ldots ,N_{\rm H}\), respectively, with corresponding subinterval notation.
It is known that the largest gradients in the solution appear in narrow Debye layers adjacent to the material interfaces [
5]. This motivates the use of a grid in which points are concentrated near the domain boundaries and at internal interfaces so that computational resolution is focused there and not wasted where it is not required. One such grid can be created by extending the
tanh grid used in [
6] to the three-layer cell geometry displayed in Fig.
2. Specifically, we set
$$\begin{aligned}&x_i = \frac{1}{2} \left( \frac{\tanh \left[ s\left( \frac{2i}{N}-1\right) \right] }{\tanh (s)}+1\right) , \\& \qquad \text{ for } i=0,\ldots ,N, \end{aligned}$$
(34)
$$\begin{aligned}&x^{E}_i = \frac{w_{\rm E}}{2} \left( \frac{\tanh \left[ s\left( \frac{2i}{N_{\rm E}}-1\right) \right] }{\tanh (s)}-1\right) , \\& \qquad \text{ for } i=0,\ldots ,N_{\rm E}-1, \end{aligned}$$
(35)
$$\begin{aligned}&x^{H}_i = 1+\frac{w_{\rm H}}{2} \left( \frac{\tanh \left[ s\left( \frac{2i}{N_{\rm H}}-1\right) \right] }{\tanh (s)}+1\right) , \\& \qquad \text{ for } i=1,\ldots ,N_{\rm H}. \end{aligned}$$
(36)
Our numerical experiments indicate that a good rule of thumb for deciding on a judicious choice for the value for
s can be to calculate a value which leads to 20% of the grid points falling within one Debye length of each interface within the perovskite layer (i.e. the intervals
\(x \in [0,\lambda ]\) and
\(x \in [1-\lambda ,1]\)), via numerical solution of
$$\begin{aligned} \lambda = \frac{1}{2} \left( \frac{\tanh \left( 0.6\right) }{\tanh (s)}+1\right) . \end{aligned}$$
(37)
The code is set up so that the numbers of grid points \(N_{\rm E}\) and \(N_{\rm H}\) are chosen based on the input parameter N to give approximately equal spacing immediately either side of the interface.
4.2 Finite element scheme
As in [
6], we employ a common finite element approach, in which each of the dependent variables is approximated as a linear combination of piecewise linear basis functions with compact support. For a generic dependent variable,
\(u\), defined within the perovskite, i.e. for
\(x \in (0,1)\), we write
$$u(x,t) = \sum _{i=0}^{i=N} u_i(t) \varphi _i(x)$$
(38)
where
$$\varphi _i(x) = {\left\{\begin{array}{ll} \frac{x-x_{i-1}}{x_i-x_{i-1}} &\quad{} {\text {if }}x \in (x_{i-1},x_i)\\ \frac{x_{i+1} - x}{x_{i+1}-x_i} &\quad{} {\text {if }}x \in (x_{i},x_{i+1}) \\ 0 &\quad{} {\text {if }}x \notin (x_{i-1},x_{i+1}) \end{array}\right. }$$
(39)
in which
\(\varphi _i(x)\) are referred to as the basis functions. Each of the governing equations of interest can be manipulated into the form
$$\begin{aligned} A \frac{\partial u}{\partial t} = B \frac{\partial }{\partial x} \left( \frac{\partial u}{\partial x} \pm u\frac{\partial \phi }{\partial x} \right) + S(x,t,u,v_1,v_2,v_3), \end{aligned}$$
(40)
in which
A and
B are constants and the function
\(S(x,t,u,v_1,v_2,v_3)\) is a source term which depends upon the spatial variable
x, the temporal variable
t, the generic variable
\(u\) and a series of other generic dependent variables
\(v_i\) for
\(i=1,2,3\). The electron, hole and halide ion vacancy conservation equations, (
1), (
2) and (
3), are rewritten in this form by eliminating the attendant electron or hole current densities, or the halide ion vacancy flux, respectively. Poisson’s equation in the perovskite, (
4), is already in this form.
The spatially discretised equations in the perovskite are derived by multiplying (
40) through each of the test functions
\(\varphi _j(x)\) (for
\(j=0,\ldots ,N\)), integrating over the domain
\(x \in (0,1)\) (using integration by parts where appropriate) and substituting form (
38) for each of the dependent variables. On doing so, we arrive at
$$\begin{aligned}&A \sum _{i=0}^{i=N} \frac{\mathrm {d}u_i}{\mathrm {d}t} \int _0^1 \varphi _i \varphi _j \,\mathrm {d}x \\ & \quad = B \left( \frac{\partial u}{\partial x} \pm u\frac{\partial \phi }{\partial x} \right) \varphi _j \Big |_{x=0}^{x=1} \\ & - B \left\{ \sum _{i=0}^{i=N} u_i \int _0^1 \varphi _i' \varphi _j' \,\mathrm {d}x \right. \\ & \left. \pm \sum _{i=0}^{i=N} \sum _{k=0}^{k=N} u_i \phi _k \int _0^1 \varphi _i \varphi _j' \varphi _k' \,\mathrm {d}x \right\} \\ & + \int _0^1 S(x,t,u,v_1,v_2,v_3) \varphi _j \,\mathrm {d}x. \end{aligned}$$
(41)
Each of the integrals containing expressions that depend solely on the basis functions and/or their derivatives can be computed exactly. Likewise, terms containing quantities evaluated on the boundaries
\(x=0,1\) can be computed exactly using the continuity conditions (
11)–(
12), else the relevant equation is replaced by the corresponding Dirichlet condition. The one remaining term that is not so readily computed is the final integral in (
41) that depends on the source terms
S. For the anion vacancy conservation,
\(S\equiv 0\) and so this term is zero. For Poisson’s equation, this term is a linear combination of dependent variables and so can be computed exactly. However, for the electron and hole conservation equations, (
2) and (
1), the source term comprises both the generation and bulk recombination rates,
G(
x) and
R(
n,
p), which are highly nonlinear, see Sect.
3.2. In order that the integral contained in the final term of (
41) can be integrated (at least approximately) regardless of the functional form of the source term, we make a further approximation, that is, to replace the dependent variables in the integrand by functions that are piecewise constant over each subinterval,
\(x\in (x_i,x_{i+1})\), and have a value equal to that of the full series (
38) at the midpoint of that interval. In short, we make the additional approximation
$$\begin{aligned}&\int _0^{1} ( G - R(n,p)) \varphi _j \,\mathrm {d}x \approx \\&{\left\{ \begin{array}{ll} \frac{\varDelta _{j-\frac{1}{2}}}{2} \left( G|_{x=x_{j-\frac{1}{2}}} - R\left( n|_{x=x_{j-\frac{1}{2}}},p|_{x=x_{j-\frac{1}{2}}} \right) \right) \\ + \frac{\varDelta _{j+\frac{1}{2}}}{2} \left( G|_{x=x_{j+\frac{1}{2}}} - R\left( n|_{x=x_{j+\frac{1}{2}}},p|_{x=x_{j+\frac{1}{2}}} \right) \right) , \\ \qquad {\text {if }}j=1,\ldots ,N-1, \\ \frac{\varDelta _{\frac{1}{2}}}{2} \left( G|_{x=x_{\frac{1}{2}}} - R\left( n|_{x=x_{\frac{1}{2}}},p|_{x=x_{\frac{1}{2}}} \right) \right) , \\ \qquad {\text {if }}j=0, \\ \frac{\varDelta _{N-\frac{1}{2}}}{2} \left( G|_{x=x_{N-\frac{1}{2}}} - R\left( n|_{x=x_{N-\frac{1}{2}}},p|_{x=x_{N-\frac{1}{2}}} \right) \right) , \\ \qquad {\text {if }}j=N. \end{array}\right. } \end{aligned}$$
(42)
The additional error incurred as a result of this approximation is comparable to the error associated with the original piecewise linear approximation for the dependent variables. Thus, even though some additional error is introduced, the scheme retains its second-order local accuracy, as demonstrated in Sect.
6. We note that this approach to deal with the nonlinear source terms is a special case of the method used in the work of Skeel and Berzins [
22], but we emphasise that in contrast to their method, we only use this additional approximation for treatment of the source terms while the rest of the terms are integrated exactly.
An analogous methodology is used to derive the discrete equations in the transport layers. The only difference is that the basis and test functions are piecewise linear functions with compact support defined within the ETL and HTL, respectively.
For notational convenience, we introduce three discrete operators: a difference operator,
\(\mathfrak {D}_i\); an interpolation operator,
\(\mathfrak {I}_i\); and, a linear operator
\(\mathfrak {L}_i\). For a generic dependent variable
\(u\), these three operators are defined as follows, in which the midpoint
\(x=x_{i+1/2}=x_i/2+x_{i+1}/2\) is halfway between
\(x=x_i\) and
\(x=x_{i+1}\).
$$\frac{\partial u}{\partial x}\Big |_{x=x_{i+1/2}} \approx \mathfrak {D}_{i+1/2}(u) = \frac{u_{i+1}-u_i}{\varDelta _{i+1/2}},$$
(43)
$$\begin{aligned}&u|_{x=x_{i+1/2}} \approx \quad \mathfrak {I}_{i+1/2}(u) = \frac{1}{2}(u_{i+1}+u_i), \end{aligned}$$
(44)
$$\begin{aligned}\mathfrak {L}_i(u) &= \frac{1}{6}\varDelta _{i+1/2}u_{i+1}+\frac{1}{3}\left( \varDelta _{i+1/2}+\varDelta _{i-1/2}\right) u_i \\& \quad +\frac{1}{6}\varDelta _{i-1/2}u_{i-1}. \end{aligned}$$
(45)
These discrete operators can be used to obtain discretised versions of the ion flux and carrier current densities in the perovskite layer, given in dimensional form in (
3b), (
2b) and (
1b), as follows:
$$\begin{aligned}&{{F}^P}_{i+1/2} =-\left[ \mathfrak {D}_{i+1/2}(P)+\mathfrak {I}_{i+1/2}(P)\mathfrak {D}_{i+1/2}(\phi )\right] , \end{aligned}$$
(46)
$$\begin{aligned}&{j^n}_{i+1/2} = \kappa _n\left[ \mathfrak {D}_{i+1/2}(n)-\mathfrak {I}_{i+1/2}(n)\mathfrak {D}_{i+1/2}(\phi )\right] , \end{aligned}$$
(47)
$$\begin{aligned}&{j^p}_{i+1/2} = -\kappa _p\left[ \mathfrak {D}_{i+1/2}(p)+\mathfrak {I}_{i+1/2}(p)\mathfrak {D}_{i+1/2}(\phi )\right] . \end{aligned}$$
(48)
for
\(i=0, \ldots , N-1\). The electron current density in the ETL (
\({j^n}^{,E}\)) and hole current density in the HTL (
\({j^p}^{,H}\)) can be expressed in an equivalent way.
The carrier generation and bulk recombination terms are approximated to be linear on each interval, and to take the value at the midpoint, hence we define
$$\begin{aligned} G_{i+1/2}&= G(\mathfrak {I}_{i+1/2}(x),t), \end{aligned}$$
(49)
$$\begin{aligned} R_{i+1/2}&= R(\mathfrak {I}_{i+1/2}(n),\mathfrak {I}_{i+1/2}(p)). \end{aligned}$$
(50)