RSS

Visualize the Orbitals of the Hydrogen atom in 3D

Description

To take a look at the source code click here.

At first we need to import the module providing the required data structures (numpy) and mathematical tools (scipy.misc, scipy.special). To obtain a nice 3-dimensional plot we import enthought.mayavi.mlab.

As the solutions to the Schrödinger equation in the case of the hydrogen atom are rotationally symmetric, we define the spherical coordinates (r,theta,phi) as functions of the cartesian coordinates (x,y,z), which form the grid (numpy.ogrid!) for this plot. Now that we work in spherical coordinates we can define the wave function (solution to Schrödinger equation) as the product of a radial function, which depends on r and two quantum numbers n,l, and a spherical harmonic, which depends on the angles theta,phi and two quantum numbers. As the values of this wave function can become complex we define a function to determine the squared absolute value of the wave function, which is also a measure for the probability of finding an electron at any point.

The variable mask as defined in the comment section would cause the wavefunction in the plot to appear like a pie which is missing a slice.

The mlab.figure() call is not required unless we want multiple windows with plots.

Using three loops we iterate over all atomic orbitals from 1s to 3d and add its contour plot of its squared value to the output. Finally we also add a colorbar (on the right) and a frame box around the orbitals.

At the end we tell Python to show (mlab.show()) us the result, which can take some time as we did not bother to use more than one CPU for this task.

Results


Figure 1: Output of script as shown above.


Figure 2: Output of script, which only displays the 3d orbitals.
In addition the mask variable shown in the comment area was used.