.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/transmission_element.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_transmission_element.py: Transmission element ==================== Example to demonstrate the flexibility of SRW propagation with the definition of a custom transmission element, given its transmissivity and phase delay. This specific example involves the creation of a four-quadrant phase mask, a special type of waveplate that delays by :math:`\pi` two half planes of the wavefront. .. GENERATED FROM PYTHON SOURCE LINES 13-14 Import libraries required for simulation .. GENERATED FROM PYTHON SOURCE LINES 14-21 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import pysrw as srw .. GENERATED FROM PYTHON SOURCE LINES 23-26 Create the wavefront arriving at the first plane of the optical system with parameters similar to :doc:`simple_propagation`. For this example we use a Gaussian beam instead of the point source. .. GENERATED FROM PYTHON SOURCE LINES 26-38 .. code-block:: Python ptSrc = srw.emitters.GaussianBeam() observer = srw.wavefronts.Observer(centerCoord=[0, 0, .5], obsXextension=5e-3, obsYextension=5e-3, obsXres=1e-6, obsYres=1e-6) wfr = srw.computeGsnBeamWfr(ptSrc, observer, wavelength=600) srw.plotI(wfr.getWfrI()) .. image-sg:: /examples/images/sphx_glr_transmission_element_001.png :alt: transmission element :srcset: /examples/images/sphx_glr_transmission_element_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-41 The optical system consists of the phase mask with its aperture, a lens and a drift to focus the light. .. GENERATED FROM PYTHON SOURCE LINES 41-47 .. code-block:: Python w = 1e-3 f = 50e-3 s1 = observer.zPos s2 = s1 * f / (s1 - f) .. GENERATED FROM PYTHON SOURCE LINES 48-52 The transmission element is created passing a matrix for the optical path difference (in nm) amd one for the amplitude. Note that the initial extension of this matrices is not important, because the actual extension of the optical element will be given by its 'extension' value. .. GENERATED FROM PYTHON SOURCE LINES 52-58 .. code-block:: Python xx, yy = np.meshgrid(np.linspace(-1, 1, 1001), np.linspace(-1, 1, 1001)) opd = np.where(xx * yy > 0, wfr.wavelength / 2, 0) amp = np.ones(np.shape(xx)) .. GENERATED FROM PYTHON SOURCE LINES 59-61 The mask is placed in the optical system dictionary as a standard optical element, specifying the 'transmission' type. .. GENERATED FROM PYTHON SOURCE LINES 61-89 .. code-block:: Python optSystem = { "aperture": { "type": "rectAp", "extension": [w, w], "centre": [0,0] }, "mask": { "type": "transmission", "extension": [w, w], "centre": [0,0], "opd": opd, "amp": amp }, "lens": { "type": "lens", "f": f, "centre": [0,0] }, "image": { "type": "drift", "length": s2, "resParam": {"hRangeChange": 1/10, "hResChange": 1.0, "vRangeChange": 1/10, "vResChange": 1.0, "hCentreChange": 0.0, "vCentreChange": 0.0} }, } .. GENERATED FROM PYTHON SOURCE LINES 90-94 We finally propagate the field and plot the intensity at the image plane. One can clearly observe that the intensity has two nodes along the vertical and horizontal axis, corresponding to the region of destructive interference created by the phase mask. .. GENERATED FROM PYTHON SOURCE LINES 94-98 .. code-block:: Python propData = srw.propagateWfr(wfr, optSystem, saveWfrAt=optSystem.keys()) srw.plotI(propData["image"]["intensity"]) .. image-sg:: /examples/images/sphx_glr_transmission_element_002.png :alt: transmission element :srcset: /examples/images/sphx_glr_transmission_element_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 99-102 It is also possible to extract and plot the wavefront phase downstream of the mask. The :math:`\pi` phase jump is indeed present, on top of the circular modulation of the phase due to the spherical wavefront. .. GENERATED FROM PYTHON SOURCE LINES 102-106 .. code-block:: Python phase = propData["mask"]["wfr"].getWfrPhase() srw.plotI(phase) .. image-sg:: /examples/images/sphx_glr_transmission_element_003.png :alt: transmission element :srcset: /examples/images/sphx_glr_transmission_element_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 37.886 seconds) .. _sphx_glr_download_examples_transmission_element.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: transmission_element.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: transmission_element.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_