U.S. Particle Accelerator School
U.S. Particle Accelerator School
America's National School of Accelerator Science and Technology

Python Programming and Applications for Accelerator Science and Engineering

Sponsoring University:

Michigan State University

Course Name:

Python Programming and Applications for Accelerator Science and Engineering
This class is full.

Instructors:

Jeff Eldred and Adam Watts, Fermilab
TA: Brandon Cathey, Oak Ridge National Lab


Purpose and Audience
Computer programming has become an essential skill for laboratory physics, with applications including in instrumentation, control, data analysis, simulation, mathematics, and optimization.

In this course we will cover basic code writing in Python including the use of the matplotlib, numpy, sympy, scipy, and pandas packages. Accelerator applications will be emphasized in classroom examples. Student exercises will demonstrate mastery of basic code writing techniques, and there will be a final project of the student’s choice (with instructor approval).

This course is designed for graduate students, advanced undergraduates in physics and engineering, and professionals 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. Familiarity with accelerator science at the level of the USPAS course Fundamentals of Accelerator Physics and Technology with Simulations and Measurements Lab is encouraged but not required.

Prior programming experience with Python is not required. Although prior exposure to at least one programming language is highly encouraged.

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
The course features morning and early afternoon lectures and examples 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 install Python and to access Jupyterhub servers.

Use of Github and git commands will also be demonstrated.

Course Content
Python coding exercises will cover (at least) 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. Numerical Integration – tracking simulations
  5. Symbolic Variables – declaring, differential equations, matrices
  6. Optimization – general minimization, curve fitting
  7. File Input & Output – csv files, pandas, text parsing, running system commands
  8. PyQT – GUIs, mouse/keyboard input

Reading Requirements
(to be provided by the USPAS) "Numerical Methods for Physics" second, revised Python edition by Alejandro L. Garcia (2017) CreateSpace Independent Publishing Platform.

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

USPAS Computer Requirements
There will be no Computer Lab and all participants are required to bring their own portable computer to access online course notes and computer resources. This can be a laptop or a tablet with a sufficiently large screen and keyboard. Windows, Mac, and Linux-based systems that are wifi capable and have a standard web browser and mouse are all acceptable. You should have privileges for software installs. If you are unable to bring a computer, please contact uspas@fnal.gov ASAP to request a laptop loan. Very limited IT support and spare loaner laptops will be available during the session.


Michigan State University course number:  PHY 905 Special Problems, Section 702 Python Programming and Applications for Accelerator Science and Engineering
Indiana University course number: Physics 671, Advanced Topics in Accelerator Physics
MIT course number: 8.790, "Accelerator Physics"