Deposition of Sol–Gel ZnO:Mg Films and Investigation of Their Structural and Optical Properties

This work presents a facile sol–gel method for the deposition of ZnO and ZnO:Mg films. The films are spin coated on silicon and quartz substrates. The impact of magnesium concentrations (0, 0.5, 1, 2 and 3 wt%) and post-annealing treatments (300–600 °C) on the film’s structural, vibrational and optical properties is investigated. Undoped ZnO films crystallize in the wurtzite phase, with crystallite sizes ranging from 9.1 nm (300 °C) to 29.7 nm (600 °C). Mg doping deteriorates the film crystallization and shifting of 002 peak towards higher diffraction angles is observed, indicating the successful incorporation of Mg into the ZnO matrix. ZnO:Mg films (2 wt%) possess the smallest crystallite size, ranging from 6.2 nm (300 °C) to 25.2 nm (600 °C). The highest Mg concentration (3 wt%) results into a segregation of the MgO phase. Lattice constants, texture coefficients and Zn–O bond lengths are discussed. The diminution of the c lattice parameter is related to the replacement of Zn2+ by Mg2+ in the ZnO host lattice. The vibrational properties are studied by Fourier transform infrared (FTIR) spectroscopy. IR lines related to Mg–O bonds are found for ZnO:Mg films with dopant concentrations of 2 and 3 wt%. The optical characterization showed that the transmittance of ZnO:Mg thin films increased from 74.5% (undoped ZnO) to about 89.1% and the optical band gap energy from 3.24 to 3.56 eV. Mg doping leads to a higher refractive index compared to undoped ZnO films. The FESEM (field emission scanning electron microscopy) technique is used for observation of the surface morphology modification of ZnO:Mg films. The doped ZnO films possess a smoother grained surface structure, opposite to the wrinkle-type morphology of undoped sol–gel ZnO films. The smoother surface leads to improved transparency of ZnO:Mg films.


Introduction
ZnO is a wide bandgap oxide semiconductor with a direct energy gap of about 3.37 eV, a high excitonic binding energy (60 meV) and high optical transparency in the visible and near-infrared ranges [1,2]. Other attractive properties of ZnO include its controllable electron mobility, low manufacturing cost, environmentally friendly nature, non-toxicity and easy availability [3]. Undoped ZnO films usually contain native defects such as zinc interstitials (Z ni ) and oxygen vacancies (V O ), and due to them, undoped ZnO is generally an intrinsic n-type semiconductor [4].
All these properties allow ZnO materials to be applied in different fields, such as UV optoelectronic devices, laser diodes, solar cells, sensors, field effect transistors, light emitting devices, photoconductive ultraviolet detectors, anti-reflective coatings and photocatalysis [3,5]. ZnO has enormous potential for optoelectronic applications. Doping with different metal and non-metal elements is a well-known approach for extending the advantages of ZnO by improving its structural, electrical, optical and physical properties [6].

XRD Study-Crystalization Behavior
XRD patterns of ZnO and ZnO:Mg films, annealed at temperatures of 300-600 • C, are presented in Figure 1. The studied films are found to be polycrystalline in nature. ZnO films exhibit intense and sharp XRD lines, assigned to the wurtzite structure (Figure 1a). The film crystallization is enhanced with increasing annealing temperatures. The peaks of the sol-gel ZnO:Mg films annealed at 300-600 • C are indexed to the Miller indices  By increasing the annealing temperatures, a new weak diffraction feature is detected at a diffraction angle of 42.8 • in the XRD patterns of ZnO:Mg 3 films (500 and 600 • C annealed, Figure 1e, inset) along with the lines attributed to the wurtzite phase. This line at 42.8 • corresponds to the (200) plane of cubic MgO (JCPDS card 78-0430, [38]). It must be noted that ZnO:Mg films with lower Mg concentrations reveal no impurity peaks related to Mg and Mg oxide fractions and indicating that the doping of Mg ions does not alter the wurtzite structure. However, the probability of the cluster formations or the existence of Mg-based amorphous phases small enough not to be exposed by XRD measurements cannot be ruled out. The highest Mg concentration (3 wt%) results in a segregation of MgO, although the XRD peaks are very weak (Figure 1e). Similar observations of the coexistence of two phases (wurtzite ZnO and cubic MgO) have been reported by other researchers [39]. The phase separation of MgO and ZnO can be explained by the fact that Mg atoms are more active than Zn atoms and they react with oxygen preferentially [40].
The film crystallization deteriorates with increasing Mg concentrations. It is observed that with increasing magnesium concentrations, the intensity of the XRD peaks decreases, as seen from Figures 1 and 2.  Figure 2a,b exhibits the intensities of the three main XRD lines, 100, 002 and 101, of ZnO and ZnO:Mg films, annealed at the lowest and highest annealing temperatures. The 002 peak intensity is best expressed after thermal treatment at 600 °C and it is reduced with Mg doping (Figure 2b). The most intense XRD line is found to be the (101) peak at a temperature of 400-600 °C of ZnO:Mg films. The diffraction patterns of ZnO:Mg films show the shifting of the 002 peak towards higher diffraction angles (see Figure 2c), which confirms the incorporation of Mg into the ZnO matrix [41][42][43]. This proves that Mg 2+ ions (with a radius of 0.65 Å) substitute Zn 2+ ions with a larger radius of 0.74 Å in the wurtzite lattice. It has been observed that the relative intensities of the main XRD peaks ((100), (002), (101)) of the wurtzite phase vary with Mg doping concentration.
The average crystallite sizes are determined by using the peaks (100), (002) and (101)  Figure 2a,b exhibits the intensities of the three main XRD lines, 100, 002 and 101, of ZnO and ZnO:Mg films, annealed at the lowest and highest annealing temperatures. The 002 peak intensity is best expressed after thermal treatment at 600 • C and it is reduced with Mg doping (Figure 2b). The most intense XRD line is found to be the (101) peak at a temperature of 400-600 • C of ZnO:Mg films. The diffraction patterns of ZnO:Mg films show the shifting of the 002 peak towards higher diffraction angles (see Figure 2c), which confirms the incorporation of Mg into the ZnO matrix [41][42][43]. This proves that Mg 2+ ions (with a radius of 0.65 Å) substitute Zn 2+ ions with a larger radius of 0.74 Å in the wurtzite lattice. It has been observed that the relative intensities of the main XRD peaks ((100), (002), (101)) of the wurtzite phase vary with Mg doping concentration.
The average crystallite sizes are determined by using the peaks (100), (002) and (101) through the Debye-Scherrer's equation [41,44]: where D is the crystallite size in nm, k is a coupling constant (=0.9), λ is the wavelength of the X-ray (λ = 1.54056 Å), β 2θ is the FWHM and θ is the Bragg angle.
The obtained data of the crystallite sizes are given in Figure 3. The crystallite sizes of pure ZnO films become greater with increasing the annealing temperatures from 9.1 nm (300 • C) to 29.7 nm (600 • C). The crystallites of the doped samples also grow bigger with annealing, revealing a strong dependence on the Mg concentration. The MgO phase, detected in the XRD patterns of ZnO:Mg (Sol 3, greatest Mg amount) films treated at 500 and 600 • C possess crystallite sizes of 10.7 nm (500 • C) and 14.9 nm (600 • C), respectively. It is established that the crystallite sizes are reduced with Mg doping. It is worth noting that ZnO:Mg 2 films have the smallest crystallites.  The decrease in the crystallite sizes with Mg doping might be caused by a Zener pinning effect, i.e., the prevention of motion of grain boundaries either by precipitation of secondary phases or by contamination at the surface [45]. An additional MgO phase may act as an obstacle for the growth of crystallites in ZnO:Mg 3 films. It is also observed that the crystallites grow with different sizes along the (100), (002), (101) diffraction planes. Figure 4 presents the estimated sizes of the crystallites, estimated from XRD data for the dependence of the three strongest lines on Mg concentration and annealing temperatures. It can be seen that the crystallites growing along the (002) plane become greater than the crystallites growing along other two diffraction planes at 500 °C ( Figure 4c) for all studied films. After the highest annealing temperature (600 °C), crystallites grown along the (002) plane are greater for ZnO, ZnO:Mg 0.5 and ZnO:Mg 1. ZnO:Mg 3 films show slightly smaller sizes for the crystallites grown along the (002) plane. The decrease in the crystallite sizes with Mg doping might be caused by a Zener pinning effect, i.e., the prevention of motion of grain boundaries either by precipitation of secondary phases or by contamination at the surface [45]. An additional MgO phase may act as an obstacle for the growth of crystallites in ZnO:Mg 3 films. It is also observed that the crystallites grow with different sizes along the (100), (002), (101) diffraction planes. Figure 4 presents the estimated sizes of the crystallites, estimated from XRD data for the dependence of the three strongest lines on Mg concentration and annealing temperatures. It can be seen that the crystallites growing along the (002) plane become greater than the crystallites growing along other two diffraction planes at 500 • C (Figure 4c) for all studied films. After the highest annealing temperature (600 • C), crystallites grown along the (002) plane are greater for ZnO, ZnO:Mg 0.5 and ZnO:Mg 1. ZnO:Mg 3 films show slightly smaller sizes for the crystallites grown along the (002) plane.  The texture coefficient of a plane illustrates the texture of a particular plane and deviation from the standard sample implies the preferred growth. The texture coefficient (TC (hkl)) can be calculated from XRD patterns using [46]: where I(hkl) and Io(hkl) are the measured relative intensity and JCPDS standard intensity, respectively, of a plane (hkl); N is the reflection number; and n is the number of diffraction peaks.
If there is a preferential orientation, the TC (hkl) value should be greater than one. If TC (hkl) is equal to or less than 1, then the sample is proposed to have randomly oriented crystallites. The texture coefficient was determined for the sol-gel ZnO and Mg-doped ZnO films using Equation (2). TC values were calculated for the diffraction planes (100), (002) and (101) considering the measured and standard (JCPDS card 01-070-8070) intensities of all detected peaks. The degree of the preferred orientation for three diffraction planes is given in Figure 5. ZnO-based films demonstrate a preferential growth along the (002) plane as the TC values of ZnO and ZnO:Mg films are greater than 1 (see Figure 5a).  The texture coefficient of a plane illustrates the texture of a particular plane and deviation from the standard sample implies the preferred growth. The texture coefficient (TC (hkl)) can be calculated from XRD patterns using [46]: where I(hkl) and I o (hkl) are the measured relative intensity and JCPDS standard intensity, respectively, of a plane (hkl); N is the reflection number; and n is the number of diffraction peaks. If there is a preferential orientation, the TC (hkl) value should be greater than one. If TC (hkl) is equal to or less than 1, then the sample is proposed to have randomly oriented crystallites. The texture coefficient was determined for the sol-gel ZnO and Mg-doped ZnO films using Equation (2). TC values were calculated for the diffraction planes (100), (002) and (101) considering the measured and standard (JCPDS card 01-070-8070) intensities of all detected peaks. The degree of the preferred orientation for three diffraction planes is given in Figure 5. ZnO-based films demonstrate a preferential growth along the (002) plane as the TC values of ZnO and ZnO:Mg films are greater than 1 (see Figure 5a).  After thermal treatments at 400 and 500 °C, ZnO:Mg films manifest a well pronounced decrease in the texture coefficient in the (002) plane, and 600 °C treatment has the greatest impact on TC (002) and it drops sharply with increasing Mg doping. All studied films manifest a decrease in the texture coefficient of the (101) plane with a change in the annealing temperature from 300 to 600 °C ( Figure  5b)  To gain further insight, the lattice parameters c and a, the c/a ratio, Zn-O bond length and u parameter of the sol-gel ZnO and ZnO:Mg films wre determined by Equations (3)-(5) [46] using the crystallographic plane indices (h, k, and l). The lattice parameters were To gain further insight, the lattice parameters c and a, the c/a ratio, Zn-O bond length and u parameter of the sol-gel ZnO and ZnO:Mg films wre determined by Equations (3)-(5) [46] using the crystallographic plane indices (h, k, and l). The lattice parameters were estimated using the X-ray diffraction least squares unit cell refinement spreadsheet templates [47]. The obtained results are given in Figures 6 and 7.
where u is the internal parameter: The lattice parameters, a and c, are changed, which was induced by Mg doping in the ZnO structure. It is revealed that the a axis is elongated and the c axis is shortened ( Figure 6a). This effect is due to the fact that zinc ion (0.60 Å) sites can be occupied by smaller Mg ions (0.57 Å) in the ZnO host matrix. Similar results for the behavior of the lattice parameters for ZnO:Mg films and nanoparticles can be found in the literature [42,48]. It must be noted that ZnO:Mg 2 films manifest the greatest change, followed by ZnO:Mg 3 (highest Mg concentration). Wurtzite ZnO (JCPDS card 01-070-8070) has standard values of lattice constants c = 5.2049 Å and a = 3.2489 Å.
Materials 2022, 15, x FOR PEER REVIEW 10 of 29 estimated using the X-ray diffraction least squares unit cell refinement spreadsheet templates [47]. The obtained results are given in Figures 6 and 7.
where u is the internal parameter: The lattice parameters, a and c, are changed, which was induced by Mg doping in the ZnO structure. It is revealed that the a axis is elongated and the c axis is shortened ( Figure 6a). This effect is due to the fact that zinc ion (0.60 Å) sites can be occupied by smaller Mg ions (0.57 Å) in the ZnO host matrix. Similar results for the behavior of the lattice parameters for ZnO:Mg films and nanoparticles can be found in the literature [42,48]. It must be noted that ZnO:Mg 2 films manifest the greatest change, followed by  The characteristic of the hexagonal lattice is the c/a ratio. ZnO has hexagonal wurtzite structure with a hexagonal unit cell and two lattice parameters a and c. The c/a ratio is known to be 1.633 for the ideal arrangement [49]. Generally, the real lattice of ZnO thin films differs from the ideal structure due to deposition methods, the presence of impurities (concentration of doping elements, defects and the difference of ionic radii with respect to the substituted matrix ion), and external factors, such as external strains, temperature and others [50]. The c/a ratio ( Figure 6b) is affected by high thermal treatments and Mg incorporation. XRD analysis shows that undoped ZnO films are already substantially distorted, as indicated by the deviation of the calculated c/a ratio (1.6063 to 1.6017) from that of the standard geometry 1.633. It is observed that the magnesium substitution results in a significant deformation of the wurtzite structure, with a more pronounced effect for the higher doping concentrations and the higher annealing temperatures. The deviations from the ideal value are due to the defects in the crystal lattice structure. The c/a ratio significantly decreases with Mg concentration and the greatest deviation is found for ZnO:Mg 2 films. The differences between c/a ratio values of sol-gel The characteristic of the hexagonal lattice is the c/a ratio. ZnO has hexagonal wurtzite structure with a hexagonal unit cell and two lattice parameters a and c. The c/a ratio is known to be 1.633 for the ideal arrangement [49]. Generally, the real lattice of ZnO thin films differs from the ideal structure due to deposition methods, the presence of impurities (concentration of doping elements, defects and the difference of ionic radii with respect to the substituted matrix ion), and external factors, such as external strains, temperature and others [50]. The c/a ratio ( Figure 6b) is affected by high thermal treatments and Mg incorporation. XRD analysis shows that undoped ZnO films are already substantially distorted, as indicated by the deviation of the calculated c/a ratio (1.6063 to 1.6017) from that of the standard geometry 1.633. It is observed that the magnesium substitution results in a significant deformation of the wurtzite structure, with a more pronounced effect for the higher doping concentrations and the higher annealing temperatures. The deviations from the ideal value are due to the defects in the crystal lattice structure. The c/a ratio significantly decreases with Mg concentration and the greatest deviation is found for ZnO:Mg 2 films. The differences between c/a ratio values of sol-gel ZnO and ZnO:Mg films and the ideal hexagonal ZnO arrangement result from the existing defects in the crystal lattice and the quantity of defects are dependent on crystallite sizes, the dopant effect and dopant concentration. The results reveal that magnesium doping in the zinc oxide matrix leads to a less close packing in the hexagonal crystalline structure.  The variation of the bond length Zn-O and parameter u, defined as the positional parameter of the wurtzite structure, with Mg incorporation and annealing temperatures is given in Figure 7. It is known that the Zn 2+ ionic radius is 0.83 Å and the ionic radius of O 2− is 1.38 Å. The bond length of Zn-O is expected to be 2.21 Å. The smaller values determined for ZnO and ZnO:Mg films (Figure 7a) are an indication of the presence of structural defects (especially oxygen vacancies). The u parameter is 0.375 in an ideal wurtzite structure. In our case, the u parameter is varied from 0.379 to 0.381, depending on Mg concentration and annealing. These values are close to the reported data for the hexagonal wurtzite MgxZn1−xO [51].
The doping of metal ions into ZnO can generate both a lattice distortion and a tendency to create lattice defects and nucleation centers [29,30]. The crystal lattice distortion degree, R, is determined according to the equation in ref. [52]: The distortion degree represents the deviation of the crystal from a perfect arrangement, and it is accepted that R = 1 suggests that there is no distortion [52]. The dependence of R on the annealing temperatures is shown in Figure 8 for ZnO and ZnO:Mg films. The degree of distortion of the sol-gel films is greater than 1 and magnesium doping causes increasing the distortion degree, R, with the greatest distortion of the crystal lattice being established for ZnO:Mg 2 films. On the other hand, a non-linear increment of R values is observed with annealing temperatures ranging from 300 to 600 °C. It can be suggested that the thermal treatments introduce new defects into the ZnO-based films and, respectively, induce higher crystal imperfection. The doping of metal ions into ZnO can generate both a lattice distortion and a tendency to create lattice defects and nucleation centers [29,30]. The crystal lattice distortion degree, R, is determined according to the equation in ref. [52]: The distortion degree represents the deviation of the crystal from a perfect arrangement, and it is accepted that R = 1 suggests that there is no distortion [52]. The dependence of R on the annealing temperatures is shown in Figure 8 for ZnO and ZnO:Mg films. The degree of distortion of the sol-gel films is greater than 1 and magnesium doping causes increasing the distortion degree, R, with the greatest distortion of the crystal lattice being established for ZnO:Mg 2 films. On the other hand, a non-linear increment of R values is observed with annealing temperatures ranging from 300 to 600 • C. It can be suggested that the thermal treatments introduce new defects into the ZnO-based films and, respectively, induce higher crystal imperfection.

FTIR Spectroscopy-Vibrational Properties
To further study the impact of the Mg dopant, FTIR spectroscopy was applied as a sensitive characterization method supplementary to the XRD investigation. FTIR spectroscopy is used for revealing the vibrational modes and functional groups in the studied ZnO and ZnO:Mg films. It is well known that the positions and intensities of the absorption peaks depend on the chemical composition, structure (crystallinity, particle sizes and shapes) and morphology of thin films [53,54]. Figure 9 presents FTIR spectra of ZnO and ZnO:Mg films, annealed at temperatures of 300-600 °C. The water and hydroxyl group stretching vibrations are mainly revealed in the spectral range 3000-4000 cm −1 , where FTIR spectra of ZnO and Mg-doped ZnO films manifest absorption features. ZnO films manifest a very broad and strong absorption band at 3420 cm −1 , extended over 3190-3600 cm −1 after 300 °C treatment, and this band disappears with increasing annealing temperatures. ZnO:Mg films also reveal broad absorption bands at 3395 cm −1 (3130-3600 cm −1 ), which depend on the Mg content and the thermal treatments.

FTIR Spectroscopy-Vibrational Properties
To further study the impact of the Mg dopant, FTIR spectroscopy was applied as a sensitive characterization method supplementary to the XRD investigation. FTIR spectroscopy is used for revealing the vibrational modes and functional groups in the studied ZnO and ZnO:Mg films. It is well known that the positions and intensities of the absorption peaks depend on the chemical composition, structure (crystallinity, particle sizes and shapes) and morphology of thin films [53,54]. Figure 9 presents FTIR spectra of ZnO and ZnO:Mg films, annealed at temperatures of 300-600 • C. The water and hydroxyl group stretching vibrations are mainly revealed in the spectral range 3000-4000 cm −1 , where FTIR spectra of ZnO and Mg-doped ZnO films manifest absorption features. ZnO films manifest a very broad and strong absorption band at 3420 cm −1 , extended over 3190-3600 cm −1 after 300 • C treatment, and this band disappears with increasing annealing temperatures. ZnO:Mg films also reveal broad absorption bands at 3395 cm −1 (3130-3600 cm −1 ), which depend on the Mg content and the thermal treatments.
The strongest absorptions in this spectral range are observed for ZnO:Mg 3 films and, although their intensity decreases at the higher temperatures, they are still noticeable in the spectra. For the other Mg-doped ZnO films, the band disappears after 400 • C treatment. Another weak IR line can be detected at 3740 cm −1 for all studied films. ZnO:Mg 0.5, 1 and 2 films also show weak absorption lines at 3850 cm −1 , independent of the thermal treatments. The spectral range 3000-4000 cm −1 is indicative of the stretching vibrations of hydrated species. The band at 3850 cm −1 is assigned to hydroxyl groups, bound to two deficient surface sites. The absorption band at 3740 cm −1 is related to the vibrations of the separate OH groups [55]. The broad bands at 3420 cm −1 (3190-3600 cm −1 for 300 • C ZnO) and at 3395 cm −1 (3130-3600 cm −1 for ZnO:Mg) are clearly overlapping, namely due to the hydrogen bound OH group (around 3400 cm −1 ), OH groups, related to Zn vacancies (around 3220 cm −1 ) and/or physically adsorbed water [56][57][58]. The clear absorption band at 1600 cm −1 is attributed to the bending OH vibrations of adsorbed water [56]. The weak lines at 2360 and 2325 cm −1 (seen in all measured spectra) are due to atmospheric CO 2 molecules, as FTIR measurements are performed in air [59]. The weak lines in the range 1300-1400 cm −1 are attributed to C-O stretching modes [60]. These lines are not observed for the films treated at higher temperature. The strongest absorptions in this spectral range are observed for ZnO:Mg 3 films and, although their intensity decreases at the higher temperatures, they are still noticeable in the spectra. For the other Mg-doped ZnO films, the band disappears after 400 °C treatment. Another weak IR line can be detected at 3740 cm −1 for all studied films. ZnO:Mg 0.5, 1 and 2 films also show weak absorption lines at 3850 cm −1 , independent of the thermal treatments. The spectral range 3000-4000 cm −1 is indicative of the stretching vibrations of hydrated species. The band at 3850 cm −1 is assigned to hydroxyl groups, bound to two deficient surface sites. The absorption band at 3740 cm −1 is related to the vibrations of the separate OH groups [55]. The broad bands at 3420 cm −1 (3190-3600 cm −1 for 300 °C ZnO) and at 3395 cm −1 (3130-3600 cm −1 for ZnO:Mg) are clearly overlapping, namely due to the hydrogen bound OH group (around 3400 cm −1 ), OH groups, related to Zn vacancies (around 3220 cm −1 ) and/or physically adsorbed water [56][57][58]. The clear absorption band at 1600 cm −1 is attributed to the bending OH vibrations of adsorbed water [56]. The weak lines at 2360 and 2325 cm −1 (seen in all measured spectra) are due to atmospheric CO2 molecules, as FTIR measurements are performed in air [59]. The weak For ZnO:Mg 2 and 3, there is a clear broad absorption band around 1440 cm −1 , which becomes better defined after 500 and 600 • C annealing (see Figure 9c,d). IR lines in the FTIR spectra of undoped ZnO films around this spectral range are completely missing. Some authors claim that these absorption bands are related to Mg-O stretching vibrations [61,62]. This is an indication of Mg incorporation into ZnO. It must be noted that XRD analysis revealed that the ZnO films with the highest Mg concentration (ZnO:Mg 3) after high temperature treatment at 500 and 600 • C possess a small fraction of the cubic MgO phase. FTIR analysis suggests that the MgO phase might have also formed in the structure of ZnO:Mg 2 films. The lines at 1100 cm −1 (only for the spectra of ZnO:Mg 2) and at 1020 cm −1 (ZnO and ZnO:Mg 2, treated at 300 • C and ZnO:Mg 3, annealed at all temperatures) are attributed to the stretching modes of C-O [31], due to carbon impurities.
The spectral range below 1000 cm −1 is very important for studying characteristic metal-oxygen frequencies, related to Zn-O and Mg-O bonds and other IR lines attributed to the functional groups. Undoped ZnO films reveal a very weak line at 667 cm −1 , a broad absorption band at 617 m −1 , and clear IR lines at 520, 490, 472 and 360 cm −1 . All these lines are assigned to Zn-O stretching modes [63] as the absorption feature at 520 cm −1 is related to Zn-O bonding in the wurtzite crystal structure [64]. The main absorption band of sol-gel ZnO films is intense and broad, which becomes stronger with increasing the annealing temperature. It shows a shift from 410 to 405 cm −1 with thermal treatments. This IR band is also related to Zn-O stretching vibrations in the wurtzite ZnO structure [64].  [67]. At the lowest temperature treatment, some of the peaks between 400 and 520 cm −1 , appearing in the spectra of Mg-doped ZnO films, can correspond to contributions of Mg-O vibrational modes [68], but it must be considered that different Zn-O stretching vibrations are also detected in this spectral range. FTIR analysis reveals changes in the positions, shapes and intensities of the absorption bands, which are a distinct indication of Mg incorporation into the ZnO host lattice. Some IR lines can be attributed to Mg-O bonds, which can especially be confirmed for ZnO:Mg 2 and ZnO:Mg 3 films. These conclusions support XRD interpretations that the MgO phase exists in ZnO:Mg 3 films. FTIR analysis proposes that the Mg oxide fraction is presented in ZnO:Mg 2 films. As previously discussed, these films exhibit the greatest differences in crystallite sizes, lattice parameters and distortion degrees, proved by XRD analysis. Figure 10 shows the transmittance and reflectance spectra of the ZnO and ZnO:Mg films in the spectral range 240-1000 nm for different annealing temperatures. The substrates used are quartz. The transparency of the sol-gel films strongly depends on the magnesium doping content and the annealing temperature. The specific bands observed in the optical spectra of undoped ZnO films below the bandgap wavelength are due to the excitonic absorption.

UV-VIS Spectroscopy-Optical Characterization
The excitonic feature of the bulk ZnO is located near 373 nm. The excitonic absorption of the studied ZnO films is expressed at 345 nm. ZnO:Mg 0.5 and ZnO:Mg 1 films also manifest excitonic absorption at 335 nm (Figure 10c,d). The films with higher Mg content show no such absorption features in the transmittance spectra. The excitonic band is related to the film crystallinity and its presence reveals that the samples are highly crystalline [69].
in the optical spectra of undoped ZnO films below the bandgap wavelength are due to the excitonic absorption. The excitonic feature of the bulk ZnO is located near 373 nm. The excitonic absorption of the studied ZnO films is expressed at 345 nm. ZnO:Mg 0.5 and ZnO:Mg 1 films also manifest excitonic absorption at 335 nm (Figure 10c,d). The films with higher Mg content show no such absorption features in the transmittance spectra. The excitonic band is related to the film crystallinity and its presence reveals that the samples are highly crystalline [69]. Figure 11 presents the average transmittance (Taverage) and reflectance (Raverage) values in the visible spectral range 450-750 nm for the sol-gel films, treated at different annealing temperatures. The transmittance is measured against air. The average transmittance of the bare quartz substrate is 93.5% and the average reflectance is 6.7%. The most transparent films are found to be ZnO:Mg 2 samples and ZnO:Mg 3 films exhibit the lowest transmittance values, respectively. The low transmittance of ZnO:Mg 3 films can be related to MgO phase segregation, as has been observed by other authors [70]. ZnO:Mg 1 and ZnO:Mg 2 films possess improved optical transparency compared to other sol-gel ZnO films. Mg incorporation leads to improved film transparency up to 500 °C annealing with the exception of the highest Mg doping (3 wt% Mg, ZnO:Mg 3 films). The transmittance of the doped films can increase due to smaller crystallite sizes, de-  Figure 11 presents the average transmittance (T average ) and reflectance (R average ) values in the visible spectral range 450-750 nm for the sol-gel films, treated at different annealing temperatures. The transmittance is measured against air. The average transmittance of the bare quartz substrate is 93.5% and the average reflectance is 6.7%. The most transparent films are found to be ZnO:Mg 2 samples and ZnO:Mg 3 films exhibit the lowest transmittance values, respectively. The low transmittance of ZnO:Mg 3 films can be related to MgO phase segregation, as has been observed by other authors [70]. ZnO:Mg 1 and ZnO:Mg 2 films possess improved optical transparency compared to other sol-gel ZnO films. Mg incorporation leads to improved film transparency up to 500 • C annealing with the exception of the highest Mg doping (3 wt% Mg, ZnO:Mg 3 films). The transmittance of the doped films can increase due to smaller crystallite sizes, decreasing the light scattering, respectively. The crystallites sizes of ZnO:Mg 2 films are the smallest and their film transparency is the highest, respectively.
The average reflectance of undoped ZnO films is below 5% (Figure 11b). The reflectance of ZnO:Mg films is higher and is strongly influenced by the doping concentration and annealing. ZnO:Mg 0.5 films have R average < 7%. The reflectance of ZnO:Mg 1 and ZnO:Mg 2 films increases with annealing temperatures to 23.6 and 15.8%, respectively. ZnO:Mg 3 films show an increase from 7.5 to 22.2% up to 500 • C annealing, and then a drop to 16.3% after 600 • C treatment. The average reflectance of undoped ZnO films is below 5% (Figure 11b). The reflectance of ZnO:Mg films is higher and is strongly influenced by the doping concentration and annealing. ZnO:Mg 0.5 films have Raverage ˂ 7%. The reflectance of ZnO:Mg 1 and ZnO:Mg 2 films increases with annealing temperatures to 23.6 and 15.8%, respectively. ZnO:Mg 3 films show an increase from 7.5 to 22.2% up to 500 °C annealing, and then a drop to 16.3% after 600 °C treatment.
Tauc relation is employed to estimate the direct optical band gap of the sol-gel films [70,71]: where 'B' is a constant, h is Plank's constant, ν is the photon frequency, α is the absorption coefficient and Eg is the optical band gap. The absorption coefficient α was estimated using the film thickness d and the transmittance T [8]: where  (7) and (8) and are given in Figure 12. The obtained results clearly reveal that Mg incorporation enlarges the optical bandgap. ZnO films have Eg values ranging from 3.27 to 3.24 eV with increasing temperatures from 300 to 600 °C. Tauc relation is employed to estimate the direct optical band gap of the sol-gel films [70,71]: where 'B' is a constant, h is Plank's constant, ν is the photon frequency, α is the absorption coefficient and E g is the optical band gap. The absorption coefficient α was estimated using the film thickness d and the transmittance T [8]:  (7) and (8) and are given in Figure 12. The obtained results clearly reveal that Mg incorporation enlarges the optical bandgap. ZnO films have E g values ranging from 3.27 to 3.24 eV with increasing temperatures from 300 to 600 • C.  The shrinkage of the optical band gap with annealing temperature can be due to the improved crystallization, the decreased defects of the film structure and greater crystallite sizes. Similar results have been reported in the literature [71].
Mg-doped films exhibits a widening of the optical band gap with respect to un- The shrinkage of the optical band gap with annealing temperature can be due to the improved crystallization, the decreased defects of the film structure and greater crystallite sizes. Similar results have been reported in the literature [71].
Mg-doped films exhibits a widening of the optical band gap with respect to undoped ZnO films. ZnO:Mg 2 films possess the highest values of E g and the optical band gap reduces sharply after thermal treatment at 600 • C. A similar tendency is found for ZnO:Mg 3. The optical band gap varies from 3.32 eV (for ZnO:Mg 0.5, 300 • C) to 3.56 eV (ZnO:Mg 2, 500 • C). The E g values of sol-gel ZnO and ZnO:Mg films are in the range of the reported data for these materials [72]. The enhanced band gap can be induced by several factors: (i) the reduced lattice constant c [73], whreby the XRD study confirms that the lowest c parameter is found for the sol-gel ZnO:Mg 2 films; (ii) the difference in electronegativities of Zn and Mg atoms may induce an attractive effect of interaction between Mg 2+ and O 2− , which may lead to a rise in band gap energy as MgO possesses a band gap energy of 7.8 eV [74] and the possible existence of the MgO phase in the structure of doped films can induce a wider band gap [75]; (iii) the Moss-Burstein effect is also possible, where Mg ions disturb the ZnO lattice leading to oxygen vacancies and to a shift of the Fermi level towards the conduction band-blue shifting [76]; and (iv) the decrease in the crystallite sizes [77].
The refractive index n is an important parameter for materials used as optical elements and applied in integrated optic devices and optoelectronic devices. It is well known that refractive index is one of the fundamental properties for an optical material and it is closely related to the electronic polarizability of ions and the local field inside materials [78].
The extinction coefficient and the refractive index of ZnO and ZnO:Mg films can be determined from the spectrophotometric data, using the equations [79]: where R represents the film reflectance, k is the calculated extinction coefficient, λ is the wavelength of the incident photon and α is the absorption coefficient, estimated from Equation (8).
The comparison of the extinction coefficient of ZnO and Mg-doped ZnO films is given in Figure 13 for annealing temperatures from 300 to 600 • C. The spectral range is 300-1000 nm. The extinction coefficient increases with the annealing temperatures and ZnO:Mg 3 films show the highest values in the visible spectral range 450-750 nm after annealing at 300-500 • C. ZnO:Mg 0.5 and ZnO:Mg 2 have the lowest extinction values in the visible spectral region. ZnO and Mg-doped ZnO films reveal that the extinction coefficient is increased with raising the annealing temperature.
The estimated values of the refractive index are presented in Figure 14, where the obtained results of ZnO and ZnO:Mg films are compared at different annealing temperatures. The refractive index of the undoped ZnO films vary from 1.25 to 1.90 in the range 450-750 nm, depending on the wavelength λ and the annealing temperature. It is revealed that the n values become greater increasing annealing temperature. The refractive index is increased with increasing wavelength. Similar behavior of the refractive index for ZnO thin films has been reported by others [80].
Mg doping leads to a higher refractive index compared to undoped ZnO films, as can be noticed from Figure 14. ZnO:Mg films also show a strong dependence of the refractive index on the annealing temperatures, except for ZnO:Mg 1 samples. The higher refractive index of the doped ZnO films can be related to the formation of agglomerations resulting from Mg doping. It is also well known that the refractive index is sensitive to structural defects and depends on dopants, impurities, crystallinity, deposition methods, stoichiometry, packing density, etc. [78,81]. the visible spectral region. ZnO and Mg-doped ZnO films reveal that the extinction coefficient is increased with raising the annealing temperature. The estimated values of the refractive index are presented in Figure 14, where the obtained results of ZnO and ZnO:Mg films are compared at different annealing temperatures. The refractive index of the undoped ZnO films vary from 1.25 to 1.90 in the range 450-750 nm, depending on the wavelength λ and the annealing temperature. It is revealed that the n values become greater increasing annealing temperature. The refractive index is increased with increasing wavelength. Similar behavior of the refractive index for ZnO thin films has been reported by others [80].
Mg doping leads to a higher refractive index compared to undoped ZnO films, as can be noticed from Figure 14. ZnO:Mg films also show a strong dependence of the refractive index on the annealing temperatures, except for ZnO:Mg 1 samples. The higher refractive index of the doped ZnO films can be related to the formation of agglomerations resulting from Mg doping. It is also well known that the refractive index is sensitive to structural defects and depends on dopants, impurities, crystallinity, deposition methods, stoichiometry, packing density, etc. [78,81]. A similar increase in the refractive index with doping with different elements is reported for sol-gel boron-doped ZnO films [82] and for Fe, Co, Mn, Ni doped ZnO films deposited by spray pyrolysis [81]. The refractive index values are also dependent on the experimental optical measurement technique used (spectrophotometry or spectroscopic ellipsometry) and the approaches used for extraction of the refractive index from these A similar increase in the refractive index with doping with different elements is reported for sol-gel boron-doped ZnO films [82] and for Fe, Co, Mn, Ni doped ZnO films deposited by spray pyrolysis [81]. The refractive index values are also dependent on the experimental optical measurement technique used (spectrophotometry or spectroscopic ellipsometry) and the approaches used for extraction of the refractive index from these measurements [78]. Table 1 presents a small part of the reference data for n values of ZnO materials, prepared by different methods [6,78,79,[81][82][83][84][85][86][87][88][89][90][91]. It can be seen that the refractive index values vary in a very broad range. Mg doping also results in an increase in the refractive index of ZnO, as it has been determined that the doping concentration and the annealing temperatures significantly affect the n values. The optical study of the sol-gel ZnO films reveals that their optical properties are affected by Mg doping. For a certain dopant content, the transparency of the films is improved. The optical band gap can be tuned by varying the Mg concentration in the sol solution. The refractive index is changed with doping and annealing.

FESEM Microscopy-Film Morphology
The study of the surface morphology was performed using FESEM for undoped ZnO, ZnO:Mg 0.5 and ZnO:Mg 3 films, annealed at 600 • C (Figures 15 and 16). The substrate used was Si wafer. FESEM images with different magnifications are used for the film morphology analysis.
In our previous research on ZnO-based films [37], we used the same sol solution for depositing pure ZnO films, at a higher spin coating rotation speed (4000 rpm). In this work, ZnO and ZnO:Mg films were deposited at a lower spin coating speed of 2000 rpm. It is interesting to inspect the impact of the rotation speed change on the film morphology. FESEM micrographs of the sol-gel ZnO films, deposited at 2000 and 4000 rpm and annealed at 600 • C, are given in Figure 15.
The images reveal a wrinkle network structure with irregular fibers (magnification 20,000 and spatial resolution of 1 micron), and in closer observation (80,000, 300 nm, imbedded figures) they reveal porous surfaces. Some differences in the film morphologies appeared: a smoother surface is observed for the ZnO film, obtained at 2000 rpm compared to other films. Its surface shows the presence of spherical particles, as well as irregular grains with different shape and sizes. The ZnO film, deposited at 4000 rpm exhibits a more porous structure and a rougher wrinkle network. Similar observations of wrinkle network morphology have been previously reported for sol-gel spin-coated ZnO films [92].
The wrinkle formation of sol-gel films can emerge due to the following reasons: (1) the increase in volumetric stress in the films and evaporation of the solvent [93], (2) the lack of hydroxyl (or alkoxy) groups in the sols [94] or (3) the release of mechanical stresses developed during densification and heat treatment of the films [92]. Other probable factors can be differences between the thermal expansion coefficients of the substrate and film, volume reduction upon crystallization and film thickness [92]. The undoped ZnO films (independent on the spin coating speed) exhibit weak and broad absorption bands due to the stretching vibrations of hydroxyl groups (at 3190-3600 cm −1 ) after 300 • C annealing, which disappeared at higher annealing temperatures. The images reveal a wrinkle network structure with irregular fibers (magnification 20,000 and spatial resolution of 1 micron), and in closer observation (80,000, 300 nm, imbedded figures) they reveal porous surfaces. Some differences in the film morphologies appeared: a smoother surface is observed for the ZnO film, obtained at 2000 rpm compared to other films. Its surface shows the presence of spherical particles, as well as irregular grains with different shape and sizes. The ZnO film, deposited at 4000 rpm exhibits a more porous structure and a rougher wrinkle network. Similar observations of wrinkle network morphology have been previously reported for sol-gel spin-coated ZnO films [92].
The wrinkle formation of sol-gel films can emerge due to the following reasons: (1) the increase in volumetric stress in the films and evaporation of the solvent [93], (2) the lack of hydroxyl (or alkoxy) groups in the sols [94] or (3) the release of mechanical stresses developed during densification and heat treatment of the films [92]. Other probable factors can be differences between the thermal expansion coefficients of the substrate and film, volume reduction upon crystallization and film thickness [92]. The undoped ZnO films (independent on the spin coating speed) exhibit weak and broad absorption bands due to the stretching vibrations of hydroxyl groups (at 3190-3600 cm −1 ) after 300 °C annealing, which disappeared at higher annealing temperatures. Figure 16 presents FESEM images of sol-gel ZnO, ZnO:Mg 0.5 and ZnO:Mg 3 films, annealed at 600 °C. The magnifications used are 10,000 with a spatial resolution of 2 microns and 160,000 with a spatial resolution of 200 nm. It can be confirmed that Mg doping changes ZnO film morphology as the wrinkle formation is distorted.  Undoped ZnO film exhibits a wrinkle-type network (as discussed above) and a relatively smooth surface. The higher magnifications reveal a close-packed grained structure with spherical and irregular particles. The wrinkles have widths of 190-540 nm and the grain sizes are in the range of 30-120 nm, but the greater particles prevail. The lowest Mg concentration (0.5 wt%) changes the film morphology (Figure 16c Undoped ZnO film exhibits a wrinkle-type network (as discussed above) and a relatively smooth surface. The higher magnifications reveal a close-packed grained struc- The film morphology of ZnO films is affected by Mg doping. The wrinkles are smaller and almost disappear for the highest magnesium concentration. The smoother film surface leads to an improved transparency of ZnO:Mg films, especially for ZnO:Mg films with 0.5, 1 and 2 wt% Mg concentration.

Figure of Merit (FOM)-Electrical Properties
Sheet resistance (R sheet ) of sol-gel ZnO and ZnO:Mg films is measured by the fourpoint probe technique. Optical transparency and sheet resistance are two factors that are crucial for transparent conductive electrodes based on metal oxides and are essential for applications of these materials in solar cells [95]. Optical transparency directly governs the amount of charge generation within solar cells. The influence of sheet resistance is more complicated and less straightforward, but it also strongly impacts the device's performance [95].
A figure of merit is defined as an appropriate quantitative measure that can rate the performance of the sample and determine its comparative effectiveness for an application. Figure of merit (FOM) can be estimated from the following equation [96]: where T average is the average transmittance in the spectral range 450-750 nm and R sheet is the measured sheet resistance. The obtained values are given in Table 2.  Table 3 presents a comparison of the FOM and resistance values found in the literature for ZnO-based thin films [96][97][98][99][100]. It can be observed that the FOM of the studied films are lower or similar to reported values of ZnO-based materials. The electrical properties of the undoped and Mg-doped ZnO films are affected by Mg concentration and high temperature treatments. It can be observed that ZnO:Mg 2 films possess the best optical and electrical properties. Further study is needed for optimization of the film thickness, transparency and sheet resistance of sol-gel Mg-doped ZnO films, but the obtained results are encouraging.

Conclusions
Thin films of ZnO and ZnO:Mg were successfully deposited by the sol-gel spin coating method on silicon wafers and quartz substrates. Their structural, optical and morphological properties were studied as functions of four magnesium doping concentrations and different thermal treatments (300-600 • C). The XRD study proves that Mg doping induces the deterioration of the film crystallizations. MgO segregation is found in ZnO:Mg 3 films with the highest Mg concentration after annealing at 500 and 600 • C. No Mg or Mg oxide phases are detected in the other ZnO:Mg films. The modifications in lattice parameters, c/a ratio, Zn-O bond and the shifting of the 002 XRD line corroborates the successful incorporation of magnesium into the ZnO host matrix. The wide absorption bands at 1400 cm −1 , observed in the FTIR spectra of ZnO:Mg 2 and ZnO:Mg 3 films, are attributed to Mg-O stretching vibrations and are completely absent in the other studied pure ZnO and doped ZnO samples. The FTIR study reveals that a small MgO fraction can also exist in ZnO:Mg 2 films, most probably in the amorphous state. This finding explains the crystalline behavior of ZnO:Mg 2 films, with the smallest values of the crystallite sizes, c parameter and c/a ratio and, respectively, the greatest distortion parameter.
Optical characterization reveals that the film transparency of the Mg-doped ZnO films is generally enhanced. The greatest transmittance is found for ZnO:Mg 2 films. Mg doping tunes the optical band gap (E g ) values and Mg incorporation results in a widening of E g . The influence of the annealing temperatures on the transmittance, reflectance, band gap, extinction coefficient and refractive index was monitored. FESEM analysis exhibits that the surface features are strongly dependent on Mg doping. The film morphology is changed from a wrinkle-type surface to a smoother morphology with increasing the magnesium doping.