Introduction

The development of coherent laser over a broad frequency spectrum from near-infrared and visible to terahertz (THz), ultraviolet, and X-rays regimes1,2,3,4 has driven much of science and technology in the past decades, ranging from sensing, communications, biomedical instruments, imaging, and most recently nuclear fusion research5,6,7,8,9,10. Since the discovery of lasers in 1960 and the nonlinear optical effect in 196111,12, nonlinear optics has been a primary source for generating a continuously tunable electromagnetic spectrum. In the last two decades, quantum communications and computing have relied on using nonlinear optics to generate entangled photons and to achieve ultrafast all-optical switching13,14,15.

Optical second harmonic generation (SHG) refers to the nonlinear optical process where two photons of the same energy (\(\hslash \omega\)) combine to generate a third photon of higher energy (\(2\hslash \omega\)) in a nonlinear optical (NLO) medium. This phenomenon is described by the nonlinear polarization, \({{\bf{P}}}^{2\omega }={{\boldsymbol{\chi }}}^{(2)}{{\bf{E}}}^{\omega }{{\bf{E}}}^{\omega }\), generated in the NLO material at \(2\omega\) frequency by the electric field of the incident light, \({{\bf{E}}}^{\omega }\) at frequency \(\omega\)16. Here, \({{\boldsymbol{\chi }}}^{(2)}\) is the second-order nonlinear optical susceptibility represented by a third-rank tensor (with 18 independent components). If the refractive index and \({{\boldsymbol{\chi }}}^{(2)}\) tensors of a crystal are known, one can employ numerical simulations to model their nonlinear optical responses17,18. However, for new materials with unknown optical properties, experimental responses need to be measured and modeled by analytical or semi-analytical approaches to determine the coefficients by fitting the models to the experimental data. The complexity of developing such analytical models becomes untenable to perform manually when, in addition to the unknown \({{\boldsymbol{\chi }}}^{(2)}\) tensor, birefringence, arbitrary crystal symmetry and orientation, complex dielectric function, multilayer geometries, and interference of all the waves involved are considered. Errors in \({{\boldsymbol{\chi }}}^{(2)}\) may be mistakenly introduced if the analysis is not handled properly19,20,21. The previous ♯SHAARP.si package addresses this need only for a single interface. The current ♯SHAARP.ml package addresses this need for realistic slabs and multilayer structures found in most optical applications.

Table 1 summarizes the commonly applied models in existing SHG analyses. The foundation for the theoretical modeling of SHG responses was established by Maker, Bloembergen and Pershan (BP), Jerphagnon and Kurtz (JK), et al. in the 1960s and 1970s22,23,24, for nonlinear optical processes in a transparent isotropic/ medium. In particular, the Maker fringes technique has become the primary method for characterizing nonlinear optical susceptibilities in transparent crystals, where the transmitted SHG intensity is measured as a function of the angle of incidence25,26,27. Further advances in the Maker fringes technique were made by Herman and Hayden (HH), and Shoji et al., extending its applicability towards uniaxial systems and biaxial materials cut along high-symmetry directions28,29,30. However, these characterization methods are generally limited to transparent systems with high crystallographic symmetry, p- and s- polarized pump and SHG waves, and relatively simple geometry such as a bulk single crystal, a single-crystal slab, or a single-crystalline film on a substrate. SHG polarimetry is another technique to map out the anisotropic \({{\boldsymbol{\chi }}}^{(2)}\) by varying the polarizations of fundamental and SHG waves, which is applicable to both transparent and absorbing crystals31,32,33,34,35,36,37. Nonetheless, the theoretical analyses for both Maker fringes and SHG polarimetry still involve many assumptions such as the slowly varying approximation, weak reflection of the nonlinear polarization, transparent medium, high crystallographic symmetry, Kleinman symmetry, easy crystal orientation along a high-symmetry direction, phase matching conditions (\({n}^{\omega }={n}^{2\omega }\)), and negligible interference among nonlinear waves23,24,29,38,39,40,41,42. Our existing package ♯SHAARP.si addressed arbitrary crystal symmetry, orientation, and complex dielectric function for a single interface21. However, its application requires analyzing nonlinear optical response in a single homogeneous crystal where the crystal is wedged to avoid specular reflections from the back surface (if the crystal is transparent), or the crystal has a thickness greater than the absorption depth for the fundamental and SHG waves (if the crystal is absorbing). To our best knowledge, there is no general tool available that can analytically or semi-analytically model, without the simplifying approximations made in BP, HH and JK models23,24,28, the SHG responses of multilayer systems where light propagates through multiple layers of nonlinear optical materials, such as stacked 2D materials43, near Fabry-Perot conditions44, periodic domain gratings45, and superlattices46.

Table 1 Comparison of modeling capabilities among Bloembergen and Pershan Method (BP), Jerphagnon and Kurtz method (JK), Herman and Hayden method (HH), #SHAARP.si, and #SHAARP.ml

In this work, we present a comprehensive theoretical framework and an open-source package, ♯SHAARP.ml (Second Harmonic Analysis of Anisotropic Rotational Polarimetry for multilayers), for modeling second harmonic generation in an arbitrary single interface (same as ♯SHAARP.si)21 and complex heterostructure with full consideration of multireflection at both linear and nonlinear frequencies. The ♯SHAARP.ml is designed to provide numerical and analytical nonlinear optical solutions for both simulation and experimental characterization, allowing for fast, flexible, and user-friendly analysis of nonlinear optical response on complex material systems. Five key attributes of ♯SHAARP.ml include: (1) ability to model a multilayer stack with an arbitrary number of layers with homogeneous optical properties, (2) allowing arbitrary crystallographic symmetry, orientation, and possess absorption, birefringence, and dispersion of each layer, (3) choices for both reflection and transmission probe geometries, (4) full control of the polarization states of the incident and detected waves, and (5) explicit consideration of the multireflection of both linear and the nonlinear waves. While there are other contributions to the SHG response, such as magnetically induced SHG47, electric quadrupole48, etc., we focus on the electric dipole SHG in this work and shall extend the ♯SHAARP package to include other sources of SHG in future studies.

Seven materials systems were used to benchmark the analysis using the ♯SHAARP.ml package: α-quartz single crystal, Au-coated α-quartz bilayer, LiNbO3 and KTP single crystals, ZnO//Pt//Al2O3 thin film and multiple SHG active layers (LiNbO3//quartz, and twisted bilayer MoS2). Good agreement between results from ♯SHAARP.ml and the literature on the measured SHG coefficients for standard single crystal materials demonstrate the accuracy and reliability of the package.

Results and discussion

Theoretical background

Figure 1a presents the ray diagram of linear and nonlinear waves through a multilayer system adopted in ♯SHAARP.ml. Without loss of generality, we assume the first layer (M1) to be SHG active. In a more general case, all layers can (but need not) be SHG active in experiments. When a monochromatic plane wave at \(\omega\) frequency is incident upon the system, the electromagnetic properties of the plane wave inside the system are governed by the wave equation at \(\omega\) frequency,

$$\begin{array}{c}{\boldsymbol{\nabla }}\times {\boldsymbol{\nabla }}\times {{\bf{E}}}^{\omega }+\left(\begin{array}{ccc}{\widetilde{\varepsilon }}_{{{\rm{L}}}_{1}{{\rm{L}}}_{1}}^{\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{1}{{\rm{L}}}_{2}}^{\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{1}{{\rm{L}}}_{3}}^{\omega }\\ {\widetilde{\varepsilon }}_{{{\rm{L}}}_{2}{{\rm{L}}}_{1}}^{\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{2}{{\rm{L}}}_{2}}^{\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{2}{{\rm{L}}}_{3}}^{\omega }\\ {\widetilde{\varepsilon }}_{{{\rm{L}}}_{3}{{\rm{L}}}_{1}}^{\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{3}{{\rm{L}}}_{2}}^{\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{3}{{\rm{L}}}_{3}}^{\omega }\end{array}\right){{\boldsymbol{\mu }}}^{\omega }\frac{{\partial }^{2}}{\partial {t}^{2}}{{\bf{E}}}^{\omega }=0\end{array}$$
(1)

where \({{\bf{E}}}^{\omega }\), \({\widetilde{{\boldsymbol{\varepsilon }}}}_{{L}_{i}{L}_{j}}^{\omega }\) and \({{\boldsymbol{\mu }}}^{\omega }\) are respectively the electric field inside the medium at \(\omega\) frequency, anisotropic dielectric tensor components in the lab coordinate system (LCS), and magnetic permeability tensor at \(\omega\) frequency. The \({{\boldsymbol{\mu }}}^{\omega }\) will be assumed to be vacuum permeability for a nonmagnetic system, \({{\boldsymbol{\mu }}}^{\omega }{\boldsymbol{ \sim }}{\mu }_{0}{\bf{I}}\), where \({\bf{I}}\) is the identity matrix. The subscripts \(i\) and \(j\) are dummy indices describing the direction of each tensor component of the anisotropic dielectric susceptibility tensor in the LCS, denoted as \({\widetilde{{\boldsymbol{\varepsilon }}}}_{{\rm{LCS}}}^{\omega }\). Note that \({\widetilde{{\boldsymbol{\varepsilon }}}}_{{\rm{LCS}}}^{\omega }\) can be complex to account for absorption. Four coordinate systems are utilized, namely, principal coordinate system (PCS), crystal physics coordinate system (ZCS), crystallographic coordinate system (CCS), and lab coordinate system (LCS). In PCS, the complex dielectric susceptibility tensor is diagonalized. ZCS is the orthogonal coordinate system in which the property tensors are defined, such as dielectric susceptibility tensor, SHG tensor, piezoelectricity tensor, etc49. The CCS describes the coordinate system formed by the basis vectors of the unit cell (which are not necessarily orthogonal), and LCS is an orthogonal coordinate system of the model system with the plane of incidence (PoI) coincides with the L1-L3 plane as shown in Fig. 1a. Note that PCS, ZCS, and LCS are orthogonal coordinate systems, while the CCS can be non-orthogonal depending on the crystal symmetry. Equation (1) is a generalized eigenvalue problem that can be solved routinely50. The resulting eigenvalues and eigenvectors are related to the effective refractive indices and electric field directions for both ordinary and extraordinary waves. Due to reflectance at various interfaces, both forward and backward propagating waves exist in the heterostructure. The resulting backward propagating wavevectors can be described as

$$\begin{array}{c}{\left({{\bf{k}}}^{{\rm{eB}},\omega }{\boldsymbol{,}}\,{{\bf{k}}}^{{\rm{oB}},\omega }\right)}_{{{\rm{M}}}_{i}}{\boldsymbol{=}}{\left(\left(\begin{array}{ccc}1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & -1\end{array}\right)\,\cdot\, {{\bf{k}}}^{{\rm{eF}},\omega }{\boldsymbol{,}}\left(\begin{array}{ccc}1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & -1\end{array}\right)\,\cdot \,{{\bf{k}}}^{{\rm{oF}},\omega }\right)}_{{{\rm{M}}}_{i}}{\boldsymbol{,}}1\le i{\boldsymbol{\le }}N\end{array}$$
(2)
Fig. 1: Ray diagram and SHG measurement geometry.
figure 1

a The ray diagram of birefringent linear and nonlinear waves in the heterostructure. The M1 layer is set to be SHG active. Both \({{\bf{k}}}^{{\rm{eFeB}},2\omega }\) and \({{\bf{k}}}^{{\rm{oFoB}},2\omega }\) are propagating parallel to layers. Different colors are used to distinguish different waves and are not indicative of their frequencies. b The SHG probing geometry. (\({L}_{1},{L}_{2},{L}_{3}\)) is the lab coordinate system. Red and blue rays are the fundamental beam at \(\omega\) and SHG waves at \(2\omega\), respectively. \({\theta }^{{\rm{i}}}\) is the angle of incidence, and the light red plane is the PoI, indicated by the \({{\bf{L}}}_{{\bf{1}}}-{{\bf{L}}}_{{\bf{3}}}\) plane. The layers are subsequently labeled from M1 to MN.

The superscripts \({\rm{e}}\), \({\rm{o}}\), \({\rm{F}},\) and \({\rm{B}}\), respectively, represent extraordinary, ordinary, forward-propagating, and backward-propagating waves. \({{\rm{M}}}_{i}\) represents the \({i}^{{\rm{th}}}\) medium in the heterostructure. Similarly, the full electromagnetic properties of backward propagating waves can be obtained using Eqs. (1) and (2). The boundary conditions require the tangential components of both wave vectors and fields to be continuous across the interface where the former relation yields Snell’s law, and the latter represents the Fresnel coefficients. Thus the propagation direction, effective refractive indices, and fields can be obtained by simultaneously solving the equations below23,51,

$$\begin{array}{l}{k}_{{{\rm{L}}}_{1}}^{{\rm{i}},\omega }={k}_{{{\rm{L}}}_{1}}^{{\rm{R}},\omega }={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{eF}},\omega }\right)}_{{{\rm{M}}}_{i}}={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{oF}},\omega }\right)}_{{{\rm{M}}}_{i}}={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{eB}},\omega }\right)}_{{{\rm{M}}}_{i}}\\\qquad={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{oB}},\omega }\right)}_{{{\rm{M}}}_{i}}={k}_{{L}_{1}}^{{\rm{T}},\omega },1\le i\le N\end{array}$$
(3)
$$\begin{array}{c}{E}_{\parallel }^{{\rm{i}},\omega }+{E}_{\parallel }^{{\rm{R}},\omega }={\left({E}_{\parallel }^{{\rm{eF}},\omega }+{E}_{\parallel }^{{\rm{oF}},\omega }+{E}_{\parallel }^{{\rm{eB}},\omega }+{E}_{\parallel }^{{\rm{oB}},\omega }\right)}_{{{\rm{M}}}_{1}}\end{array}$$
(4)
$$\begin{array}{c}{\left({E}_{\parallel }^{{\rm{eF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},\omega }}+{E}_{\parallel }^{{\rm{oF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},\omega }}+{E}_{\parallel }^{{\rm{eB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},\omega }}+{E}_{\parallel }^{{\rm{oB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},\omega }}\right)}_{{{\rm{M}}}_{i}}\\= {\left({E}_{\parallel }^{{\rm{eF}},\omega }+{E}_{\parallel }^{{\rm{oF}},\omega }+{E}_{\parallel }^{{\rm{eB}},\omega }+{E}_{\parallel }^{{\rm{oB}},\omega }\right)}_{{{\rm{M}}}_{i+1}},1\le i\le N-1\end{array}$$
(5)
$$\begin{array}{c}{\left({E}_{\parallel }^{{\rm{eF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},\omega }}+{E}_{\parallel }^{{\rm{oF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},\omega }}+{E}_{\parallel }^{{\rm{eB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},\omega }}+{E}_{\parallel }^{{\rm{oB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},\omega }}\right)}_{{{\rm{M}}}_{N}}={E}_{\parallel }^{{\rm{T}},\omega }\end{array}$$
(6)
$$\begin{array}{c}{H}_{\parallel }^{{\rm{i}},\omega }+{H}_{\parallel }^{{\rm{R}},\omega }={\left({H}_{\parallel }^{{\rm{eF}},\omega }+{H}_{\parallel }^{{\rm{oF}},\omega }+{H}_{\parallel }^{{\rm{eB}},\omega }+{H}_{\parallel }^{{\rm{oB}},\omega }\right)}_{{{\rm{M}}}_{1}}\end{array}$$
(7)
$$\begin{array}{c}{\left({H}_{\parallel }^{{\rm{eF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},\omega }}+{H}_{\parallel }^{{\rm{oF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},\omega }}+{H}_{\parallel }^{{\rm{eB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},\omega }}+{H}_{\parallel }^{{\rm{oB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},\omega }}\right)}_{{{\rm{M}}}_{i}}\\= {\left({H}_{\parallel }^{{\rm{eF}},\omega }+{H}_{\parallel }^{{\rm{oF}},\omega }+{H}_{\parallel }^{{\rm{eB}},\omega }+{H}_{\parallel }^{{\rm{oB}},\omega }\right)}_{{{\rm{M}}}_{i+1}},1\le i\le N-1\end{array}$$
(8)
$$\begin{array}{c}{\left({H}_{\parallel }^{{\rm{eF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},\omega }}+{H}_{\parallel }^{{\rm{oF}},\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},\omega }}+{H}_{\parallel }^{{\rm{eB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},\omega }}+{H}_{\parallel }^{{\rm{oB}},\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},\omega }}\right)}_{{{\rm{M}}}_{N}}={E}_{\parallel }^{{\rm{T}},\omega }\end{array}$$
(9)

Here, \(\phi\) is the phase difference for a forward wave propagating from top to bottom surfaces and for a backward wave propagating from bottom to top surfaces of layer \({{\rm{M}}}_{i}\), defined as \(\phi ={h}_{{{\rm{M}}}_{i}}{\bf{k}}\,\cdot \,({0,0},-1)\), where \({h}_{{{\rm{M}}}_{i}}\) is the thickness of the \({i}^{{\rm{th}}}\) medium. The subscript \(\parallel\) indicates tangential components along both \({{\bf{L}}}_{{\bf{1}}}\) and \({{\bf{L}}}_{{\bf{2}}}\) directions. Equations (3)–(9) can be expanded depending on the number of layers in the heterostructure.

The optical dipolar second harmonic generation is defined by the generation of nonlinear polarization at \(2\omega\) frequency when the NLO materials are pumped by the incident electric fields at \(\omega\) frequency. The nonlinear polarization is defined as

$$\begin{array}{c}{{\bf{P}}}_{{{\rm{M}}}_{i}}^{2\omega }={\varepsilon }_{0}{{\boldsymbol{\chi }}}^{(2)}{{\bf{E}}}_{{{\rm{M}}}_{i}}^{\omega }{{\bf{E}}}_{{{\rm{M}}}_{i}}^{\omega }{{\rm{e}}}^{{\rm{i}}({{\bf{k}}}^{{\bf{S}}}\,\cdot\, {\bf{r}}-2\omega t)}\end{array}$$
(10)

where \({{\bf{P}}}_{{{\rm{M}}}_{i}}^{2\omega }\), \({{\bf{E}}}_{{{\rm{M}}}_{i}}^{\omega }\), \({\varepsilon }_{0}\), \({{\boldsymbol{\chi }}}^{(2)}\), \({{\bf{k}}}^{{\bf{S}}}\) and \({\bf{r}}\) are nonlinear polarization, fundamental electric field, vacuum dielectric permittivity, second-order nonlinear optical susceptibility, wave vector of the source wave, and position vector, respectively. Since arbitrary layers can be SHG active, \({{\bf{P}}}_{{{\rm{M}}}_{i}}^{2\omega }\) will appear when the \({i}^{{\rm{th}}}\) layer is SHG active, as denoted by the subscript \({{\rm{M}}}_{i}\). The generated nonlinear polarization is often known as the source wave that gives rise to the nonlinear optical effects. It is important to note that during the propagation of fundamental waves, the nonlinear polarization is generated throughout the entire optical path of \({{\bf{E}}}_{{{\rm{M}}}_{i}}^{\omega }\), according to Eq. (10). When the multiple reflections of nonlinear polarization are considered, the interference of nonlinear polarization can be obtained by considering the multiple reflections of \({{\bf{E}}}_{{{\rm{M}}}_{i}}^{\omega }\). Many previous theoretical studies of transmission SHG assume weak reflection of the source wave and ignore the interference among nonlinear polarization24,28. Though a few other works considered the multiple reflections explicitly30,52,53, they rely on approximations such as high symmetry structures with high symmetry axes aligned along the probing directions.

The propagation of nonlinear waves is governed by the wave equation at \(2\omega\) frequency, written as

$$\begin{array}{c}{\boldsymbol{\nabla }}\times {\boldsymbol{\nabla }}\times {{\bf{E}}}^{2\omega }+\left(\begin{array}{ccc}{\widetilde{\varepsilon }}_{{{\rm{L}}}_{1}{{\rm{L}}}_{1}}^{2\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{1}{{\rm{L}}}_{2}}^{2\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{1}{{\rm{L}}}_{3}}^{2\omega }\\ {\widetilde{\varepsilon }}_{{{\rm{L}}}_{2}{{\rm{L}}}_{1}}^{2\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{2}{{\rm{L}}}_{2}}^{2\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{2}{{\rm{L}}}_{3}}^{2\omega }\\ {\widetilde{\varepsilon }}_{{{\rm{L}}}_{3}{{\rm{L}}}_{1}}^{2\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{3}{{\rm{L}}}_{2}}^{2\omega } & {\widetilde{\varepsilon }}_{{{\rm{L}}}_{3}{{\rm{L}}}_{3}}^{2\omega }\end{array}\right){{\boldsymbol{\mu }}}^{2\omega }\frac{{\partial }^{2}}{\partial {t}^{2}}{{\bf{E}}}^{2\omega }=-{{\boldsymbol{\mu }}}^{2\omega }\frac{{\partial }^{2}}{\partial {t}^{2}}{{\bf{P}}}^{2\omega }\end{array}$$
(11)

where \({{\bf{P}}}^{2\omega }\), \({{\bf{E}}}^{2\omega }\), \({\widetilde{\varepsilon }}_{{L}_{i}{L}_{j}}^{2\omega }\), and \({{\boldsymbol{\mu }}}^{2\omega }\) are nonlinear polarization, radiated electric field, the component of complex dielectric permittivity tensor in LCS (\({\widetilde{{\boldsymbol{\varepsilon }}}}_{{\rm{LCS}}}^{2\omega }\)), and magnetic permeability tensor at \(2\omega\) frequency. Equation (11) highlights the fundamental mechanism of nonlinear optics, where the generated nonlinear polarization works as a source wave, generating and radiating second harmonic electric fields that can freely propagate inside the medium. Therefore, the particular and general solutions of Eq. (11) correspond to the bound and free waves, respectively28. The propagation of \({{\bf{P}}}^{2\omega }\) is confined to the propagation of the fundamental wave at \(\omega\) that generates it, and the corresponding \({{\bf{E}}}^{2\omega }\) is hence called the bound wave or inhomogeneous wave. On the other hand, the SHG wave generated by the bound wave can freely propagate governed by the direction specified by Snell’s law at \(2\omega\), hence it is called the free wave or the homogeneous wave.

The anisotropic three-wave mixing phenomena is revealed in Eq. (10), where material anisotropy is taken into account. In each SHG active medium (\({{\rm{M}}}_{i}\)), the forward and backward nonlinear wavevectors can thus be identified as \({{\bf{k}}}^{{\rm{S}},2\omega }=2{{\bf{k}}}^{{\rm{eF}},\omega }\), \(2{{\bf{k}}}^{{\rm{oF}},\omega }\),\(\,{{\bf{k}}}^{{\rm{eF}},\omega }+{{\bf{k}}}^{{\rm{oF}},\omega }\), \(2{{\bf{k}}}^{{\rm{eB}},\omega }\), \(2{{\bf{k}}}^{{\rm{oB}},\omega }\), \({{\bf{k}}}^{{\rm{eB}},\omega }+{{\bf{k}}}^{{\rm{oB}},\omega }\), \({{\bf{k}}}^{{\rm{eF}},\omega }+{{\bf{k}}}^{{\rm{eB}},\omega }\), \({{\bf{k}}}^{{\rm{eF}},\omega }+{{\bf{k}}}^{{\rm{oB}},\omega }\), \({{\bf{k}}}^{{\rm{oF}},\omega }+{{\bf{k}}}^{{\rm{eB}},\omega }\), and \({{\bf{k}}}^{{\rm{oF}},\omega }+{{\bf{k}}}^{{\rm{oB}},\omega }\). The wavevectors for the ten nonlinear polarizations in the \({i}^{{\rm{th}}}\) layer are thus denoted as (\({{\bf{k}}}^{{\rm{eFeF}},2\omega }\), \({{\bf{k}}}^{{\rm{oFoF}},2\omega }\), \({{\bf{k}}}^{{\rm{eFoF}},2\omega }\), \({{\bf{k}}}^{{\rm{eBeB}},2\omega }\), \({{\bf{k}}}^{{\rm{oBoB}},2\omega }\), \({{\bf{k}}}^{{\rm{eBoB}},2\omega }\), \({{\bf{k}}}^{{\rm{eFeB}},2\omega }\), \({{\bf{k}}}^{{\rm{eFoB}},2\omega }\), \({{\bf{k}}}^{{\rm{oFeB}},2\omega }\), \({{\bf{k}}}^{{\rm{oFoB}},2\omega }{)}_{{{\rm{M}}}_{i}}\) for clarity, as shown in Fig. 1a. For example, a nonlinear polarization \({{\bf{P}}}^{{\rm{eFoB}},2\omega }\) is formed when a forward propagating extraordinary wave (\({{\bf{k}}}^{{\rm{eF}},\omega }\)) and a backward propagating ordinary wave (\({{\bf{k}}}^{{\rm{oB}},\omega }\)) are combined. However, the wave mixing terms containing both forward and backward waves, such as \({{\bf{k}}}^{{\rm{eFeB}},2\omega }\) and \({{\bf{k}}}^{{\rm{oFoB}},2\omega }\), are often dropped or ignored in existing literature due to a large phase mismatch29,30. Although these terms form standing waves propagating parallel to the layers, the standing waves at both the top and bottom surfaces of each layer can still contribute to the boundary conditions. For example, a nonlinear polarization (\({{\bf{P}}}^{{\rm{eFeB}},2\omega }\)) can be generated by a mixture of \({{\bf{k}}}^{{\rm{eF}},\omega }\) and \({{\bf{k}}}^{{\rm{eB}},\omega }\) at top or bottom surfaces of layers leading to additional components in the boundary conditions. Therefore, we have implemented the mixing terms in ♯SHAARP.ml, resulting in, at most, ten distinct nonlinear polarizations of different combinations of wavevectors for each SHG active layer. These ten waves are shown as ten different arrows in Fig. 1a.

The particular solutions of Eq. (11) can be obtained using the method described in previous work21. For example, the electric field of the nonlinear polarization induced by the mixture of two forward extraordinary waves can be written as \({{\bf{E}}}^{{\rm{eFeF}},2\omega }={{\bf{C}}}^{{\rm{eFeF}},2{\rm{\omega }}}{{\rm{e}}}^{{\rm{i}}({{\bf{k}}}^{{\rm{eFeF}},2\omega }\,\cdot\, {\bf{r}}-2\omega t)}\), where \({{\bf{C}}}^{{\rm{eFeF}},2{\rm{\omega }}}\) is a vector describing the direction and magnitude of the resulting bounded electric field due to the nonlinear polarization. Thus, all electric and magnetic fields generated by the ten distinct nonlinear polarizations can be uniquely identified by solving Eq. (11). On the other hand, the general solution of Eq. (11), which represents the homogeneous waves, can be calculated following the same procedure as solving Eq. (1) but at \(2\omega\) frequency. Four nonlinear waves will be obtained to fully describe the multiple reflections of homogeneous waves, namely, \({\left({{\bf{E}}}^{{\rm{eF}},2\omega },{{\bf{E}}}^{{\rm{oF}},2\omega },{{\bf{E}}}^{{\rm{eB}},2\omega },{{\bf{E}}}^{{\rm{oB}},2\omega }\right)}_{{{\rm{M}}}_{i}}\), whose field strengths are determined using the boundary conditions to be described below.

The momentum conservation and energy conservation of the generated \(2\omega\) waves lead to the following boundary condition:

$$\begin{array}{l}{k}_{{{\rm{L}}}_{1}}^{{\rm{R}},2\omega }={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{eF}},2\omega }\right)}_{{{\rm{M}}}_{i}}={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{oF}},2\omega }\right)}_{{{\rm{M}}}_{i}}={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{eB}},2\omega }\right)}_{{{\rm{M}}}_{i}}\\\qquad\,={\left({k}_{{{\rm{L}}}_{1}}^{{\rm{oB}},2\omega }\right)}_{{{\rm{M}}}_{i}}={k}_{{{\rm{L}}}_{1}}^{{\rm{T}},2\omega },1\le i\le N\end{array}$$
(12)
$$\begin{array}{c}{E}_{\parallel }^{{\rm{R}},2\omega }=\big({E}_{\parallel }^{{\rm{eF}},2\omega }+{E}_{\parallel }^{{\rm{oF}},2\omega }+{E}_{\parallel }^{{\rm{eB}},2\omega }\\+{E}_{\parallel }^{{\rm{oB}},2\omega }+{E}_{\parallel }^{{\rm{eFeF}},2\omega }+{E}_{\parallel }^{{\rm{oFoF}},2\omega }+{E}_{\parallel }^{{\rm{eFoF}},2\omega }\\ +{E}_{\parallel }^{{\rm{eBeB}},2\omega }+{E}_{\parallel }^{{\rm{oBoB}},2\omega }+{E}_{\parallel }^{{\rm{eBoB}},2\omega }+{E}_{\parallel }^{{\rm{eFeB}},2\omega }\\+{E}_{\parallel }^{{\rm{eFoB}},2\omega }+{E}_{\parallel }^{{\rm{oFeB}},2\omega }+{{E}_{\parallel }^{{\rm{oFoB}},2\omega }\big)}_{{{\rm{M}}}_{1}}\end{array}$$
(13)
$$\begin{array}{c}\left(\right.{E}_{\parallel }^{{\rm{eF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},2\omega }}+{E}_{\parallel }^{{\rm{oF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},2\omega }}+{E}_{\parallel }^{{\rm{eB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},2\omega }}\\+\,{E}_{\parallel }^{{\rm{oB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},2\omega }}+{E}_{\parallel }^{{\rm{eFeF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left(2{\phi }^{{\rm{eF}},\omega }\right)}\\ +{E}_{\parallel }^{{\rm{oFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left(2{\phi }^{{\rm{oF}},\omega }\right)}+{E}_{\parallel }^{{\rm{eFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }+{\phi }^{{\rm{oF}},\omega }\right)}\\+{E}_{\parallel }^{{\rm{eBeB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{eB}},\omega }\right)}+{E}_{\parallel }^{{\rm{oBoB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{oB}},\omega }\right)}\\ +\,{E}_{\parallel }^{{\rm{eFeB}},2\omega }+{E}_{\parallel }^{{\rm{eFoB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }-{\phi }^{{\rm{oB}},\omega }\right)}\\+{E}_{\parallel }^{{\rm{oFeB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{oF}},\omega }-{\phi }^{{\rm{eB}},\omega }\right)}+{{E}_{\parallel }^{{\rm{oFoB}},2\omega }\left.\right)}_{{{\rm{M}}}_{i}}\\ =\left(\right.{E}_{\parallel }^{{\rm{eF}},2\omega }+{E}_{\parallel }^{{\rm{oF}},2\omega }+{E}_{\parallel }^{{\rm{eB}},2\omega }+{E}_{\parallel }^{{\rm{oB}},2\omega }\\+{E}_{\parallel }^{{\rm{eFeF}},2\omega }+{E}_{\parallel }^{{\rm{oFoF}},2\omega }+{E}_{\parallel }^{{\rm{eFoF}},2\omega }+{E}_{\parallel }^{{\rm{eBeB}},2\omega }\\+{E}_{\parallel }^{{\rm{oBoB}},2\omega }+{E}_{\parallel }^{{\rm{eBoB}},2\omega }+{E}_{\parallel }^{{\rm{eFeB}},2\omega }+\\{E}_{\parallel }^{{\rm{eFoB}},2\omega }+{E}_{\parallel }^{{\rm{oFeB}},2\omega }+{{E}_{\parallel }^{{\rm{oFoB}},2\omega }\left.\right)}_{{{\rm{M}}}_{i+1}},1\le i\le N-1\end{array}$$
(14)
$$\begin{array}{c}\left(\right.{E}_{\parallel }^{{\rm{eF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},2\omega }}+{E}_{\parallel }^{{\rm{oF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},2\omega }}+{E}_{\parallel }^{{\rm{eB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},2\omega }}\\+\,{E}_{\parallel }^{{\rm{oB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},2\omega }}+{E}_{\parallel }^{{\rm{eFeF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left(2{\phi }^{{\rm{eF}},\omega }\right)}\\+ \,{E}_{\parallel }^{{\rm{oFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left(2{\phi }^{{\rm{oF}},\omega }\right)}+{E}_{\parallel }^{{\rm{eFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }+{\phi }^{{\rm{oF}},\omega }\right)}\\+\,{E}_{\parallel }^{{\rm{eBeB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{eB}},\omega }\right)}+{E}_{\parallel }^{{\rm{oBoB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{oB}},\omega }\right)}\\+\,{E}_{\parallel }^{{\rm{eFeB}},2\omega }+{E}_{\parallel }^{{\rm{eFoB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }-{\phi }^{{\rm{oB}},\omega }\right)}\\+{E}_{\parallel }^{{\rm{oFeB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{oF}},\omega }-{\phi }^{{\rm{eB}},\omega }\right)}+{{E}_{\parallel }^{{\rm{oFoB}},2\omega }\left.\right)}_{{{\rm{M}}}_{N}}={E}_{\parallel }^{{\rm{T}},2\omega }\end{array}$$
(15)
$$\begin{array}{l}{H}_{\parallel }^{{\rm{R}},2\omega }=\left(\right.{H}_{\parallel }^{{\rm{eF}},2\omega }+{H}_{\parallel }^{{\rm{oF}},2\omega }+{H}_{\parallel }^{{\rm{eB}},2\omega }+{H}_{\parallel }^{{\rm{oB}},2\omega }\\\qquad\qquad+\,{H}_{\parallel }^{{\rm{eFeF}},2\omega }+{H}_{\parallel }^{{\rm{oFoF}},2\omega }+{H}_{\parallel }^{{\rm{eFoF}},2\omega }+ {H}_{\parallel }^{{\rm{eBeB}},2\omega }\\\qquad\qquad+\,{H}_{\parallel }^{{\rm{oBoB}},2\omega }+{H}_{\parallel }^{{\rm{eBoB}},2\omega }+{H}_{\parallel }^{{\rm{eFeB}},2\omega }+{H}_{\parallel }^{{\rm{eFoB}},2\omega }\\\qquad\qquad+\,{H}_{\parallel }^{{\rm{oFeB}},2\omega }+{{H}_{\parallel }^{{\rm{oFoB}},2\omega }\left.\right)}_{{{\rm{M}}}_{1}}\end{array}$$
(16)
$$\begin{array}{ll}\quad\left(\right.{H}_{\parallel }^{{\rm{eF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},2\omega }}+{H}_{\parallel }^{{\rm{oF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},2\omega }}+{H}_{\parallel }^{{\rm{eB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},2\omega }}\\\quad+{H}_{\parallel }^{{\rm{oB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},2\omega }}+{H}_{\parallel }^{{\rm{eFeF}},2\omega }{{\rm{e}}}^{{\rm{i}}(2{\phi }^{{\rm{eF}},\omega })}\\\quad+ {H}_{\parallel }^{{\rm{oFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left(2{\phi }^{{\rm{oF}},\omega }\right)}+{H}_{\parallel }^{{\rm{eFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }+{\phi }^{{\rm{oF}},\omega }\right)}\\\quad+{H}_{\parallel }^{{\rm{eBeB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{eB}},\omega }\right)}+{H}_{\parallel }^{{\rm{oBoB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{oB}},\omega }\right)}\\ \quad+{H}_{\parallel }^{{\rm{eFeB}},2\omega }+{H}_{\parallel }^{{\rm{eFoB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }-{\phi }^{{\rm{oB}},\omega }\right)}\\\quad+{H}_{\parallel }^{{\rm{oFeB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{oF}},\omega }-{\phi }^{{\rm{eB}},\omega }\right)}+{{H}_{\parallel }^{{\rm{oFoB}},2\omega }\left.\right)}_{{{\rm{M}}}_{i}}\\= \left(\right.{H}_{\parallel }^{{\rm{eF}},2\omega }+{H}_{\parallel }^{{\rm{oF}},2\omega }+{H}_{\parallel }^{{\rm{eB}},2\omega }+{H}_{\parallel }^{{\rm{oB}},2\omega }\\\quad+{H}_{\parallel }^{{\rm{eFeF}},2\omega }+{H}_{\parallel }^{{\rm{oFoF}},2\omega }+{H}_{\parallel }^{{\rm{eFoF}},2\omega }+{H}_{\parallel }^{{\rm{eBeB}},2\omega }\\\quad+{H}_{\parallel }^{{\rm{oBoB}},2\omega }+{H}_{\parallel }^{{\rm{eBoB}},2\omega }+{H}_{\parallel }^{{\rm{eFeB}},2\omega }+{H}_{\parallel }^{{\rm{eFoB}},2\omega }\\\quad+{H}_{\parallel }^{{\rm{oFeB}},2\omega }+{{H}_{\parallel }^{{\rm{oFoB}},2\omega }\left.\right)}_{{{\rm{M}}}_{i+1}},1\le i\le N-1\\ \end{array}$$
(17)
$$\begin{array}{c}\left(\right.{H}_{\parallel }^{{\rm{eF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{eF}},2\omega }}+{H}_{\parallel }^{{\rm{oF}},2\omega }{{\rm{e}}}^{{\rm{i}}{\phi }^{{\rm{oF}},2\omega }}+{H}_{\parallel }^{{\rm{eB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{eB}},2\omega }}\\+{H}_{\parallel }^{{\rm{oB}},2\omega }{{\rm{e}}}^{-{\rm{i}}{\phi }^{{\rm{oB}},2\omega }}+{H}_{\parallel }^{{\rm{eFeF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left(2{\phi }^{{\rm{eF}},\omega }\right)}\\ +{H}_{\parallel }^{{\rm{oFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left(2{\phi }^{{\rm{oF}},\omega }\right)}+{H}_{\parallel }^{{\rm{eFoF}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }+{\phi }^{{\rm{oF}},\omega }\right)}\\+{H}_{\parallel }^{{\rm{eBeB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{eB}},\omega }\right)}+{H}_{\parallel }^{{\rm{oBoB}},2\omega }{{\rm{e}}}^{-{\rm{i}}\left(2{\phi }^{{\rm{oB}},\omega }\right)}\\ +{H}_{\parallel }^{{\rm{eFeB}},2\omega }+{H}_{\parallel }^{{\rm{eFoB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{eF}},\omega }-{\phi }^{{\rm{oB}},\omega }\right)}\\+{H}_{\parallel }^{{\rm{oFeB}},2\omega }{{\rm{e}}}^{{\rm{i}}\left({\phi }^{{\rm{oF}},\omega }-{\phi }^{{\rm{eB}},\omega }\right)}+{{H}_{\parallel }^{{\rm{oFoB}},2\omega }\left.\right)}_{{{\rm{M}}}_{N}}={H}_{\parallel }^{{\rm{T}},2\omega}\end{array}$$
(18)

where \(\phi\) is the phase difference for a forward wave propagating from top to bottom surface and for a backward wave propagating from bottom to top surface in layer \({{\rm{M}}}_{i}\), defined as \(\phi ={h}_{{{\rm{M}}}_{i}}{\bf{k}}\,\cdot\, ({0,0},-1)\). Equations (12)–(18) describe the most general case where all layers are SHG active, except for the air layers. For a non-SHG active layer, all the fields of the inhomogeneous waves will be zero due to the absence of nonlinear polarization while the homogeneous \(2\omega\) waves will still be present. For a standing wave formed at either the top or bottom surface in the medium \({{\rm{M}}}_{i}\), taking \({E}_{\parallel }^{{\rm{eFeB}},2\omega }\) as an example, the phase terms are mutually canceled out, leading to the same field strength at both interfaces. Finally, with all the nonlinear waves and boundary conditions considered, both polarization-resolved reflected and transmitted SHG intensities can be obtained.

The SHG measurement geometry is shown in Fig. 1b, where the incident light (red) is focused on the surface of the sample (a heterostructure labeled by M1 to MN), and the generated SHG response can be collected in either transmission or reflection geometry. With this measurement geometry, two common techniques, namely SHG polarimetry and Maker fringe methods, can be deployed to probe the SHG tensors of nonlinear optical materials. For SHG polarimetry measurement, both the incident polarization (\(\varphi\), polarizer) and SHG polarization (\(\psi\), analyzer) can be varied to probe the polarization-dependent anisotropic SHG tensor. This method provides more comprehensive information on the anisotropy than the Maker fringe method and can be utilized to identify the orientation and the point group symmetry of a crystal. On the other hand, the Maker fringes method measures the transmitted SHG response as a function of angle of incidence (\({\theta }^{{\rm{i}}}\)) with fixed polarization directions of both the incident and the SHG waves, such as p- or s- polarized light waves. The variation in the envelope of the SHG intensity versus the angle of incidence can reveal the relative magnitude of nonlinear susceptibilities. However, the transmission geometry for Maker fringes limits its applications to material systems that are transparent. ♯SHAARP.ml can model both the SHG polarimetry and Maker fringes numerically or semi-analytically, which can be used to determine the unknown SHG tensors of new materials.

Outline of ♯SHAARP.ml

The theoretical method described in the preceding section is implemented using Wolfram Mathematica with a user-friendly GUI and a detailed tutorial, which can be found in ref. 54. Following the naming convention of our previous work, we named the software presented in this work as ♯SHAARP.ml, which is capable of modeling optical SHG of multilayer system. Figure 2 illustrates the calculation procedure of ♯SHAARP.ml. Additional features compared with SHAARP.si are the capability of handling more than one interface, the addition of backward propagating waves and resulting nonlinear polarizations, interference at each frequency, etc. First, with a given point group symmetry, the dielectric tensor in the ZCS, and its orientation relative to the LCS coordinate system as inputs, one can conveniently obtain the mutual relations among the four coordinate systems within ♯SHAARP.ml, and thus define the geometry of the system. Then, by solving the wave equation with the boundary conditions at \(\omega\) frequencies, one can obtain the forward and backward propagating waves in each layer,\(\,{\left({{\bf{E}}}^{{\rm{eF}},\omega },{{\bf{E}}}^{{\rm{oF}},\omega },{{\bf{E}}}^{{\rm{eB}},\omega },{{\bf{E}}}^{{\rm{oB}},\omega }\right)}_{{{\rm{M}}}_{i}}\). The obtained sets of field strengths are the result of multiple reflections at the pump frequency51. The generated nonlinear polarization vectors can thus be obtained from electric fields at \(\omega\) frequency. Further solving the wave equation at the nonlinear frequency can provide the wavevector and electric field directions of all forward and backward homogeneous and inhomogeneous waves in each layer (14 waves in each NLO layer, 4 waves in the non-NLO layer). Finally, plugging all the waves at \(2\omega\) frequency into the boundary conditions of electric and magnetic fields gives transmitted and reflected polarization-resolved nonlinear optical response.

Fig. 2: Calculation procedures for ♯SHAARP.ml.
figure 2

The dashed regions indicate repeating processes for all layers in the heterostructure.

Case studies using ♯SHAARP.ml

In the following, we present our experimental measurements of the SHG responses for a few typical nonlinear optical crystals and their heterostructures to demonstrate how they can be interpreted by numerical and semi-analytical analyses using ♯SHAARP.ml. In particular, we studied the Maker fringes of pure and Au-coated quartz single crystals and the SHG polarimetry of LiNbO3, KTP, and ZnO//Pt//Al2O3 heterostructure. We also performed two predictive modelings of bilayers consisting of two SHG active materials, namely, LiNbO3//α-SiO2 and twisted bilayer MoS2, which can be helpful in distinguishing ferroelectric domain states and nonlinear optical studies in low dimensional material systems. These examples not only serve as benchmark tests of ♯SHAARP.ml against known NLO materials covering a wide range of types (uniaxial, biaxial, and absorbing) but also demonstrate the broad applicability of ♯SHAARP.ml to a variety of situations (e.g., Maker fringes, polarimetry, quantifying the effect of adopting different assumptions in the SHG modeling, analytical fitting to extract absolute values of SHG coefficients, and predictive simulations of SHG responses of NLO heterostructures).

Maker fringes of α-quartz single crystal

The study of α-quartz in nonlinear optics can be traced back to the discovery of second harmonic generation in 196111. The first benchmark study for ♯SHAARP.ml is performed using the single crystalline α-quartz, which has been extensively investigated previously using the Maker fringes method22,24,28,30. The SHG coefficient \({d}_{11}\) has been measured to be 0.3 pm V−155. In this case study, we demonstrate the capability of ♯SHAARP.ml in obtaining the semi-analytical expression for Maker fringe response and benchmark analysis with both existing models in the literature24,28 and our experimental investigations. Figure 3 shows the comparison among numerical simulation results from ♯SHAARP.ml with various modeling conditions and existing results using analytical methods24,28. The Maker fringes condition is summarized in Fig. 3a. The fundamental wavelength (\({\lambda }^{\omega }\)) is 1064 nm and the generated SHG signal from a 300 µm X-cut quartz is analyzed. Both the fundamental and SHG waves are p- polarized. Two widely applied Maker fringes models are utilized for comparison, namely the JK (Jerphagnon & Kurtz24) method and HH (Herman & Hayden28) method. The JK method was developed for a high symmetry medium with an assumption that only forward propagating waves are involved24. The HH method extended this model to a birefringent uniaxial system with multiple reflections of homogeneous waves (free waves) at \(2\omega\) frequency, but not for the inhomogeneous waves or linear waves. ♯SHAARP.ml involves multiple reflections for both linear and nonlinear waves (homogeneous and inhomogeneous) and thus can be reduced to JK or HH methods by making the corresponding assumptions. Schematics of the assumptions made for the three approaches can be found in Supplementary Note 1 and Supplementary Fig. 1. Figure 3b, c illustrates the three Maker fringes patterns obtained from the HH method (denoted as analytic HH) and numerical analysis using ♯SHAARP.ml with both JK and HH modeling conditions, denoted as ♯SHAARP(JK) and ♯SHAARP(HH)24,28. The blue dots, yellow and green lines correspond to analytic HH, ♯SHAARP(JK) and ♯SHAARP(HH), respectively. All three Maker fringes patterns are consistent with the literature28. In particular, analytic HH and ♯SHAARP(HH) show good agreement, demonstrating ♯SHAARP.ml can accurately reproduce the prior results. Figure 3c shows the magnified area of the dashed box region in Fig. 3b. By enabling the multiple reflections of homogeneous waves at \(2\omega\) frequency, ♯SHAARP(HH) produce additional fine fringes at \({\theta }^{{\rm{i}}}\) from \({20}^{\circ}\) to \({30}^{\circ}\), which are absent for ♯SHAARP(JK). This difference indicates that the interferences between forward and backward homogenous \(2\omega\) waves result in these fine fringes.

Fig. 3: Comparison of Maker fringes results between ♯SHAARP.ml and early analytical Herman & Hayden’s and Jerphagnon & Kurtz’s models.
figure 3

a Schematic of Maker fringes condition using 300 µm X-cut quartz. The fundamental wavelength is 1064 nm. Red is fundamental light, and blue represents the generated SHG response. \({\theta }^{{\rm{i}}}\) is the angle of incidence. Polarizations of both the fundamental and the SHG waves are set to be p- polarized. b SHG Maker fringes patterns obtained using Herman & Hayden’s analytical expressions (analytic HH) and ♯SHAARP.ml analysis using Herman & Hayden’s modeling condition, ♯SHAARP(HH), and Jerphagnon & Kurtz modeling condition, ♯SHAARP(JK). c Magnified region of b as indicated by the dashed box in b.

To demonstrate the effect of full multiple reflection (FMR) in determining the nonlinear optical responses, we performed a comparative study to measure the Maker fringes of uncoated and Au-coated quartz slabs, as shown in Fig. 4. Figure 4a, b shows the experimental conditions and corresponding Maker fringes patterns using a 123.6 µm uncoated Z-cut quartz slab. The incident fundamental wave is p- polarized centered at 800 nm, and the generated p- polarized SHG intensity is collected as a function of \({\theta }^{{\rm{i}}}\). Four Maker fringes patterns are compared, namely, experimental results (Expt.), ♯SHAARP(JK), ♯SHAARP(HH), and full multiple reflections of linear and nonlinear waves (♯SHAARP(FMR)). Due to the weak reflectance of quartz, all three modeling conditions yield similar Maker fringes patterns, in agreement with the experimental results. The centers of the fringes overlap with that of ♯SHAARP(JK). The major difference lies in the fine fringes of the Maker fringes patterns, as highlighted in the inset of Fig. 4b (a zoom-in of the dashed regions near \({\theta }^{{\rm{i}}}={30}^{\circ}\)). With multiple reflections considered and thus more interferences, the amplitude of the fine fringes increases. Experimentally, the fine fringes are not observable with a fine step size of \({\theta }^{{\rm{i}}}\) at \({0.1}^{\circ}\), and possible reasons for not detecting fine fringes can be the range of angles of incidence, the nonuniformity of sample thickness within the probing area, or the bandwidth of the laser. To confirm the above effects, Maker fringes patterns with averaging angle of incidence (due to beam divergence of ~\({3}^{\circ}\)), thickness variation (of ~50 nm across the beam), and wavelength averaging (\({\lambda }^{\omega }\pm 5\) nm) are performed (see Supplementary Note 2, Supplementary Fig. 2a, b). It is found that by averaging the above three parameters one can effectively smoothen the calculated Maker fringes pattern, confirming that the variation of experimental conditions, as used for the case of quartz, can smear out the fine fringes. Averaging \({\theta }^{{\rm{i}}}\) and \({\lambda }^{\omega }\) have a more dominating effect compared with averaging \(h\) for the case of quartz in this study. It is important to note that although the JK method can also produce a smooth Maker fringes pattern, this coincidence is accidental. In fact, the smooth pattern obtained by averaging the angle of incidence correctly considers the multiple reflection of waves and the variation of experimental conditions while the JK method excludes the fine fringes due to the neglect of reflective waves.

Fig. 4: Experimental verifications of ♯SHAARP.ml and influence of full multiple reflections using Maker fringes technique.
figure 4

a Schematic of the experimental condition using Z-cut quartz. b The comparison among Maker fringes patterns from experiment and different modeling conditions based on the geometry in a. The inset is the zoomed-in Maker fringes highlighted in the dashed area. c Schematic of the experimental condition using Z-cut quartz with a backside Au coating. d The comparison among Maker fringes patterns from experiment and different modeling conditions based on the geometry in c. JK, HH, FMR and FMR+\({\theta }^{{\rm{i}}}\) + h + \({\lambda }^{\omega }\) represent JK method, HH method, full multiple reflections of linear and nonlinear waves, and averaged Maker fringes with a span of angles of incidence (\({\theta }^{{\rm{i}}}\)), crystal thicknesses (h) and wavelength of fundamental light (\({\lambda }^{\omega }\)) due to a finite bandwidth based on ♯SHAARP(FMR). The fundamental wavelength \({\lambda }^{\omega }\) is 800 nm.

To illustrate the circumstance under which FMR becomes critical, we further studied the Maker fringes of a Z-cut quartz with Au coating at the backside of the slab, as shown in Fig. 4c, d. The thickness and complex refractive index of Au coating are determined by spectroscopic ellipsometry (see Supplementary Note 3 and Supplementary Fig. 3). The thickness of the Au layer is found to be 13.9 nm, far below the penetration depth (~45 nm). Due to the strong reflection of the Au layer, the resulting backward propagating waves are expected to be more intense than those in the pure quartz case. To test such hypothesis, we compared the simulation results based on ♯SHAARP(HH) and ♯SHAARP(FMR) against the experimental results, as shown in Fig. 4d. Due to the inclusion of Au, the fine fringes resulting from multiple reflections become more prominent as compared with Fig. 4b. Similar phenomenon has also been observed in other studies30,52,56. It can be seen from Fig. 4d that ♯SHAARP(HH) fails to capture the total transmitted SHG intensity and the relative intensity ratio between \({\theta }^{{\rm{i}}}=0^{\circ}\) and \(\approx 40^{\circ}\). In contrast, the results from ♯SHAARP(FMR) indicate better agreement with experiments regarding these SHG intensities but exhibit large variation in the fine fringes that are smeared out in the experiments. These oscillations can be corrected by averaging the angle of incidence, thickness variation in the probed area, and finite bandwidth of the fundamental wavelength, leading to the results denoted as ♯SHAARP(FMR+\({\theta }^{{\rm{i}}}\) + h + \({\lambda }^{\omega }\)). Detailed discussion on the corrections can be found in Supplementary Note 2, Supplementary Fig. 2c, d. With ♯SHAARP(FMR+\({\theta }^{{\rm{i}}}\) + h + \({\lambda }^{\omega }\)), the SHG relative intensities, peak, and minimum positions are well captured simultaneously with good agreement between the experiments.

In contrast to the fine fringes originating from the interference of the fundamental waves, the broader envelope in the SHG intensity with respect to \({\theta }^{{\rm{i}}}\) (interval ranging across tens of degrees visible in Figs. 3b and 4b, d) carry the essential information associated with the interference between the homogeneous and inhomogeneous waves. This interference originates from the phase difference between the source waves (\({{\bf{k}}}^{{\rm{S}},2\omega }\)) and the homogeneous waves (\({{\bf{k}}}^{{\rm{e}},2\omega }\) and \({{\bf{k}}}^{{\rm{o}},2\omega }\)) accumulated throughout the bilayer structure, and thus, the broader envelope is extremely sensitive to the changes in the crystal thickness and refractive indices at both \(\omega\) and \(2\omega\) frequencies. Therefore, SHG Maker fringes can be utilized as a sensitive probe of wafer uniformity57. For example, with a thickness variation of 1 \(\mu m\), the Maker fringes change drastically, as demonstrated in Supplementary Note 4 and Supplementary Fig. 4. It is worth noting that the crystal thicknesses determined in Fig. 4b, d are slightly different, i.e., 123.6 \(\mu m\) and 121.4 \(\mu m\), respectively, due to the change of probing positions and nonuniform thickness across the sample (10 μm variation across a 10 mm × 10 mm sample), as confirmed by the stylus profilometry. In addition, we note that the example presented in Fig. 4c, d also illustrates the capability of ♯SHAARP.ml in handling multiple layers with strong reflections.

The phase difference between two propagating waves is critical to determining their interference, e.g., being constructive and destructive for in-phase and out-of-phase situations respectively. With ♯SHAARP.ml, we show that different ways to compute the relative phase terms of the waves can lead to dissimilar results. Conventionally, the phases of electromagnetic waves propagating through layers are calculated as \(\phi ={h}_{{{\rm{M}}}_{i}}{\bf{k}}\,\cdot \,({0,0},-1)\), where only the \({L}_{3}\) component of the wavevector is considered. On the other hand, the full phase of the electromagnetic wave accumulated through layers can be written as \(\phi ={h}_{{{\rm{M}}}_{i}}{\bf{k}}\,\cdot\, (\tan \theta ,0,-1)\), where \(\theta\) represents the refractive angle of the corresponding wave. However, the Maker fringes obtained using full phase show large deviation from the experiments (see Supplementary Note 5 and Supplementary Fig. 5). Such discrepancy may come from the fact that a small beam size comparative to the crystal thickness is used in the experiment, where a sizeable beam overlap and finite resolution of angles are essential for the interference to become observable in the experiments. Therefore, for the quartz case, taking only the vertical phase along \({L}_{3}\) direction will be sufficient in the SHG analysis throughout the current work.

LiNbO3 and KTP single crystals

LiNbO3 and KTiOPO4 (potassium titanyl phosphate, KTP) have been widely studied for decades owing to their excellent nonlinear optical properties58,59,60. Their well-established nonlinear optical susceptibilities make the two crystals suitable for benchmarking analysis. Utilizing the partial analytical expressions generated by ♯SHAARP.ml, the experimental polarimetry results can be analyzed to extract relative ratios of SHG coefficients, and the absolute SHG coefficients of the two single crystals can be obtained using α-quartz as the reference.

LiNbO3 crystallizes in a trigonal structure with the point group 3 m and has a bandgap of around 3.8 eV59,61. Two orientations, namely (0001) (i.e., Z-cut) and (\(11\bar{2}0\)) (i.e., X-cut) were measured in the transmission geometry and analyzed simultaneously to determine the full SHG tensor using a fundamental wavelength (\({\lambda }^{\omega }\)) centered at 1550 nm. Figure 5a–d shows the experimental results and fitting analysis of LiNbO3. Three angles of incidence \(({\theta }^{{\rm{i}}}=0^{\circ} ,10^{\circ} ,30^{\circ} )\) are analyzed simultaneously, and the SHG intensities are normalized within each orientation. Figure 5a, b is the SHG polarimetry results of ~538 μm thick LiNbO3 (\(11\bar{2}0\)) crystal slab, whose c axis is placed along the \({{\bf{L}}}_{{\bf{1}}}\) direction (see the experimental orientations in Supplementary Note 6 and Supplementary Fig. 6). The obtained polar plots are p- and s- polarized SHG intensities as a function of incident polarization (\(\varphi\)). The dominating \({d}_{33}\) (corresponds to \({\theta }^{{\rm{i}}}=0^{\circ}\) in Fig. 5a) results in a large intensity difference between the p- and s- polarized SHG responses (~135 times difference), which can be well captured by ♯SHAARP.ml. Figure 5c, d is the measured SHG intensities and fitting results of ~119 μm LiNbO3 (0001). At normal incidence, both p- and s- polarized SHG show four lobes with equal intensities arising from the in-plane isotropy in this orientation. As the crystal is tilted towards a larger angle of incidence, the projection of \({d}_{33}\) to the \({{\bf{L}}}_{{\bf{1}}}\) increases, leading to an increase in the p- polarized SHG intensity, as seen in Fig. 5c. By fitting two LiNbO3 crystals with different orientations and using quartz as the reference, the extracted ratios and absolute values of the SHG coefficients of LiNbO3 are summarized in Table 2, which agree well with previously reported values24,29.

Fig. 5: Case studies of LiNbO3 and KTP single crystals at 1550 nm.
figure 5

a, b The p- and s- polarized SHG response of LiNbO3 (\(11\bar{2}0\)) as a function of incident polarization direction (\(\varphi\)). c, d The p- and s- polarized SHG response of LiNbO3 (\(0001\)) as a function of incident polarization direction (\(\varphi\)). e, f The p- and s- polarized SHG response of KTP (100) and KTP (010) as a function of incident polarization direction (\(\varphi\)). Comparison of extracted SHG coefficients ratios among different modeling conditions for (g) LiNbO3 and (h) KTP. KS is Kleinman’s symmetry. NMR stands for no multiple reflections of linear waves and nonlinear inhomogeneous waves. No \({{\bf{P}}}^{{\rm{FB}}}\) represents the case when the nonlinear polarizations generated by mixtures of forward and backward waves are ignored.

Table 2 Comparison of absolute SHG coefficients and their ratios between ♯SHAARP and literature

KTP adopts an orthorhombic crystal structure with a point group of mm2. It is classified as a biaxial material with distinct optical responses along all three crystal physics axes. Thus, a careful analysis of full anisotropy and the presence of two optical axes are critical in optical modeling. In this study, we used two KTP slabs simultaneously, namely ~370 μm X-cut ((100) orientation) slab and ~570 μm Y-cut ((010) orientation) slab, to analyze the full SHG tensor. Both c axes are placed along the \({{\bf{L}}}_{{\bf{2}}}\) direction, and their two optical axes lie in \({{\bf{Z}}}_{{\bf{1}}}\)-\({{\bf{Z}}}_{{\bf{3}}}\) plane (see the experimental orientations in Supplementary Note 6 and Supplementary Fig. 6)49,62. Figure 5e, f is the SHG polar plots for p- and s- polarized SHG response, respectively. Four angles of incidence are utilized to identify five unknown SHG susceptibilities uniquely (\({\theta }^{{\rm{i}}}=0^{\circ} ,10^{\circ} ,20^{\circ}\), and \(40^{\circ}\)). Using partial analytical expressions generated by ♯SHAARP.ml, the SHG polarimetry fittings show good agreement between the theory and experimental data, and the extracted ratios and absolute values of SHG coefficients of KTP are summarized in Table 2.

As discussed in previous work21, the symmetry assumptions, such as that of isotropy, can lead to errors of up to 30% in the ratios between SHG coefficients, depending on the anisotropy of the materials. In this work, our discussion will focus on the influence of Kleinman’s symmetry (KS), the exclusion of multireflection of linear waves and nonlinear inhomogeneous waves (NMR), and the exclusion of the nonlinear polarizations formed by the mixture of forward and backward waves (No \({{\bf{P}}}^{{\rm{FB}},2{\rm{\omega }}}\)). Using ♯SHAARP.ml, these three factors can be selectively applied in the modeling and fitting analysis to investigate the influence of individual assumptions on the final obtained nonlinear susceptibilities. Figure 5g, h summarizes the SHG coefficients ratios obtained under different assumptions to fit the same experimental data for LiNbO3 and KTP, respectively. The Kleinman’s symmetry (KS) assumes all three indices in the d tensor are permutable, leading to \({d}_{31}\,\)= \({d}_{15}\) in LiNbO3, and \({d}_{31}\,\)= \({d}_{15}\), \({d}_{32}\,\)= \({d}_{24}\) in KTP63,64,65,66,67. The NMR case is equivalent to the HH method, where only multiple reflections of the nonlinear homogeneous wave are considered. The “No \({{\bf{P}}}^{{\rm{FB}},2{\rm{\omega }}}\)” case neglects the nonlinear polarizations generated by mixed forward and backward waves, i.e., \({{\bf{P}}}^{{\rm{eFeB}},2\omega }\), \({{\bf{P}}}^{{\rm{eFoB}},2\omega }\), \({{\bf{P}}}^{{\rm{oFeB}},2\omega }\), and \({{\bf{P}}}^{{\rm{oFoB}},2\omega }\). The ♯SHAARP.ml case represents the analysis with full consideration of multireflection of linear and nonlinear waves, all possible nonlinear polarizations and complete material anisotropy, and no Kleinmann symmetry assumed. Comparing the four cases, we found most of the obtained SHG ratios vary within 20–30%, which are commonly comparable to the error bars. The NMR case is close to the ♯SHAARP.ml case, implying that the HH method may be a good approximation for studying KTP with photon energies below its bandgap. The difference between “♯SHAARP.ml” and “No \({{\bf{P}}}^{{\rm{FB}}.2\omega }\)” lies in whether or not to include the nonlinear polarization created by the interference of forward and backward electric fields at \(\omega\) frequency. For transparent crystals (such as LiNbO3 and KTP) whose reflectance is smaller, the backward propagating electric fields are weaker, and thus the resulting \({{\bf{P}}}^{{\rm{FB}},2{\rm{\omega }}}\) does not contribute much to the final transmitted SHG intensities. This observation also supports the claims of early models that only nonlinear polarization formed by forward propagating waves is considered for transparent samples23,24,28. The KS case, however, can introduce relatively large deviations in the obtained coefficient ratios such as a 60% error for \({d}_{31}/{d}_{32}\) in KTP.

ZnO//Pt//Al2O3 thin films

ZnO has been widely studied for decades for electronics, photonics, and optoelectronics applications owing to its large piezoelectric coefficients, large exciton binding energies, wide optical bandgap, and good chemical and thermal stability68,69,70. Recently, ZnO with Mg substitution (Zn1-xMgxO) has been shown to possess ferroelectricity, paving its way toward waveguides and quasi-phase-matched (QPM) frequency conversion devices15,45. Though the nonlinear optical process in ZnO has been extensively explored in both bulk and thin films forms, its nonlinear optical susceptibilities have been reported with a large scatter in the values from less than one pm V−1 to hundreds of pm V−1, indicating either sample variations or inconsistent modeling of the SHG data71,72,73,74. In this work, we select 159 nm ZnO//200 nm Pt//0.5 mm Al2O345 as an example to demonstrate the capabilities of ♯SHAARP.ml in probing thin films on substrates with a bottom electrode and the importance of multiple reflections in the analysis.

As described in earlier work, ZnO was grown using RF magnetron sputtering and formed a stack of ZnO//Pt//Al2O3, as shown in Fig. 6a45. The fundamental wavelength is centered at 1550 nm, and the angle of incidence is set to 45 degrees (\({\theta }^{{\rm{i}}}=45^{\circ}\)). The reflected p- and s- polarized SHG intensities at 775 nm are then collected as a function of incident polarization (azimuthal angle \(\varphi\)). The epitaxial ZnO (0001) films adopt the wurtzite structure (point group 6mm) and remain isotropic within the in-plane direction. Figure 6b shows the crystal structure of ZnO and its crystallographic directions relative to the lab coordinate systems, where \({{\bf{Z}}}_{{\bf{1}}}\parallel {{\bf{L}}}_{{\bf{1}}}\) and \({{\bf{Z}}}_{{\bf{3}}}\parallel {{\bf{L}}}_{{\bf{3}}}\). Due to the strong reflection of the Pt bottom electrode at fundamental 1550 nm and SHG wavelength at 775 nm, the multiple reflections at both frequencies inside the ZnO layer are thus significant and cannot be ignored. The thickness of the Pt layer is around 200 nm, and therefore both incident and SHG waves will be fully blocked and reflected by the Pt layer. Since earlier theoretical approaches often assume weak reflection of the nonlinear source wave23,24,28, a suitable theoretical model in the literature that can resolve a near Fabry-Perot condition is difficult to find. Using expressions generated by ♯SHAARP.ml, the experimental results can thus be fitted, as demonstrated in Fig. 6c, d.

Fig. 6: Second harmonic generation analysis of ZnO//Pt//Al2O3 thin film at 1550 nm.
figure 6

a The probing geometry of ZnO//Pt//Al2O3 heterostructure. The red beam is the fundamental ray, and the blue is the generated SHG response. The light red plane represents the plane of incidence parallel to \({{\bf{L}}}_{{\bf{1}}}-{{\bf{L}}}_{{\bf{3}}}\) plane. The p- and s- polarized SHG response (\({I}_{p}^{{\rm{R}},2\omega }\) and \({I}_{s}^{{\rm{R}},2\omega }\)) are collected as a function of incident polarization (\(\varphi\)). Superscript R indicates the reflected waves. b the relations between the crystallographic coordinate system (\(a,b,c\)) and lab coordinate system (\({L}_{1},{L}_{2},{L}_{3}\)). The SHG polarimetry results collected at \({\theta }^{{\rm{i}}}=45^{\circ}\) for (c) p- polarized SHG intensity \({I}_{p}^{{\rm{R}},2\omega }(\varphi )\) and (d) s- polarized SHG intensity \({I}_{s}^{{\rm{R}},2\omega }(\varphi)\). Data acquired from the sample in ref. 45. e The comparison of extracted complete absolute SHG tensor (\({d}_{33}\), \({d}_{31}\), \({d}_{15}\)) among full analysis (♯SHAARP.ml) and various assumptions. KS is Kleinman’s symmetry. NMR stands for no multiple reflections of linear waves and nonlinear inhomogeneous waves. No \({{\bf{P}}}^{{\rm{FB}}}\) represents the nonlinear polarizations generated by mixtures of forward and backward waves are ignored.

Further reference against a wedged X-cut LiNbO3 yields the absolute SHG coefficients of the entire SHG tensor. Figure 6e summarizes the absolute SHG coefficients obtained from ♯SHAARP.ml in comparison with the cases under various assumptions (the meanings of the notations are consistent with the previous section). The “♯SHAARP.ml” case yields the absolute \({d}_{33}=6.6\pm 2.2\) pm V−1, which is close to early reported values for films and single crystals (~7.15 pm V−1)45,72. This indicates the film under study has good qualities and low optical loss. Comparing the results from ♯SHAARP.ml with those from KS and No \({{\bf{P}}}^{{\rm{FB}}}\), the obtained absolute SHG coefficients are reasonably close. On the other hand, the multiple reflections play a more significant role in the analysis. As can be seen from the NMR case, the obtained nonlinear susceptibilities are greatly exaggerated by one order of magnitude. This is because the total SHG signals were attributed to the single propagation of nonlinear polarization from the top to the bottom surface instead of multiple bounces. To compensate for the path difference between NMR and FMR, the nonlinear susceptibilities have to be increased, leading to \({d}^{{\rm{SHG}}}\) of nearly 10 times higher than the actual value.

This case study of ZnO thin films highlights the necessity of a more general nonlinear optical model because of the increased complexity as more materials are involved in a heterostructure. For example, SHG has been widely applied in characterizing 2D materials on top of SiO2//Si substrate which is highly reflective in the visible regime32,75. Nevertheless, the multireflection of the heterostructure is often assumed to be negligible76. Additionally, as more binary ferroelectric semiconductors are being discovered, such as (Al,Sc)N and (Al,B)N44,77,78, optical second harmonic generation as a non-destructive method will be a useful tool for probing ferroelectricity. The ZnO//Pt//Al2O3 case shown here highlights the capability of ♯SHAARP.ml not only in handling various probing geometries (transmission and reflection) that goes beyond the well-established Maker fringes method but also in modeling heterostructures near the Fabry-Perot condition. In particular, the analytical and numerical approaches enabled by ♯SHAARP.ml provide versatile solutions for the purpose of materials characterization and numerical simulation.

Table 2 summarizes the absolute nonlinear optical susceptibilities and their relative ratios of all four crystalline materials obtained from this work and reported in literature. The accuracy of ♯SHAARP.ml is benchmarked, covering single crystals and thin film-based heterostructure, material systems that are highly transparent or reflective, and distinct anisotropy from uniaxial to biaxial optical classes.

SHG active bilayers, LiNbO3//Quartz

The generated SHG signals, in general, contain both amplitude and phase information of materials, such as the direction of a static (zero frequency) spontaneous polarization, Ps, of ferroelectric materials. (Note that this static ferroelectric polarization is distinct from any optical polarization at optical frequencies we have discussed earlier). Two ferroelectric domains with antiparallel spontaneous polarizations (separated by a 180° domain wall) will generate nonlinear optical polarizations with a \({\rm{\pi }}\) phase shift, yet of the same amplitude. Thus, the corresponding SHG intensities are identical for the two domains, leaving the ferroelectric domain state indistinguishable based on the intensity alone16,33,79. The SHG interference contrast imaging has been developed to resolve this issue47,79,80,81,82. In this subsection, we employ ♯SHAARP.ml simulation to illustrate the basic idea of SHG interference contrast imaging, intimately (without an air gap in this example) placing a periodically poled LiNbO3 (\(2\bar{1}\bar{1}0\)) crystal on top of a Z-cut quartz crystal as a model system.

The principle of SHG interference contrast imaging is schematically shown in Fig. 7a, where the red and blue rays are fundamental waves and SHG waves, respectively16,47. An additional quartz is placed beneath the LiNbO3 crystal (abbreviated as LNO) to generate the interference of the nonlinear waves through reflection. The nonlinear waves generated by LiNbO3 (denoted as \({{\bf{k}}}_{{\rm{L}}}^{2\omega }\)) and quartz (denoted as \({{\bf{k}}}_{{\rm{Q}}}^{2\omega }\)) will interfere to resolve the phase information of \({{\bf{k}}}_{{\rm{L}}}^{2\omega }\). Figure 7b shows four cases where Case 1 and 4 involve only LiNbO3 (\(2\bar{1}\bar{1}0\)) crystals with opposite polarization directions and Case 2 and 3 have an identical (001) quartz layer placed under the LiNbO3. The thicknesses of both LiNbO3 and quartz are assumed to be 50 µm and 35 µm, respectively, and the fundamental light is set at normal incidence (\({\theta }^{{\rm{i}}}={0}^{\circ}\)) with a wavelength centered at 1550 nm (\({\lambda }^{\omega }=1550\) nm). Figure 7c, d shows simulation results of the SHG responses for the four cases using ♯SHAARP.ml. The simulated SHG polarimetry responses (\({I}_{{{\rm{L}}}_{1}}^{2\omega }(\varphi )\) and \({I}_{{{\rm{L}}}_{2}}^{2\omega }(\varphi )\)) as a function of the incident optical polarization (\(\varphi\)) is illustrated in Fig. 7c. The pure LNO cases with opposite ferroelectric polarization directions (cases 1 and 4) show identical SHG responses that cannot be distinguished from SHG polarimetry. In contrast, by placing the quartz below the LNO, the corresponding SHG responses between Cases 2 and 3 show a clear change. We pick \({I}_{{{\rm{L}}}_{1}}^{2\omega }(0^{\circ})\) for comparison among the four cases (Fig. 7d) since when \(\varphi =0^{\circ}\), the light polarization at \(\omega\) and \(2\omega\) are parallel to the ferroelectric polarization, Ps, of LiNbO3, giving rise to the largest SHG intensity. The intensities of the SHG waves in Cases 1 and 4 are the same while they are different in Cases 2 and 3. This is because the nonlinear waves generated by LNO (\({{\bf{k}}}_{{\rm{L}}}^{2\omega }\)) and quartz (\({{\bf{k}}}_{{\rm{Q}}}^{2\omega }\)) interfere constructively in Case 2 and destructively in Case 3. Thereby, the two ferroelectric domain states of LiNbO3 can be differentiated by measuring the SHG intensity with the aid of a quartz reference layer. Beyond this example, ♯SHAARP.ml can easily handle extending this problem to include many SHG active layers and with arbitrary direction of ferroelectric polarization as long as each layer is homogeneous.

Fig. 7: Interferences of SHG intensities in LiNbO3 and quartz (001) heterostructures.
figure 7

a The ray diagrams of nonlinear waves in LiNbO3 (LNO) and LiNbO3//quartz. Red is fundamental light, and blue is SHG light. \({{\bf{k}}}_{{\rm{L}}}^{2\omega }\) and \({{\bf{k}}}_{{\rm{Q}}}^{2\omega}\) respectively refer to nonlinear waves generated by LiNbO3 and quartz. b Four cases used in the ♯SHAARP.ml simulation. The LiNbO3 (\(2\bar{1}\bar{1}0\)) and quartz (001) are used. The dark arrows in LiNbO3 indicate polarization directions parallel to the c axis. The dark arrows in quartz indicate the direction of [100]. Both case 2 and 3 use the same quartz for the interference study. c The resulting SHG polar plots for four cases in b, subscripts \({{\rm{L}}}_{1}\) and \({{\rm{L}}}_{2}\) refer to SHG intensities polarized along \({{\bf{L}}}_{{\bf{1}}}\) and \({{\bf{L}}}_{{\bf{2}}}\) directions in b. d The SHG intensity, \({I}_{{{\rm{L}}}_{1}}^{T,2\omega }(\varphi =0^{\circ} )\), for four cases in b.

Twisted bilayer MoS2

Nonlinear optical probes have been widely applied in the studies of two-dimensional material systems due to their sensitivity to structure, orientation, electronic structure, and material compositions. Twisted bilayer MoS2 is one of the examples that contains two SHG active layers that are offset by certain degrees. The SHG signal from these bilayer systems is often modeled as an interference effect between the second harmonic waves arising from each monolayer with a phase difference depending on the twist angle81,83. Figure 8 shows the ♯SHAARP.ml simulation results of twisted bilayer MoS2 for various twist angles (\(\Delta \theta\)) in the rotating polarizer, rotating analyzer configuration (RA) at normal incidence as described in ref. 81. The material orientations and stacking orders are shown in Fig. 8a. The bottom blue layer has a fixed orientation where the b-axis (zig-zag) is placed along the \({{\bf{L}}}_{{\bf{2}}}\) direction (i.e., MoS2(\(\theta =0^{\circ}\))). The top orange layer (MoS2(\(\theta\))) is then rotated counterclockwise by \(\Delta \theta\). The complete stacking order is thus MoS2(\(\theta =\Delta \theta\))//MoS2(\(\theta =0^{\circ}\))//Al2O3(0001). In this case study, the fundamental wavelength is set at 800 nm, where MoS2 remain transparent at \(\omega\) frequency but highly resonating at \(2\omega\) frequency with established refractive indices84,85. Figure 8b illustrates the SHG intensity variations and effective orientation change of monolayer MoS2 with \(\theta =0^{\circ}\) or \(25^{\circ}\) and the bilayer MoS2(\(\theta =25^{\circ}\))//MoS2(\(\theta =0^{\circ}\)). The reflected light with parallel polarizer and analyzer condition is chosen, i.e., \({I}_{\parallel }^{{\rm{R}},2\omega }\). For monolayers, the peaks of the lobes in Fig. 8b are perpendicular to a, b and a + b directions, where a and b are crystallographic lattices. On the other hand, the peaks of bilayers are located between the peaks of monolayers, consistent with the experimental observations81,86. With a thickness of Al2O3 set at 501.93 um, the observed intensity ratio between the bilayer and monolayer is around 2.1, close to the intensity ratio observed experimentally81. It is worth noting that this ratio varies periodically between ~2.1 to ~2.4 with varying Al2O3 thickness (a few hundred micrometers). To further explore the FMR effects induced by the substrate, we use \(\kappa \left(\Delta \theta \right)\equiv \frac{{I}_{{\rm{B}}}-2{I}_{{\rm{M}}}}{2{I}_{{\rm{M}}}}\) as the indicator, where \({I}_{{\rm{B}}}\) and \({I}_{{\rm{M}}}\) are peak intensities of bilayer and monolayer, as depicted in Fig. 8c. In a simplified situation where only the anisotropic SHG tensor is considered, it can be derived that \(\kappa \left(\Delta \theta \right)=\cos 3\Delta \theta\), as indicated by the black curve81. When \(\Delta \theta =0^{\circ}\), the two monolayers are aligned, and the SHG fields thus constructively interfere, generating the maximum reflected intensity. On the other hand, destructive interfere will occur at \(\Delta \theta =60^{\circ}\). Leveraging the partial analytical expression from ♯SHAARP.ml, we found that varying the Al2O3 thickness (500 ± 200 μm) can reduce the total refleted SHG intensity by 7–31% together with the absorption of MoS2 at 2\(\omega\) frequency (using the imaginary dielectric constants of MoS2 as \({\varepsilon }_{{\rm{I}}}^{\omega }=0\) and \({\varepsilon }_{{\rm{I}}}^{2\omega }=14.6)\)84, as shown by the red area. Detailed discussion on the substrate effect can be found in Supplementary Note 7 and Supplementary Fig. 7. Our simulation results using ♯SHAARP.ml reproduced the sign change of \(\kappa\) and indicate that the substrate effect may account for the scattered \(\kappa\) values lying below the \(\cos 3\Delta \theta\) curve as measured in the previous study81.

Fig. 8: SHG polarimetry of twisted bilayer MoS2.
figure 8

a Crystal structure and relative orientations. \(\Delta \theta\) represents the twist angle between the twisted top layer (orange) and the fixed bottom layer (blue). \({L}_{1}\)-\({L}_{2}\) and a-b represents LCS and CCS, respectively. b Resulting reflective SHG polarimetry (\({I}_{\parallel }^{R,2\omega }\)) with parallel polarizer and analyzer conditions, where blue and orange represent monolayers and green stands for the bilayer. \(0^{\circ}\) in the polar plot refers to the electric field parallel to \({L}_{1}\) direction. The triangles indicate the orientations of monolayer MoS2 in panel a. c \(\kappa\) as a function of the twist angle (\(\Delta \theta\)). The red area shows the variation of \(\kappa\) due to absorption of MoS2 and thickness variation of Al2O3 substrate.

Summary

In summary, we have developed a comprehensive theoretical framework and implemented it into an open-source package (♯SHAARP.ml) for nonlinear optical analysis of multilayer systems including slabs and heterostructures, extending the existing capabilities of the prior ♯SHAARP.si package for single-interface systems. In addition to arbitrary materials properties such as symmetry, absorption, orientations, and dispersion, ♯SHAARP.ml also allows multiple reflections of both inhomogeneous and homogeneous waves at \(\omega\) and \(2\omega\) frequency, editable heterostructure schemes for versatile materials systems, integrated Maker fringes and polarimetry capabilities, and flexible probing conditions for both transmission and reflection geometries. The experimental and theoretical analyses based on various nonlinear optical crystals and multilayers help validate the capabilities and accuracy of ♯SHAARP.ml in the determination of nonlinear optical susceptibilities, crystal symmetries, and ferroelectric polarization directions. Seven material systems, namely α-quartz, α-quartz with Au coating, LiNbO3, KTP, ZnO//Pt//Al2O3, LiNbO3//α-quartz and twisted bilayer MoS2 are chosen to benchmark ♯SHAARP.ml against our experimental measurements. The resulting absolute nonlinear optical susceptibilities and their relative ratios show excellent agreement with the reported values. The successful demonstrations for the quartz+Au and ZnO//Pt//Al2O3 cases highlight the capabilities of modeling multiple reflection in a near Fabry-Perot condition. The simulation of a bilayer system with two SHG active media reveals the ability to accurately model SHG interference contrast imaging of otherwise undifferentiable ferroelectric domain states. The combined Maker fringes and SHG polarimetry capabilities of ♯SHAARP.ml make it a comprehensive analytical modeling tool for the optical metrology of new materials and heterostructures.

Looking forward, we expect that ♯SHAARP.ml can broadly streamline research in nonlinear optics. The complete and accurate analytical framework with editable assumptions from ♯SHAARP.ml can provide nonlinear optical solutions in an on-demand modality. As more integrated nonlinear optical devices and topological superlattices are being developed, the capability of modeling these heterostructure can thus be an effective way to design, characterize, and optimize nonlinear optical response from complex systems. Furthermore, ♯SHAARP.ml provides a programmable platform for future extensions to more functionalities, such as other three-wave mixing processes, magnetic-dipole or quadrupole induced nonlinear optical effects, Gaussian beams with finite beam size, and inhomogeneous material systems.

Methods

Sample preparation

Both α-quartz and LiNbO3 single crystals were obtained from MTI Corporation. The (\(11\bar{2}0\)) and (\(0001\)) oriented LiNbO3, namely X-cut and Z-cut, were utilized in the analysis. Since the definition of X-cut LiNbO3 from MTI is distinct from the orientations used in other analyses87,88, we have used the Miller indices for clarity. The X-cut and Y-cut KTP crystals were obtained from CASTECH Inc (Conex Systems Technology, Inc.). The ZnO//Pt//Al2O3 was prepared using RF magnetron sputtering, and the detailed growth procedure can be found in the earlier work45.

Second-harmonic generation

The second harmonic generation measurements were performed using a Ti: Sapphire femtosecond laser system with the central wavelength at 800 nm (1 kHz, 100 fs). The 1550 nm (1 kHz, 100 fs) was generated through an optical parametric amplifier, pumped by the 800 nm amplified laser. The SHG polarimetry measurements were performed using a combination of a zero-order half waveplate for the incident beam and an analyzer for the SHG signals. The polarization (azimuthal angle \(\varphi\)) of the incident linearly polarized light was rotated by the half-wave plate. The analyzer was set either parallel or perpendicular to PoI, equivalent to p- and s- polarized SHG, respectively. The polarized SHG was then filtered by the band pass filter to avoid additional spectrum contribution from the laser and samples. The Maker fringes measurements were performed by tilting samples while keeping incident and detecting polarization fixed. The rotation center of the sample stage is confirmed to be along the beam path to minimize the beam drift during the experiment. A photomultiplier tube (PMT) was used to collect SHG signals. The detected signals were further processed by the lock-in amplifier (SR830) to remove additional noise before feeding into the home-developed LabView program. The SHG fittings were then conducted using the expression generated by the ♯SHAARP.ml. All the SHG coefficients from the literature are recalibrated using Miller’s rule before the comparison89.