Energy Production in the Core
In the core, which is the innermost 10% or so of the solar radius and mass, hydrogen atoms are converted into helium atoms through a process known as thermonuclear fusion (which simply means, building up little nuclei into bigger ones, through collisions made possible by the high temperatures in the core). The specific method used to accomplish this is called the proton-proton cycle, because it starts by putting two protons together, to make a nuclear particle called a deuteron. If an electron were added to the deuteron, it would be a deuterium atom, which is an isotope of hydrogen -- chemically identical to hydrogen, but as far as nuclear physics is concerned, as different from hydrogen as helium or oxygen or uranium. This deuteron is then combined with another proton to make a nucleus of light helium (a helium atom with only three nucleons, instead of the normal four nucleons), and in one method or another, the light helium is eventually transformed into normal helium. The total process turns four hydrogen atoms (four nuclei, and four electrons) into one helium atom (one nucleus, consisting of four nucleons, and two electrons). In the process, a very tiny amount of mass "disappears", and is transformed into light, in an amount given by Einstein's formula, E = mc2. The energy produced by this process tries to leave the Sun, at the speed of light, but with more than 300 thousand Earth masses of gas in the way, it doesn't get very far before it is frustrated in that effort (as discussed below, under "The Radiative Zone").
The amount of energy produced in the core must be the same as that being lost at the surface of the Sun. The Sun is gaseous, throughout, and if the heat flow in the Sun were uneven, so that some regions could be gradually heating up, and other regions gradually cooling, the gases would expand, or contract, as a result of those temperature changes, which would change the way in which heat flows outwards, in such a way as to reduce to heating or cooling. Because of this, every part of the Sun is producing, or transporting, or losing, almost exactly the same amount of energy as at the surface.
The surface brightness, or luminosity of the Sun, is about 400 trillion trillion (4 x 1026) watts. This is such a large amount of energy that even nuclear reactions have to proceed at an extremely rapid pace, to provide the energy. In fact, in Einstein's formula, above, to create that much energy requires the annihilation (transformation into energy) of 4 million tons of mass per second. However, the nuclear reactions involved only result in a reduction of about .7% of the original mass, so to annihilate that much material, almost 600 million tons of hydrogen must be converted into helium every single second in the center of the Sun. This is equivalent to several tens of billions of hydrogen bombs exploding every second, which might lead one to suppose that the energy production is an extremely violent affair, but in reality, it is a relatively smooth, quiet process, because of the conditions in the region where the energy is produced.
In that region, we have a gas -- a very dense gas, more than a hundred times denser than water, but still a gas -- consisting of bare atomic nuclei (mostly hydrogen nuclei), and free electrons. They are all running around at tremendous speeds, banging into each other, over and over and over again -- typically, hundreds of millions of collisions per particle per second. In most of these collisions, NOTHING HAPPENS, save that the particles bounce off of each other, and continue on their way. In fact, for an average proton, in the core of the Sun, collisions occur, over and over and over again, hundreds of millions or billions of them per second, for more than ten billion years (which is more than 30 million billion seconds), and in all of those hundreds of millions of billions of trillions of collisions, ONLY ONE involves a nuclear reaction -- all the others simply bounce the particle back and forth. So, most of the time, absolutely nothing of any great interest is happening to an individual particle.
However, each cubic inch of material in the core of the Sun contains trillions of trillions of particles, so even though any given one of them is doing hardly anything, save bouncing back and forth, quite a lot of them are in the (unlucky?) minority that actually has a nuclear transformation, in any given second. And there is a very large region -- about 10% of the size of the Sun, containing more than 30000 Earth masses -- in which this is occuring, so the total number of transformations is, although an almost infinitely tiny number compared to the number of collisions, an extremely large number. In fact, a number large enough to transform 600 million tons of hydrogen into helium, each second.
Now, the energy produced by all these reactions (400 trillion trillion watts) floods outwards (or tries to flood outwards) in all directions, gradually flowing from layer to layer, through the solar interior, toward the surface. If the huge amount of energy involved were to raise the temperature of the gases through which it passes, they would expand, and cool off (in fact, cool off more than the energy heated them up, in the first place). This rather odd effect -- that trying to heat a gas, in the solar interior, causes it to expand and actually cool off -- keeps the Sun's nuclear furnaces absolutely stable. For, if the nuclear reactions were to go too fast (producing, say, 10% too much energy), which should increase the heat, and temperature, of the gas in the interior, the gas would expand, and cool off, which would cut down the rate of nuclear energy production (which is quite sensitive to temperature and density, both of which would be reduced by such an expansion). On the other hand, if the nuclear reactions were to go too slowly, the gases would cool off and contract, and in the process, the density and temperature of the gases would increase, pushing up the nuclear reaction rates. Because of this, the nuclear reactions are forced to go at the same rate at which the light escapes the core. If they try to go faster than the light can escape the core, they are shut down (to a certain extent). If they try to go slower than the light is escaping, they are increased.
The Radiative Zone
In the region outside the core, light bounces from collision to collision, back and forth and forth and back, a virtually infinite number of times (several hundred trillion trillion times) before finally, more or less accidentally finding its way to the outer layers of the Sun. The main way in which the light is bounced back and forth is through collisions with electrons. In most of the collisions, nothing happens to the light except that it is bounced in some random direction, compared to the direction that it was originally going. This is referred to as scattering, and since it is done primarily by electrons, is sometimes called electron scattering. Theoretically, the light photons can also be bounced off of each other, or off of atomic nuclei, but both those processes are much less efficient than electron scattering.
The tremendous number of scatterings that the photons suffer, before they reach the outer layers of the Sun, tremendously slows their outward progress. If they could just zip right out of the Sun at the speed of light, they would do so in less than 3 seconds. But since they are bounced back and forth so many times, they actually take more than a million years to get out of the Sun.
Since it takes so long for the light to get out of the Sun, and it suffers so many scatterings, it should hardly be surprising that, although most of the scatterings do nothing but change its direction, some of them involve an exchange of energy with the electrons. In these energy exchanges, it is possible for energy to go from the less energetic particle (gas particle or light particle) to the more energetic one, but the normal result is that the more energetic particle will lose energy, and the less energetic particle will gain energy. As a result, over a large number of interactions, the average energy per gas particle becomes virtually identical to the average energy per light particle. This equality of energies is referred to as Local Thermodynamic Equilibrium, and suggests a way of modifying the nature of the light that is passing through the gas, on its way to the surface.
As will be discussed below, the temperature of the Sun is lowest at the photosphere, and increases steadily as you go into the Sun, rising to about 15 million Kelvins in the center. Because of this, the gas particles near the center of the Sun have about 2500 times as much energy (they have 2500 times the temperature) as the gas particles near the surface, and if they are in equilibrium with the light particles (photons), then the photons near the center of the Sun must have, on average, 2500 times the energy of those near the surface. This doesn't mean that the total energy is any different at the center, than at the surface -- in fact, the energy created in the core of the Sun, and flowing from layer to layer to layer, must be virtually identical to the energy being lost at the surface of the Sun. But in the center, that energy is concentrated in photons which have, individually, 2500 times as much energy, as the much lower energy photons which pass out of the Sun, at the surface.
As discussed in chapter 4, the energy of the photons of light in a beam of light determines the wavelength, or color, of that light beam. At the surface, the radiation consists primarily of visible light, with smaller amounts of infrared radiation and ultraviolet radiation, and much lower amounts of radiations further removed from the visible. In the center, because the energy of the photons is 2500 times higher, the radiation consists primarily of X and gamma radiation. This difference in color is related to Wien's Law, which states that for black body radiation, the higher the temperature, the shorter the wavelength at which the maximum brightness of the radiation occurs.