Note
Go to the end to download the full example code. or to run this example in your browser via Binder
Photonic crystal slab#
Metasurface with holes.
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import nannos as nn
We will study a benchmark of hole in a dielectric surface similar to those studied in [Fan2002].
Define the lattice
lattice = nn.Lattice([[1.0, 0], [0, 1.0]], discretization=(2**9, 2**9))
Define the layers
sup = lattice.Layer("Superstrate", epsilon=1)
ms = lattice.Layer("Metasurface", thickness=0.5)
sub = lattice.Layer("Substrate", epsilon=1)
Define the pattern and add it to the metasurface layer
ms.epsilon = lattice.ones() * 12.0
circ = lattice.circle(center=(0.5, 0.5), radius=0.2)
ms.epsilon[circ] = 1
Visualize the permittivity
plt.figure()
cmap = mpl.colors.ListedColormap(["#ffe7c2", "#232a4e"])
bounds = [1, 12]
norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
ims = ms.plot(cmap=cmap, ax=plt.gca())
plt.axis("scaled")
plt.colorbar(ims[0], ticks=bounds)
plt.xlabel("$x$")
plt.ylabel("$y$")
plt.title(r"permittitivity $\varepsilon(x,y)$")
plt.tight_layout()
plt.show()
Define the incident plane wave
pw = nn.PlaneWave(wavelength=1 / 1.4, angles=(0, 0, 0))
Define the simulation
stack = [sup, ms, sub]
sim = nn.Simulation(stack, pw, nh=100)
Compute diffraction efficiencies
Compute diffraction efficiencies per order
Ri = [ 6.77626358e-21 2.37169225e-20 -3.04931861e-20 -2.87991202e-20
-9.61418648e-22]
Ti = [-4.44692297e-21 -1.84229666e-20 -2.71050543e-20 8.47032947e-21
1.19916752e-21]
R = 0.5255529342260137
T = 0.47444706577398366
R+T = 0.9999999999999973
Plot
fig, (axR, axT) = plt.subplots(1, 2, figsize=(4, 2))
labels = [f"({g[0]},{g[1]})" for g in (sim.harmonics[:, :nmax]).T]
axR.bar(range(nmax), Ri[:nmax], color=["#e69049"])
axR.set_xticks(range(nmax))
axR.set_xticklabels(labels=labels)
axR.set_xlabel("order")
axR.set_ylabel("reflection $R_{i,j}$")
axR.annotate(
r"$R = \sum_i\,\sum_j\, R_{i,j}=$" + f"{sum(Ri[:nmax]):0.4f}",
(0.5, 0.9),
xycoords="axes fraction",
)
axT.bar(range(nmax), Ti[:nmax], color=["#4a77ba"])
axT.set_xticks(range(nmax))
axT.set_xticklabels(labels=labels)
axT.set_xlabel("order")
axT.set_ylabel("transmission $T_{i,j}$")
axT.annotate(
r"$T =\sum_i\,\sum_j\, T_{i,j}=$" + f"{sum(Ti[:nmax]):0.4f}",
(0.5, 0.9),
xycoords="axes fraction",
)
plt.suptitle(f"Diffraction efficiencies: $R+T=${sum(Ri[:nmax] + Ti[:nmax]):0.4f}")
plt.tight_layout()
plt.show()
Fig 12 (c) from [Fan2002].
def compute_transmission(fn):
pw = nn.PlaneWave(wavelength=1 / fn, angles=(0, 0, 0))
sim = nn.Simulation(stack, pw, 100)
R, T = sim.diffraction_efficiencies()
print(f"f = {fn} (normalized)")
print("T = ", T)
return T
freqs_norma = np.linspace(0.25, 0.6, 100)
freqs_adapted, transmission = nn.adaptive_sampler(
compute_transmission,
freqs_norma,
)
plt.figure()
plt.plot(freqs_adapted, transmission, c="#be4c83")
plt.xlim(freqs_norma[0], freqs_norma[-1])
plt.ylim(0, 1)
plt.xlabel(r"frequency ($2\pi c / a$)")
plt.ylabel("Transmission")
plt.tight_layout()
f = 0.25 (normalized)
T = 0.5871769954230958
f = 0.25353535353535356 (normalized)
T = 0.6127114048067472
f = 0.25707070707070706 (normalized)
T = 0.6397742448919543
f = 0.2606060606060606 (normalized)
T = 0.6682915971742557
f = 0.2641414141414141 (normalized)
T = 0.6981339912261155
f = 0.2676767676767677 (normalized)
T = 0.729103454011132
f = 0.27121212121212124 (normalized)
T = 0.7609202977021531
f = 0.27474747474747474 (normalized)
T = 0.7932109710789937
f = 0.2782828282828283 (normalized)
T = 0.8254988935998094
f = 0.2818181818181818 (normalized)
T = 0.8572007710494809
f = 0.28535353535353536 (normalized)
T = 0.8876312892712366
f = 0.28888888888888886 (normalized)
T = 0.9160190597315638
f = 0.2924242424242424 (normalized)
T = 0.9415359815185509
f = 0.295959595959596 (normalized)
T = 0.9633405904476421
f = 0.2994949494949495 (normalized)
T = 0.9806334964445885
f = 0.30303030303030304 (normalized)
T = 0.9927200164792702
f = 0.30656565656565654 (normalized)
T = 0.999072323283492
f = 0.3101010101010101 (normalized)
T = 0.999381811999393
f = 0.3136363636363636 (normalized)
T = 0.9935927797983551
f = 0.31717171717171716 (normalized)
T = 0.9819112119188917
f = 0.3207070707070707 (normalized)
T = 0.9647869524753525
f = 0.3242424242424242 (normalized)
T = 0.9428725796644448
f = 0.3277777777777778 (normalized)
T = 0.9169664379766085
f = 0.33131313131313134 (normalized)
T = 0.887949416577712
f = 0.33484848484848484 (normalized)
T = 0.8567249036442024
f = 0.3383838383838384 (normalized)
T = 0.824169397999379
f = 0.3419191919191919 (normalized)
T = 0.7910985213761828
f = 0.34545454545454546 (normalized)
T = 0.7582507389776987
f = 0.34898989898989896 (normalized)
T = 0.7262899225643585
f = 0.3525252525252525 (normalized)
T = 0.6958289506392602
f = 0.3560606060606061 (normalized)
T = 0.6674815940091826
f = 0.3595959595959596 (normalized)
T = 0.6419638910047187
f = 0.36313131313131314 (normalized)
T = 0.6203051632381306
f = 0.36666666666666664 (normalized)
T = 0.6043531734427654
f = 0.3702020202020202 (normalized)
T = 0.5982443206163617
f = 0.3737373737373737 (normalized)
T = 0.6140718049660813
f = 0.37727272727272726 (normalized)
T = 0.7070360917222199
f = 0.3808080808080808 (normalized)
T = 0.5606113983011991
f = 0.3843434343434343 (normalized)
T = 0.19219542508035714
f = 0.3878787878787879 (normalized)
T = 0.2776103455526068
f = 0.39141414141414144 (normalized)
T = 0.29591420578280947
f = 0.39494949494949494 (normalized)
T = 0.2945364228287613
f = 0.39848484848484844 (normalized)
T = 0.28325183403172194
f = 0.402020202020202 (normalized)
T = 0.2628201220916335
f = 0.40555555555555556 (normalized)
T = 0.2262594024232491
f = 0.40909090909090906 (normalized)
T = 0.1391573280911514
f = 0.4126262626262626 (normalized)
T = 0.6120190949984275
f = 0.4161616161616162 (normalized)
T = 0.5306604288003999
f = 0.4196969696969697 (normalized)
T = 0.4126728834534292
f = 0.4232323232323232 (normalized)
T = 0.37064030318478525
f = 0.4267676767676768 (normalized)
T = 0.34804481739823356
f = 0.4303030303030303 (normalized)
T = 0.33347468601917996
f = 0.4338383838383838 (normalized)
T = 0.32317042487058567
f = 0.43737373737373736 (normalized)
T = 0.3155390061122447
f = 0.4409090909090909 (normalized)
T = 0.30979225635678775
f = 0.4444444444444444 (normalized)
T = 0.3054976988313594
f = 0.447979797979798 (normalized)
T = 0.302400872165184
f = 0.45151515151515154 (normalized)
T = 0.3003455402617778
f = 0.45505050505050504 (normalized)
T = 0.2992343822863914
f = 0.45858585858585854 (normalized)
T = 0.29900825823682053
f = 0.4621212121212121 (normalized)
T = 0.2996347399215036
f = 0.46565656565656566 (normalized)
T = 0.30110159626718225
f = 0.46919191919191916 (normalized)
T = 0.3034130782711382
f = 0.4727272727272727 (normalized)
T = 0.3065878126138381
f = 0.4762626262626263 (normalized)
T = 0.3106574751269153
f = 0.4797979797979798 (normalized)
T = 0.3156652943484792
f = 0.4833333333333333 (normalized)
T = 0.32166250094015464
f = 0.4868686868686869 (normalized)
T = 0.32869767420881735
f = 0.4904040404040404 (normalized)
T = 0.33678308365847126
f = 0.4939393939393939 (normalized)
T = 0.3457790155199464
f = 0.49747474747474746 (normalized)
T = 0.35491609328671003
f = 0.501010101010101 (normalized)
T = 0.35986977435696044
f = 0.5045454545454545 (normalized)
T = 0.28649294081828475
f = 0.5080808080808081 (normalized)
T = 0.4823425282154299
f = 0.5116161616161616 (normalized)
T = 0.49248429588328124
f = 0.5151515151515151 (normalized)
T = 0.5433840623044776
f = 0.5186868686868686 (normalized)
T = 0.6468899018461377
f = 0.5222222222222221 (normalized)
T = 0.888874020316687
f = 0.5257575757575758 (normalized)
T = 0.398994493620005
f = 0.5292929292929293 (normalized)
T = 0.02433686176825547
f = 0.5328282828282829 (normalized)
T = 0.10000592162385782
f = 0.5363636363636364 (normalized)
T = 0.0700708655975761
f = 0.5398989898989899 (normalized)
T = 0.33705772644704046
f = 0.5434343434343434 (normalized)
T = 0.842135232411078
f = 0.5469696969696969 (normalized)
T = 0.7055844894301483
f = 0.5505050505050505 (normalized)
T = 0.683310106833747
f = 0.554040404040404 (normalized)
T = 0.6940404245552357
f = 0.5575757575757576 (normalized)
T = 0.7184230399653498
f = 0.5611111111111111 (normalized)
T = 0.7498154939251622
f = 0.5646464646464646 (normalized)
T = 0.7850997838538093
f = 0.5681818181818181 (normalized)
T = 0.8222992583075877
f = 0.5717171717171716 (normalized)
T = 0.8597839791288094
f = 0.5752525252525252 (normalized)
T = 0.8959690636966311
f = 0.5787878787878787 (normalized)
T = 0.9292125956991646
f = 0.5823232323232324 (normalized)
T = 0.9578207136846666
f = 0.5858585858585859 (normalized)
T = 0.9801232109557064
f = 0.5893939393939394 (normalized)
T = 0.9945939623390158
f = 0.5929292929292929 (normalized)
T = 0.999985894805802
f = 0.5964646464646464 (normalized)
T = 0.9954428166730076
f = 0.6 (normalized)
T = 0.9805477501576467
f = 0.37550505050505045 (normalized)
T = 0.6422751427019138
f = 0.37904040404040407 (normalized)
T = 0.8746179191976698
f = 0.38611111111111107 (normalized)
T = 0.25052794505143033
f = 0.3896464646464647 (normalized)
T = 0.29052496742822675
f = 0.4037878787878788 (normalized)
T = 0.24752526999828614
f = 0.4108585858585858 (normalized)
T = 0.03403613566879883
f = 0.4143939393939394 (normalized)
T = 0.7362427632801761
f = 0.42146464646464643 (normalized)
T = 0.387794502249051
f = 0.49924242424242427 (normalized)
T = 0.3586124826235992
f = 0.5063131313131313 (normalized)
T = 0.5720382224155343
f = 0.5133838383838384 (normalized)
T = 0.5134913358948184
f = 0.5169191919191919 (normalized)
T = 0.5854679438714192
f = 0.5204545454545454 (normalized)
T = 0.7415878112612226
f = 0.523989898989899 (normalized)
T = 0.9920637788857214
f = 0.531060606060606 (normalized)
T = 0.07203741413490297
f = 0.5381313131313131 (normalized)
T = 0.0049241853122052445
f = 0.5416666666666666 (normalized)
T = 0.9964957065437643
f = 0.5452020202020201 (normalized)
T = 0.7479809307026332
f = 0.5487373737373737 (normalized)
T = 0.6879413253464386
f = 0.3763888888888889 (normalized)
T = 0.6677203725163371
f = 0.37815656565656564 (normalized)
T = 0.7702811331981976
f = 0.38257575757575757 (normalized)
T = 0.05778525642002937
f = 0.3869949494949495 (normalized)
T = 0.26652064265680725
f = 0.4073232323232323 (normalized)
T = 0.19414626426249867
f = 0.41174242424242424 (normalized)
T = 0.011212128215431431
f = 0.413510101010101 (normalized)
T = 0.9588348527680468
f = 0.41792929292929293 (normalized)
T = 0.4528982735939771
f = 0.5027777777777778 (normalized)
T = 0.3525198703270333
f = 0.5071969696969697 (normalized)
T = 0.49979581508451276
f = 0.5098484848484849 (normalized)
T = 0.480043570339786
f = 0.5178030303030303 (normalized)
T = 0.6130961310457648
f = 0.519570707070707 (normalized)
T = 0.6888413297413573
f = 0.5213383838383838 (normalized)
T = 0.8080437936735201
f = 0.5231060606060606 (normalized)
T = 0.9712916887010835
f = 0.5275252525252525 (normalized)
T = 0.009357592205174849
f = 0.5345959595959596 (normalized)
T = 0.10194853353497961
f = 0.5390151515151516 (normalized)
T = 0.028943268359501693
f = 0.5407828282828282 (normalized)
T = 0.8743753145981669
f = 0.5425505050505051 (normalized)
T = 0.9208016480481417
f = 0.5443181818181817 (normalized)
T = 0.7859645754432506
f = 0.5460858585858586 (normalized)
T = 0.7225117902763867
f = 0.3777146464646465 (normalized)
T = 0.7347561942059524
f = 0.37859848484848485 (normalized)
T = 0.8161176693170122
f = 0.37992424242424244 (normalized)
T = 0.9980264765673615
f = 0.3816919191919192 (normalized)
T = 0.005722699085214214
f = 0.38345959595959594 (normalized)
T = 0.13842413907085174
f = 0.3852272727272727 (normalized)
T = 0.227163315385236
f = 0.4082070707070707 (normalized)
T = 0.17080529450992182
f = 0.40997474747474744 (normalized)
T = 0.09466771883879016
f = 0.411300505050505 (normalized)
T = 0.005453530404000098
f = 0.41306818181818183 (normalized)
T = 0.9771548039717054
f = 0.4139520202020202 (normalized)
T = 0.8391308654103139
f = 0.4152777777777778 (normalized)
T = 0.6047136674040706
f = 0.41704545454545455 (normalized)
T = 0.48439090250076194
f = 0.4188131313131313 (normalized)
T = 0.4300548989682276
f = 0.5036616161616161 (normalized)
T = 0.337240059569688
f = 0.505429292929293 (normalized)
T = 0.08279924215554361
f = 0.507638888888889 (normalized)
T = 0.48839935838241944
f = 0.5235479797979798 (normalized)
T = 0.9970731029642242
f = 0.5248737373737373 (normalized)
T = 0.8011552478765056
f = 0.5266414141414142 (normalized)
T = 0.10706549548261081
f = 0.5284090909090908 (normalized)
T = 0.003118475891013855
f = 0.5372474747474747 (normalized)
T = 0.03856671596059672
f = 0.5385732323232324 (normalized)
T = 0.000942469956856858
f = 0.540340909090909 (normalized)
T = 0.6302686912310151
f = 0.5412247474747474 (normalized)
T = 0.9853500471918629
f = 0.5421085858585859 (normalized)
T = 0.9642865803401948
f = 0.5447601010101009 (normalized)
T = 0.7650909815618256
f = 0.38036616161616166 (normalized)
T = 0.9278162484794771
f = 0.3821338383838384 (normalized)
T = 0.014295425440381865
f = 0.38301767676767673 (normalized)
T = 0.1015327563872723
f = 0.38390151515151516 (normalized)
T = 0.16825019537573588
f = 0.3847853535353535 (normalized)
T = 0.21149560904083703
f = 0.4121843434343434 (normalized)
T = 0.1614082238958865
f = 0.41284722222222225 (normalized)
T = 0.8490751144293848
f = 0.4137310606060606 (normalized)
T = 0.8997061981755153
f = 0.4148358585858586 (normalized)
T = 0.660365196938165
f = 0.415719696969697 (normalized)
T = 0.5629234916043064
f = 0.41660353535353534 (normalized)
T = 0.5051016977846264
f = 0.5041035353535352 (normalized)
T = 0.32032300692968624
f = 0.5049873737373738 (normalized)
T = 0.19964347528773527
f = 0.5067550505050504 (normalized)
T = 0.521994466644581
f = 0.5226641414141413 (normalized)
T = 0.9319463803864837
f = 0.5244318181818182 (normalized)
T = 0.9327263507610333
f = 0.5253156565656565 (normalized)
T = 0.6079068528680843
f = 0.526199494949495 (normalized)
T = 0.22477793761451909
f = 0.5279671717171717 (normalized)
T = 0.00015180527598462437
f = 0.5394570707070707 (normalized)
T = 0.12716443135400715
f = 0.5410037878787878 (normalized)
T = 0.9461737538803555
f = 0.541445707070707 (normalized)
T = 0.9994265222676755
f = 0.3794823232323232 (normalized)
T = 0.9437635404697714
f = 0.3801452020202021 (normalized)
T = 0.9909240447885453
f = 0.38125 (normalized)
T = 0.1466622700972987
f = 0.41152146464646466 (normalized)
T = 2.1291413133681646e-05
f = 0.412405303030303 (normalized)
T = 0.35258010234993525
f = 0.4132891414141414 (normalized)
T = 0.997569473268187
f = 0.5047664141414141 (normalized)
T = 0.2547700045752462
f = 0.5058712121212121 (normalized)
T = 0.7362801443616881
f = 0.5069760101010101 (normalized)
T = 0.5089497098197782
f = 0.5242108585858586 (normalized)
T = 0.9706828547572688
f = 0.5246527777777777 (normalized)
T = 0.876239551780435
f = 0.5250946969696969 (normalized)
T = 0.709993196074382
f = 0.5259785353535353 (normalized)
T = 0.30536769085056314
f = 0.5270833333333333 (normalized)
T = 0.040357514870284
f = 0.5392361111111111 (normalized)
T = 0.06623771442318938
f = 0.5396780303030303 (normalized)
T = 0.21706904854685846
f = 0.5405618686868686 (normalized)
T = 0.767026193103546
f = 0.3797032828282828 (normalized)
T = 0.9765523265577749
f = 0.38058712121212124 (normalized)
T = 0.7819896036886403
f = 0.38147095959595956 (normalized)
T = 0.045921433868968436
f = 0.38191287878787883 (normalized)
T = 0.001148547241296023
f = 0.4119633838383838 (normalized)
T = 0.056066381216895216
f = 0.5056502525252525 (normalized)
T = 0.97843118105301
f = 0.5060921717171717 (normalized)
T = 0.6257693718256032
f = 0.5065340909090909 (normalized)
T = 0.541366038454838
f = 0.5268623737373738 (normalized)
T = 0.06824499393820634
f = 0.5273042929292929 (normalized)
T = 0.021358217324820596
f = 0.3810290404040404 (normalized)
T = 0.3255195343357858
f = 0.5052083333333334 (normalized)
T = 0.09214826034036697
f = 0.5264204545454546 (normalized)
T = 0.15876940373716028
Total running time of the script: (0 minutes 39.270 seconds)
Estimated memory usage: 519 MB