# Color Simulation of Multilayered Thin Films Using Python
## 2 Materials and Methods
### Theoretical Background
#### 2.1.2 Reflection from a (Multilayered) Thin Film
Using Equation (19) and \(\overline{\text{AB}}=\overline{\text{BC}}=d/\cos\theta_{\text{t}}\), we arrive at  
\[\alpha=\frac{4\pi dN_{1}}{\lambda}\cdot\cos\theta_{\text{t}}. \tag{20}\]  
The plane wave, when considering the phase difference, becomes  
\[\tilde{\mathbf{E}}=\tilde{\mathbf{E}}_{0}\text{exp}[i\bigg{(}\omega t-\overset{ \sim}{K}x\bigg{)}] \tag{13}\]0  
Equation (21) indicates that the phase difference can be imposed by multiplying \(\exp(-i\alpha)\). To account for the optical interference, we need to find the superposition of the light waves which are reflected from both upper and lower boundaries. The primary wave (i.e., that directly reflected from the film surface) becomes \(E_{1}=r_{01}E_{\text{i}}\), which is the reflection coefficient determined by the Fresnel equations for the boundary between the air and the thin film. The secondary wave, which is transmitted at the boundary between the air and the thin film, is then reflected from the substrate and transmitted at the boundary between the thin film and air and can be written by imposing the coefficients corresponding to each stage as follows:  
\[\tilde{\mathbf{E}}=\tilde{\mathbf{E}}_{0}\text{exp}[i\bigg{(}\omega t-\overset{ \sim}{K}x\bigg{)}] \tag{13}\]1  
As each additional order is considered, the wave undergoes two reflections (\(r_{10}\) and \(r_{12}\)) and acquires a phase difference. Each subsequent term is multiplied by a factor of \(r_{10}r_{12}\exp(-i\alpha)\). The total reflected wave (\(E_{012}\)) can be expressed as the sum of the primary wave (\(E_{1}\)), the secondary wave (\(E_{2}\)), the third wave (\(E_{3}\)), and so on:  
\[ \begin{split} E_{012}&=(r_{01}\ +t_{01}t_{10}r_{12} \exp(-i\alpha)+\ t_{01}t_{10}r_{10}r_{12}^{2}\exp(-i2\alpha)+\dots)E_{\text{i}} \\ &\quad=[r_{01}\ +t_{01}t_{10}\sum\limits_{\text{m}=1}^{\infty}r_{10} ^{m-1}r_{12}^{\text{m}}\exp(-\text{m}i\alpha)]E_{\text{i}}=r_{012}E_{\text{i}}.\end{split}  \tag{23}\]  
Figure 3: Optical interference in a thin film. The interference between the reflected light from both the upper and lower boundaries needs to be taken into account. \(\theta_{\text{i}}\) and \(\theta_{\text{t}}\) are the angles of incidence and refraction, respectively. \(\theta_{\text{i}}\) and \(\theta_{\text{t}}\) are equal to the \(\angle\)\(\Lambda\)CD and half of the \(\angle\)ABC, respectively, according to the reflection law. \(d\) is the thickness of the film. Each arrow represents the path of a reflected or transmitted wave, and the adjacent coefficients \(r_{mn}\) (\(t_{mn}\)) indicate the amplitude reflection (transmission) coefficient for the light incident from medium \(N_{m}\) to medium \(N_{n}\). The topmost coefficients along each ray represent the product of the corresponding amplitude coefficient and the phase difference accumulated along that path. \(r_{012}\) thus represents the reflection coefficient obtained when considering the optical interference. Using the formula for the sum of an infinite geometric series, we can simply write Equation (23) as  
\[r_{012}=r_{01}+\frac{t_{01}t_{10}r_{12}\text{exp}(-i\alpha)}{1-r_{10}r_{12}\text{ exp}(-i\alpha)}. \tag{24}\]  
Using \(r_{10}=-r_{01}\) and \(t_{01}t_{10}=1-r_{01}^{2}\), obtained by Equations (4), (5), (8), and (9), \(r_{012}\) can be reduced further [25]:  
\[r_{012}=\frac{r_{01}+r_{12}\text{exp}(-\text{i}\alpha)}{1+r_{01}r_{12}\text{ exp}(-\text{i}\alpha)}. \tag{25}\]  
Using Equation (25), the reflection coefficient for the air/thin film/substrate structure (Figure 3) can be obtained. Based on Equation (25), additional layers can be incorporated. When an additional layer is introduced (e.g., the buffer layer in an air/thin film/buffer layer/substrate structure), the reflection coefficient \(r_{0123}\) is derived.