betaFeedback

WorksPhysics and Astronomy

PyMoosh : a comprehensive numerical toolkit for computing the optical properties of multilayered structures

Abstract

We present PyMoosh, a Python-based simulation library designed to provide a comprehensive set of numerical tools allowing to compute essentially all optical characteristics of multilayered structures, ranging from reflectance and transmittance to guided modes and photovoltaic efficiency. PyMoosh is designed not just for research purposes, but also for use-cases in education. To this end, we have invested significant effort in ensuring user-friendliness and simplicity of the interface. PyMoosh has been developed in line with the principles of Open Science and taking into account the fact that multilayered structures are increasingly being used as a testing ground for optimization and deep learning approaches. We provide in this paper the theoretical basis at the core of PyMoosh, an overview of its capabilities, as well as a comparison between the different numerical methods implemented in terms of speed and stability. We are convinced such a versatile tool will be useful for the community in many ways.

Introduction

In optics, multilayered structures have been studied extensively for more than a century. The very first effort at calculating the reflectance of multilayers dates back to the early work of Lord Rayleigh[1, 2]. The subject gained increasing attention in the middle of the twentieth century when quarter-wave stacks (also called Bragg mirrors or 1D photonic crystals) were fabricated and fully understood for the first time[3]. An important contribution has been the formalism introduced by Abélès[4], which provided a deeper insight into the physical mechanisms behind the optical properties of multilayer systems, as well as a convenient mathematical framework for their calculation.In the years that followed, this formal approach was extended and successfully applied to periodic structures[5, 6, 7] and anisotropic media[8]. The resulting formalisms have been widely incorporated in optical textbooks[9, 10, 11].

The design of diverse optical filters, guided by physical intuition, emerged as early as 1958[12], and thrived in the subsequent years, notably due to the works of Thelen[13, 14, 15]. The first computer program that allowed foreword for the automation of optical filter design was published by Dobrowolsky and Lowe in 1978[16]. Given the versatility of multilayered structures, very efficient design methods have been conceived since then[17], requiring the reliable computation of the optical properties of increasingly complex filters. A direct application has been the Wavelength-Division Multiplexing technology, which allowed a substantial increase of the transcontinental optical connection bandwidth in recent decades. Today, optical filter design and fabrication contests[18, 19, 20] are periodically organized, showing how powerful state-of-the-art techniques have become. In the late 20th century, multilayered structures gained renewed interest and became widespread due to advances in fabrication techniques. In particular, two types of problems have received particular attention due to their practical importance: sensors based on surface plasmon resonances for the detection of biologically relevant molecules[21], and anti-reflective coatings used in photovoltaic devices[22]. In parallel, the increasingly complex problems associated with plasmonics[23], metamaterials[24] or non-specular phenomena[25] have also made multilayer simulations more challenging, particularly due to the frequent need to include a large number of metallic layers in the structures.

Over the years, an increasing number of numerical tools have thus been proposed to compute the optical response of complex multilayers[26, 27, 28], with a significant portion of them tailored for specific applications such as optical filters[29] or surface plasmon resonance (SPR)[30]. The demand for accurate and efficient computation of properties has grown significantly, while well-studied and understood structures serve as a testing ground for optimization techniques[31, 32]. In the recent past, thanks to the fast computation methods, multi-layer stacks have also often been used as large and cost-effective datasets for rapid testing of deep learning algorithms[33, 34, 35, 36, 37, 38, 39]. Due to its relative simplicity, differentiable transfer matrix implementations have furthermore been used as actual part of deep learning models for accelerated training[40, 41]. Because of this multiplication of objectives, the range of computed quantities of physical interest has also expanded.

Here we introduce PyMoosh (Python-based Multilayer Optics Optimization and Simulation Hub), a user-friendly and comprehensive set of numerical tools to compute as efficiently and as reliably as possible many optical properties of multilayered structures[42, 43]. This includes reflectance and transmittance in any condition and with different state-of-the-art numerical methods, but also absorption and Poynting flux in any layer, 2D Green functions, and the computation of structure modes and their dispersion curves. Finally, PyMoosh is specifically designed to be used together with optimization tools. Developed in Python, PyMoosh is an open-source software aimed at maximizing usability. It is intended to be simple enough to be used for educational purposes, while also offering advanced features for research, with a particular focus on tackling demanding problems such as optimization and deep learning. It is the successor of Moosh, which was implemented in Octave/Matlab [44].

This article is structured as follows. In a first section, we detail the different techniques included in PyMoosh to solve Maxwell’s equations in multilayered structures. PyMoosh specifically includes transfer and scattering matrices, the Abélès formalism, Dirichlet-to-Neumann maps and the admittance formalism. The methods, all gathered and described in a single place for educational and convenience purposes, are compared in terms of computational costs and tested for reliability on common photonics problems. In a second section we detail how the Poynting flux and absorption in each layer can be computed and explain the tools specific to photovoltaic problems that are implemented in PyMoosh. In a third section we explain how the field inside the structure can be computed with high accuracy using scattering matrices. We demonstrate this for two example illuminations, namely an incoming beam and an oscillating line current source, placed at an arbitrary location inside the structure. The fourth section describes how resonant modes (leaky or guided) can be retrieved. The last section describes our general approach in terms of coding and implementation, along with a discussion of the motivations behind our choices. PyMoosh comes in fact with a very large number of examples, under the form of Jupyter Notebooks[45], which are used to illustrate its capabilities, and that may serve as starting points for applications of other users.

Computing reflectance and transmittance

Historically, and for understandable practical reasons, the focus of multilayer structure studies has been put on computing the reflectance and eventually the transmittance of a given structure for a given wavelength λ\lambda. This is equivalent to solving Maxwell’s equations in the structure for a time dependency e−iωt\mathrm{e}^{-\mathrm{i}\omega t} where ω=2πcλ\omega= \frac{2\pi c}{\lambda} is the angular frequency of the electromagnetic wave. Since the structure is invariant by translation along the xx and yy axis, we choose without any loss of generality, on the one hand, a eikxx\mathrm{e}^{\mathrm{i}k_xx} spatial dependency with respect to xx and invariance along yy for all fields. In Transverse Electric (TE) (resp. Transverse Magnetic (TM)) polarization, EyE_y (resp. HyH_y) satisfies the following Helmholtz equation:

∂z2Ey+(μrϵrω2c2−kx2)Ey=0,(1)\partial_z^2 E_y + \left(\frac{\mu_r\epsilon_r\omega^2}{c^2} - k_x^2\right) E_y = 0, \tag*{(1)}

in any linear medium characterized by its relative permittivity ϵr\epsilon_r and permeability μr\mu_r. While the contribution of μr\mu_r is often neglected because natural materials do not involve any magnetic response at optical wavelengths (μr≈1\mu_r \approx1 due to the small size of the Bohr radius in atoms[46]), metamaterials can be tailored to form materials with an effective magnetic response.

Because the kxk_x spatial dependency is constant through the stack, in any layer ii, the vertical (zz) propagation constant of the field can be defined by:

γi=μiϵik02−kx2,(2)\gamma_i = \sqrt{\mu_i\epsilon_i k_0^2 - k_x^2}, \tag*{(2)}

where k0=ωc≡2πλk_0 = \frac{\omega}{c} \equiv\frac{2\pi}{\lambda} and where we write the relative permeabilities and permittivities of the ii-th layer’s material as μi\mu_i and ϵi\epsilon_i.

The solution to Eq. (1) can be written in layer ii as:

Ey,i(z)=Ai+eiγi(z−zi)+Bi+e−iγi(z−zi),Ey,i(z)=Ai−eiγi(z−zi+1)+Bi−e−iγi(z−zi+1).(3)\begin{aligned} E_{y,i}(z) &= A_i^+ \mathrm{e}^{\mathrm{i}\gamma_i(z-z_i)} + B_i^+ \mathrm{e}^{-\mathrm{i}\gamma_i(z-z_i)},\\ E_{y,i}(z) &= A_i^- \mathrm{e}^{\mathrm{i}\gamma_i(z-z_{i+1})} + B_i^- \mathrm{e}^{-\mathrm{i}\gamma_i(z-z_{i+1})}. \tag*{(3)} \end{aligned}

where Ai±A_i^\pm (resp. Bi±B_i^\pm) are defined as the amplitude of the upward propagating (resp. downward propagating) field in layer ii, and the + (resp. −) superscript indicates that the phase reference of each mode is taken at the top (resp. bottom) of layer ii, as the equations show. Figure 1 represents these coefficients in the corresponding layers and close to their respective interfaces.

Figure 1. Multilayer structure and definition of important variables. We consider the light coming from the top of the image. ϵi\epsilon_i and μi\mu_i are respectively the permittivity and the permeability of layer ii. AiA_i (resp. BiB_i) are defined as the amplitude of the upward propagating (resp. downward propagating) field in layer ii, and the + (resp. −-) superscript indicates that the field value is taken at the top (resp. bottom) of layer ii.

The continuity conditions for the tangential electric and magnetic fields at each interface between layer ii and layer i+1i+1 lead to the following equations:

Ai−+Bi−=Ai+1++Bi+1+,(4)A_i^- + B_i^- = A_{i+1}^+ + B_{i+1}^+, \tag*{(4)}
γiμi(Ai−−Bi−)=γi+1μi+1(Ai+1+−Bi+1+).(5)\frac{\gamma_i}{\mu_i}\left(A_i^- - B_i^-\right) = \frac{\gamma_{i+1}}{\mu_{i+1}}\left(A_{i+1}^+ - B_{i+1}^+\right). \tag*{(5)}

When the amplitude of the incident plane wave is taken equal to 1 (B0−=1B_0^- = 1) and there is no incoming light from below (AN+1−=0A_{N+1}^- = 0), then the reflection and transmission coefficient are A0−=rA_0^- = r and BN+1+=tB_{N+1}^+ = t, respectively. This means we have a system of 2(N+1)2(N+1) continuity equations and 2N2N propagation equations for just as many unknowns (the four Ai±A_i^\pm and Bi±B_i^\pm coefficients of each layer i∈[1,N]i \in[1,N], A0−A_0^- and BN+1+B_{N+1}^+). In theory, such a system could be solved numerically using classical algorithms. However, the corresponding matrix is sparse and contains figures with very different magnitudes so that classical approaches are numerically unstable, to the point that it often can not be used for more than typically a few layers. Specific formalisms to solve this system of equations have therefore been developed, and are presented below.

The TM polarization can be treated simply by changing μi\mu_i into ϵi\epsilon_i in the system above. We underline however that there is a π\pi phase in normal incidence for the reflection coefficient defined in TE and in TM polarization.

Now, because of Eq. (2), we need to discuss how the square root of a complex number is defined and how this may have an impact on the accuracy of the calculation. By default, on any computer, the phase of a complex number ζ\zeta is defined in [−π,π[[-\pi,\pi[, meaning that taking its square root thus produces a complex number with an argument in [−π/2,π/2[[-\pi/2,\pi/2[, i.e., with positive real part and arbitrary imaginary part. This determination of the square root can be changed manually, in order to obtain a positive imaginary part and arbitrary real part for instance, by taking the opposite of the result of the square root if the argument of ζ\zeta is negative. In any case, this introduces a cut in the complex plane, which cannot always be ignored.

Here, Eq. (3) indicates that changing the determination of the square root for γ\gamma is equivalent to exchanging AA and BB for all the layers in the structure, so that this is not expected to change the result of the computation, as Eq. (4) and Eq. (5) are unchanged by this permutation. However, it is clear that if γi\gamma_i has a negative imaginary part, then these equations introduce positive real exponentials, which would amplify any numerical error made on their amplitude. We have made the choice to use γi\gamma_i with positive imaginary parts in PyMoosh to maximize the stability of the code by using only decreasing exponential functions in all our calculations (especially the computation of the whole field, see below), inspired by what is done in RCWA [47, 48]. The change we have brought to the determination of the square root for the surrounding medium has more importance and will be discussed later.

From there, there are different ways to eliminate all the unknowns to obtain the reflection or the transmission coefficients. The most common formalism is based on Transfer Matrices (T-matrices). However, a more physical and stable formalism consists in writing reflection and transmission coefficients for each layer or interface. This is the Scattering Matrix (S-Matrix) method, widely used in more advanced simulation techniques where evanescent waves are ubiquitous. Since the work of Abelés [4], we also know that considering the impedance or admittance of each layer is a relevant approach. This approach can be translated both into a matrix formalism and into a recursive formula to compute how the admittance of a structure is modified by adding a supplementary layer [11]. Because these methods are not perfectly stable, an adaptation called the Dirichlet-to-Neumann (DtN) maps has been proposed more recently [49]. The DtN technique is related to the Abelés matrices formalism exactly in the same way that the scattering matrix formalism is related to the transfer matrix approach. In the following we derive the main formalisms of these different approaches.

T-matrices

Let us define ψi=γiμi\psi_i = \frac{\gamma_i}{\mu_i} for all layers. For the interface between layers ii and i+1i+1, the continuity conditions (4) and (5) can be rewritten as:

(Ai+1+Bi+1+)=Ti,i+1(Ai−Bi−)=12ψi+1(ψi+1+ψiψi+1−ψiψi+1−ψiψi+1+ψi)(Ai−Bi−)\begin{pmatrix} A_{i+1}^{+} \\ B_{i+1}^{+} \end{pmatrix} = T_{i,i+1}\begin{pmatrix} A_i^{-} \\ B_i^{-} \end{pmatrix} = \frac{1}{2\psi_{i+1}} \begin{pmatrix} \psi_{i+1}+\psi_i & \psi_{i+1}-\psi_i \\ \psi_{i+1}-\psi_i & \psi_{i+1}+\psi_i \end{pmatrix} \begin{pmatrix} A_i^{-} \\ B_i^{-} \end{pmatrix}

which defines the T-matrix for a given interface. The propagation relations linking Ai−A_i^{-}, Bi−B_i^{-} and Ai+A_i^{+}, Bi+B_i^{+}, through the layer of height hih_i can be written as

(Ai−Bi−)=Ci(T)(Ai+Bi+)=(e−iγihi00eiγihi)(Ai+Bi+)(6)\begin{pmatrix} A_i^{-} \\ B_i^{-} \end{pmatrix} = C_i^{(T)}\begin{pmatrix} A_i^{+} \\ B_i^{+} \end{pmatrix} = \begin{pmatrix} e^{-i\gamma_i h_i} & 0 \\ 0 & e^{i\gamma_i h_i} \end{pmatrix} \begin{pmatrix} A_i^{+} \\ B_i^{+} \tag*{(6)} \end{pmatrix}

which defines the T-matrix for layer ii. We underline that two exponential functions appear in the above expression. When the propagation constant γi\gamma_i is complex, one of these two terms can be very small in front of the other, leading to floating point cancellation [50] and to numerical errors. Layer and interface matrices just need to be multiplied by each other to eliminate the unknowns corresponding to the field amplitude inside each layer, but this is what may produce floating point cancellation:

(AN+1+BN+1+)=TN,N+1∏i=0N−1(Ci+1(T)Ti,i+1)(A0−B0−)(7)\begin{pmatrix} A_{N+1}^{+} \\ B_{N+1}^{+} \end{pmatrix} = T_{N,N+1}\prod_{i=0}^{N-1}\left(C_{i+1}^{(T)}T_{i,i+1}\right) \begin{pmatrix} A_0^{-} \\ B_0^{-} \tag*{(7)} \end{pmatrix}

From the transfer matrix

T=TN,N+1∏i=0N−1(Ci+1(T)Ti,i+1),(8)T = T_{N,N+1}\prod_{i=0}^{N-1}\left(C_{i+1}^{(T)}T_{i,i+1}\right), \tag*{(8)}

for the whole structure we can retrieve coefficients

r=A0−=−T01T00(9)r = A_0^- = -\frac{T_{01}}{T_{00}} \tag*{(9)}

and

t=BN+1+=rT10+T11.(10)t = B_{N+1}^+ = rT_{10} + T_{11}. \tag*{(10)}

S-matrices

Scattering matrices are simply another way to eliminate the unknowns. The S-matrix formalism uses the same field definitions, but rewrites the continuity conditions obtained from Eqs. (4)–(5) in order to link incoming fields at the interface (Ai+,Bi+1−)(A_i^+, B_{i+1}^-) with the outgoing fields (Ai+1−,Bi+)(A_{i+1}^-, B_i^+), giving the new interface matrices:

(Ai−Bi+1+)=Ii,i+1(Bi−Ai+1+)(11)\begin{pmatrix} A_i^- \\ B_{i+1}^+ \end{pmatrix} = I_{i,i+1} \begin{pmatrix} B_i^- \\ A_{i+1}^+ \tag*{(11)} \end{pmatrix}
=1ψi+ψi+1(ψi−ψi+12ψi+12ψiψi+1−ψi)(Bi−Ai+1+).(12)= \frac{1}{\psi_i+\psi_{i+1}} \begin{pmatrix} \psi_i-\psi_{i+1} & 2\psi_{i+1} \\ 2\psi_i & \psi_{i+1}-\psi_i \end{pmatrix} \begin{pmatrix} B_i^- \\ A_{i+1}^+ \end{pmatrix}. \tag*{(12)}

The propagation matrices are also modified:

\begin{pmatrix} A_i^+ \\ B_i^- \end{pmatrix} = C_i^{(S)} \begin{pmatrix} B_i^+ \\ A_i^- \end{pmatrix} = \begin{pmatrix} 0 & e^{i\gamma_i h_i} \\ e^{i\gamma_i h_i} & 0 \end{pmatrix} \begin{pmatrix} B_i^+ \\ A_i^- \end{pmatrix}. \tag*{(13)}\end{pmatrix}

As we will see later, these propagation matrices, where both exponentials are identical, lead to a greater numerical stability. However, computing the matrix linking boundary conditions is no longer a straightforward matrix product, since the coefficients of a given layer are not on the same side of Eq. (12). Therefore, the relationship between the different II and C(S)C^{(S)} matrix equations can be written as:

\begin{pmatrix} A \\ B \end{pmatrix} = \begin{pmatrix} U_{00} & U_{01} \\ U_{10} & U_{11} \end{pmatrix} \begin{pmatrix} C \\ D \end{pmatrix}, \quad\text{and} \quad \begin{pmatrix} D \\ E \end{pmatrix} = \begin{pmatrix} V_{00} & V_{01} \\ V_{10} & V_{11} \end{pmatrix} \begin{pmatrix} B \\ F \end{pmatrix}, \tag*{(14)}\end{pmatrix}

where the new matrix we want to define is:

\begin{pmatrix} A \\ E \end{pmatrix} = \begin{pmatrix} S_{00} & S_{01} \\ S_{10} & S_{11} \end{pmatrix} \begin{pmatrix} C \\ F \end{pmatrix}. \tag*{(15)}\end{pmatrix}

We can define a “cascading” operation, computing SS as a function of UU and VV coefficients:

S=(U00+U01V00U101−V00U11U01V011−V00U11U10V101−V00U11V11+V10U11V011−V00U11).(16)S = \begin{pmatrix} U_{00}+\dfrac{U_{01}V_{00}U_{10}}{1-V_{00}U_{11}} & \dfrac{U_{01}V_{01}}{1-V_{00}U_{11}} \\ \dfrac{U_{10}V_{10}}{1-V_{00}U_{11}} & V_{11}+\dfrac{V_{10}U_{11}V_{01}}{1-V_{00}U_{11}} \end{pmatrix}. \tag*{(16)}

Applying this computation iteratively on every interface and layer leads to the scattering matrix SS for the whole structure:

\begin{pmatrix} A_0^- \\ B_{N+1}^+ \end{pmatrix} = S \begin{pmatrix} B_0^- \\ A_{N+1}^+ \end{pmatrix}. \tag*{(17)}\end{pmatrix}

The reflection and transmission coefficient can be read directly, knowing B0−=1B_0^- = 1, AN+1+=0A_{N+1}^+ = 0: r=S00r = S_{00}, t=S10t = S_{10}.

Abélès formalism

Contrary to T-matrices and S-matrices, the Abélès formalism (as well as the following Dirichlet-to-Neumann formalism) uses only one EyE_y field position in each layer, thus removing the need for propagation matrices. We will also therefore directly speak in terms of Ey,iE_{y,i} and ∂zEy,i\partial_z E_{y,i}. Taking for instance the field on the upper side of the layers and using the field continuity, we can write:

Ey,i(zi)=Ai++Bi+,∂zEy,i(zi)/μi=iψi(Ai+−Bi+),Ey,i+1(zi+1)=Ai+e−iγihi+Bi+eiγihi,∂zEy,i+1(zi+1)/μi+1=iψi(Ai+e−iγihi−Bi+eiγihi).(18)\begin{aligned} E_{y,i}(z_i) &= A_i^+ + B_i^+, \\ \partial_z E_{y,i}(z_i)/\mu_i &= i\psi_i(A_i^+ - B_i^+), \\ E_{y,i+1}(z_{i+1}) &= A_i^+e^{-i\gamma_i h_i} + B_i^+e^{i\gamma_i h_i}, \\ \partial_z E_{y,i+1}(z_{i+1})/\mu_{i+1} &= i\psi_i(A_i^+e^{-i\gamma_i h_i} - B_i^+e^{i\gamma_i h_i}). \tag*{(18)} \end{aligned}

These relations and the continuity conditions at the interface at zi+1z_{i+1} lead to the matrix equations:

(Ey,i+1∂zEy,i+1/μi+1)=Mi(Ey,i∂zEy,i/μi)=(cos⁡(γihi)−sin⁡(γihi)ψiψisin⁡(γihi)cos⁡(γihi))(Ey,i∂zEy,i/μi).\begin{aligned} \begin{pmatrix} E_{y,i+1} \\ \partial_z E_{y,i+1}/\mu_{i+1} \end{pmatrix} = M_i \begin{pmatrix} E_{y,i} \\ \partial_z E_{y,i}/\mu_i \end{pmatrix} \\ &= \begin{pmatrix} \cos(\gamma_i h_i) & -\dfrac{\sin(\gamma_i h_i)}{\psi_i} \\ \psi_i\sin(\gamma_i h_i) & \cos(\gamma_i h_i) \end{pmatrix} \begin{pmatrix} E_{y,i} \\ \partial_z E_{y,i}/\mu_i \end{pmatrix}. \end{aligned}

Once the matrix product M=∏iMiM = \prod_i M_i is computed, the rr and tt coefficients are slightly more complicated to retrieve than for T-matrices:

Ey,N+1=t(19)E_{y,N+1} = t \tag*{(19)}
Ey,0=r+1(20)E_{y,0} = r + 1 \tag*{(20)}
∂zEy,N+1/μN+1=−iψN+1t(21)\partial_z E_{y,N+1}/\mu_{N+1} = -i\psi_{N+1}t \tag*{(21)}
∂zEy,0/μi=0=iψ0(r−1)(22)\partial_z E_{y,0}/\mu_{i=0} = i\psi_0(r-1) \tag*{(22)}

Dirichlet-to-Neumann formalism

Finally, just like the S-matrix formalism was the equivalent of T-matrices but using incoming field on one side of the equation and outgoing fields on the other, the Dirichlet-to-Neumann (DtN) formalism is the equivalent of the Abélès formalism but keeping EyE_y on one side of the equation and ∂zEy\partial_z E_y on the other:

(∂zEy,i/μi∂zEy,i+1/μi+1)=Ni,i+1(Ey,iEy,i+1)(23)\begin{pmatrix} \partial_z E_{y,i}/\mu_i \\ \partial_z E_{y,i+1}/\mu_{i+1} \end{pmatrix} = N_{i,i+1} \begin{pmatrix} E_{y,i} \\ E_{y,i+1} \tag*{(23)} \end{pmatrix}
=(ψicos⁡(γihi)sin⁡(γihi)−ψisin⁡(γihi)ψisin⁡(γihi)−ψicos⁡(γihi)sin⁡(γihi))(Ey,iEy,i+1).(24)= \begin{pmatrix} \dfrac{\psi_i\cos(\gamma_i h_i)}{\sin(\gamma_i h_i)} & -\dfrac{\psi_i}{\sin(\gamma_i h_i)} \\ \dfrac{\psi_i}{\sin(\gamma_i h_i)} & -\dfrac{\psi_i\cos(\gamma_i h_i)}{\sin(\gamma_i h_i)} \end{pmatrix} \begin{pmatrix} E_{y,i} \\ E_{y,i+1} \end{pmatrix}. \tag*{(24)}

As with S-matrices, the complete structure matrix computation is not straightforward, and needs a cascading operation similar to the one used for S-matrices. To this end, if we call A=Ni,i+1A = N_{i,i+1} and B=Ni+1,i+2B = N_{i+1,i+2}, then the Di,i+2D_{i,i+2} matrix linking fields in layer ii and in layer i+2i+2 is given by:

Di,i+2=(A00−A01A10A11−B00A01B01A11−B00−B10A10A11−B00B11+B10B01A11−B00).(25)D_{i,i+2}=\begin{pmatrix} A_{00}-\dfrac{A_{01}A_{10}}{A_{11}-B_{00}} & \dfrac{A_{01}B_{01}}{A_{11}-B_{00}} \\ -\dfrac{B_{10}A_{10}}{A_{11}-B_{00}} & B_{11}+\dfrac{B_{10}B_{01}}{A_{11}-B_{00}} \end{pmatrix}. \tag*{(25)}

For all other formalisms, we typically consider a superstrate of thickness 0, in order to have a phase reference exactly at the interface between the superstrate and the first layer of the structure. However, for the DtN formalism, as we can see in Eq. (24) this would lead to division by 0 in the first matrix. So we choose an arbitrary thickness for the superstrate (λ/100\lambda/100 in the PyMoosh code), and compensate for the additional phase at the end of the computation.

Admittance formalism

The admittance formalism is based on the Abélès formalism and its main advantage is to make computations of the structure’s reflectivity much faster. We define:

δi=γihi,neff,i=γiμik0,(26)\delta_i=\gamma_i h_i,\qquad n_{eff,i}=\frac{\gamma_i}{\mu_i k_0}, \tag*{(26)}

with γi\gamma_i as defined in Eq. (2).

With the Abélès formalism (inverting Eq. (19)):

\begin{pmatrix} E_{y,i} \\ \partial_z E_{y,i}/\mu_i \end{pmatrix} = \begin{pmatrix} \cos\delta_i & \dfrac{\sin\delta_i}{\psi_i} \\ -\psi_i\sin\delta_i & \cos\delta_i \end{pmatrix} \begin{pmatrix} E_{y,i+1} \\ \partial_z E_{y,i+1}/\mu_{i+1} \end{pmatrix}. \tag*{(27)}\end{pmatrix}

We then define Xi=∂zEy,iμiEy,iX_i=\dfrac{\partial_z E_{y,i}}{\mu_i E_{y,i}}.

\begin{pmatrix} \dfrac{E_{y,i}}{E_{y,i+1}} \\ \dfrac{\partial_z E_{y,i}}{\mu_i E_{y,i+1}} \end{pmatrix} = \begin{pmatrix} \cos\delta_i & \dfrac{\sin\delta_i}{\psi_i} \\ -\psi_i\sin\delta_i & \cos\delta_i \end{pmatrix} \begin{pmatrix} 1 \\ X_{i+1} \end{pmatrix}. \tag*{(28)}\end{pmatrix}

Computing the matrix-vector product and dividing both rows, we get:

Xi=Xi+1−ψitan⁡δi1+Xi+1ψitan⁡δi.(29)X_i=\frac{X_{i+1}-\psi_i\tan\delta_i}{1+\dfrac{X_{i+1}}{\psi_i}\tan\delta_i}. \tag*{(29)}

Let us define Yi=ik0XiY_i=\dfrac{i}{k_0}X_i, leading to:

Yi=Yi+1−ineff,itan⁡δi1−iYi+1neff,itan⁡δi.(30)Y_i=\frac{Y_{i+1}-i n_{eff,i}\tan\delta_i}{1-i\dfrac{Y_{i+1}}{n_{eff,i}}\tan\delta_i}. \tag*{(30)}

Then, we use YN=neff,NY_N=n_{eff,N} as initial condition and compute all YiY_i, with the final reflection coefficient being for TE polarization:

rTE=neff,0−Y0neff,0+Y0.(31)r_{\mathrm{TE}}=\frac{n_{eff,0}-Y_0}{n_{eff,0}+Y_0}. \tag*{(31)}

In TM, the difference is that neff,i(TM)=ϵik0γin_{eff,i}^{(\mathrm{TM})}=\dfrac{\epsilon_i k_0}{\gamma_i} and

rTM=−neff,0(TM)−Y0neff,0(TM)+Y0.(32)r_{\mathrm{TM}}=-\frac{n_{eff,0}^{(\mathrm{TM})}-Y_0}{n_{eff,0}^{(\mathrm{TM})}+Y_0}. \tag*{(32)}

This formalism allows to compute the reflectance of a structure very quickly. It can also be generalized to transmission computations, but then loses its computation speed advantage. It can be however of particular interest for pedagogical reasons or in time-critical applications, given its simplicity and, as a direct consequence, its computational efficiency.

Comparing the different methods

Choosing the right method to compute the reflectance or transmittance of a structure depends on the context and whether stability or computational speed are particularly sought after. No method is both the fastest and the most stable. We have thoroughly tested the stability and estimated the efficiency of each of the methods as implemented in PyMoosh, to assist users in determining the most suitable approach for their specific needs.

Computational speed. As can be guessed from the mathematical expressions above and as is shown Figure 2, the computational time required for computing the reflectance of a given structure increases linearly with the number of considered layers. Also, as can be expected, the scattering matrix method is the slowest. It is typically twice as slow as the T-matrix or DtN methods. On the other hand, the Abélès formalism is twice as fast as these, but the most computationally efficient technique of all is the admittance formula. It is thus ideally suited for optimizing the reflectance of a multilayer. Alas, this technique is also the most prone to stability issues.

Figure 2. Computation time of the rr and tt coefficients for all methods as a function of the number of layers in a stack, averaged over 500 runs. As exact computation times are heavily influenced by hardware capabilities, it remains important to prioritize the relative comparison between formalisms over these precise times.

Numerical stability. For a random dielectric structure, all formalisms can be considered stable, as the transmission can be expected to be relatively high. Numerical accuracy issues occur when evanescent waves are present, whether they are due to total internal reflection, to the presence of metals, or if evanescent Bloch waves are excited in the bandgaps of Bragg mirrors. While for optical filters such problems are unlikely, evanescent waves are ubiquitous in prism couplers or plasmonic structures, not to mention photonic crystal-based structures.

The scattering matrix method has proven to be the most stable and accurate of all, regardless of the situation[28, 47, 48]. For this reason, we consider its results as our reference in all the following. Figure 3-Figure 5 show the absolute difference between the values given by the scattering matrix method and the other methods for the reflection and transmission coefficient in several cases. We discuss here explicitly the computation errors for TE illumination, but TM polarization faces roughly the same instabilities.

Figure 3. a) Absolute error between S-matrix (considered as our reference) and other formalisms. Transmission coefficient for a quarter-wave stack of materials n=1.2n = 1.2 and n=1.5n = 1.5 as a function of the total number of layers of the stack. b) Schematic representation of the structure.

Absolute error between S-matrix and other formalisms, and schematic representation of the structure

Figure 5. a) Absolute error between S-matrix (considered as our reference) and other formalisms. Surface plasmon resonance coupler in the Kretschmann-Raether configuration with a prism of index n=1.5n = 1.5 coupling to air through a silver layer of width DD. b) Schematic representation of the structure.

The first case, depicted in Figure 3, is a simple Bragg mirror, illuminated at oblique incidence (15∘15^\circ) with a wavelength in the middle of the bandgap. As the number of layers increases, the transmission coefficient goes down to zero. As can be seen, the DtN and scattering matrix methods differ only by an error of the order of machine precision. Therefore when the relative error stays the same, as the value of the transmission coefficient decreases, so does the absolute error.

It can be seen however that the Abélès formalism and the T-matrix method are subject to numerical instability, which typically occurs for more than 150 layers. This means that these methods should be considered with caution when structures involve Bragg mirrors, for instance in microcavities[51] for which the transmission through the stack is crucial. It should also be noted that the TE case is slightly more stable than the TM case, when no magnetic materials are involved, and that the Abélès formalism is significantly more stable under normal incidence illumination.

The second case, depicted in Figure 4, is a simple frustrated total internal reflection, i.e., a layer of air comprised between two layers of high index material n=1.5n = 1.5, illuminated with a 42∘42^\circ incidence angle, slightly beyond the critical angle. When the air layer thickness is increased beyond a few wavelengths, the evanescent field within causes numerical instabilities for the T-matrices and the Abélès matrices, similar to what occurs for the Bragg mirror. This means these two algorithms should be avoided when simulating prism couplers, where evanescent waves occur. Above a thickness of 2 μm2\,\mu\mathrm{m} for the air layer, as the theoretical transmission tends towards zero, the DtN and S matrix methods often agree down to machine precision, leading to a zero absolute numerical error. They differ only by a relative error of the order of machine precision in other cases.

Figure 4. a) Absolute error between S-matrix (considered as our reference) and other formalisms. Transmission coefficient in a frustrated total internal reflection situation for a layer of air of width DD between materials of index n=1.5n = 1.5. b) Schematic representation of the structure.

As a final example, we consider a metallic (silver) layer comprised between an upper layer with a high index (n=1.5n = 1.5) and air – a typical prism coupler for surface plasmon in Kretschmann-Raether configuration[52]. In the previous cases, we underline that the reflection coefficient is computed with no instability for T, S, Abélès or DtN matrices, even when the transmission coefficient is unstable. However, as can be seen in Figure 5, the admittance formalism is not accurate for thin metallic layers, and while the instability is not exponential, the value computed is not at all accurate. This shows that the admittance formalism is most adapted to optical filters with no metallic layers. While this can not be seen in the linear scale graph, shown in Figure 5a, the difference between the values computed using the three other methods is down to machine precision.

Despite their stability in these typical examples, S and DtN matrices also have specific breaking points. For scattering matrices, when γi/μi∼−γi+1/μi+1\gamma_i/\mu_i \sim-\gamma_{i+1}/\mu_{i+1} (in TE polarization, but this occurs in TM too with ϵi\epsilon_i instead of μi\mu_i), a division by zero occurs. This can only happen when lossless metamaterials are considered, which is not realistic, but is often studied for educational purposes (showing the ideal response of Pendry’s lens for instance[53]). As for the DtN formalism, its better stability is due to the terms in 1/sin⁡1/\sin and 1/tan⁡1/\tan, which are less prone to numerical errors than exponentials. However, there are still specific breaking points. For instance, for a layer of optical thickness λ/2n\lambda/2n, where nn is the refractive index of the layer, in normal incidence, the argument of the 1/sin⁡1/\sin is π\pi, leading to a division by 0. As this may occur with any kind of transparent material, and it is actually typically used as a cavity in Distributed-Feedback Lasers, for instance, the DtN formalism must be used with care.

Discussion. From the above results, it seems clear that scattering matrices should be the default choice when stability matters because it presents only very specific breaking points and we underline that the supplementary computational effort is reasonable. Transfer matrices seem an obvious choice in the literature, however our results show that the Abélès formalism is equivalently stable but twice as computationally efficient, while being no more complex to implement. When speed really matters, when no metal is present and when the computation of reflectance is sufficient, the admittance formalism is a less explored but very interesting alternative, for instance in the context of optimization[31] or for database generation for deep learning, being one order of magnitude more efficient than S-matrices. Finally, the Dirichlet-to-Neumann formalism is a good compromise for large multilayer stacks that may exhibit evanescent fields, as long as no λ/2n\lambda/2n layer is present. PyMoosh allows to make such choices and to assess easily the accuracy of any method by comparing it to the S-Matrix result.

Computing absorption in an arbitrary layer

In many applications, e.g., sensing or photovoltaic stacks, knowing where the absorption takes place is of paramount importance. This requires to compute the field amplitudes Ai±A_i^{\pm} and Bi±B_i^{\pm} that are ignored when only reflectance is to be computed. This can be done in any of the four main formalisms, and the present section describes how these fields can be computed for the S-matrix and the Abélès formalisms, because they have been shown to be respectively the most stable and the fastest. The admittance formalism can obviously not be used as it is designed to only compute the external coefficients.

In order to compute how much of the incident power is absorbed in each layer, the PyMoosh library computes the (time-averaged) projection along the zz axis of the normalized Poynting vector at the top of every layer ii, NiN_i. This projected Poynting vector is proportional to the power flux through the top interface of the layer. Since we normalize all power by the incident power, then the difference in power given by the difference in Poynting vector Ni=Ni−Ni+1\mathcal{N}_i = N_i - N_{i+1} is the fraction of the incident power absorbed in layer ii.

Abélès matrices

With MiM_i defined in Eq. (19), we can define Mtot(k)=∏i=1kMi−1M_{\mathrm{tot}}^{(k)} = \prod_{i=1}^{k} M_{i-1} which allows us to compute the fields in the structure:

\begin{pmatrix} E_{y,k} \\ \frac{\partial_z E_{y,k}}{\mu_k} \end{pmatrix} = M_{\mathrm{tot}}^{(k)} \begin{pmatrix} E_{y,0} \\ \frac{\partial_z E_{y,0}}{\mu_0} \end{pmatrix} = M_{\mathrm{tot}}^{(k)} \begin{pmatrix} r+1 \\ i(r-1)\psi_0 \end{pmatrix}. \tag*{(33)}\end{pmatrix}

Knowing this, the equation used to compute the normalized Poynting vector at the top of one layer is:

Ni=Re⁡(−iEy,i∂zEy,i∗1ψ0μi∗),(34)N_i = \operatorname{Re}\left(-i E_{y,i}\partial_z E_{y,i}^{*}\frac{1}{\psi_0\mu_i^{*}}\right), \tag*{(34)}

in the TE case, and where μ\mu and ϵ\epsilon are switched to get the TM case.

S-matrices

Using the cascading operation defined in Eq. (16), we can introduce the ⊙\odot operator, where A⊙BA \odot B is the result of cascading operation. This allows to write more simply the partial scattering matrices U(k)U^{(k)} and D(k)D^{(k)} corresponding to scattering matrices of incomplete structures:

U(2i)=C0(2i)⊙I01⊙C1(S)⋯⊙Ii−1,i,U(2i+1)=C0(S)⊙I01⊙C1(S)⋯⊙Ci(S),D(2i)=Ci(S)⊙Ii,i+1⋯⊙CN+1(S),D(2i+1)=Ii,i+1⊙Ci+1(S)⋯⊙CN+1(S).(35)\begin{aligned} U^{(2i)} &= C_0^{(2i)} \odot I_{01} \odot C_1^{(S)} \cdots\odot I_{i-1,i},\\ U^{(2i+1)} &= C_0^{(S)} \odot I_{01} \odot C_1^{(S)} \cdots\odot C_i^{(S)},\\ D^{(2i)} &= C_i^{(S)} \odot I_{i,i+1} \cdots\odot C_{N+1}^{(S)},\\ D^{(2i+1)} &= I_{i,i+1} \odot C_{i+1}^{(S)} \cdots\odot C_{N+1}^{(S)}. \tag*{(35)} \end{aligned}

In the case when we consider the upper coefficients of layer ii, this allows to write

\begin{pmatrix} A_0^- \\ B_i^+ \end{pmatrix} = U^{(2i)} \begin{pmatrix} B_0^- \\ A_i^+ \end{pmatrix}, \tag*{(36)}\end{pmatrix}
\begin{pmatrix} A_i^+ \\ B_{N+1}^+ \end{pmatrix} = D^{(2i)} \begin{pmatrix} B_i^+ \\ A_{N+1}^+ \end{pmatrix}. \tag*{(37)}\end{pmatrix}

The same can be written for the lower coefficients using odd index 2i+12i+1. The idea here is that if we assume an incoming plane wave from above with a unity amplitude (i.e., B0−=1B_0^- = 1 and AN+1+=0A_{N+1}^+ = 0), we can use the intermediate matrix that usually appear when calculating the cascading formula to retrieve the unknowns:

\begin{pmatrix} A_i^+ \\ B_i^+ \end{pmatrix} = \frac{1}{1-U_{11}^{(2i)}D_{00}^{(2i)}} \begin{pmatrix} D_{00}^{(2i)} & U_{10}^{(2i)}D_{00}^{(2i)} \\ U_{11}^{(2i)}D_{01}^{(2i)} & U_{10}^{(2i)}D_{01}^{(2i)} \end{pmatrix} \begin{pmatrix} A_{N+1}^+ \\ B_0^- \end{pmatrix}. \tag*{(38)}\end{pmatrix}

Again, using odd index 2i+12i+1 instead of 2i2i allows us to retrieve the Ai+A_i^+ and Bi−B_i^- coefficients. The equation used to compute the normalized Poynting vector at a given interface, using the corresponding coefficients, is:

Ni=−Re⁡(ψi−∗ψ0(Ai+−Bi+)∗(Ai++Bi+)),(39)N_i=-\operatorname{Re}\left(\frac{\psi_i^{-*}}{\psi_0}\left(A_i^+ - B_i^+\right)^*\left(A_i^+ + B_i^+\right)\right), \tag*{(39)}

where γ\gamma is defined in Eq. (2), for the TE case. For the TM case, simply replace ϵ\epsilon with μ\mu as usual.

Application to solar cells

Solar cells can most often be modeled as a multilayered structure. Once the absorption in the active part, AactiveA_{active}, is computed for the whole spectrum, it can be converted into an estimate of the short-circuit current jscj_{sc} delivered by the cell under standard illumination (an AM1.5 solar spectrum) using the following formula, assuming a unity quantum yield [54]:

jsc=∫Aactive(λ)dIdλeλhc dλ,(40)j_{sc}=\int A_{active}(\lambda)\frac{dI}{d\lambda}\frac{e\lambda}{hc}\,d\lambda, \tag*{(40)}

where dIdλ\frac{dI}{d\lambda} is the spectral intensity for the AM1.5 spectrum per wavelength, ee the charge of the electron, hh Planck’s constant and cc the speed of light. The efficiency of the device can then be computed as the ratio of the short-circuit current over the maximum achievable current for the considered spectral window.

Because of how important this type of application is, there are functions in PyMoosh specifically designed to simulate photovoltaic multilayers, taking into account the photon density of the solar spectrum and the conversion efficiency of solar cells.

fig:6a shows the photon density of the visible solar spectrum, received on the Earth, as included in the PyMoosh

library. fig:6b shows the absorptance of two structures: one that is a single layer of amorphous Silicon (aSi) of 1 μm1\ \mu\mathrm{m} thickness, and a second structure with an additional dielectric anti-reflecting (AR) layer on top (n=1.5n=1.5, h=λ/4nh=\lambda/4n, λ=600 nm\lambda=600\ \mathrm{nm}). These absorptance curves show that bulk aSi already has an absorptance of about 50%, and that a single AR coating can improve this absorptance to over 85% for half of the visible spectrum.

Field computation

While reflectance or transmittance spectra are among the most represented quantities, it is highly informative to be able to compute the electric or magnetic fields inside a structure in response to an illumination, either with an incoming beam, or when a source is placed in the structure. The magnetic field is especially relevant for all situations involving metals. The computational cost is less of a concern in such a situation, while the numerical stability is crucial. We thus use the S-matrix method in that context, and the technique explained above to compute all the intermediate coefficients Ai±A_i^\pm and Bi±B_i^\pm. The electric (resp. magnetic) field in TE (resp. TM) polarization can be written, assuming x=0x=0 and for a single incident plane wave:

Ey,i(x=0,z)=Ai−eiγi(z−zi+1)+Bi+e−iγi(z−zi).(41)E_{y,i}(x=0,z)=A_i^-e^{i\gamma_i(z-z_{i+1})}+B_i^+e^{-i\gamma_i(z-z_i)}. \tag*{(41)}

Using this expression and the determination of the square root mentioned above (positive imaginary part), presents the advantage that, since all the coefficients are computed with the best possible accuracy, all the exponentials are decreasing away from the interfaces. No numerical error can thus be amplified.

Illumination with a Gaussian beam

A Gaussian beam can be written as a superposition of plane waves. In TE polarization, the EyE_y field in layer ii can be written as:

Ey,i(x,z)=12π∫E0(kx)(Ai−eiγi(z−zi+1)+Bi+e−iγi(z−zi))eikxx dkx,(42)E_{y,i}(x,z)=\frac{1}{2\pi}\int\mathcal{E}_0(k_x)\left(A_i^-e^{i\gamma_i(z-z_{i+1})}+B_i^+e^{-i\gamma_i(z-z_i)}\right)e^{ik_xx}\,dk_x, \tag*{(42)}

where the amplitude is a Gaussian:

E0(kx)=w2πe−w24(kx−nk0sin⁡θ0)2e−ikxx0,(43)\mathcal{E}_0(k_x)=\frac{w}{2\sqrt{\pi}}e^{-\frac{w^2}{4}(k_x-nk_0\sin\theta_0)^2}e^{-ik_xx_0}, \tag*{(43)}

for a Gaussian beam centered at x0x_0, θ0\theta_0 being the central incidence angle and ww the waist of the beam. The refractive index of the upper medium is noted nn. We underline that the above definition of ww is standard for the study of non-specular phenomena[55, 56], but that this means ww is the waist along the xx axis and not the minimum waist of the beam perpendicularly to the propagation direction (w′w'). There is a cos⁡θ\cos\theta factor between these two definitions: w′=w/cos⁡θw' = w/\cos\theta. While for small angles of incidence this has little importance, for grazing angles it should be taken into account.

In Pymoosh, the field is computed for each given kxk_x in all the layers using Eq. (41) and for all the points defined in the vertical discretization. Then, the full field at different horizontal positions is computed by multiplying this vertical vector by eikxxe^{ik_xx} for all the values of xx included in the horizontal discretization. The thus computed fields for each plane wave kxk_x are subsequently multiplied by the corresponding complex amplitude E0(kx)E_0(k_x) (see Eq. (43)) and all the plane wave contributions are summed, leading to the calculation given by Eq. (42). Importantly, as the number of incidence angles (and thus kxk_x values) is finite and thus discretized, in consequence the resulting field is periodic. The period is what is called the window size, dd. If Δkx\Delta k_x is the difference between two successive values of kxk_x, we have the relation d=2πΔkxd = \frac{2\pi}{\Delta k_x}. The number of plane waves is chosen such that the amplitude for the maximum and minimum wavevectors given by Eq. (43) is smaller than 1% and has thus no impact on the final field-image.

The exact same procedure can be applied to obtain images corresponding to HxH_x and HzH_z in TE polarization:

Hx(0,z)=−γiωμi(Ai−eiγi(z−zi+1)−Bi+e−iγi(z−zi)),(44)H_x(0,z)=-\frac{\gamma_i}{\omega\mu_i}\left(A_i^-e^{i\gamma_i(z-z_{i+1})}-B_i^+e^{-i\gamma_i(z-z_i)}\right), \tag*{(44)}
Hz(0,z)=kxωμi(Ai−eiγi(z−zi+1)+Bi+e−iγi(z−zi)),(45)H_z(0,z)=\frac{k_x}{\omega\mu_i}\left(A_i^-e^{i\gamma_i(z-z_{i+1})}+B_i^+e^{-i\gamma_i(z-z_i)}\right), \tag*{(45)}

and for the TM polarization, HH and EE, μ\mu and ϵ\epsilon have to be exchanged. Theoretically a minus sign should also be added in front of all the expressions, adding a global phase-shift of π\pi. Since the phase origin is arbitrary, we did not take it into account in the code.

Current line source

It is relatively simple to compute the field corresponding to a source of oscillating current II, invariant in the yy direction, in TE polarization (electric field, hence the oscillation direction, along the infinite axis), even in a complex multilayered structure. The equation that must be solved inside the homogeneous layer where the source is placed, can be written:

∂2Ey∂z2+∂2Ey∂x2+ϵiμik02Ey=−iωμ0μiIδ(x−xs,z),(46)\frac{\partial^2 E_y}{\partial z^2}+\frac{\partial^2 E_y}{\partial x^2}+\epsilon_i\mu_i k_0^2 E_y=-i\omega\mu_0\mu_i I\delta(x-x_s,z), \tag*{(46)}

with δ\delta the Dirac function, if we assume that the source is placed in (xs,0)(x_s,0). Because of the invariance of the problem, taking the Fourier transform in the xx direction yields:

∂2E~y∂z2+(ϵiμik02−kx2)E~y=−iωμ0μiIδ(z)eikxxs.(47)\frac{\partial^2 \widetilde{E}_y}{\partial z^2}+\left(\epsilon_i\mu_i k_0^2-k_x^2\right)\widetilde{E}_y=-i\omega\mu_0\mu_i I\delta(z)e^{ik_xx_s}. \tag*{(47)}

This means that, while E~y\widetilde{E}_y is continuous, its derivative is not, but undergoes a jump equal to −iωμ0μiIeikxxs-i\omega\mu_0\mu_iIe^{ik_xx_s}. We assume a single source in layer isi_s, above which the field can be written:

E~y,is(z)=Ais+eiγisz+Bis+e−iγisz,(48)\widetilde{E}_{y,i_s}(z)=A_{i_s}^{+}e^{i\gamma_{i_s}z}+B_{i_s}^{+}e^{-i\gamma_{i_s}z}, \tag*{(48)}

and below it is:

E~y,is(z)=Ais−eiγisz+Bis−e−iγisz,(49)\widetilde{E}_{y,i_s}(z)=A_{i_s}^{-}e^{i\gamma_{i_s}z}+B_{i_s}^{-}e^{-i\gamma_{i_s}z}, \tag*{(49)}

where γis=ϵisμisk02−kx2\gamma_{i_s}=\sqrt{\epsilon_{i_s}\mu_{i_s}k_0^2-k_x^2}. The continuity of E~y\widetilde{E}_y and the jump in its derivative lead to the following equations:

Ais++Bis+=Ais−+Bis−,(50)A_{i_s}^{+}+B_{i_s}^{+}=A_{i_s}^{-}+B_{i_s}^{-}, \tag*{(50)}
Ais+−Bis+=Ais−−Bis−−iωμ0μisγisIeikxxs.(51)A_{i_s}^{+}-B_{i_s}^{+}=A_{i_s}^{-}-B_{i_s}^{-}-\frac{i\omega\mu_0\mu_{i_s}}{\gamma_{i_s}}Ie^{ik_xx_s}. \tag*{(51)}

Now it is always possible to write that Bis+=ruAis+B_{i_s}^{+}=r_uA_{i_s}^{+} and Ais−=rdBis−A_{i_s}^{-}=r_dB_{i_s}^{-}, whatever the surrounding of the source. The coefficients rdr_d and rur_u are simply found in the scattering matrix corresponding to the part of the structure below (respectively above) the source as in Eq. (38). A simple representation of these fields and the contribution of the line source is presented in Figure 7. A straightforward calculation yields an expression for the coefficients representing the wave amplitudes traveling into directions upwards (Ais+A_{i_s}^{+}), respectively downwards (Bis−B_{i_s}^{-}) from the source:

Figure 7. Schematic representation of the field values surrounding the source.

Ais+=−ieikxxs1−ru+(1+ru)1−rd1+rdωμ0μisIγis,(52)A_{i_s}^{+}=\frac{-ie^{ik_xx_s}}{1-r_u+(1+r_u)\frac{1-r_d}{1+r_d}}\frac{\omega\mu_0\mu_{i_s}I}{\gamma_{i_s}}, \tag*{(52)}
Bis−=−ieikxxs1−rd+(1+rd)1−ru1+ruωμ0μisIγis.(53)B_{i_s}^{-}=\frac{-ie^{ik_xx_s}}{1-r_d+(1+r_d)\frac{1-r_u}{1+r_u}}\frac{\omega\mu_0\mu_{i_s}I}{\gamma_{i_s}}. \tag*{(53)}

These two coefficients represent the amplitudes of the plane waves excited by the source, and as can be clearly seen, both depend highly on the surroundings through rdr_d and rur_u, which means the surroundings do influence the source itself. This allows to compute the field above and under the source when no other incoming light is considered. Practically, we use Eq. (42) with amplitude E0(kx)\mathcal{E}_0(k_x) unity for all the values of kxk_x.

Guided modes tracking

It is extremely useful to be able to find the electromagnetic modes of a multilayered structure, whether these modes are strictly guided or leaky. Both types of modes correspond to a solution of the system of equations evoked above (see Eqs. (4)–(5)) without any illumination (B0−=AN+1+=0B_0^{-}=A_{N+1}^{+}=0), meaning the determinant of the system has to be zero[57], i.e., a zero of the dispersion relation.

The dispersion relation corresponds also to a zero of the determinant of S−1S^{-1} or a pole of SS, where SS is the scattering matrix of the whole structure. We underline, however, that this does not work for a single interface and the surface plasmon modes, for instance (the determinant of an interface scattering matrix is always equal to −1-1).

A solution of the dispersion relation is also a pole of the reflection coefficient in the kxk_x complex plane, because it corresponds to the existence of a solution or an outgoing wave without any incoming plane wave – and thus a diverging reflection coefficient. Obtaining the guided modes in this way works in the general case, including the case of only a single interface. It is therefore the approach implemented in PyMoosh.

The solutions of the dispersion relation, and thus the poles of the reflection coefficient, can generally be found either for a real value of the wavevector kxk_x and a complex value of the frequency ω\omega (the imaginary part representing the typical lifetime of the mode) or for a real value of the frequency ω\omega and a complex value of the wavevector kxk_x (the imaginary part representing the typical propagation distance of the mode before leaking). In PyMoosh we have, so far, made the latter choice. However, the default choice for the computation of the complex square root is not adequate for finding the solution of the dispersion relation. Given the physical meaning of the imaginary part of the poles, it is, most of the time[56], positive. The determination of the square root has to be modified to make the poles appear[59] and the default choice is to consider that the phase of kzk_z should be comprised between −π/5-\pi/5 and 4π/54\pi/5. This allows, in most cases, to see the poles correctly and to explore the complex plane close to them.

In order to find the guided modes, we define a minimum and a maximum effective index, defining bounds on the wavevectors. Then we start from a set of points regularly placed on the real axis between these values for kxk_x and run a steepest descent over 1∣r∣\frac{1}{|r|} using a finite difference scheme to estimate the gradient of the function. Steepest descent algorithms are typically employed to locate any minima, but here we leverage the fact that the minima correspond to zeroes, to determine when the algorithm should stop. Several of the initial points will converge to the same pole, and only unique poles are kept. While this technique is probably not the most efficient nor the most advanced, it has proven relatively reliable so far.

Once the modes have been found, their profile can be computed. An evanescent wave with a unity amplitude at the first interface is assumed. The rest of the mode is reconstructed using scattering matrices. Any inaccuracy in the determination of kxk_x will result in a discontinuity at the first interface. Figure 8b presents the modes found in a 2000 nm thick slab of dielectric with a refractive index n=1.5n=1.5 in air.

Figure 8. a) Dispersion of the guided modes of a 2000 nm thick slab of dielectric with a refractive index n=1.5n = 1.5 in air, plotted as the effective wavelength of the mode as a function of the wavelength in vacuum in a manner similar to [58]. b) Corresponding field profiles of the 6 modes with lowest effective index.

It is often practical to obtain the dispersion curve, i.e., the values of the wavevector of a given mode for different frequencies. In PyMoosh, once the modes have been found for the largest considered frequency, they can be tracked using steepest descents while the frequency changes. An example is shown Figure 8a). We begin with the smallest wavelength so that no mode appears during the sweep, however modes do disappear when they reach a cut-off.

Code design principles

PyMoosh has been developed with the core principles of Open Science in mind. The choice of Python as the programming language plays a central role: Python packages are extremely easy to find and install through the use of the PyPI repository[60], Python is often called to be good glue, thanks to its ability to interface other programming languages seamlessly. Moreover, modern repositories such as GitHub[61], being partly social networks, combined with the GNU General Public Licence, allow to maximize the accessibility and reusability of the code. Our approach thus aligns with the principles of the FAIR data framework, which underscore the importance of making data and methods Findable, Accessible, Interoperable, and Reusable[62].

The code architecture was chosen with simplicity of use in mind, especially for researchers and physicists in photonics. Although Python is an object-oriented language, we intentionally minimized the use of objects in order to facilitate code comprehension for non-programming experts. For convenience some parts such as materials handling are implemented as classes, but we emphasize that the part concerning materials can be used and expanded upon completely independently from the rest of the code. Finally, due to the inherent ease of implementation in Python, some interesting numerical optimizations that could be deemed fundamental (e.g. parallel computing) are left entirely in the hand of the user.

Our code is highly versatile, which may initially disorient some users - especially those who are not familiar with Python. To address this, in addition to this tutorial, we have provided extensive documentation and illustrated various use cases using Jupyter notebooks : a beginner’s guide to simulation, another for optimization, and then specific use cases: Surface Plasmon Resonance, Total Internal Reflection, Photovoltaics devices, Ellipsometry problems, Green function computation, Use of various formalisms, Guided Mode representation and tracking, Prism couplers, Photonic Crystals, and Managing materials. A sample of the results these notebooks provide is shown in Figure 9. Jupyter notebooks have gained significant popularity, particularly in the context of open science[45], making them an accessible and user-friendly tool for exploring and utilizing our code. Finally, we illustrate possible applications for deep learning training dataset generation by an own set of open source, extensive python notebook examples, which are exhaustively discussed in a recent tutorial article [63, 64].

Figure 9. PyMoosh use case examples. a-b) Ellipsometry results rprs=tan⁡(ϕ)eiΔ\frac{r_p}{r_s} = \tan(\phi)e^{i\Delta} for a layer of n=1.33n = 1.33 and width 400 nm on top of a Gold substrate. c) Mode profiles for two coupled waveguides of index n=1.5n = 1.5, width 1.2 μ\mum and separated by 300 nm of air. d) Bulk 1 μ\mum aSi cell absorbance in two cases. Simple Anti-Reflective Coating (ARC): 100 nm layer of n=1.5n = 1.5 as shown in Figure 6b. Complex ARC: optimized 6 layer Bragg mirror and impedance matching layers above and below (see notebook). e) Surface Plasmon Resonance excitation with a prism in Kraetschmann configuration: prism made out of BK7 on top of a 55 nm layer of Gold illuminated at 45.5° and λ=600\lambda= 600 nm. f) Electric field intensity of a current source encased in a layer of width 1 μ\mum and ϵ=1.4+0.1i\epsilon= 1.4 + 0.1i at λ=600\lambda= 600 nm.

Figure 6. a) Photon spectral density (photons per wavelength unit) of the AM1.5 visible solar spectrum. b) Absorptance in the active layers of 2 different basic solar cells (S-Matrix). 1 μm\mu\mathrm{m} of SiA bulk with or without adding a layer of optical index n=1.5n = 1.5 and thickness λ/4n\lambda/4n with λ=600\lambda= 600 nm.

Conclusion

In conclusion, we have presented PyMoosh, a user-friendly Python tool for the analysis and design of photonic multilayers. PyMoosh has been developed with Open Science principles in mind, to make it genuinely Findable, Accessible, Interoperable and Reusable (FAIR data approach). With its comprehensive set of features, numerical stability, readiness for optimization and deep learning problems and its extensive set of examples, we hope our platform will be adopted by the community at large to build upon. Already utilized in teaching and research, PyMoosh offers a versatile platform for studying the rich physics of multilayered structures, particularly those incorporating metallic or metallic-like layers. In a subsequent publication, we aim to demonstrate how PyMoosh can be seamlessly integrated with advanced optimization algorithms and optimization libraries and that its features allow for an efficient exploration of inverse design problems[63, 65]. Future plans include incorporating more advanced material descriptions, such as spatial dispersion in metals[66, 67], to further expand the capabilities of PyMoosh. We are dedicated to continuously improving PyMoosh and welcome any suggestions and contributions from the community.

Acknowledgements

A.M. is an Academy CAP 20-25 chair holder. He acknowledges the support received from the Agence Nationale de la Recherche of the French government through the program Investissements d’Avenir (16-IDEX-0001 CAP 20-25). This work was supported by the International Research Center "Innovation Transportation and Production Systems" of the Clermont-Ferrand I-SITE CAP 20-25. P.R.W. acknowledges the support of the French Agence Nationale de la Recherche (ANR) under grant ANR-22-CE24-0002 (project NAINOS), and from the Toulouse high performance computing facility CALMIP (grant p20010).

References

References

  1. [1]J. W. Strutt, Proceedings of the Royal Society of London. Series A, Containing Papers of a Mathematical and Physical Character 86, 207 (1912).
  2. [2]J. W. Strutt, Proceedings of the Royal Society of London. Series A, Containing Papers of a Mathematical and Physical Character 93, 565 (1917).
  3. [3]A. Macleod, Bulletin, Society of Vacuum Coaters, Issue Summer, 22 (2012).
  4. [4]F. Abelès, Journal de Physique et le Radium 11, 307 (1950).
  5. [5]P. Yeh, A. Yariv, and C.-S. Hong, JOSA 67, 423 (1977).
  6. [6]A. Yariv and P. Yeh, JOSA 67, 438 (1977).
  7. [7]P. Yeh, A. Yariv, and A. Y. Cho, Applied Physics Letters 32, 104 (1978).
  8. [8]P. Yeh, Surface Science 96, 41 (1980).
  9. [9]M. Born and E. Wolf, Principles of optics: electromagnetic theory of propagation, interference and diffraction of light (Elsevier, 2013).
  10. [10]P. Yeh, Optical Waves in Layered Media (Wiley Online Library, 2006).
  11. [11]H. A. Macleod, Thin-film optical filters (CRC press, 2017).
  12. [12]P. Baumeister, JOSA 48 (1958).
  13. [13]A. Thelen, JOSA 56, 10.1364/JOSA.56.001533 (1966).
  14. [14]A. Thelen, JOSA 61, 10.1364/JOSA.61.000365 (1971).
  15. [15]J. H. Apfel, Applied Optics 16, 10.1364/AO.16.001880 (1977).
  16. [16]J. Dobrowolski and D. Lowe, Applied Optics 17 (1978).
  17. [17]A. V. Tikhonravov and M. K. Trubetskov, in Optical Interference Coatings, Vol. 2253 (SPIE, 1994) pp. 10–20.
  18. [18]D. Poitras, L. Li, M. Jacobson, and C. Cooksey, Applied Optics 56, 10.1364/AO.56.0000C1 (2017).
  19. [19]J. D. T. Kruschwitz, V. Pervak, J. Keck, I. Bolshakov, Z. Gerig, F. Lemarchand, K. Sato, W. Southwell, M. Sugiura, M. Trubetskov, and W. Yuan, Applied Optics 56, 10.1364/AO.56.00C151 (2017).
  20. [20]J. D. T. Kruschwitz, V. Pervak, and J. Keck, in Optical Interference Coatings Conference (OIC) 2019 (Optica Publishing Group, 2019) p. TC.1.
  21. [21]M. Bocková, J. Slabý, T. Špringer, and J. Homola, Annual Review of Analytical Chemistry 12, 151 (2019).
  22. [22]H. K. Raut, V. A. Ganesh, A. S. Nair, and S. Ramakrishna, Energy & Environmental Science 4, 3779 (2011).
  23. [23]S. I. Bozhevolnyi and T. Sondergaard, Optics express 15, 10869 (2007).
  24. [24]P. Shekhar, J. Atkinson, and Z. Jacob, Nano convergence 1, 1 (2014).
  25. [25]R. Pollès, M. Mihailovic, E. Centeno, and A. Moreau, Physical Review A 94, 063808 (2016).
  26. [26]C. C. Katsidis and D. I. Siapkas, Applied Optics 41, 3978 (2002).
  27. [27]A. Luce, A. Mahdavi, F. Marquardt, and H. Wankerl, JOSA A 39, 1007 (2022).
  28. [28]M. M. Bay, S. Vignolini, and K. Vynck, Computer Physics Communications 273, 108256 (2022).
  29. [29]S. Larouche and L. Martinu, Applied optics 47, C219 (2008).
  30. [30]E. B. Costa, E. P. Rodrigues, and H. A. Pereira, Plasmonics 14, 1699 (2019).
  31. [31]M. A. Barry, V. Berthier, B. D. Wilts, M.-C. Cambourieux, P. Bennet, R. Pollès, O. Teytaud, E. Centeno, N. Biais, and A. Moreau, Scientific reports 10, 12024 (2020).
  32. [32]H. Wankerl, C. Wiesmann, L. Kreiner, R. Butendeich, A. Luce, S. Sobczyk, M. L. Stern, and E. W. Lang, Scientific Reports 12, 5226 (2022).
  33. [33]Z. Liu, D. Zhu, S. P. Rodrigues, K.-T. Lee, and W. Cai, Nano Letters 18, 6570 (2018).
  34. [34]R. Unni, K. Yao, and Y. Zheng, ACS Photonics 7, 10.1021/acsphotonics.0c00630 (2020).
  35. [35]P. Dai, Y. Wang, Y. Hu, C. H. De Groot, O. Muskens, H. Duan, and R. Huang, Photonics Research 9, B236 (2021).
  36. [36]P. Dai, K. Sun, X. Yan, O. L. Muskens, C. H. K. de Groot, X. Zhu, Y. Hu, H. Duan, and R. Huang, Nanophotonics 11, 3057 (2022).
  37. [37]Z. Wang, Y. C. Lin, K. Zhang, W. Wu, and S. Huang, EllipsNet: Deep-learning-enabled optical ellipsometry for complex thin films (2022), arXiv:2210.05630 [physics].arxiv.org/abs/2210.05630
  38. [38]A. Luce, A. Mahdavi, H. Wankerl, and F. Marquardt, Machine Learning: Science and Technology 4, 015014 (2023).
  39. [39]T. Ma, H. Wang, and L. J. Guo, OptoGPT: A Foundation Model for Inverse Design in Optical Multilayer Thin Film Structures (2023), arXiv:2304.10294 [physics].arxiv.org/abs/2304.10294
  40. [40]J. Jiang and J. A. Fan, Nanophotonics 10, 361 (2020).
  41. [41]Shiyuan Liu, Xiuguo Chen, and Shuo Liu, Smart ellipsometry with physics-informed deep learning (2023), Research Square:rs.3.rs-3205511.DOI
  42. [42]A. Moreau, Pymoosh, https://github.com/AnMoreau/PyMoosh (2023).
  43. [43]D. Langevin, P. Bennet, P. Wiecha, P. Chevalier, O. Teytaud, and A. Moreau, Anmoreau/pymoosh: Resub’ release (2023).
  44. [44]J. Defrance, C. Lemaître, R. Ajib, J. Benedicto, E. Mallet, R. Pollès, J.-P. Plumey, M. Mihailovic, E. Centeno, C. Ciraci, D. Smith, and A. Moreau, Journal of Open Research Software 4, e13 (2016).
  45. [45]B. M. Randles, I. V. Pasquetto, M. S. Golshan, and C. L. Borgman, in 2017 ACM/IEEE Joint Conference on Digital Libraries (JCDL) (IEEE, 2017) pp. 1–2.
  46. [46]H. Giessen and R. Vogelsang, Science 326, 529 (2009).
  47. [47]P. Lalanne and G. M. Morris, JOSA A 13 (1996).
  48. [48]G. Granet and B. Guizal, JOSA A 13, 10.1364/JOSAA.13.001019 (1996).
  49. [49]T. J. Hughes, Computer methods in applied mechanics and engineering 127, 387 (1995).
  50. [50]J.-M. Muller, N. Brisebarre, F. De Dinechin, C.-P. Jeannerod, V. Lefevre, G. Melquiond, N. Revol, D. Stehlé, S. Torres, et al., Handbook of floating-point arithmetic (Springer, 2018).
  51. [51]D. D. Solnyshkov, G. Malpuech, P. St-Jean, S. Ravets, J. Bloch, and A. Amo, Optical Materials Express 11, 1119 (2021).
  52. [52]E. Kretschmann and H. Raether, Zeitschrift für Naturforschung A 23, 2135 (1968).
  53. [53]J. B. Pendry, Physical Review Letters 85, 3966 (2000), publisher: American Physical Society.
  54. [54]R. Santbergen, J. Goud, M. Zeman, J. van Roosmalen, and R. C. van Zolingen, Solar energy materials and solar cells 94, 715 (2010).
  55. [55]T. Tamir, JOSA A 3, 558 (1986).
  56. [56]R. Polles, A. Moreau, and G. Granet, Optics letters 35, 3237 (2010).
  57. [57]R. Petit, (No Title) (1989).
  58. [58]M. Khaywah, A. Potdevin, F. Réveret, R. Mahiou, Y. Ouderdane, A. Désert, S. Parola, G. Chadeyron, E. Centeno, R. Smaali, et al., The Journal of Physical Chemistry C 125, 7780 (2021).
  59. [59]R. E. Smith, S. Houde-Walter, and G. Forbes, IEEE journal of quantum electronics 28, 1520 (1992).
  60. [60]M. Valiev, B. Vaselscu, and J. Herbsleb, in Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering (2018) pp. 644–655.
  61. [61]V. Cosentino, J. Luis, and J. Cabot, in Proceedings of the 13th International Conference on Mining Software Repositories (2016) pp. 137–141.
  62. [62]T. Tanhua, S. Pouliquen, J. Hausman, K. O’Brien, P. Bricher, T. De Bruin, J. J. Buck, E. F. Burger, T. Carval, K. S. Casey, et al., Frontiers in Marine Science 6, 440 (2019).
  63. [63]A. Khaireh-Walieh, D. Langevin, P. Bennet, O. Teytaud, A. Moreau, and P. R. Wiecha, Nanophotonics (2023).
  64. [64]P. R. Wiecha, A newcomer’s guide to deep learning for inverse design in nano-photonics, https://gitlab.com/wiechapeter/newcomer_guide_dl_inversedesign (2023).
  65. [65]P. Bennet, D. Langevin, C. Essoual, A. Khaireh-Walieh, O. Teytaud, P. Wiecha, and A. Moreau, An illustrated tutorial on global optimization in nanophotonics (2023), arXiv:2309.09760 [physics.optics].DOI
  66. [66]A. R. Melnyk and M. J. Harrison, Physical Review B 2, 835 (1970).
  67. [67]J. Benedicto, R. Polles, C. Ciraci, E. Centeno, D. R. Smith, and A. Moreau, JOSA A 32, 1581 (2015).

Paper details

vlnc:W_b8fg6wfp
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents