{"id":202,"date":"2025-05-24T10:24:27","date_gmt":"2025-05-24T10:24:27","guid":{"rendered":"https:\/\/synchrotron-light.net\/wp\/?page_id=202"},"modified":"2025-07-20T05:13:10","modified_gmt":"2025-07-20T05:13:10","slug":"chapter-6-quantum-effects-in-synchrotron-radiation","status":"publish","type":"page","link":"https:\/\/synchrotron-light.net\/wp\/?page_id=202","title":{"rendered":"Chapter 6: Quantum effects in synchrotron radiation"},"content":{"rendered":"<p>Below is a set of python codes associated with Chapter 6 of Daniele Pelliccia and David M. Paganin, &#8220;Synchrotron Light: A Physics Journey from Laboratory to Cosmos&#8221; (Oxford University Press, 2025).<\/p>\n<p>In order to run any of these python codes, you will need to include the following header file.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">import numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\nsynchrotron_style = {\r\n    'font.family': 'FreeSerif',\r\n    'font.size': 30,\r\n    'axes.linewidth': 2.0,\r\n    'axes.edgecolor': 'black',\r\n    'grid.color': '#5b5b5b',\r\n    'grid.linewidth': 1.2,\r\n}<\/pre>\n<h2 id=\"The-basics:-plotting-a-radial-field\">Compton scattering<\/h2>\n<p>Increase in wavelength of a photon undergoing Compton scattering, as in Fig. 6.4<\/p>\n<pre class=\"theme:obsidian lang:python decode:true \">h = 6.62607015e-34 # J\/Hz\r\nee = 1.602176634e-19  C\r\nhbar = h\/(2*np.pi)\r\nme = 9.11e-31 # kg\r\nc = 2.99792458e8 # m\/s, speed of light \r\nlambda_c = h\/(me*c)\r\n\r\nB_star = me**2 * c**2 \/ (ee*hbar)\r\n\r\nphi = np.linspace(0, np.pi, 100)\r\ndelta_l = 2*lambda_c*np.sin(phi\/2)**2\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, axs = plt.subplots(1, 1,figsize=(8,8))\r\n    axs.plot(phi, delta_l, 'b', lw = 4)\r\n    \r\n    axs.tick_params(axis='x', labelsize=20)\r\n    axs.tick_params(axis='y', labelsize=20)\r\n    \r\n    axs.set_xlabel('$\\\\varphi$ (rad)', fontsize=32, labelpad = 5)  \r\n    axs.set_xticks([0, np.pi\/4, np.pi\/2, 3*np.pi\/4, np.pi])\r\n    axs.set_xticklabels([\"0\", \"$\\\\pi\/4$\",\"$\\\\pi\/2$\",\"$3\\\\pi\/4$\",\"$\\\\pi$\"], fontsize=28)\r\n    \r\n    axs.set_yticks([0, lambda_c, 2*lambda_c])\r\n    axs.set_yticklabels([\"0\", \"$\\\\lambda_{C}$\",\"$2\\\\lambda_{C}$\"], fontsize=28)\r\n    axs.set_ylim(0, 2.5*lambda_c)   \r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-203\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.4.png\" alt=\"\" width=\"600\" height=\"613\" srcset=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.4.png 600w, https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.4-480x491.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 600px, 100vw\" \/><\/p>\n<p>Fractional energy change for a photon undergoing Compton scattering, as in Fig. 6.5.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">phi = np.linspace(0, np.pi, 100)\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, axs = plt.subplots(1, 1,figsize=(12,8))\r\n\r\n    for E_ph in [5,10,20,40,60,80,100]:\r\n        axs.plot(phi, 1.0\/(1+2*E_ph\/511*np.sin(phi\/2)**2), lw = 4, label=\"$\\\\mathcal{E}_{ph}^{(i)}=$\"+str(E_ph)+\" keV\")\r\n\r\n    axs.tick_params(axis='x', labelsize=24)\r\n    axs.tick_params(axis='y', labelsize=24)        \r\n    \r\n    axs.set_xlabel('$\\\\varphi$ (rad)', fontsize=26, labelpad = 5)  \r\n    axs.set_xticks([0, np.pi\/4, np.pi\/2, 3*np.pi\/4, np.pi])\r\n    axs.set_xticklabels([\"0\", \"$\\\\pi\/4$\",\"$\\\\pi\/2$\",\"$3\\\\pi\/4$\",\"$\\\\pi$\"], fontsize=20)\r\nplt.legend(fontsize=19, framealpha=1, handlelength=1) \r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-204\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.5.png\" alt=\"\" width=\"600\" height=\"421\" \/><\/p>\n<h2>Inverse Compton scattering<\/h2>\n<p>Contour plots of the relative energy boost for a photon undergoing inverse Compton scattering, as in Fig. 6.7.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">gamma_e = 2 # Change this value to generate the other panels in Fig. 6.7\r\nif gamma_e == 2:\r\n    phi = np.linspace(0, np.pi, 2000)\r\nif gamma_e == 1000:\r\n    phi = np.linspace(0, 0.005, 2000)\r\nif gamma_e == 10000:\r\n    phi = np.linspace(0, 0.0007, 2000)\r\n\r\nlambda_ratio = np.logspace(2,9,1000)\r\ne_ratio = np.zeros((lambda_ratio.shape[0],phi.shape[0]))\r\nfor i in range(lambda_ratio.shape[0]):\r\n    for j in range(phi.shape[0]):\r\n        e_ratio[i,j] = (np.sqrt(1-1\/gamma_e**2) + 1) \/ \\\r\n                  (1- np.cos(phi[j])*np.sqrt(1-1\/gamma_e**2) + (1+np.cos(phi[j]))\/(gamma_e*lambda_ratio[i])  )\r\n\r\nif gamma_e == 2:\r\n    xscale = phi\r\nelse:\r\n    xscale = 1000*phi\r\n\r\nwith plt.style.context(('default')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, axs = plt.subplots(1, 1,figsize=(18,6))\r\n    cs = axs.contourf(xscale,lambda_ratio,  e_ratio, cmap='cividis',levels=20)\r\n    axs.contour(xscale,lambda_ratio,  e_ratio, levels=20, colors='k')\r\n\r\n    axs.set_yscale('log')\r\n    axs.tick_params(axis='x', labelsize=30)\r\n    axs.tick_params(axis='y', labelsize=30) \r\n    #axs.yaxis.get_offset_text().set_fontsize(20)\r\n    plt.title(\"$\\\\times 10^{6}$\")\r\n    cbar = fig.colorbar(cs)\r\n    cbar.ax.tick_params(labelsize=30) \r\n    plt.show()<\/pre>\n<h1><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-205\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.7-1024x429.png\" alt=\"\" width=\"800\" height=\"335\" \/><\/h1>\n<h2 style=\"text-align: left;\">Simulating the energy distribution of an electron bunch undergoing inverse Compton scattering<\/h2>\n<p>Computational exercise on page 199 and Fig. 6.8.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">lambdaC = 2.42631023867e-3 #nm\r\nlambda_i = 632.8\r\nsig_laser = 0.002\r\ngamma_e = 1000\r\nsigma_gamma = 1\r\nphi = 0.1\r\nsigma_phi = 0.01\r\n\r\nn_events = 100000\r\n\r\nlambda_laser = lambda_i+sig_laser*np.random.normal(size=n_events)\r\ngamma_electr = gamma_e+sigma_gamma*np.random.normal(size=n_events)\r\nangle = phi + sigma_phi*np.random.normal(size=n_events)\r\n\r\nen_boost = []\r\nfor i in range(n_events):\r\n    sq = np.sqrt(1-1\/gamma_electr[i]**2)\r\n    sf = (1 + np.cos(angle[i])) \/ (gamma_electr[i]*lambda_laser[i]\/lambdaC)\r\n    en_boost.append( ((sq + 1) \/ (1-sq*np.cos(angle[i]) + sf)))\r\n\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, ax = plt.subplots(figsize=(10,10))\r\n    plt.hist(en_boost, bins=100, log=True)\r\n\r\n    plt.xticks(fontsize = 36)\r\n    plt.yticks(fontsize = 36)\r\n    plt.xlabel(\"Relative energy boost\")\r\n    plt.ylabel(\"Number of events\")\r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-208\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.8_.png\" alt=\"\" width=\"600\" height=\"553\" srcset=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.8_.png 600w, https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.8_-480x442.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 600px, 100vw\" \/><\/p>\n<h2>Parameter-space plots for domain of validity of classical synchrotron-light theory<\/h2>\n<p>Bohr synchrotron (see Fig. 6.10).<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">alpha = 0.007297\r\ngamma = np.logspace(0,6, 2000)\r\nB_ratio = alpha**2 *gamma\/10\r\n\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, axs = plt.subplots(1, 1,figsize=(15,8))\r\n    #axs.loglog(gamma, B_ratio,lw = 4)\r\n    \r\n    axs.fill_between(gamma, B_ratio, y2=0, lw=4, edgecolor = 'k',\r\n                             alpha=0.5, facecolor='red') #zorder=2,\r\n    \r\n    axs.set_xscale('log')\r\n    axs.set_yscale('log')\r\n    axs.tick_params(axis='x', labelsize=34, pad=10)\r\n    axs.tick_params(axis='y', labelsize=34) \r\n    \r\n    axs.set_xlim(1,900000)\r\n    \r\n    axs.set_xlabel('$\\\\gamma$', fontsize=26, labelpad = 5)\r\n    axs.set_ylabel('$B\/B_{*}$', fontsize=26, labelpad = 5)\r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-209\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.10-1024x573.png\" alt=\"\" width=\"800\" height=\"447\" \/><\/p>\n<p>Electron recoil (see Fig. 6.11).<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">alpha = 0.007297\r\ngamma = np.logspace(0,6, 2000)\r\nB_ratio = 0.1*np.sqrt(1. - 1.0\/gamma**2)\/gamma \r\n\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, axs = plt.subplots(1, 1,figsize=(15,8))\r\n    \r\n    axs.plot(gamma, 0.1*(1\/(gamma)), lw=4, color='k' )\r\n    axs.fill_between(gamma, B_ratio, y2=0, lw=4, edgecolor = 'k',\r\n                             alpha=0.5, facecolor='red') #zorder=2,\r\n    \r\n    axs.set_xscale('log')\r\n    axs.set_yscale('log')\r\n    axs.tick_params(axis='x', labelsize=34, pad=10)\r\n    axs.tick_params(axis='y', labelsize=34) \r\n    \r\n    axs.set_xlim(1,900000)\r\n    axs.set_ylim(0.0000001,1)\r\n    \r\n    axs.set_xlabel('$\\\\gamma$', fontsize=26, labelpad = 5)\r\n    axs.set_ylabel('$B\/B_{*}$', fontsize=26, labelpad = 5)\r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-211\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.11_-1024x573.png\" alt=\"\" width=\"800\" height=\"448\" \/><\/p>\n<p>Compton wavelength (see Fig. 6.12).<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">alpha = 0.007297\r\ngamma = np.logspace(0,6, 2000)\r\nB_ratio = 0.1*gamma*np.sqrt(1. - 1.0\/gamma**2) \/(2*np.pi)\r\n\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, axs = plt.subplots(1, 1,figsize=(15,8))\r\n    \r\n    axs.plot(gamma, 0.1*(gamma\/(2*np.pi)), lw=4, color='k' )\r\n    axs.fill_between(gamma, B_ratio, y2=0, lw=4, edgecolor = 'k',\r\n                             alpha=0.5, facecolor='red') #zorder=2,\r\n    \r\n    axs.set_xscale('log')\r\n    axs.set_yscale('log')\r\n    axs.tick_params(axis='x', labelsize=34, pad=10)\r\n    axs.tick_params(axis='y', labelsize=34) \r\n    \r\n    axs.set_xlim(1,900000)\r\n    axs.set_ylim(0.00001,1000)\r\n    \r\n    axs.set_xlabel('$\\\\gamma$', fontsize=26, labelpad = 5)\r\n    axs.set_ylabel('$B\/B_{*}$', fontsize=26, labelpad = 5)\r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-212\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.12-1024x585.png\" alt=\"\" width=\"800\" height=\"457\" \/><\/p>\n<p>Parameter space plots of all curves which indicate the region where classical synchrotron theory is valid, as in Fig. 6.13.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">def ratio2Bstar(x):\r\n    return x * B_star\r\ndef Bstar2ratio(x):\r\n    return x \/ B_star\r\n\r\nalpha = 0.007297\r\ngamma = np.logspace(0,7, 2000)\r\nmask = gamma &gt; 10\/alpha\r\ncurve_I = 0.1*np.sqrt(1. - 1.0\/gamma**2)\/gamma \r\ncurve_III = 0.1*gamma*np.sqrt(1. - 1.0\/gamma**2) \/(2*np.pi)\r\n\r\ncurve_VI = 0.1*1.0\/(alpha*gamma)\r\ncurve_VII = 0.1*1.0\/(alpha*gamma**2)\r\ncurve_VIII = 0.1*alpha**2 *gamma\r\ncurve_IX = 0.1*np.ones_like(gamma)\r\n\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig, axs = plt.subplots(figsize=(15,10))\r\n    \r\n    axs.plot(gamma, curve_I, lw=4, color='k' )\r\n    axs.plot(gamma, curve_III, lw=4, color='b', linestyle='dashed' )\r\n    axs.plot([10\/alpha, 10\/alpha], [1e-12, 100], lw=4, color='red', linestyle='dashed'  ) # curve_V\r\n    axs.plot(gamma, curve_VI, lw=4, color='k', linestyle='dashed' )\r\n    axs.fill_between(gamma, curve_VII, lw=4, color='red', alpha=0.5, where=mask)\r\n    axs.plot(gamma, curve_VII, lw=4, color='r')\r\n    axs.plot(gamma, curve_VIII, lw=4, color='b' )\r\n    axs.plot(gamma, curve_IX, lw=4, color='brown' )\r\n    \r\n    axs.set_xscale('log')\r\n    axs.set_yscale('log')\r\n    axs.tick_params(axis='x', labelsize=34, pad=10)\r\n    axs.tick_params(axis='y', labelsize=34) \r\n    \r\n    axs.set_xlim(1,1000000)\r\n    axs.set_ylim(1e-11,100)\r\n    \r\n    axs.set_ylabel(\"$B\/B_{*}$\", fontsize = 26)\r\n    axs.set_xlabel(\"$\\gamma$\", fontsize = 26)\r\n    \r\n    secax = axs.secondary_yaxis('right', functions=(ratio2Bstar, Bstar2ratio))\r\n    secax.set_ylabel(\"$B$ (T)\", fontsize = 26)\r\n    secax.tick_params(axis='y', labelsize=34) \r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-213\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/05\/shynchrotron-light-6.13-1024x624.png\" alt=\"\" width=\"800\" height=\"488\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below is a set of python codes associated with Chapter 6 of Daniele Pelliccia and David M. Paganin, &#8220;Synchrotron Light: A Physics Journey from Laboratory to Cosmos&#8221; (Oxford University Press, 2025). In order to run any of these python codes, you will need to include the following header file. import numpy as np import matplotlib.pyplot [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":79,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-202","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=202"}],"version-history":[{"count":7,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/202\/revisions"}],"predecessor-version":[{"id":797,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/202\/revisions\/797"}],"up":[{"embeddable":true,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/79"}],"wp:attachment":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}