{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Transmission element\n\nExample to demonstrate the flexibility of SRW propagation with the definition \nof a custom transmission element, given its transmissivity and phase delay.\nThis specific example involves the creation of a four-quadrant phase mask, a\nspecial type of waveplate that delays by $\\pi$ two half planes of \nthe wavefront.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import libraries required for simulation\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nimport pysrw as srw" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create the wavefront arriving at the first plane of the optical system with \nparameters similar to :doc:`simple_propagation`. For this example we use a \nGaussian beam instead of the point source.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ptSrc = srw.emitters.GaussianBeam()\n\nobserver = srw.wavefronts.Observer(centerCoord=[0, 0, .5],\n obsXextension=5e-3, \n obsYextension=5e-3,\n obsXres=1e-6,\n obsYres=1e-6)\n\nwfr = srw.computeGsnBeamWfr(ptSrc, observer, wavelength=600)\nsrw.plotI(wfr.getWfrI())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The optical system consists of the phase mask with its aperture, a lens and \na drift to focus the light.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "w = 1e-3\nf = 50e-3\ns1 = observer.zPos\ns2 = s1 * f / (s1 - f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The transmission element is created passing a matrix for the optical path \ndifference (in nm) amd one for the amplitude. Note that the initial extension\n of this matrices is not important, because the actual extension of the \noptical element will be given by its 'extension' value.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "xx, yy = np.meshgrid(np.linspace(-1, 1, 1001), np.linspace(-1, 1, 1001))\n\nopd = np.where(xx * yy > 0, wfr.wavelength / 2, 0)\namp = np.ones(np.shape(xx))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The mask is placed in the optical system dictionary as a standard optical \nelement, specifying the 'transmission' type.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "optSystem = {\n \"aperture\": {\n \"type\": \"rectAp\",\n \"extension\": [w, w],\n \"centre\": [0,0]\n },\n \"mask\": {\n \"type\": \"transmission\",\n \"extension\": [w, w],\n \"centre\": [0,0],\n \"opd\": opd,\n \"amp\": amp\n },\n \"lens\": {\n \"type\": \"lens\",\n \"f\": f,\n \"centre\": [0,0]\n }, \n \"image\": {\n \"type\": \"drift\",\n \"length\": s2,\n \"resParam\": {\"hRangeChange\": 1/10, \"hResChange\": 1.0,\n \"vRangeChange\": 1/10, \"vResChange\": 1.0,\n \"hCentreChange\": 0.0, \"vCentreChange\": 0.0}\n },\n}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We finally propagate the field and plot the intensity at the image plane. \nOne can clearly observe that the intensity has two nodes along the vertical \nand horizontal axis, corresponding to the region of destructive interference\ncreated by the phase mask.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "propData = srw.propagateWfr(wfr, optSystem, saveWfrAt=optSystem.keys())\nsrw.plotI(propData[\"image\"][\"intensity\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is also possible to extract and plot the wavefront phase downstream of the \nmask. The $\\pi$ phase jump is indeed present, on top of the circular \nmodulation of the phase due to the spherical wavefront.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "phase = propData[\"mask\"][\"wfr\"].getWfrPhase()\nsrw.plotI(phase)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.2" } }, "nbformat": 4, "nbformat_minor": 0 }