U.S. Particle Accelerator School
U.S. Particle Accelerator School
Education in Beam Physics and Accelerator Technology

MATLAB and Python for Beam and Accelerator Physics

Sponsor:

Texas A&M University Public Partnership & Outreach

Course Name:

MATLAB and Python for Beam and Accelerator Physics

Instructor:

Dan Green, Fermilab Emeritus; Jeff Eldred and Adam Watts, Fermilab


Purpose and Audience
With the advent of personal computing and tools such as MATLAB and Python, it has become much easier to study numerically complex problems in physics, specifically the time evolution of systems.

In this course we will use MATLAB Apps to increase understanding of select concepts from accelerator physics and technology. The aim is not to teach physics from first principles, but rather to display solutions and then have the student explore the effect of changes to the problem parameters and build up an intuitive feel for the solutions. The supplied Apps allow the student to “morph” the given solutions. The course will also cover basic code writing in Python as well as use of the matplotlib, numpy, sympy, and scipy packages. This course is designed for graduate students or advanced undergraduates in physics and engineering. It is also appropriate for scientists and engineers working on accelerator systems who want to gain more experience with programming.

Prerequisites

Courses in classical mechanics, special relativity, electrodynamics and mathematical methods for scientists and engineers at a senior undergraduate level or higher; and familiarity with accelerator science at the level of the USPAS course Fundamentals of Accelerator Physics and Technology with Simulations and Measurements Lab or higher are required.

Prior programming experience with MATLAB or Python is not required.

It is the responsibility of the student to ensure that they meet the course prerequisites or have equivalent experience.

Objectives
On completion of this course, the students are expected to better understand the physical principles of the accelerator systems covered. Students will learn to execute and/or write Python scripts to analyze a variety of accelerator concepts. This will provide a firm basis to extrapolate what they learn to other accelerator systems after completion of the course.

Instructional Method
This course includes morning physics instruction through interactive MATLAB apps and afternoon lectures on how to write code in Python. There will be three daily homework exercises to write code in Python, with homework graded and solutions presented the following afternoons. There will also be an individual final projects to write and present a detailed physics program. Students should bring their own laptop or tablet computer to the school to access our Amazon Web Service cloud computers where MATLAB and Python will be installed.

Course Content
Numerical modeling of physics processes relevant to particle beams in MATLAB, including the use of MATLAB symbolic math and visualization tools. Emphasis will be drawn from the following eight topics applicable to a variety of linear and circular accelerator systems:

  1. Uniform electric and magnetic fields – dipole, solenoid, cyclotron, ExB
  2. Quadrupole – doublet, beams – sextupole
  3. Accelerator parameters – Twiss and rays, complementary descriptions
  4. FODO and dispersion – unit cell
  5. Magnet errors – Quad misalign and gradient error
  6. Induced charge and BPM – measuring emittance and dp/p
  7. Cables and striplines
  8. Acceleration

Python coding exercises will cover the following methods:
  1. The Basics – interpret vs scripting, basic coding operations, numpy
  2. Plotting – matplotlib, 2D colormap, histograms
  3. Statistical / Analytical Tools – random numbers, percentiles, FFTs
  4. Symbolic Variables – declaring, differential equations, matrices
  5. Optimization – general minimization, curve fitting
  6. Input & Output – csv files, text parsing, running system commands


Reading Requirements
(to be provided by the USPAS) The text for the course is The Physics of Experiment Instrumentation Using MATLAB Apps by Dan Green, World Scientific, 2021.

Credit Requirements
Students will be evaluated based on the following performance - homework assignments (100% grade).


Indiana University course number: Physics 671, "Advanced Topics in Accelerator Physics"
Michigan State University course number: PHY 963, "U.S. Particle Accelerator School"
MIT course number: 8.790, "Accelerator Physics"