Atom - Hydrogen Quantum Orbital Visualizer

Orbital Controls

4
3
1
1

Clipping

0
0
0

Physics Explanation

This visualization shows the probability density of an electron in an atom.
The color intensity represents the likelihood of finding an electron at a given point. The orbital shapes are determined by quantum numbers n, l, and m.

Click threw the cards to go from the basic bohr model all the way to the quantum orbitals, step by step.

Full Code Explanation:

Here is the full code explained step-by-step in chunks:

Includes


This block of code includes all the libraries used in the code file. Lines 1-5 include the OpenGL libraries (both modern and legacy).

Lines 7-9 include the standard C++ libraries for input/output, math, and random number generation.

Declare Constants

This block of code declares all global constants
← a0 = The Bohr Radius
← electron_r = Radius for our electron spheres
← hbar = Reduced Planck's constant
← m_e = Mass of an electron
← zmSpeed. = Speed of our scroll

Initialize Particles

This block of code initializes all the particles in the simulation.

← particleCount = Number of particles to be initialized
← particles = Array of all initialized particles

Initialize Random Device

This uses the random library to create a random object.

Sample Radial Distance

This function samples random radial distances for use in the simulation given the probability distrubition of the orbital

← sampleR1 takes in n (principle) and l (azimuthal)
← creates list for CDF sampling, the resolution (N) of the sampling and the max radius (rM)

CDF Sampling

Culminative distribution function sampling (CDF sampling) is kind of line throwing a ball into buckets with different radius'. The buckets with larger radius' are more likely to get the ball.

CDF Sampling


← You can see the radial probability function on line 50-51. Explanation for how I got this function is above in the physics section.

← For every "bucket" in the c list (that has N buckets total), we calculate the probability, (R^2) and add it to that list.

← Then at lines 59-60 we generate a random number between 0 and 1 and line 63 uses that number to get a random index frmo the list

← Then we return that index value (in %) and multiply it by the max radius to get a random radius value that follows the probability distribution of the orbital

Sample Theta

This function samples the theta coordinate for the given orbital.

It uses the same CDF sampling, and its own Y(theta) radial probability function