All software used to generate these graphs and build this site, as well as all the graphs themselves, can be found at https://github.com/liam-ilan/electron-orbitals. Built by Liam Ilan.
Note: the following is just a summary. I highly recommend reading this Wikipedia article, and this LibreTexts article. A large amount of the following explanation uses both of these articles as a source. Additionally, this explanation on stack exchange on the difference between real and complex orbitals was extremely useful.
Classical models of the atom, such as Bohr's model, model electrons as particles with definitive positions and momenta. This model does not account for various observed wave phenomena (see Double-slit Experiment). In reality, it is observed that particles, such as electrons, exhibit both particle and wave behavior.
In the quantum model of an atom, electrons do not exist in definite positions, rather, they are described by their wave functions (denoted \(\psi\)). According to the Born interpretation, the value of the probability distribution function describing the chance of an electron being found at any given position, can be calculated by taking the amplitude of the wave function, and then squaring it (\(|\psi|^2\)). The graphs of this project are of this probability distribution function.
The wave function for an electron around a hydrogen nucleus (single proton), is defined in spherical coordinates as follows: $$\psi_{n,l,m}(r,\theta,\phi)=R_{n,l}(r)Y_{l,m}(\theta,\phi)$$ Where,
scipy.special.sph_harm
)Note: in chemistry class, you may have learned that subshells are labeled s, p, d, f, g, h, and i. These refer to the azimuthal quantum numbers (\(l\)) 0, 1, 2, 3, 4, 5, and 6 respectively.
The diagrams generated from this project are titled with the three numbers characterizing electrons, (n, l, m).
This wave function is most often used in physics, and is always rotationally symmetrical around the z-axis. With that being said, the most common visual of an electron orbital is its real orbital. This is likely the orbital you've seen in a highschool textbook. Real orbital wave functions are superpositions of the two complex orbital wave functions, \(\psi_{n,l,m}(r,\theta,\phi)\) and \(\psi_{n,l,-m}(r,\theta,\phi)\). Since both of these are complex conjugates of each other, the resulting wave function is real-valued. The real orbital wave function can be computed as follows, $$\psi^{real}_{n,l,m}(r,\theta,\phi)= \begin{cases} \sqrt{2}(-1)^{m}Im(\psi_{n,l,|m|}(r,\theta,\phi)) & \text{if } m < 0\\ \psi_{n,l,|m|}(r,\theta,\phi) & \text{if } m = 0 \\ \sqrt{2}(-1)^{m}Re(\psi_{n,l,|m|}(r,\theta,\phi)) & \text{if } m > 0 \end{cases} $$
Rendering the probability distribution function, is done by sampling and even distribution of points in cartesian space, converting the cartesian coordinates to spherical coordinates, and computing \(|\psi|^2\) at that point. This is done either in a two dimensional grid for the cross section diagrams, or in a 3d grid for the 3d diagrams. The cross section diagrams are sampled in a \(400 \times 400\) grid (160,000 data points total), and the 3d diagrams are sampled in a \(100 \times 100 \times 100\) grid (1,000,000 data points total).
For easier depth perception, each point in the 3d graphs gets its color from its cartesian coordinates. The red channel corresponds to the x-axis, the blue channel to the y-axis, and the green channel to the z-axis.
Cross sections are provided only for complex orbitals.