Mathematical modeling, parameter identification, and electrical performance of a DSSC based on nature-inspired optimization techniques

The aim of this research is to achieve the highest efficiency for a dye-sensitized solar cell (DSSC) before the fabrication process. For DSSC efficiency improvement, six different optimization algorithms are used for the DSSC parameter extraction. The algorithms used are the genetic algorithm, grey wolf algorithm, dragonfly algorithm, moth flame algorithm, ant-lion algorithm, and whale algorithm, developed based on MATLAB coding. The physical parameters for the DSSC are the electron lifetime, electrode thickness, ideality factor, absorption coefficient, and diffusion coefficient. A comparative study is carried out among the six algorithms based on the highest efficiency and computational speed. Finally, a sensitivity analysis of environmental conditions (solar irradiance and temperature) and physical parameters is implemented and analyzed to simulate the DSSC performance for different values of these parameters. The DSSC parameters studied are short-circuit current density, open-circuit voltage, fill factor, and efficiency. The optimal electron lifetime is 100 ms, and the optimal thickness of the photoanode layer is 1 μm, reaching maximum efficiency equal to 11.79%.


Introduction
Continuous population growth, industrial revolutions, depletion of fossil fuel reserves, and climate change have led to the increased demand for renewable energy globally. The principle of dye-sensitized solar cell (DSSC) operation depends on photoanodes bound to a wide-bandgap semiconductor material, electrolyte, and counter electrode. DSSCs have many advantages, including low material cost, compatibility with flexible substrates, cost-effectiveness, simplicity, and energy-efficient production methods. However, low efficiency is a major challenge with DSSCs that must be solved to reach commercialization without affecting cell stability. The highest efficiency recorded for DSSCs is approximately 14%, but it is not proven [1]. Improving DSSC parameters [open-circuit voltage (V oc ), short-circuit current density (J sc ), efficiency (η), and cell fill factor (FF)] is a vital requirement for solving these challenges. The models most commonly used to represent the equivalent circuit of the DSSC are single-and double-diode models. Different mathematical models are used to simulate the nonlinear relationship of current-voltage characteristics.
Currently, meta-heuristic optimization algorithms are quite attractive due to their distinct advantages over conventional algorithms. Meta-heuristics have the ability to solve multi-objective and nonlinear problems. Despite the random nature of these algorithms, they have the ability to obtain global maxima and avoid local maxima [2][3][4]. Accurate estimation and optimization of DSSC parameters are very important in improving cell quality during fabrication, modeling, and simulation [5][6][7][8][9][10]. This study analyzed the influence of photoanode thickness (d), electron lifetime (τ), electron diffusion coefficient (D), light absorption coefficient (α), and diode ideality factor (m) on the main DSSC parameters. The performance of the proposed optimization algorithms was analyzed by comparing the extracted electrical parameters of the solar cell. Moreover, sensitivity analysis of DSSC performance was carried out for different values The J-V characteristics model is governed by the physical parameters of the DSSC. The differential diffusion model can be used to describe the electron injection from dye to the photoanode and recombination within the electrolyte at the steady state as [16][17][18]: where n(x) is the concentration of the excess electrons at position x, n o is the concentration of electrons under dark conditions [19,20], τ describes the electron lifetime, φ is the flux intensity, α is the absorption coefficient of incident light, and D is the electron diffusion coefficient.  By neglecting electron trapping/detrapping in the steadystate case, the electron lifetime is considered constant [21,22]. The solution equation using open-circuit and short-circuit boundary conditions is given by [11,23]: where J PV is the DSSC current density, J g is the photocurrent density, J o is the saturation current density, m describes the DSCC ideality factor, K is the Boltzmann constant, q is the electron charge, and T represents the cell temperature. Solving Eq. (3) with boundary conditions in Eq. (2), the short-circuit current density is calculated by: where J sc is the short-circuit current density, L is the length of electron diffusion, and d is the thickness of the photoanode layer.
Based on the analytical expression for J sc , the current density under illumination can be obtained as a function of the bias voltage as [23]: where I max is the maximum current density, P max is the maximum power, V max is the maximum voltage, R s is series resistance, and FF is the fill factor. Table 1 gives the mathematical modeling parameters definition used for the DSSC.

Problem formulation
Equations (5-7) are nonlinear transcendental equations that represent the DSSC output current and that have no clear analytical solutions. The problem of parameter identification for the DSSC is to determine the optimal physical parameter values to achieve the highest cell efficiency. The objective function maximizes the DSSC efficiency subject to the minimum and maximum bounds of the required parameters. These parameters are electrode thickness, diffusion coefficient, absorption coefficient, lifetime, and ideality factor. The objective function is as follows: To achieve highly efficient DSSCs, the constraints of the proposed optimization variables are limited within the minimum and maximum bounds, as follows: The optimal parameter values are analyzed based on the results of the electric current density-voltage (J-V) characteristics. The photoanode thickness is in the range of 1-100 μm, electron lifetime is 1-100 ms, ideality factor is 2-4.5, absorption coefficient is 1000-50,000 cm −1 , and the diffusion coefficient is in range of (1-8) × 10 -4 cm 2 /s. Figure 3 shows the input and output parameters that affected DSSC performance. The input parameters are electrode x min j ≤ x j ≤ x max j j = 1, 2, 3, 4, 5

Meta-heuristic optimization methods
Meta-heuristic optimization techniques have become popular for numerous engineering applications due to their simplicity, ease of implementation, and ability to avoid local optima. In nature-inspired algorithms, imitating natural and biological physics phenomena is used to solve the objective functions. They are divided into three main groups: evolutionary, physical, and swarm. Evolutionary methods are controlled by the concepts of natural evolution, the most familiar of which is the genetic algorithm (GA) [25], whereas swarm techniques simulate the group behavior of animals. Using meta-heuristic algorithms to search for an optimal solution through J-V data for the DSSC, the cell parameters can be obtained with high accuracy and convergence rate. The meta-heuristic parameters used are the population size and the maximum number of iterations [26,27]. Figure 4 presents a flowchart of the proposed optimization algorithms.

GA optimization
The GA is an algorithm inspired by the evolutionary process [28], and consists of three main steps: selection process, crossover process, and mutation process [29,30]. The main concept is to generate a population, and for each individual of the population, calculate the fitness function, then the next generation by applying selection, recombination, and mutation. The process is repeated until the required stop criteria are reached [31]. The pseudo-code of GA optimization is shown in Fig. 5.

GWO algorithm
The grey wolf optimization (GWO) algorithm was first used by Mirjalili [32] and is inspired by the hunting behavior of the grey wolf. To mathematically model the GWO, the hunting and social hierarchies are used. The grey wolf leader is called the alpha ( ), which is considered the fittest solution in the algorithm. The second best solution is called beta ( ), and the third is called delta ( ), whereas all the other possible solutions are called omegas ( ). The three leading grey wolves ( , , and ) will lead all during the optimization process of searching and hunting. When the prey is found, the iterations start, and the ( , , and ) wolves will lead, monitor, and finally surround the target. The surrounding behavior is as follows [32]: where �⃗ X(t) is the grey wolf position vector at the current iteration (t), while ��� ⃗ X P (t) is the prey position vector.

The vectors �� ⃗
A and �� ⃗ C coefficient can be modeled as: where � ⃗ a decreases linearly from 2 to 0 throughout iterations, and �� ⃗ r 1 , �� ⃗ r 2 are random vectors in the range [0, 1]. The mathematical modeling of ( , , and, ) grey wolf hunting processes are given by: where ��� ⃗ X 1 , ��� ⃗ X 2 and ��� ⃗ X 3 are the α, β, and δ position vectors. After gaining the three best solutions (α, β, and δ), then the other agents ( ) will be obliged to update their positions based on the best solutions and compute the fitness function value up to the determined stopping criteria. The pseudocode of GWO is given by Fig. 6.

MFO algorithm
The MF is another type of nature-inspired algorithm that was first presented by Mirjalili [33]. MFO is simple, flexible, and robust, has a fast searching speed, and is easy to use with the other algorithms at the same time [34]. Moths are a type of insect that has peregrination behavior called transverse orientation based on moonlight navigation. The flying technique of a moth maintains a fixed angle with respect to the moon, which is considered a very effective method for traveling long distances in an upward line. MFO steps can be outlined as follows. Firstly, moths are randomly generated in the search space, and then their position is calculated, adopting the best position using a flame. Finally, to achieve the best positions, the positions of moths are updated by a spiral movement as [33]: where M i , F j are the ith moth and the jth flame, b is the variability of the model of the logarithmic maturation pattern, y is a random number in the range of [−1, 1], and XD i is the distance between the ith moth and the jth flame.
The number of flames is updated by: where N is the maximum number of flames, t is the current iteration, and iter max is the maximum iterations. Finally, the new best positions of moths are updated and the previous steps are repeated until the termination criteria are reached. Figure 7 gives the pseudocode of the MFO algorithm.

ALO algorithm
Ant-lion optimization (ALO) is another type of natureinspired algorithm introduced by Mirjalili [35] that simulates the hunting behavior of ant-lions in catching their prey. AL have five steps in their hunting process, which include random walk, trap construction, ant (prey) entrapment, prey capture, and finally, trap reconstruction. ALO steps are summarized as follows. Firstly, an initial population of ants given by X Ant = (x 1 , x 2 , …, x N ) and ant-lions given by X Antlion = (x 1 , x 2 , …, x N ) are generated in the search space of the parameters. Fig. 6 The pseudocode of GWO For each ant, using a roulette wheel, an AL is selected based on the best fitness to construct a trap for the ants, and then the ants' random walk is mathematically presented as [35,36]: where cumsum is the cumulative sum, iter max is the maximum number of iterations, iter is the random walk steps, and r(iter) is a stochastic function defined as: where rand is a number generated randomly in [0, 1]. The normalized random walk formula is used to keep the ants' position in the search space as: where mi and mx are the minimum and maximum of a random walk, and L and U are the lower and upper bounds of the variable, respectively. Trapping of ants is expressed as: where ω is a constant defined as: The fitness of the ants' new position is expressed by: where x Ai is the ant-lion position. Elitism is the process that keeps the best ant-lion position by using: 2 when iter > 0.10 iter max 3 when iter > 0.50 iter max 4 when iter > 0.70 iter max 5 when iter > 0.90 iter max 6 when iter > 0.95 iter max Fig. 7 The pseudocode of the MFO algorithm where x iter A is the position of the ant, R A is the ant random walk for an ant-lion selected using a roulette wheel, and R E is an elite ant-lion. The elite is updated, and if termination criteria are reached, the process is stopped or the next iteration is begun. Figure 8 explains the pseudocode of the ALO algorithm.

DA optimization
The dragonfly algorithm (DA) was proposed by Mirjalili in 2015 [37]. The inspiration for DA is based on dragonfly swarming behaviors. There are two important behaviors of dragonflies in nature, which are static and dynamic. In the static case, dragonflies create a very small group to fly a small distance and hunt small insects. On the other hand, in the dynamic case, dragonflies create a large group and travel in one specific direction for long distances, which agree with the two optimization phases of exploration and exploitation. The main goals of dragonfly swarms are attraction to food sources and distracting enemies. According to these two behaviors, there are five factors for position updating of individuals, namely separation, alignment, cohesion, attraction to food sources, and distracting enemies [37]. The mathematical model of the separation is calculated as [37]: where X indicates the current position, X j shows the jth neighboring individual position, and N is the number of neighboring individuals. Alignment (A) is represented as: where X j is the jth neighboring individual velocity. The cohesion (C) is calculated as: The attraction towards a food source (F) is determined by:

Distracting an enemy (E) outwards is determined by:
where X + is the food source position and X − is the enemy position.
Updating the dragonfly's position in a search space and analyzing their movements takes into account step vectors (ΔX) and position (X) vectors. The step vector of the DA is similar to particle swarm optimization (PSO), so the DA step vector shows the direction of movement as given by: where s is the weight of separation, a is the weight of alignment, A is the alignment of the ith individual, c is the weight of cohesion, f is the food factor, e is the enemy factor, w is the weight of inertia, and t is the iteration count. The position vectors are computed as: To improve the randomness, Lévy flight random walk is used for dragonflies to fly when there are no neighboring solutions. Thus, the dragonfly's position is updated by: where d indicates the dimension of position vectors, r 1 and r 2 are random numbers in [0, 1], and β is a constant (= 1.5) [38,39]. Figure 9 gives the pseudocode for the DA.

WO algorithm
The whale optimization algorithm (WOA) is a new optimization algorithm based on meta-heuristics that simulates the hunting behavior of the humpback whale [40][41][42]. Humpback whales use random search strategies for finding prey through the transfer of data with the others. Figure 10 gives the pseudo-code of the WOA. The mathematical model of encirclement of prey, net of the bubble method for hunting, and the prey behavior are as follows [43]: The pseudo-code of the DA  where D represents the distance between the whale and the prey, t is the iteration, A and C are vector coefficients, X * is the best solution position vector gained, and X is the position vector. Vectors � ⃗ A and �� ⃗ C are presented by: where � ⃗ a decreases linearly from 2 to 0 for iterations, and ⃗ r is a random vector in [0, 1]. To update the positions of whale and prey, the spiral equation is used to simulate the spiralshaped movement of humpback whales as: where b is a constant for the shape definition, and l is a random number in [−1, 1].
The humpback whales swim around the prey in a shrinking circle and a spiral simultaneously. The mathematical model of this behavior has a 50% probability (p) of choosing between them during the optimization process, expressed as: According to the random searching of humpback whales, � ⃗ A is used with the random values [−1, 1] based on the exploration and exploitation for updating the position of the search agent. This mechanism and | � ⃗ A | > 1 emphasize exploration and allow the WOA to perform a global search. The mathematical model representing this mechanism is as follows: where ������� ⃗ X rand is a random position vector chosen from the current population [43].

Results and discussion
Convergence curves for the best run of the six proposed algorithms are shown in Fig. 11. It is evident that all the optimization algorithms have the ability to reach an optimal objective function value in less than 20 iterations. Comparisons of the extracted optimal DSSC parameters using different optimization techniques are presented in Table 2. Figure 12 shows the J-V characteristic curve of the DSSC based on optimal parameter values obtained.

Sensitivity analysis
As presented, the increase in temperature causes an increase in the photocurrent density and the voltage and, Fig. 11 Convergence curves of the proposed optimization algorithms  due to the increase in the charge recombination with temperature that results in a directly proportional relationship between temperature and open-circuit voltage, as shown in Fig. 13. V oc increases due to the increase in chemical potential caused by the increased charge generation with increasing solar radiation. On the other hand, the charge lifetime decreases with increasing solar radiation intensity, resulting in a reduction in chemical potential, which leads to lowering of the V oc . However, the dominant process is the increase in charge generation and hence the increase in open-circuit voltage as given by Fig. 14. Also, short-circuit current density increases significantly with the increase in solar radiation. As shown in Fig. 15, the lifetime affected mainly the open-circuit voltage; as τ increases, V oc increases due to the decrease in the recombination rate, hence resulting in higher electron density in the photoanode. The photocurrent density is not affected by the lifetime variation. Figure 16 presents the variation in the DSSC J sc , V oc and P max with the variation in electron lifetime. Lifetime V oc and P max increase while J sc is approximately constant. The variation in fill factor and efficiency with electron lifetime is given by Fig. 17.
The variation in the J-V characteristics with various absorption coefficients is presented in Fig. 18. It is observed that both the current density and potential difference increase with the increase in the absorption coefficient. This behavior can be interpreted as follows: with the increase in the absorption coefficient, more photons are absorbed by the dye molecules on the surface of the photoanode, resulting in the generation of more electrons and consequently enhancing the conversion efficiency. Both  Figure 19 displays the variation in the output parameters of the DSSC (J sc , V oc , and P max ) with the variation in the absorption coefficient. The variation in the efficiency and fill factor with the absorption coefficient is presented in Fig. 20. Both the efficiency and fill factor increase with an increase in the absorption coefficient due to the increase in photon absorption by the DSSC and hence the collection of more electrons.
The thickness of photoanode film is an important technological parameter for the design and optimization of the dye cell. The effect of the variation in photoanode thickness on the J-V curves can be clearly seen in Fig. 21. The range of variation taken into consideration is between 0.1 and 30 μm. Figure 22 presents the effect of the variation in thickness on J sc . The current increases up to a certain value, and after the optimal point, the current starts to decrease. This effect can lead to an increase in the area of the internal surface and the absorption of more photons by the photoanode, but if the thickness is greater than the light penetration depth, the number of photons will reach the limit, and J sc will start to decrease because more recombination  occurs, causing electron loss. This behavior can be explained as follows: the increase in the thickness of the photoanode increases the dye absorbance in the photoanode porous voids, thus enhancing its light absorbance and further increasing the density of photogenerated carriers. Hence, photocurrent density increases, but at the same time, the series resistance of the electrode also tends to increase, affecting the cell performance. In addition, V oc decreases with the increase in thickness due to the high series resistance. Figure 23 presents the effect of the variation in thickness on the fill factor and efficiency. Increasing thickness leads to an increase in the internal resistance of the cell.
The results indicate that finding the optimal value of thickness leads to high efficiency, and the maximum values of the DSSC electrical parameters can be obtained.
The effect of the variation in the diffusion coefficient on DSSC performance is indicated in Fig. 24. There is a directly proportional relationship between the diffusion coefficient and the current density, but the converse is seen with its voltage. This is because increasing the value of the diffusion coefficient leads to an increase in electron diffusion length. This means that a greater diffusion coefficient causes a decrease in the recombination rate, and thus more electrons can be collected. This increases the current density. However, the greater electron extraction results in a smaller value of electron density. The small  With increasing D, J sc increases but V oc decreases. The variations can be understood by the fact that an increase in D increases the diffusion length, and subsequently more electrons are taken out to the external circuit, resulting in higher electrical current. Consequently, the electron density is reduced, causing a lower V oc .
The variations in DSSC parameters J sc , V oc , FF, and η with the electron diffusion coefficient is demonstrated in

Conclusion
DSSCs have received extensive attention from many scientists over the past three decades. Fast theoretical and practical studies have been undertaken to enhance the  performance of DSSCs. To identify the DSSC intrinsic parameters, we need to tune each component and determine the appropriate conditions in optimizing the performance of complete cells. Meta-heuristic optimization techniques are applied to extract the DSSC parameters using semiconductor thin-film electron diffusion modeling. MATLAB software is used to investigate the influence of various physical and environmental parameters on DSSC characteristics and to perform sensitivity analysis. The electrode thickness, electron lifetime, diffusion coefficient, absorption coefficient, radiation, and air temperature are the parameters under consideration. J sc , V oc , P max , FF, and efficiency are the DSSC performance indicators. The suggested optimization algorithms have been verified as offering superior characteristics, including good solutions, stable and fast convergence to the best solution, and high computational performance.  Data availability All data generated are included in the paper.

Conflict of interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper. The authors declare that they have no known competing financial interests.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/.