While nobody can tell you what is really going on at the level of atoms , quantum mechanics has been very successful in explaining / predicting phenomena in the ultra-tiny world of atoms. The quantum world is difficult to wrap our macro-scale brains around - it is entirely alien to our way of thinking and how the world around us works.
The primary things that should be understood about quantum phenomena are that:
A molecule is two or more atoms which are bound together. An atom consists of one or more protons (+1 charge), and one or more elecrons (-1 charge). Additionally, neutrons (a combination proton/electron) can be present with no charge associated.
If an atom manages to lose its pull on an electron, the electron becomes a negative ion and the remaining atom becomes a positive ion. Conversely, if an atom manages to capture an extra electron, it becomes a negative ion.
An atom is more complex that it sounds - the simplest, Hydrogen, helps us to understand what is happening at this unbelievably small scale. Distances in this realm are on the order of 10-10 meters, called Angstroms (0.1 nm). The "size" of the proton itself is on the order of 10-15 meters.
Molecules are collections of multiple atoms. For example, atomic hydrogen is "H" and molecular hydrogen (2 bound atoms) is "H2". Adding an atom of oxygen gives "H2O", ordinary water. In the case of a hydrogen molecule, the two electrons "orbit" both nuclei, sharing, filling their outer shell of electrons.
The periodic table of the elements lays out the pattern of how atoms are constructed. Electrons come in groups, called shells, which they "like" to fill to maximum capacity. For example, NaCl is sodium chloride (table salt). Looking at the periodic table, we see that Na is in group IA and Cl is in group VIIA, so group 1 and group 7. They are both in row 3, so have an outer shell that would like to be filled with 8 electrons. As you can see, if Na comes together with Cl, they share the outer elecron shell, with the sodium effectively losing its single outer elecron to the Cl. Effectively, the Cl has a filled outer shell in the third row, and the Na has a filled outer shell in the second row, which makes both atoms "happy", so this is a stable molecule - the two atoms have an affitity for one another.
It takes a (relatively) lot of energy to ionize an atom. This is, perhaps unsurprisingly, called the ionization energy . Light is also a quantum phenomenon, where instead of being considered a ray or wave, light is considered to be a "particle of energy", where the "particle" has a frequency associated with it as in wave theory, and a ray direction as in geometrical optics. The energy of the light quanta, called a photon is directly proportional to the frequency by way of Planck's constant .
The energy levels in an atom are quantized - the most mobile electrons of the outer shell are the principle players in determining the total energy of an atom, but they cannot take on a continuous spectrum of values. Therefore, the frequency of an incoming photon must be matched to one of the allowed transitional energies for its energy to be absorbed by the atom. If it does match, there is a high probability that it will be absorbed and push the atom into an excited state, where the lowest energy level is called the ground state. There may be multiple possible transitions, with their relative "brightness" determined by the statistical relationship between them (i.e. more likely transitions will have a brighter output over time).
The phenomenon known as fluorescence is when a material absorbs one frequency and then re-emits the energy through spontaneous emission at one or more lower frequency, (lower energy, longer wavelength) allowed transitions.
Electronic transitions are the most obvious, energetic sources of stored energy, but "mechanical" motions, such as rotation and vibration have small influences on the detailed energy levels. They contribute to the overall wave function of the system. Vibrational and rotational modes generally have lower energy levels than electronic transitions, so they generally emit in the infrared part of the spectrum. One of the more famous transitions is the carbon dioxide (CO2) laser transition from molecular vibration at a wavelength of 10.6 microns, or about 5% of the engergy of a visible photon.
There is also spin-orbit interaction , where the elecron spin direction splits energy levels into fine structure about the mean energy level.
A blackbody cavity produces nearly ideal blackbody radiation . Objects in thermal equilibrium with their surroundings, and with a uniform temperature, produce blackbody radiation. This curve can be calculated, for a given temperature, by Planck's law . Tungsten and halogen light bulbs a have similar spectral properties, so can be related to a color temperature.
The term color temperature refers to the spectrum obtained by a blackbody source at that temperature. For example, a 6500 K source would be a fairly uniform white, since it covers the entire visible spectrum, but a 3500 K source would appear very yellowish-orange, due to the lack of the blue end of the spectrum.
Here is a Matlab function to calculate the spectral radiance at a temperature T (in Kelvin). Note that 6500 K has over 1000 times the energy output than does 1500 K. The peak wavelength shifts from just under 2 microns in the infrared down to just under 0.5 microns in the visible, heating up from 1500 K to 6500 K.
The sun has a spectrum that is very much like a 5900 K blackbody. The color temperature of a halogen or tungsten lamp depends on the current supplied, which changes the temperature, so it is much better to run the lamp nearly at full voltage and use a Neutral Density (ND) filter to dim the image, rather than running at a low voltage. The images below show the spectrum of a 50 W halogen lamp, running at low voltage. A Neutral Color Balancing (NCB10) filter can help balance the colors out, as seen in the much more uniform spectrum on the second image.
To view a spectrum, you can pass the light through an appropriate prism or diffraction grating. A spectroscope is a cheap device with a slit and diffraction grating, as shown below. I glued a plate on the bottom for tripod mounting.
The top row is low voltage and the bottom row is high voltage. On the left is the unfiltered lamp and on the right is with the NCB10 blue filter. In terms of non-uniformity of brightness, you can see that the unfiltered low voltage lamp is the worst - way too much green / yellow / red, and not enough blue and violet. Using the color balancing filter, NCB10, a large improvement in the spectrum is observed, with much more uniform response, down into the violet. The best, however, was the high-voltage, filtered version - full rich colors and almost perfect uniformity out to both edges.
I have no proof of this, but I think that the NCB10 filter raises the color temperature 1000 K, the NCB11 by 1100 K and the NCB14 by 1400 K. This is just a hunch...
It is somewhat tricky photographing these spectra. Some interesting results can happen with manual settings!
The spectra shown above are continuous spectra, similar to the sun's radiation. Gas discharge lamps, such as deuterium, xenon, neon, sodium, and mercury, on the other hand, show distinct bands of colors which denote the electronic transitions in the atom or molecule. The pressure the gas is held at also determines the output spectrum. I will post some pictures of more spectra as time allows.