Interaction of Several Toxic Heterocarbonyl Gases with Polypyrrole as a Potential Gas Sensor

: The interactions of the toxic heterocarbonyl gases phosgene, carbonyl ﬂuoride, formaldehyde, carbonyl sulﬁde, and acetone with polypyrrole as a toxic heterocarbonyl gas sensor, were extensively studied by density functional theory (DFT). The Becke 3-parameter, Le e -Yang-Parr (B3LYP) exchange-correlation functional methods were ﬁrst tested against several high-level DFT methods employing the Dunning’s double- ζ and triple- ζ basis sets and were found to be su ﬃ cient in describing the non-covalent interactions involved in this study. The interaction of pyrrole with the heterocarbonyl gases resulted in changes in the structure and optoelectronic properties of the polymer and it was observed that acetone and formaldehyde had the strongest H-bonding interaction with polypyrrole, while the interaction of phosgene and formaldehyde resulted in the lowest energy gap and may result in its high sensitivity towards these gases. The UV-Vis absorption revealed signiﬁcant red-shifted ﬁrst singlet excited states ( E excited, 1st ) of the complexes and follows the same trend as the E Gap values. It is shown that the E excited, 1st was due to the π (HOMO Py ) −→ π *(LUMO HC ) transitions and the excited state at maximum absorption ( E excited, max ) was due to the π (HOMO Py ) −→ π *(LUMO Py ) transitions. This study demonstrates the potential sensitivity and selectivity of polypyrrole as a toxic heterocarbonyl sensor.


Introduction
Heterocarbonyl gases such as phosgene, carbonyl fluoride, formaldehyde, carbonyl sulfide, and acetone are well-known toxic compounds and may cause numerous health problems, especially through chronic exposure. The effects of these compounds may range from mild irritation, and allergy to more serious ones, including asthma, cancer, genetic deficiency, damage to organs, and others [1][2][3]. Phosgene is a colorless gas and a highly toxic industrial gas that is very reactive and poses a significant public health risk. In aqueous media, it hydrolyzes to form hydrochloric acid and carbon dioxide. Phosgene is widely used in the industry for various chemical processes involving plastics, pesticides, dyes, pharmaceuticals. It was even used during World War I as a chemical weapon, resulting in a large number of deaths. Inhalation of phosgene gas results in very harmful effects on the lungs and respiratory tract. When inhaled excessively, the person may suffer from pulmonary edema or pulmonary emphysema, and even death [1,4]. Carbonyl fluoride is also a colorless and highly toxic gas. This gas may undergo hydrolysis in water, producing hydrofluoric acid and carbon dioxide. It is primarily used as an intermediate for the production of organic fluorine compounds. Similar to phosgene, the production of acid products may be the main cause of toxicity in the body. Exposure to this gas may lead to irritation, inflammation, pulmonary congestion, and may lead to death [2,5,6]. Formaldehyde is a flammable and colorless gas that is characterized by its distinct strong unpleasant odor. This compound is typically found in household products, resins, building materials, preservatives, Figure 1 shows the chemical structures of the polypyrrole (9Py), represented as nine units of pyrrole monomers, interacting with several heterocarbonyl gases (HC): phosgene (CCl), carbonyl fluoride (CF), formaldehyde (CH), carbonyl sulfide (CS), and acetone (CMe), used in this study. In gas sensing experiments, the polymer films are deposited on the surface of the electrode [24,73] and gas molecules mostly interact on the surface and in the bulk of the long polymer chain, as demonstrated in previous polymer-based gas sensor calculations [51,74,75]. Thus, in this study, polypyrrole was represented by a nine-unit-long oligomer, and the gas analyte was placed in the middle of the chain to reduce the interaction of the gas molecules with the edges of the polymer. All DFT calculations were carried out using the Gaussian16 computational package [76]. Geometry optimizations and energy calculations were performed using the B3LYP functional in the gas phase. The coordinates of the optimized geometries are presented in the Supplementary Material, Table S1. As mentioned, the B3LYP functional has limitations in describing non-covalent interactions due to the presence of dispersion forces. Nevertheless, the B3LYP functional is arguably the most popular functional in theoretical studies involving the sensing capability of polypyrrole and other conducting polymers [49,51,53,55]. However, several methods may be carried out to reduce these errors, such as counterpoise (CP) [77] and Grimme's dispersion [69][70][71] corrections. In a recent study on 21 small bimolecular van der Waals organic complexes, it was demonstrated that the functionals B97-D3, B3LYP-D3 and M05-2X functionals with Dunning's aug-cc-pVDZ basis set are suitable for predicting the equilibrium geometries of non-bonded complexes [78]. In another study on the performance of various DFT functionals on the non-covalent interaction of organic complexes with the double-ζ(aug-cc-pVDZ) and triple-ζ(aug-ccpVTZ) basis sets by Dunning, it was shown that, for the double-ζbasis, the B97-D2, B97-D3, M06-2X, and M05-2X functionals are recommended. While for the triple-ζbasis, the ωB97X-D, B2PLYPD3, B3LYP-D3, and M06-2X functionals are recommended [79]. Therefore, these high-level methods were tested against several B3LYP methods with and without the Grimme's and CP corrections together with various basis sets for 1Py-CH to determine the appropriate level for the polypyrrole-carbonyl complexes in this study. the equilibrium geometries of non-bonded complexes [78]. In another study on the performance of various DFT functionals on the non-covalent interaction of organic complexes with the double-ζ (aug-cc-pVDZ) and triple-ζ (aug-ccpVTZ) basis sets by Dunning, it was shown that, for the double-ζ basis, the B97-D2, B97-D3, M06-2X, and M05-2X functionals are recommended. While for the triple-ζ basis, the ωB97X-D, B2PLYPD3, B3LYP-D3, and M06-2X functionals are recommended [79]. Therefore, these high-level methods were tested against several B3LYP methods with and without the Grimme's and CP corrections together with various basis sets for 1Py-CH to determine the appropriate level for the polypyrrole-carbonyl complexes in this study. The equilibrium geometries of the polypyrrole-carbonyl (9Py-HC) complexes in the gas phase were determined by DFT using the B3LYP functional together Grimme's electron dispersion correction (D3) with modification of damping (BJ) and 6-31+G(d,p) as the basis set, B3LYP-D3(BJ)/6-31+G(d,p), followed by vibrational analysis at the same level to ensure that the structures are at the local minima. Energy calculations were done using the same level with an additional counterpoise correction (CP), DFT/B3LYP-D3(BJ)-CP/6-31+G(d,p) to reduce the basis set superposition error (BSSE). Interaction energies were calculated as

Materials and Methods
where Ecomplex, EPy, and EX are the total energies of the pyrrole-heterocarbonyl (Py-HC) complexes, isolated pyrrole (9Py), and isolated heterocarbonyl gas (HC), respectively. The UV-Vis spectrum was simulated by TDDFT calculations at the B3LYP/6-31+G(d,p) level. The structures were viewed using Chemcraft [80], while the molecular orbitals were shown using GaussView6 [81]. The NBO population analysis was carried out using the NBO program [82], while the UV-Vis spectrum and the density of states were determined using the GaussSum package [83]. Table 1 shows the structural parameters obtained for 1Py-CH using several B3LYP methods: B3LYP-D3(BJ), B3LYP, B3LYP-CP, and B3LYP-D3(BJ)-CP, with various basis sets: 6-31+G(d,p), 6-311+G(d,p), aug-cc-pVDZ, and aug-cc-pVTZ. These B3LYP methods and basis sets were tested against the B97D3, M05-2X, and ωB97xD methods with aug-cc-pVDZ as the basis set. It can be observed The equilibrium geometries of the polypyrrole-carbonyl (9Py-HC) complexes in the gas phase were determined by DFT using the B3LYP functional together Grimme's electron dispersion correction (D3) with modification of damping (BJ) and 6-31+G(d,p) as the basis set, B3LYP-D3(BJ)/6-31+G(d,p), followed by vibrational analysis at the same level to ensure that the structures are at the local minima. Energy calculations were done using the same level with an additional counterpoise correction (CP), DFT/B3LYP-D3(BJ)-CP/6-31+G(d,p) to reduce the basis set superposition error (BSSE). Interaction energies were calculated as

Determination of the Appropriate B3LYP Method and Basis Set against Several High-Level DFT Methods
where E complex , E Py , and E X are the total energies of the pyrrole-heterocarbonyl (Py-HC) complexes, isolated pyrrole (9Py), and isolated heterocarbonyl gas (HC), respectively. The UV-Vis spectrum was simulated by TDDFT calculations at the B3LYP/6-31+G(d,p) level. The structures were viewed using Chemcraft [80], while the molecular orbitals were shown using GaussView6 [81]. The NBO population analysis was carried out using the NBO program [82], while the UV-Vis spectrum and the density of states were determined using the GaussSum package [83].

Results and Discussion
3.1. Determination of the Appropriate B3LYP Method and Basis Set against Several High-Level DFT Methods Table 1 shows the structural parameters obtained for 1Py-CH using several B3LYP methods: B3LYP-D3(BJ), B3LYP, B3LYP-CP, and B3LYP-D3(BJ)-CP, with various basis sets: 6-31+G(d,p), 6-311+G(d,p), aug-cc-pVDZ, and aug-cc-pVTZ. These B3LYP methods and basis sets were tested against the B97D3, M05-2X, and ωB97xD methods with aug-cc-pVDZ as the basis set. It can be observed that the distances between N 4 and H 8 are the same for all combinations, while the C 3 N 4 C 5 angles are virtually the same for all methods. Significant differences were observed for the hydrogen-bonded atoms H 8 and O 9 , and the angle between the hydrogen-bonded atoms C 3 , N 4 , and C 5 . The B97D3, M05-2X, and ωB97xD combinations have H 8 -O 9 distances ranging from 2.10 to 2.17 Å, with an average of 2.13 Å, while the C 3 N 4 C 5 angles ranged from 134.0 • to 142.4 • , with an average of 139.2 • . For the B3LYP methods, the B3LYP and B3LYP-CP combinations generated shorter H 8 -O 9 distances and higher C 3 N 4 C 5 angles. On the other hand, The B3LYP-D3(BJ) and B3LYP-D3(BJ)-CP combinations generated similar H 8 -O 9 distances (2.11 and 2.12 Å) and virtually the same C 3 N 4 C 5 angles (139.5 • to 142.6 • ). Thus, the B3LYP-D3(BJ)/6-31+G(d,p), less computationally intensive than B3LYP-D3(BJ)-CP, was used for the 9Py-HC geometry optimizations. Table 1. Structural parameters from the equilibrium geometries of 1Py-CH using several B3LYP methods and basis sets in the gas phase against several high-level density functional theory (DFT) methods with an aug-cc-pVDZ basis set.  Table 2 shows the interaction energies using several B3LYP methods: B3LYP-D3(BJ) and B3LYP-D3(BJ)-CP with the 6-31+G(d,p) and 6-311+G(d,p) basis sets from the B3LYP-D3(BJ)/6-31G+(d,p) optimized structure. These B3LYP combinations were then tested against the B97D3, B97D2, M05-2X, and M06-2X methods with aug-cc-pVDZ as the basis set, and M06-2X, ωB97xD, B2PLYPD3, and B3LYP-D3(BJ) methods with aug-cc-pVTZ as the basis set. The interaction energies of the DFT methods with the Dunning's correlation consistent basis sets were observed to range from −5.35 to −6.05 kcal/mol, with an average of −5.69 ± 0.24 kcal/mol. The B3LYP-D3(BJ) method was observed to overestimate the magnitude of the interaction energies, −6.00 kcal/mol for 6-31+G(d,p) and −6.08 kcal/mol for 6-311+G(d,p), but was in line with the counterpoise-corrected B3LYP-D3(BJ)-CP method, where the 6-31+G(d,p) and 6-311+G(d,p) basis sets have very similar values of −5.74 and −5.70 kcal/mol, respectively. The B3LYP-D3(BJ)-CP/6-31+G(d,p) was then utilized for the 9Py-HC energy calculations. Table 2. Interaction energies of 1Py-CH using several B3LYP methods against high-level DFT methods with aug-cc-pVDZ and aug-cc-pVTZ basis sets.

Method
Basis

Structural Parameters for the 9Py-HC Complexes
The structural changes in 9Py upon its interaction with the HC gases are shown in Table 3. It was previously shown in previous studies with polypyrrole [52,55,56] that these structural parameters are virtually the same for shorter chain lengths, thus, only n = 9 units (9Py) to represent infinite chain length were carried out in this study. The length between the hydrogen-bonded (H-bond) atoms, H 8 -O 9 , showed that the shortest distance was observed for 9Py-CMe (1.929 Å) followed by 9Py-CH (1.981 Å), 9Py-CCl (2.176 Å), 9Py-CF (2.194 Å), and the longest for 9Py-CS (2.352 Å). The angle between the hydrogen bond donor (N 4 ), hydrogen atom (H 8 ), and hydrogen bond acceptor (O 9 ), N 4 H 8 O 9 angle, is closest to linearity in 9Py-CMe (163.9 • ), followed by 9Py-CH (160.2 • ), 9Py-CCl (152.4 • ), 9Py-CF (150.0 • ) and lastly 9Py-CS (134.5 • ). The trend could indicate that CMe has the strongest H-bond interaction with 9Py and the weakest interaction occurs with CS. Moreover, due to the interaction of the gases, the weakening of the N 4 -H 8 bond was observed, where the largest increase in N 4 -H 8 bond length was observed with 9Py-CMe and has the opposite trend with the shortening of H-bond lengths. Table 3. Structural parameters for the optimized 9Py-HC complexes at the B3LYP-D3(BJ)/6-31+G(d,p) level. The N 1 C 2 C 3 N 4 , C 2 C 3 N 4 C 5 , and N 4 C 5 C 6 N 7 dihedral angles indicate the planarity of the polypyrrole before and after its interactions with the HC gases and therefore could affect its electronic properties. The C 2 C 3 N 4 C 5 dihedral angles remained close to 180 • with only about a~1 • or less decrease for all complexes, however, both N 1 C 2 C 3 N 4 and N 4 C 5 C 6 N 7 dihedral angles had significant changes for all complexes upon the interaction of polypyrrole with the gases. All complexes exhibited increased planarity for the N 1 C 2 C 3 N 4 dihedral angle, with the most planar observed in 9Py-CH (177.6 • ), followed very closely by 9Py-CMe (177.4 • ), 9Py-CCl (161.5 • ), 9Py-CF (161.3 • ), and the least planar for 9Py-CS (159.9 • ) as compared to 9Py (157.7 • ). The increase in planarity could be due to the strong electronic effect brought by the interaction of the HC gases with Py. However, the N 4 C 5 C 6 N 7 dihedral angles were observed to decrease for all complexes, with the lowest observed for 9Py-CMe (−143.9 • ), followed by 9Py-CCl (−146.2 • ), 9Py-CF (−148.8 • ), 9Py-CS (−151.8 • ), and the most planar 9Py-CH (−153.6 • ) compared to 9Py (−157.7 • ). As observed in Figure 2, this dihedral angle is greatly affected by the presence of the bulky α-groups (CMe and CCl) attached to the carbonyl carbon, resulting in an increase in the dihedral angles due to steric effect and the gases with the least bulky α-groups (CH and CS) having the smallest increase in dihedral angles.

Vibrational Analysis of the 9Py-HC Complexes
The vibrational frequencies of the 9Py-HC complexes were observed to decrease from the 3676 cm −1 (N4-H8 stretching) for the isolated polypyrrole (9Py) upon its interaction with the HC gases. The most significant shift was observed for 9Py-CMe (3482 cm −1 ), followed by 9Py-CH (3519 cm −1 ), 9Py-CCl (3636 cm −1 ), 9Py-CF (3637 cm −1 ), and CS (3658 cm −1 ). The observed decrease is due to the weakening of the N4-H8 bond length, as shown in Table 3, brought by the increase in H-bonding between 9Py and HC gases and has the same trend as the H-bond distances and angles. Thus, the stronger is the H-bond strength, the larger the shift in the vibrational frequencies. Table 4 shows the complexation energies for the interaction of 9Py with HC gases for both B3LYP-D3(BJ) and the counterpoise corrected B3LYP-D3(BJ)-CP. The complexation energies show that the BSSE energies are quite significant, about 7-15% of the corrected complexation energies. The trend observed for the complexation energies is consistent with the structural analysis of the H-bond

Vibrational Analysis of the 9Py-HC Complexes
The vibrational frequencies of the 9Py-HC complexes were observed to decrease from the 3676 cm −1 (N 4 -H 8 stretching) for the isolated polypyrrole (9Py) upon its interaction with the HC gases. The most significant shift was observed for 9Py-CMe (3482 cm −1 ), followed by 9Py-CH (3519 cm −1 ), 9Py-CCl (3636 cm −1 ), 9Py-CF (3637 cm −1 ), and CS (3658 cm −1 ). The observed decrease is due to the weakening of the N 4 -H 8 bond length, as shown in Table 3, brought by the increase in H-bonding between 9Py and HC gases and has the same trend as the H-bond distances and angles. Thus, the stronger is the H-bond strength, the larger the shift in the vibrational frequencies. Table 4 shows the complexation energies for the interaction of 9Py with HC gases for both B3LYP-D3(BJ) and the counterpoise corrected B3LYP-D3(BJ)-CP. The complexation energies show that the BSSE energies are quite significant, about 7-15% of the corrected complexation energies. The trend observed for the complexation energies is consistent with the structural analysis of the H-bond lengths and angles, and vibrational frequencies. The strongest interaction was observed for 9Py-CMe (−11.64 kcal/mol), followed by 9Py-CH (−7.98 kcal/mol), 9Py-CCl (−7.27 kcal/mol), 9Py-CF (−6.26 kcal/mol), and the weakest interaction was observed in 9Py-CS (−5.70 kcal/mol). The complexation energies showed various strengths of interaction, as the α-group of the heterocarbonyl gas was varied.  Table 5 summarizes the NBO population for the HC gases in complex with 9Py. It shows that the various gases have different effects on the polypyrrole, where CMe, CH, and CCl gases were observed to donate electron charges to the 9Py (n-doping), while CF and CS gases were observed to accept electron charges from the 9Py (p-doping). The CMe (0.02016 e − ) gas has the highest electron donation, followed by CH (0.01875 e − ), and CCl (0.00292 e − ), while the CS (−0.00439 e − ) has the strongest electron-accepting capability, followed by CF (−0.00087 e − ). The high electron-donating capability of CMe is due to the electron-donating capability of its alkyl methyl groups to the carbonyl O, resulting in electron donation to the polypyrrole and strong H-bond formation. It can be observed that the electron-donating/accepting capability trend of the HC gas has the same trend as the interaction energies and H-bond distances. This is due to the strong electron-withdrawing nature of polypyrrole, having an extensive conjugation and electron delocalization in its backbone. Thus, the stronger the H-bond, i.e., shorter H-bond distance and linear H-bond angle, the easier it is for the polypyrrole to accept electron charge from the HC gases. The effect of the electron charge transfer between 9Py and HC gases to the frontier orbital energies is then described in the next section.

Effect of Carbonyl Gases on the Electronic Properties of Pyrrole
The changes in the electronic properties of the polypyrrole due to its interaction with heterocarbonyl gases may result in variation in its chemiresistive properties. Since the conductivity of polypyrrole is directly related to its energy gap (E Gap ), understanding the interaction of the HC gases with its frontier orbitals is very important. As shown in Figure 3, there are significant variations in the E HOMO and E LUMO energies among different HC gases. The E HOMO and the E LUMO for 9Py were observed to be at −4.346 and −1.077 eV, respectively, while the E Gap was determined to be 3.269 eV, which is consistent with the experimental E Gap of 3.1 eV for polypyrrole [84]. The 9Py-CMe complex (−4.257 eV) was observed to have the highest E HOMO energy increase, followed by 9Py-CH (−4.273 eV). On the other hand, the 9Py-CCl (−4.347 eV) has a similar value to polypyrrole, while 9Py-CS (−4.358 eV), 9Py-CF (−4.362 eV) have lower E HOMO energies. The observed changes could be attributed to, as discussed in the previous section, the electron donation of the CMe and CH gases to the E HOMO of 9Py. As will be discussed in the next section, the HOMO surfaces of the complexes mainly have the 9Py character, therefore, electron donation to the 9Py backbone will result in an increase in the E HOMO energy. The opposite happens when the 9Py instead donates an electron charge to the HC gases, where the E HOMO orbitals are either unchanged or result in lower energy. For the E LUMO energies, the values are similar to the E LUMO energies of the isolated HC gases and, as can be seen in Figure 5 in the next section, the LUMO surfaces mainly have the HC gas LUMO character. The E LUMO energies of the 9Py-HC complexes and the E LUMO energies of the isolated gases (E LUMO, complex /E LUMO, HC gas ) are: 9Py-CCl (−2.203 eV/−2.085 eV), 9Py-CF (−1.235 eV/−1.162 eV), 9Py-CH (−2.102 eV/−1.7039 eV), 9Py-CS (−1.249 eV/−1.216 eV), and 9Py-CMe (−1.177 eV/−0.740 eV). All the E LUMO energies were observed to decrease as 9Py interacts with the HC gases and result in smaller E Gap values for all the 9Py-HC complexes compared to isolated 9Py. Due to the interaction of the different HC gases and its interaction with the frontier orbital energies of 9Py, varying E Gap values were observed for the 9Py-HC complexes. The smallest E Gap was observed for 9Py-CCl (2.144 eV), followed by 9Py-CH (2.171 eV), 9Py-CMe (3.081 eV), 9Py-CS (3.109 eV), and the largest was observed for 9Py-CF (3.128 eV). Table 6 presents a summary of the frontier orbital energies (E HOMO and E LUMO ), E Gap , ionization potential (IP), and electron affinity (EA), where the IP and EA were estimated using Koopman's theorem: IP = −E HOMO and EA = −E LUMO . The analysis of the calculated electronic energies demonstrates the potential sensitivity (significant reduction in E Gap values), especially for CCl and CH and the selectivity (variation in E Gap values for different HC gases) of polypyrrole as a potential sensor of the heterocarbonyl gases in this study. In order to further understand the effect of concentration, interferents, and charge transport along the polymer due to the interaction of the gas molecules with polypyrrole, large-scale molecular dynamics or monte carlo simulations are recommended [85][86][87][88].
Chemosensors 2020, 8, x FOR PEER REVIEW 9 of 17 discussed in the previous section, the electron donation of the CMe and CH gases to the EHOMO of 9Py. As will be discussed in the next section, the HOMO surfaces of the complexes mainly have the 9Py character, therefore, electron donation to the 9Py backbone will result in an increase in the EHOMO energy. The opposite happens when the 9Py instead donates an electron charge to the HC gases, where the EHOMO orbitals are either unchanged or result in lower energy. For the ELUMO energies, the values are similar to the ELUMO energies of the isolated HC gases and, as can be seen in Figure 5 Table 6 presents a summary of the frontier orbital energies (EHOMO and ELUMO), EGap, ionization potential (IP), and electron affinity (EA), where the IP and EA were estimated using Koopman's theorem: IP = −EHOMO and EA = −ELUMO. The analysis of the calculated electronic energies demonstrates the potential sensitivity (significant reduction in EGap values), especially for CCl and CH and the selectivity (variation in EGap values for different HC gases) of polypyrrole as a potential sensor of the heterocarbonyl gases in this study. In order to further understand the effect of concentration, interferents, and charge transport along the polymer due to the interaction of the gas molecules with polypyrrole, large-scale molecular dynamics or monte carlo simulations are recommended [85][86][87][88].

Density of States
To have a better understanding of the electronic properties of the 9Py-HC complexes, the density of states (DOS) and the frontier molecular orbital (FMO) surfaces are discussed. Figure 4 shows the total density of states (TDOS) of the 9Py-HC complexes and the isolated 9Py, and the projected density of states (PDOS) of the HC gases, while Figure 5 shows the HOMO and LUMO surfaces of the isolated 9Py and 9Py-HC complexes. The TDOS curves in Figure 5 show additional peaks or increased density in the LUMO energy region, mainly due to the LUMO orbitals of the HC gases, and are shown as large orbital densities in the LUMO surfaces in Figure 6. The 9Py-CCl and 9Py-CH were both observed to have the smallest E Gap values due to the existence of the additional peak in the TDOS of the two complexes, significantly reducing their LUMO energies, resulting in much lower E Gap values. For 9Py-CMe, 9Py-CF, and 9Py-CS, the reduction in LUMO energies is minimal since the LUMO energies of these HC gases are only slightly lower than the LUMO energy of the isolated 9Py, resulting in less lowering in the E Gap values. For the HOMO energies, the 9Py-CMe and 9Py-CH complexes have higher HOMO energies as compared to the rest of the complexes and result in more effective electron transfer to the 9Py, thus significantly increasing their HOMO energies. The combination of the HOMO and LUMO orbital interactions of the HC gases resulted in varying electronic properties of the 9Py-HC complexes.

Density of States
To have a better understanding of the electronic properties of the 9Py-HC complexes, the density of states (DOS) and the frontier molecular orbital (FMO) surfaces are discussed. Figure 4 shows the total density of states (TDOS) of the 9Py-HC complexes and the isolated 9Py, and the projected density of states (PDOS) of the HC gases, while Figure 5 shows the HOMO and LUMO surfaces of the isolated 9Py and 9Py-HC complexes. The TDOS curves in Figure 5 show additional peaks or increased density in the LUMO energy region, mainly due to the LUMO orbitals of the HC gases, and are shown as large orbital densities in the LUMO surfaces in Figure 6. The 9Py-CCl and 9Py-CH were both observed to have the smallest EGap values due to the existence of the additional peak in the TDOS of the two complexes, significantly reducing their LUMO energies, resulting in much lower EGap values. For 9Py-CMe, 9Py-CF, and 9Py-CS, the reduction in LUMO energies is minimal since the LUMO energies of these HC gases are only slightly lower than the LUMO energy of the isolated 9Py, resulting in less lowering in the EGap values. For the HOMO energies, the 9Py-CMe and 9Py-CH complexes have higher HOMO energies as compared to the rest of the complexes and result in more effective electron transfer to the 9Py, thus significantly increasing their HOMO energies. The combination of the HOMO and LUMO orbital interactions of the HC gases resulted in varying electronic properties of the 9Py-HC complexes.   Figure 6 shows the simulated UV-Vis absorption spectra of the 9Py-HC gases. The changes in the electronic structure of the 9Py results in changes in its chemiresistivity and also in its optical properties. As described in the previous sections, the EGap values decreased upon the interaction of HC gases with 9Py. The same was also observed in the excitation spectra of the 9Py-HC complexes. The isolated 9Py showed three major peaks at 436 (λmax), 372, and 345 nm (shoulder) consistent with previous reports [52,55,89,90]. The λmax at 436 nm (2.85 eV), attributed to the π ⟶ π* excitation, is consistent with the previous experimental value of 442 nm for polypyrrole [89][90][91]. The λmax (Eexcited, max) of the 9Py-HC complexes, as shown in Table 7, are similar to the λmax of 9Py with a slight red-shift for 9Py-CH (439 nm/2.82 eV) and 9Py-CMe (438 nm/2.83 eV), while a slight blue-shift was observed for 9Py-CCl (431 nm/2.88 eV), 9Py-CF (432 nm/2.87 eV), and 9Py-CS (431 nm/2.88 eV). On the other hand, the first singlet excitations (Eexcited, 1st), although at significantly lower oscillator strengths, for all 9Py-HC complexes have significantly shifted to longer wavelengths with the 9Py-CCl (743  Figure 6 shows the simulated UV-Vis absorption spectra of the 9Py-HC gases. The changes in the electronic structure of the 9Py results in changes in its chemiresistivity and also in its optical properties. As described in the previous sections, the E Gap values decreased upon the interaction of HC gases with 9Py. The same was also observed in the excitation spectra of the 9Py-HC complexes. The isolated 9Py showed three major peaks at 436 (λ max ), 372, and 345 nm (shoulder) consistent with previous reports [52,55,89,90]. The λ max at 436 nm (2.85 eV), attributed to the π −→ π* excitation, is consistent with the previous experimental value of 442 nm for polypyrrole [89][90][91]. The λ max (E excited, max ) of the 9Py-HC complexes, as shown in Table 7, are similar to the λ max of 9Py with a slight red-shift for 9Py-CH (439 nm/2.82 eV) and 9Py-CMe (438 nm/2.83 eV), while a slight blue-shift was observed for 9Py-CCl (431 nm/2.88 eV), 9Py-CF (432 nm/2.87 eV), and 9Py-CS (431 nm/2.88 eV). On the other hand, the first singlet excitations (E excited , 1st ), although at significantly lower oscillator strengths, for all 9Py-HC complexes have significantly shifted to longer wavelengths with the 9Py-CCl (743 nm/1.67 eV) and 9Py-CH (737 nm/1.68 eV) having the longest red-shifts, followed by 9Py-CMe (476 nm/2.60 eV), 9Py-CS (472 nm/2.62 eV), and 9Py-CF (469 nm/2.65 eV). The E excited , 1st are assigned to the π(HOMO Py ) −→ π*(LUMO HC ) transitions from the HOMO (bonding π-orbital) of 9Py to the LUMO (antibonding π-orbital) of the HC gases, as described in the previous section, while the E excited, max are assigned to the π(HOMO Py ) −→ π*(LUMO Py ) transitions from the HOMO of 9Py to the LUMO of 9Py. The observed large red shifts in the complexes, especially for CCl and CH, demonstrate the potential sensitivity of polypyrrole via UV-Vis absorbance measurements. . The Eexcited, 1st are assigned to the π(HOMOPy) ⟶ π*(LUMOHC) transitions from the HOMO (bonding π-orbital) of 9Py to the LUMO (antibonding π-orbital) of the HC gases, as described in the previous section, while the Eexcited, max are assigned to the π(HOMOPy) ⟶ π*(LUMOPy) transitions from the HOMO of 9Py to the LUMO of 9Py.

Simulated UV-Vis Absorption Spectra of the 9Py-HC Complexes
The observed large red shifts in the complexes, especially for CCl and CH, demonstrate the potential sensitivity of polypyrrole via UV-Vis absorbance measurements.

Conclusions
The potential of polypyrrole as a gas sensor for several toxic heterocarbonyl gases: phosgene, carbonyl fluoride, formaldehyde, carbonyl sulfide, and acetone was successfully described by DFT calculations. The B3LYP-D3/6-31+G(d,p) level for geometry optimizations and the B3LYP-D3-CP/6-31+G(d,p) level for energy calculations were found to be sufficient in describing non-covalent interactions when tested against several high-level DFT methods employing the Dunning's aug-cc-pVDZ and aug-ccpVTZ basis sets. The resulting geometries of the complexes from the interaction of the heterocarbonyl gases with polypyrrole were observed to have significant effects on its structural parameters. Increased planarity was observed in the non-interacting region of the polymer due to electronic effects, while decreased planarity was observed in the interacting region due to steric

Conclusions
The potential of polypyrrole as a gas sensor for several toxic heterocarbonyl gases: phosgene, carbonyl fluoride, formaldehyde, carbonyl sulfide, and acetone was successfully described by DFT calculations. The B3LYP-D3/6-31+G(d,p) level for geometry optimizations and the B3LYP-D3-CP/6-31+G(d,p) level for energy calculations were found to be sufficient in describing non-covalent interactions when tested against several high-level DFT methods employing the Dunning's aug-cc-pVDZ and aug-ccpVTZ basis sets. The resulting geometries of the complexes from the interaction of the heterocarbonyl gases with polypyrrole were observed to have significant effects on its structural parameters. Increased planarity was observed in the non-interacting region of the polymer due to electronic effects, while decreased planarity was observed in the interacting region due to steric effects. The analysis of the H-bond distances, vibrational frequencies, and complexation energies show that among the heterocarbonyl gases, acetone (CMe) had the strongest interaction as a result of the electron charge transfer (n-doping) of the acetone molecule to the polypyrrole backbone. The acetone and formaldehyde (CH) gases were observed to have significant electron charge donation to the polypyrrole backbone which increases the HOMO energies of these two complexes. On the other hand, the carbonyl fluoride (CF) and carbonyl sulfide (CS) gases were observed to receive electron charges from the polypyrrole backbone, resulting in a decrease in their HOMO energies. The LUMO orbitals of the complexes were observed to mainly have the LUMO orbital character of the heterocarbonyl gases. Due to the significantly lower LUMO energies of phosgene and formaldehyde gases, the LUMO energies of their complexes were observed to have the lowest energies, resulting in the smallest energy gaps among the gases studied. This demonstrates the potential chemiresistive sensitivities to these two gases. The first excited singlet states from the absorption calculations have the same trend as the energy gap values and were shown to be due to the π(HOMO Py ) −→ π*(LUMO HC ) energy transition from the HOMO orbital of polypyrrole to the LUMO orbital of the gas. The significant changes and variation among different analyte gases in their electronic and optical properties reveal its potential sensitivity and selectivity. The analysis and results in this study demonstrate the promise of polypyrrole as a sensor for various toxic heterocarbonyl gases and may aid in its future experiments and design.
Funding: This research received no external funding.