.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/basic/plot_conversion_eff.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_basic_plot_conversion_eff.py: Polarization conversion ========================= Simulation of conversion efficiency of a geometric metasurface. .. GENERATED FROM PYTHON SOURCE LINES 15-21 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import nannos as nn .. GENERATED FROM PYTHON SOURCE LINES 22-26 The unit cell is a rectangular Si structure on a SiO2 substrate as in :cite:p:`Yoon2021`. Circularly-polarized light of wavelength 635 nm is normally incident from the substrate to the structure .. GENERATED FROM PYTHON SOURCE LINES 26-36 .. code-block:: Python wl = 635 # wavelength P = 350 # period W = 100 # pillar width along x L = 190 # pillar length along y eps_Si = (3.87 + 0.02j) ** 2 eps_SiO2 = 1.4573**2 nh = 100 .. GENERATED FROM PYTHON SOURCE LINES 37-38 Define a function to initialize simulation .. GENERATED FROM PYTHON SOURCE LINES 38-52 .. code-block:: Python def simu(H, psi): lattice = nn.Lattice([[P, 0], [0, P]], discretization=2**9) sup = lattice.Layer("Superstrate", epsilon=eps_SiO2) sub = lattice.Layer("Substrate", epsilon=1) epsilon = lattice.ones() metaatom = lattice.rectangle((0.5 * P, 0.5 * P), (W, L)) epsilon[metaatom] = eps_Si ms = lattice.Layer("Metasurface", thickness=H, epsilon=epsilon) pw = nn.PlaneWave(wavelength=wl, angles=(0, 0, psi)) return nn.Simulation([sup, ms, sub], pw, nh=nh) .. GENERATED FROM PYTHON SOURCE LINES 53-55 Since the layer eigenmodes do not change with thickness we compute them only once for the first iteration. .. GENERATED FROM PYTHON SOURCE LINES 55-83 .. code-block:: Python nb_thick = 100 thicknesses = np.linspace(200, 500, nb_thick) conv_effs = np.zeros(nb_thick) for ih, H in enumerate(thicknesses): # x-polarization if ih == 0: simx = simu(H, 0) else: simx.layers[1].thickness = H simx.reset("S") rxi, txi = simx.diffraction_efficiencies(orders=True, complex=True) txx = simx.get_order(txi[0], (0, 0)) # y-polarization if ih == 0: simy = simu(H, 90) else: simy.layers[1].thickness = H # print(self.is_solved) simy.reset("S") ryi, tyi = simy.diffraction_efficiencies(orders=True, complex=True) tyy = simy.get_order(tyi[1], (0, 0)) conv_effs[ih] = np.abs((tyy - txx) / 2) ** 2 .. GENERATED FROM PYTHON SOURCE LINES 84-85 Plot the efficiency .. GENERATED FROM PYTHON SOURCE LINES 85-94 .. code-block:: Python plt.clf() plt.plot(thicknesses, conv_effs) plt.xlabel("H (nm)") plt.ylabel("conversion efficiency") plt.tight_layout() plt.show() .. image-sg:: /examples/basic/images/sphx_glr_plot_conversion_eff_001.png :alt: plot conversion eff :srcset: /examples/basic/images/sphx_glr_plot_conversion_eff_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 95-96 Plot the unit cell .. GENERATED FROM PYTHON SOURCE LINES 96-100 .. code-block:: Python p = simx.plot_structure() p.show_axes() p.show() .. image-sg:: /examples/basic/images/sphx_glr_plot_conversion_eff_002.png :alt: plot conversion eff :srcset: /examples/basic/images/sphx_glr_plot_conversion_eff_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 27.391 seconds) **Estimated memory usage:** 757 MB .. _sphx_glr_download_examples_basic_plot_conversion_eff.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/nannos/nannos.gitlab.io/doc?filepath=notebooks/examples/basic/plot_conversion_eff.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_conversion_eff.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_conversion_eff.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_conversion_eff.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_