{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Interferometer\n\nA double slit interferometer with a point source. Multiprocess propagation is \nused to obtain the interferogram produced by different configurations of the \noptical system.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import libraries required for simulation\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from copy import deepcopy\n\nimport 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`\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ptSrc = srw.emitters.PointSource()\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.computePtSrcWfr(ptSrc, observer, wavelength=600)\n\nw = 500e-6\nd = 2e-3\nf = 50e-3\ns1 = observer.zPos\ns2 = s1 * f / (s1 - f)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use a rectangular aperture with an obstacle at the centre to create the \ntwo interferometer slits\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "optSystem = {\n \"slitAp\": {\n \"type\": \"rectAp\",\n \"extension\": [w, d + w],\n \"centre\": [0,0]\n },\n \"slitOb\": {\n \"type\": \"rectOb\",\n \"extension\": [2 * w, d - w],\n \"centre\": [0,0]\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/20, \"hResChange\": 2.0,\n \"vRangeChange\": 1/20, \"vResChange\": 2.0,\n \"hCentreChange\": 0.0, \"vCentreChange\": 0.0}\n }\n}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We proceed with a standard propagation to check that the parameters are good.\nAs expected, the interferogram of the point emitter exhibits a unitary \nvisibility and its envelope lies within the single slit diffraction pattern.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "propData = srw.propagateWfr(wfr, optSystem, saveIntAt=[\"image\"])\nsrw.plotI(propData[\"image\"][\"intensity\"])\n\ncuts = srw.extractCrossCuts(propData[\"image\"][\"intensity\"])\nyax = cuts[\"yax\"]\nint_srw = cuts[\"ydata\"]\nint_theo = np.sinc(w * yax / (s2 * wfr.wavelength*1e-9))**2\n\nfig, ax = plt.subplots()\nax.plot(yax*1e3, int_srw / np.max(int_srw))\nax.plot(yax*1e3, int_theo, label=\"theo\", linestyle=\"--\")\nax.set_xlabel(\"y position [mm]\")\nax.set_ylabel(\"Intensity [arb. unit]\")\nax.legend()\nplt.tight_layout()\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can finally create a list of optical systems by changing the slit \nseparation and observe the corresponding change in the fringe periodicity.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "deltas = np.linspace(-.5, .5, 3) * 1e-3\n\noptSystems = []\nfor delta in deltas:\n optSystemNew = deepcopy(optSystem)\n optSystemNew[\"slitAp\"][\"extension\"][1] += delta\n optSystemNew[\"slitOb\"][\"extension\"][1] += delta\n\n optSystems.append(optSystemNew)\n\npropDatas = srw.propagateWfrMultiProcess(4, wfr, optSystems, saveIntAt=[\"image\"])\n\nfig, ax = plt.subplots()\nfor i, propData in enumerate(propDatas):\n cuts = srw.extractCrossCuts(propData[\"image\"][\"intensity\"])\n yax = cuts[\"yax\"]\n int_srw = cuts[\"ydata\"]\n ax.plot(yax*1e3, int_srw / np.max(int_srw), label=f\"{(d + deltas[i])*1e3}\")\nax.set_xlabel(\"y position [mm]\")\nax.set_ylabel(\"Intensity [arb. unit]\")\nax.legend(title=\"Separation [mm]\")\nplt.tight_layout()\nplt.show()" ] } ], "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.9.9" } }, "nbformat": 4, "nbformat_minor": 0 }