# Color Simulation of Multilayered Thin Films Using Python
## 2 Materials and Methods
### Theoretical Background
#### 2.1.2 Reflection from a (Multilayered) Thin Film  
For a thin film or multilayered structure, we need to consider the absorption and optical interference of multiple reflections, transmissions, and absorptions occurring at interfaces underneath the surface. Figure 1: Incident wave at angle \(\theta_{\mathrm{i}}\) hits the interface between two media with refractive indices \(n_{\mathrm{i}}\) and \(n_{\mathrm{2}}\): (**a**) the electric field (**E**) parallel to the plane of incidence (\(p\)-polarization) and (**b**) **E** perpendicular to the plane of incidence (\(s\)-polarization). **E** and the magnetic field (**B**) are mutually perpendicular (i.e., the propagation vector \(\mathbf{k}=\mathbf{E}\times\mathbf{B}\)). The subscripts i, r, and t represent the incident, reflected, and transmitted waves, respectively. This absorption can be formulated by incorporating a complex refractive index into the wave function (Figure 2). The wave function of a plane wave traveling in the \(x\) direction can be written in complex notation as follows:  
\[\tilde{\mathbf{E}}=\tilde{\mathbf{E}}_{0}\text{exp}[i\bigg{(}\omega t-\overset{ \sim}{K}x\bigg{)}] \tag{13}\]  
where \(\tilde{\mathbf{E}}_{0}\), \(\omega\), \(t\), \(\overset{\sim}{K}\), and \(x\) are the complex wave amplitude's, angular frequency, time, complex wavenumber, and position, respectively. The complex wavenumber can be written as  
\[\overset{\sim}{K}\equiv\frac{2\pi\overset{\sim}{N}}{\lambda} \tag{14}\]  
where \(\overset{\sim}{N}\) is the complex refractive index. \(\overset{\sim}{N}\) is defined as  
\[\overset{\sim}{N}\equiv n-\overset{\sim}{k} \tag{15}\]  
where \(n\) and \(k\) are the refractive index and extinction coefficient, respectively. By substituting Equations (14) and (15) into Equation (13), we obtain an expression for the electromagnetic wave that takes attenuation (i.e., exponential decay) due to the absorption into account:  
\[\overset{\sim}{\mathbf{E}}=\tilde{\mathbf{E}}_{0}\text{exp}\bigg{(}-\frac{2 \pi kx}{\lambda}\bigg{)}\cdot\text{exp}\bigg{[}i\bigg{(}\omega t-\frac{2\pi n} {\lambda}x\bigg{)}\bigg{]}. \tag{16}\]  
In addition to absorption, we need to consider optical interference. Figure 3 shows the presence of reflected light from the interfaces between (1) air and the thin film (upper) and (2) the thin film and its substrate (lower). The reflected light waves will interfere either constructively or destructively, depending on the phase difference between the two waves. The path length difference between the two waves is \(\overline{\text{AB}}+\overline{\text{BC}}-\overline{\text{AD}}\). The paths \(\overline{\text{AB}}\) and \(\overline{\text{BC}}\) traverse a medium with a refractive index of \(N_{1}\), while path \(\overline{\text{AD}}\) traverses a medium with a refractive index of \(N_{0}\). Therefore, the phase difference (\(\alpha\)) is obtained by applying the different wavenumbers (\(K=2\pi N/\lambda\)) as follows:  
\[\alpha=\frac{2\pi N_{1}}{\lambda}(\overline{\text{AB}}+\overline{\text{BC}}) -\frac{2\pi N_{0}}{\lambda}\overline{\text{AD}}. \tag{17}\]  
Considering the incident and transmitted angles, we obtain \(\overline{\text{AD}}=\overline{\text{AC}}\text{sin}\,\theta_{\text{i}}\) and \(\overline{\text{AC}}\)= \(2d\text{tan}\,\theta_{\text{t}}\), which lead to  
\[\overline{\text{AD}}=2d\text{tan}\,\theta_{\text{t}}\cdot\text{sin}\theta_{ \text{i}}. \tag{18}\]  
By incorporating [PERSON]'s law (\(\text{sin}\,\theta_{\text{i}}=\text{sin}\,\theta_{\text{t}}N_{1}/N_{0}\)),  
\[\overline{\text{AD}}=2d\frac{\text{sin}^{2}\,\theta_{\text{t}}}{\cos\theta_{ \text{t}}}\frac{N_{1}}{N_{0}}. \tag{19}\]  
Figure 2: Wave propagation in a medium with (**a**) zero and (**b**) a nonzero extinction coefficient (\(k\)). When the extinction coefficient is zero (**a**), the amplitude (\(E_{\text{t}}\)) remains constant. In contrast, with a nonzero extinction coefficient (**b**), the amplitude exhibits exponential decay.