Skip to content

Exploring the Hydrogen Spectrum with Glowscript

November 13, 2018

As part of my sabbatical work at the Center for Computing in Science Education, I’ve learned a lot about the Norwegian Science and Math Curriculum, and gotten to meet some teachers who are doing very great work at bringing programming and computational thinking into their classes. In the next few posts, I want to share out some examples of what I’ve been working on.

One topic that isn’t a part of the high school physics curriculum I’ve taught is the Bohr model and in particular, the formula for calculating spectral lines


I must admit I’ve always found this formula a bit hard to build an intuition around. You’re calculating the inverse of a wavelength, and it’s dependent on the difference of the inverse of the squares of two integers. It was easy enough for me to realize that if you transition over a greater number of quantum states, the energy of the released photon must increase, resulting in a higher frequency, smaller wavelength photon, but that was never obvious to me from working with this equation as a student.

A teacher I met designed an activity to give students more practice with thinking about this formula by asking them to write a simple python program to calculate the wavelength of the emitted photon for a given transition. Once they had this program, it was much easier for students to think conceptually about questions designed to push their understanding. For instance, you could ask them to calculate the wavelength of the transition from n = 101 to n=1 to the transition from n =100 to n=1 and let them see that these wavelengths are nearly identical, and then come to the idea of ionization energy.

This discussion got me thinking that a glowscript program might add a bit more to this work since you could also display the spectral line that is produced for a particular transition. After doing some searching for some code to convert wavelengths to RGB values, I was able to put together this program:

Bohr Spectrum

And here is what the program produces. The top black bar is the reference spectrum of the Balmer series. If I were giving this to students, I would remove the lines 14 and 15 that calculate the wavelength of a particular transition, and ask students to implement the function to calculate lambda. Then I would ask them to try various transitions to see if they could produce the Balmer spectrum.


I’m not sure this is the deepest application of computational thinking—basically, students are just writing a few lines of code to do a calculation they could easily do on a calculator. But I do think it provides students with a tool to explore spectral lines a bit more and start to develop some insights about the relationship between transition energy and wavelength, and with the right prompts, insight into what sorts of transitions will produce visible spectral line, which might give a bit more meaning to the sea of names for spectra we have—did you know that we have names for 6 different series? Lyman, Balmer, Paschen, Brackett, Pfund, and Humprheys? Honestly, before I started working on this program, I had no idea why there were even separate names for these series, but I now see that they’re named according to the final energy level of the transition.

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: