Atomic orbitals from the Scroedinger equation.
The aim is to draw the distribution of the probability of finding an electron near a chosen point in space around the nucleus of an Hydrogen-like atom (that is to say an atom with only 1 electron but with a nucleus composed by Z protons). You have to imagine the electron as a cloud around the nucleus of the atom: the colours represent the probability of findind the electron in the neighbourhood of a chosen point in space for the chosen atomic orbital (the one you select fixing three parameters (n,l,m)). The parameters have their usual meanings: n is called the "principal quantum number" and is related to the energy of the orbital; l is called "azimuthal quantum number" because it is related to the orbital angular momentum; m is called the "magnetic quantum number". Every different choice of the triplet identifies a different orbital and so a different behaviour of the electron. To render the 3-dimensionality of the orbitals you have to sweep them around the screen vertical axis. Note how the same orbital gets smaller when you increase the number Z of positive charges in the nucleus.
Because I am a physicist first of all I'll tell you something about the Scroedinger equation (if you already know this stuff you can skip it: Goto Shortcut): you need just a few notions of elementary algebra because I'm going to omit all the details and retain only the basic concepts. Besides, everything that follows until the Shortcut label exclusive is not necessary for the comprehension of the program.
The Scroedinger equation solutions give us the distribution of the probability density in space, that is to say what the chance is to find a particle in the neighbourhood of a given point. The eigenvalue equation is written:
Hu(x) = Eu(x)
where H is the Hamiltonian operator, E is the eigenvalue (the energy) and u(x) is the eigenfunction. The next step is to write the vector x = (x, y, z) in spherical coordinates (r, theta, phi) and to search for a solution of the above equation in the form R(r)T(theta)P(phi), where R depends only on the radius r, T depends only on the angle theta and P depends only on the angle phi. So we write:
H[R(r)T(theta)P(phi)] = E [R(r)T(theta)P(phi)]
If we write the operator H as the Laplacian operator (in TeX syntax: \nabla^2) plus a potential U(r) dependent only on the radial coordinate, the general solution is:
u (r, theta, phi) = R (r) Y (theta, phi) nlm n lm
where the Y are the so called spherical harmonics (some useful functions that have already been studied by mathematicians).
The Hydrogen-like atom belongs to this general scheme: we imagine a particle with a negative charge moving in a Coulomb field
2 Ze U(r) = - --- r
generated by a fixed nucleus with Z positive charges. Substituting such a potential in the preceding expressions, with a lot of annoying and subtle computations we obtain that the R part is made by the Laguerre polinomials (some other awful functions). In this way we got the u_{nlm} functions, some of which appear in the program.
Suppose you've skipped all the preceding part (if not, now you probably have a terrible headache): start with a function u depending on three nonnegative interger parameters (n,l,m) and on three variables (r, theta, phi) which are the spherical coordinates of a point in space. Fix the three parameters (e.g.: (n,l,m)=(1,0,0)): I tell you that the resulting function u has a rotational simmetry with respect to the angle phi, so we can represent it using only the remaining coordinates (r, theta) on a 2-dimensional screen; next we can rotate it with our imagination around the screen vertical axis to obtain the final result. Depending on the values of the parameters the function u has different expressions and different are the shapes that appear on your monitor.
The program is a function plotter: it cycles through a range of values for the two variables (r, theta) and computes the value of the function u(r, theta); the latter is then converted to a "colour value" and plotted on the screen. Because the function u gives a probability, it ranges from 0 to 1, but its value is often so small that, when converted to a colour, it will always give 0 as a result. So I had to add the "colour factor", that is to say a multiplicative factor that "moves" the probability value in a range useful for selecting colours. There is a better way to accomplish this task: to calculate the whole graph without drawing it and to store the maximum value obtained for the probability u; then you can scale the probability density in such a way that the maximum value corresponds to colour number 31, and so on... I didn't write this part of the algorithm (you can do it for exercise if you want) because the program gets slower and, on the contrary, I wanted you to admire the Hydrogen atom orbitals without waiting too much.
Written By: Andrea Galimberti e-mail: fsoft@intercom.it Via E.Villoresi Turbigo (MI) ITALY tel: (ITA) - (0)331 - 871009