Teaching Quantum Mechanics with Python

I’m excited to announce that I’ll be giving a talk at PyCon 2017, on May 18 in Portland OR. The talk is based on a set of Jupyter Notebooks that I’ve developed over the past two years for use in my quantum mechanics class. As the talk comes together, and as I clean up and document the resources, I plan to write a series of posts describing how I use the libraries (like QuTiP) that make these lessons possible, the process I used to revise these resources, and the things I learned along the way about teaching students python and teaching students with python.

Printing on Shims

An emergency hack saves a doomed print job.

I’ve been 3d printing since late 2010 when I built my first kit. One thing I learned early on is that overhangs are tricky in printed objects. Generally that means that you either design an object to minimize overhangs or you print with support. Usually you can pick an orientation and part design that work well together and give good results. Sometimes you need to print support. Today, I ran into another issue. I’ve been printing many items for student projects in my electronics class and got a bit casual about sending files to the printer without looking too closely. I had a full print bed worth of parts running when I realized one part was designed with major overhangs; essentially a flat plate that had some mounting lugs extending up and down from it. The print was already 1/3 through and I didn’t want to kill the job it since most of the print would be fine… but I knew that this part of the print would fail. Staring down this impending problem, I figured I’d try a hack and at least see if I could salvage the print job.

I looked through my gcode in octoprint to see where the overhang would kick in (layer 13 it turns out). Grabbed enough index cards to make a stack about 13*0.25mm high and started cutting. When I had a reasonable set of cards ready to go, I waited for layer 12 and paused the print. I started to stack the cards and tape them down with kapton tape. Based on feel, the layer height wasn’t 0.25mm so I pulled a few cards off the stack until they felt as tall as the existing print. The results are certainly better than if there wasn’t any support, and I’m actually surprised it worked as well as it did. Surface quality is actually about as good as it is with support; not as nice as it would be if the surface were more even, but I had to have a way to hold the cards in place so the tape strips show up a bit. In the future, I’d just lay down wide strips of masking tape (i.e. blue tape) since I like the finish it gives and I know PLA sticks to it.

An interesting note is that the cards definitely change the heat properties of the bed but that doesn’t seem to have changed the outcome much. I was worried about printing on a cold surface instead of the heated bed but that seems to be an unfounded concern. I suspect ABS may be more picky about this, but the PLA didn’t show any warping.


Shims in place. The printer was paused at this point.


Finished print on the bed. Looks good so far.


Part printed on shims shows minor surface defects.

Overall, this definitely worked as a rescue mission. The easiest approach is to avoid the issue with careful design choices. However, some parts need to break the no overhangs rule. And for those parts, shims may be a solution.

Video of the print in action:

Update: After posting this I found Xiang Chen‘s work on print-over and other augmented printing techniques. Very exciting, and I’m going to have to start playing with some possibilities along those lines.

Inkscape clipboard fix on mac

Inkscape is my go-to vector editing program and I’ve done many publication figures, exam questions, and other general work in inkscape on both mac and linux. I’ve always just resigned to use clone (ctrl-D) instead of copy/paste since on the mac, the copy/paste cycle results in a pixelated image being pasted into the document. After beating my head against a wall trying to create a pattern-on-path effect, I realized that there must be something wrong with the clipboard implementation on the mac. Sure enough, a quick search took me to the inkscape FAQ, and this section in particular:

Starting with XQuartz 2.3.2, X11 has some functionality to exchange the content of the clipboard with OS X. It currently does not know how to deal with vector images, so it just captures the screen, i.e., creates a bitmap copy, and then pastes that. You need to deactivate this functionality in X11 preferences > Pasteboard: uncheck “Update Pasteboard when CLIPBOARD changes”. However, this will also prevent copying text from any X11 application to Mac OS X ones. It will not prevent copying text from OS X to X11.

When you just want to make a copy of an object within Inkscape, you can also use duplicate (Ctrl-D) rather than copy/paste (Ctrl-C/Ctrl-V) — Duplicate does not interact with the X11/OSX clipboards. For other Inkscape commands involving the system clipboards (e.g.Paste StylePaste Size or Paste Path in path effects) there is no alternative workaround other than changing the X11/XQuartz preferences as described above.

On the bright side, I had found the suggested workaround, and was able to effectively duplicate items in my drawings. However, that doesn’t work when the effects are expected paths in the clipboard (and they weren’t there). Since inkscape is about the only thing I use X11 for on the mac, I went ahead and disabled the X11-mac clipboard sync. I will dive in the the nuanced solutions if I need to. It’s been a blessing to have access to many of the path effects and other cool tools in recent inkscape versions.

NSF Grant awarded to Photonics and Quantum Optics Lab at Pacific

I’m pleased to announce that my research group has been awarded a second NSF RUI grant to further support our research. The RUI (research at undergraduate institutions) program specifies resources for scientific research at colleges like Pacific and is a valuable funding mechanism for science research at smaller colleges. I feel very fortunate to continue to offer summer research opportunities to undergraduates for at least the next three years. Below is the public abstract that is posted on the NSF website.

As electronic devices reach their maximum processing speeds, the demand for high speed internet communications and data networks will require new technologies for storing and processing large amounts of data. Electronics are built on the use of the electron to carry and process information and in an analogous way the field of photonics is developing devices that use particles of light called photons to carry and process information. Individual photons obey the laws of quantum mechanics, so in order to fully understand the operation of photonic devices, quantum measurements must be performed on these new devices. One particularly essential component is a memory or information storage device. Many candidates for photonic memory exist but few have been characterized at the quantum (few-photon) level. This research program will apply new techniques for measuring the quantum properties of light to a variety of photonic memory devices. The result will be a deeper understanding of device operation that will lead to optimized devices for future applications.
Photonic memory devices have been demonstrated using slow and stored-light protocols based on electromagnetic-induced transparency (EIT) in Rubidium. The goal of this program is to measure the quantum state of light retrieved from several implementations of these devices in both warm and cold Rubidium vapor samples. The light stored and retrieved from such systems will be measured and analyzed using a highly efficient array of low-noise photodetectors. This technique can simultaneously measure multiple optical modes and will be used to correlate multiple modes and determine which modes (or combinations of modes) are most robust under different storage conditions. A full quantum-mechanical understanding of the optical signal retrieved from memory allows complete characterization of the device performance and will inform future work in the development of photonic memory devices.

Margin comments in Overleaf

I have started using overleaf a lot more these days and came across a nice way to add margin comments and notes (similar to MS Word comments). Simply include the todonotes package and then add a note where you want it:

\todo{Note text goes here}

Of course this works on any regular latex installation too (i.e. overleaf isn’t required). This can be especially important for shared projects and communication between authors.

IPython notebooks for a Quantum Mechanics course

I have finally published the IPython notebooks that I have worked up for our Quantum Mechanics course. This is a one-semester course for juniors and seniors. We use the book Quantum Mechanics: Theory and Experiment by Mark Beck. This is relevant because some of the notebooks refer to in-text examples and chapter problems. I use these notebooks during our weekly lab time for those students that are not working on the entangled-photon experimental apparatus for that week. We rotate through the experiment in groups of four. The students are responsible for the material in the notebooks, and have taken to using the notebook tools on their homework as well.

Chapter-specific notebooks and the lab activities are available on github. I have also created a web page that links to viewable (and downloadable) versions of the notebooks so you can see them before you install IPython or any other prerequisites. Please contact me with any questions. I continue to use these in my course and am happy to support them for others who are interested in using them.

The notebooks make heavy use of the QuTip package for python, a very useful set of functions and objects for quantum calculations and simulations.