{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Electric Fields - All About\n", "\n", "The functions available for electric fields are identical as for magnetic fields, but with the 'bfield' keyword replaced by 'efield'." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# matplotlib plots inline\n", "%matplotlib inline\n", "\n", "# Import the OSCARS SR module\n", "import oscars.sr\n", "\n", "# Import OSCARS plots (matplotlib)\n", "from oscars.plots_mpl import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Create a new OSCARS SR object\n", "osr = oscars.sr.sr()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Strong Field\n", "\n", "Let's start with a strong field for acceleration making sure the stepsize is small enough." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Clear any previous fields and add a constant large field\n", "# in the negative Z-direction\n", "osr.clear_efields()\n", "osr.add_efield_uniform(efield=[0, 0, -10e9])\n", "\n", "# Plot the field if you like\n", "plot_efield(osr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "scrolled": true }, "outputs": [], "source": [ "# Setup an electron beam with zero energy at X=Y=Z=0 (These are all defaults so no arguments given)\n", "osr.set_particle_beam()\n", "osr.set_ctstartstop(0, 1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Calculate trajectory\n", "trajectory = osr.calculate_trajectory()\n", "plot_trajectory_velocity(trajectory)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Proton\n", "\n", "Other particle types are also possible, for instance proton. For a full list see the all about particle beams." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Setup a proton beam with zero energy at Z=0\n", "osr.set_particle_beam(type='proton')\n", "osr.set_ctstartstop(0, 1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Calculate trajectory\n", "trajectory = osr.calculate_trajectory()\n", "plot_trajectory_velocity(trajectory)" ] }, { "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 }