jonschlipf / RigorousCoupledWaveAnalysis.jl

Rigorous Coupled-Wave Analysis (RCWA) for nanophotonics simulations
GNU General Public License v3.0
33 stars 7 forks source link

Inconsistent results when substrate material is added as a layer in front #7

Closed wschmail closed 5 months ago

wschmail commented 5 months ago

Hi,

Thanks for creating this nice Julia package!

I have tried a few structures and stumbled upon an example where the results seem counterintuitive. Maybe I'm not defining it correctly, or maybe it's a bug.

Below is the MWE:

using RigorousCoupledWaveAnalysis
using CairoMakie

Air = ConstantPerm(1)
Si = InterpolPerm(RigorousCoupledWaveAnalysis.si_schinke)
SiO2 = ModelPerm(RigorousCoupledWaveAnalysis.sio2_malitson)
Al = ModelPerm(RigorousCoupledWaveAnalysis.al_rakic)
sio2 = SimpleLayer(50, SiO2)
si = SimpleLayer(12000, Si)
al = SimpleLayer(200, Al)

N = 1
λs = 600:0.2:950
Rtms = zeros(length(λs))
Rtes = zeros(length(λs))
θ = 1E-5
α = 0
ax = ay = 500

# ---------------------------------------------- #
# Two variants that produce different results
# ---------------------------------------------- #
Mdl_1 = RCWAModel([sio2, si], Air, Al)
Mdl_2 = RCWAModel([sio2, si, al], Air, Al)

Mdl = Mdl_2;title = "Mdl_2";
Mdl = Mdl_1;title = "Mdl_1";
# ---------------------------------------------- #
for (i, λ) in enumerate(λs)

    Grd = rcwagrid(N, N, ax, ay, θ, α, λ, Air)
    ste, stm = rcwasource(Grd)
    # Rte, Tte = srcwa_reftra(ste, Mdl, Grd, λ)
    Rte, Tte, fte = etm_reftra_flows(ste, Mdl, Grd, λ)
    # Rtm, Ttm = srcwa_reftra(stm, Mdl, Grd, λ)
    Rtm, Ttn, ftm = etm_reftra_flows(stm, Mdl, Grd, λ)
    Rtes[i] = Rte
    Rtms[i] = Rtm
end

fig = Figure()
ax = Axis(fig[1, 1]; title=title, limits=(λs[1], λs[end], 0, 1), xlabel="Wavelength (nm)", ylabel="Reflectance")
lines!(ax, λs, Rtes)
# lines!(ax, λs, Rtms)
fig
image image

As I understand it, both model definitions should result in the same reflectance values. Am I doing something wrong?

Thanks!

jonschlipf commented 5 months ago

Hi,

Thank you for pointing this out. This is issue is due to the fact that I did not consider lossy substrates and superstrates. What the algorithm does is take only the real part of the refractive index for the substrate and superstrate. For substrates with significant loss, this naturally leads to an incorrect interface reflection.

I have committed a solution to the master branch: https://github.com/jonschlipf/RigorousCoupledWaveAnalysis.jl/commit/b013a081d65c2ef2e185015afa07301170b6f8a6

It appears to make your minimum example work, giving the result of your Model_2 plot and agreeing nicely with the Filmetrics online calculator. You can get the new changes by installing the package via the github URL instead of the julia registry. If you have time, please test it. I am planning a new official release by the end of the month, so this will be included if it works well.

By the way, if you want to solve 1D systems without lateral structuring, you could also compute with N=0 instead of N=1 for a tiny bit of speed.

wschmail commented 5 months ago

I changed the line of code in Common.jl that you suggested, and now both models give exactly the same results. Thanks for the quick response and fix!