{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "*This notebook was created by Sergey Tomin (sergey.tomin@desy.de). Source and license info is on [GitHub](https://github.com/ocelot-collab/ocelot). June 2019.*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PFS tutorial N1. Synchrotron radiation module.\n", "\n", "Synchrotron radiation module is also included to the OCELOT multiphysics simulation toolkit .\n", "\n", "The OCELOT SR module is capable of calculating spectrum and spatial distribution of spontaneous radiation from a single electron in a magnetic field defined by file data (field on an insertion device axis or 3D magnetic field map) or using standard elements as Undulator with arbitrary defined period, length and $K$.\n", "\n", "Some details about SR module can be found in [S. Tomin, G. Geloni, Synchrotron Radiation Module in OCELOT Toolkit](http://accelconf.web.cern.ch/AccelConf/ipac2019/papers/wepts017.pdf)\n", "\n", "### Contents\n", "1. [Ideal magnetic field](#ideal)\n", " * [Spatial distribution](#spatial)\n", " - [Phase](#phase)\n", " * [Spectrum](#spectrum)\n", " * [3D spatial distribution](#3d_spatial)\n", "2. [Magnetic Field map on the undulator axis](#field_map)\n", "3. [Radiation from a Bending Magnet](#BM)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Ideal magnetic field\n", "\n", "To estimate SR from undulator you can use ideal sinus like magnetic field \n", "$$B_y(x, y, z) = B_0 \\sin(\\lambda_u z)$$ \n", "with $B_x(x, y, z) = B_z(x, y, z) = 0$. In that case, we can use **Undulator** element with standard parameters like $K$, period length, number of periods. \n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# To activate interactive matplolib in notebook\n", "#%matplotlib notebook" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "initializing ocelot...\n" ] } ], "source": [ "# import main functions from Synchrotron Radation (SR) module \n", "from ocelot.rad import *\n", "# import OCELOT main functions \n", "from ocelot import *\n", "# import OCELOT plotting functions \n", "from ocelot.gui import *\n", "import time" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As usual we start from creating elements and lattice. \n", "\n", "At the moment SR module recognize only **Undulator** element. Even if you want to calculate radiation from dipole magnet. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "und = Undulator(Kx=0.43, nperiods=500, lperiod=0.007, eid=\"und\")\n", "\n", "lat = MagneticLattice((und))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To calculate radiation one needs two additional objects\n", "* ```Beam()``` \n", "to provide the electron beam energy and beam current. \n", "