{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Undulator Power Density on a 3D Object\n", "\n", "This is a simple example of how to calculate a power density distribution from an undulator on a 3D object." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Plots inline for notebook\n", "%matplotlib inline\n", "\n", "# Import the OSCARS SR module\n", "import oscars.sr\n", "\n", "# Import the 3D and parametric surfaces utilities\n", "from oscars.plots3d_mpl import *\n", "from oscars.parametric_surfaces import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Create a new OSCARS object. Default to 8 threads and always use the GPU if available\n", "osr = oscars.sr.sr(nthreads=8, gpu=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Undulator Field\n", "\n", "Create a simple undulator field" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Clear all existing fields and create an undulator field\n", "osr.clear_bfields()\n", "osr.add_bfield_undulator(bfield=[0, 1, 0], period=[0, 0, 0.050], nperiods=31)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Particle Beam and Trajectory\n", "\n", "Define a particle beam, in this case a 3 [GeV] electron beam. You must also define the start and stop times for the calculation." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Define simple electron beam\n", "osr.set_particle_beam(energy_GeV=3, x0=[0, 0, -1], current=0.5)\n", "\n", "# Define the start and stop times for the calculation\n", "osr.set_ctstartstop(0, 2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Create 3D Object and Calculate Power Density\n", "\n", "Calculate the spectrum 30 [m] downstream from the center of the device on a cylindrical surface." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# First create the surface of interest\n", "cylinder = PSCylinder(R=0.020, L=0.010, nu=101, nv=101)\n", "\n", "# Run calculation and plotting\n", "pd = power_density_3d(osr, cylinder, rotations=[osr.pi()/2, 0, 0], translation=[0, 0, 30])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "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.6.1" } }, "nbformat": 4, "nbformat_minor": 1 }