A simple computer model

of carbon dioxide's infrared scattering effect

Some time back I became interested in the behaviour of carbon dioxide and other gases which exhibit infrared 'absorbtion spectra' due to molecular resonance effects. Why not, I thought, rather than just accept what we are told, try to derive the behaviour of such gases from first principles?

The first prerequisite is to understand exactly what's going on in the IR 'absorbtion' process. Well, for a start the word absorbtion is a term of convenience used by scientists, mainly because when you are examining a typical infrared beam which has passed through a tube filled with the the gas, you will notice that some of the beam's power has been lost.  However, absorbtion is not strictly an accurate term. Scattering would be a better approximation.

If in the above situation you were to look for radiation emerging from the sides of the gasfilled tube, then you would notice where the missing, presumably 'absorbed' infrared had gone. In fact, it is as if the whole tube glows like a lightbulb, but at the 'absorbtion' wavelength(s) only. Basically, instead of the narrow beam which entered the gas, you now have infrared being sent-out diffusely in all directions.  Understandably, your infrared meter will show less illumination in the main direction, but if you move your detector around it will show a low level of infrared illumination over a much wider area than without the gas. 

A good analogy would be what happens if you turn on your car's full-beam headlights in fog. Instead of projecting forward the light is scattered in all directions by the fog, with a fair amount coming straight back toward you, and this makes it harder, rather than easier, to see ahead. Change to dip beam and you don't have this problem because you are not in the return-path of the scattered light. This is actually a pretty good analogy since if our eyes could see in the wavelengths that carbon dioxide scatters, the atmosphere would look rather like a glowing fog in which we could only see about as far as a tall building is high. (and since that wouldn't be much use for seeing our way around, that's probably why our eyes are not sensitive in that range)

OK, so down to analysis: The starting point for our model is a single photon of infrared leaving the Earth's surface. We shall assume that this photon has a suitable wavelength to interact with our greenhouse gas, whatever gas that happens to be. The question is, how far upward in the atmosphere is our photon likely to get before it encounters a greenhouse gas molecule?

You would think, given the small fraction of a percent of greenhouse gases in the atmosphere we'd be talking a long distance, maybe miles or even hundreds of miles. Actually, wrong. The reason intuition gets this one wrong is the sheer number of molecules in, say, a cubic metre of gas. There have been several analyses of this question, all of which give a result of at most a few tens of metres between each encounter with a greenhouse gas molecule, and the next such encounter. You might note that there will be even more encounters between our photon and nitrogen or oxygen molecules in the same distance travelled, but in their case there will be no interaction.

Probably the best mathematical analysis of this question is by Nasif Nahle which yields a 'mean free path' for photons of 33 metres between carbon dioxide molecules, at sea level. Thus, for a photon heading upward through multiple kilometres of air, there is a high probability that it will have many 'close encounters of the greenhouse gas kind' on its way to space. The photon which makes it through unscathed will in fact be a rarity.

So, when an upward-bound photon encounters a CO2 molecule, its energy will be absorbed as a molecular vibration. Barring other eventualities the photon will be re-emitted about 10ns later, only not necessarily travelling in the same direction. Strictly speaking the photon may exit in any direction around a 3D sphere, but for the since we are only concerned here with the photon's vertical angle of deflection we can consider the event to take place in a single vertical 2D plane.


Typical .ini file settings for 10m and 100m mean free path runs, 1000 runs per value:

Code Description

The model is written in the AutoIt language, available for free download from http://autoitscript.com

Parameters are loaded from an .ini file. Only the  [global] section is read by the program, other sections are allowed for reference purposes. 

The main program takes the basemfp comma-delimited list from the ini-file and carries out a DataSet() run for each value, incrementing the CO2 concentration from startppm by ppmincrement to endppm. In this way, several assessments can be carried out for various theoretical mean free path values.


The DataSet() function runs a series of PhotonPath() calculations for a given (sea level) concentration of carbon dioxide. Each PhotonPath() run simulates the journey of one photon from the Earth's surface to escape to space, be reflected back to the surface, or be absorbed as atmospheric heat. 

Since each PhotonPath() run contains a high degree of randomicity, sufficient runs must be performed to obtain a reliable mean result. 100 runs of PhotonPath() would suitable for a quick analysis, but 1,000 or 10,000 will give greater confidence in the result.

The samples are output to plot files in two formats; a simple x/y version for direct graphing, and a more comprehensive set for spreadshseet analysis.


The PhotonPath() function is probably the most important component. This takes values for the photon mean free path at sea level (default is 33m) and the starting altitude for the photon, which would normally be zero. The routine then repeatedly calculates the likely distance travelled by our single photon before the first CO2 molecule encounter. In reality this distance will not, of course, be the mean value but will vary randomly from it by way of a Gaussian probability distribution in which most path lengths will be near the mean, but a few may be much more or less.  A Box-Muller algortithm in the Gaussian() function takes care of this randomness element. This algortihm was tested separately from the main program to ensure that it produced an acceptable randomicity.

Following our simulated encounter the photon may be re-emitted in any direction at random. For our purposes the only component of importance is whether the net direction is upwards or downwards, and we obtain that vector by taking the cosine of a randomly-chosen direction.

We then compute the new altitude of the photon, and decide whether to repeat the process, based on a limit for number of CO2 encounters, or on an altitude being reached at which it is considered to have escaped. For each increment in altitude we also feed a correction back into the mean free path calculation, to allow for reduction of pressure (and hence CO2 density) with altitude.

The routine terminates and returns its data when the photon strikes the earth, escapes the atmosphere, or a set number of CO2 encounters is exceeded.

Note that the model takes some time to run owing to its calculation-intensive nature. Datasets with many free-path ranges and many photon-runs per range may take several hours to complete. A relatively powerful PC is recommended for such runs.


The output of the basic data set is shown, converted to a visual representation using graph.exe

Relative greenhouse effect, versus concentration

The red plot represents the photon-retention effect of CO2 at sea level. You will note that this follows the theoretical predictions of Arrhenius' equation quite well, and demonstrated the logarithmic nature of the relationship between concentration and photon retention. It is notable that using the mean free path found at sea level most of the photon retention effect is present at less than 50ppm concentration, and any further increases in CO2 have only a small effect. 

However, it is also notable that with longer mean free paths, as would be found in the upper rarefied atmosphere where distance between CO2 molecules are much longer,  the relationship is of a more linear nature. Although, to reach such  long path lengths (a kilometre or more) would require our simulated photons to reach an an altitude where the air pressure is less than a twentieth of that at sea level -about 20km or 60,000ft high. Which is spyplane altitude, well above the tropospheric regions which experience the main climatic effects.  Whether this is of real-world consequence I wouldn't like to say, but I include these rarified-atmosphere datasets for completeness.

If we take the range between 270ppm and 400ppm, and compare the change in retention with the likely overall greenhouse effect of CO2, then we get a manmade warming of about 1C. Give or take maybe 0.5C as the accuracy in this narrow range of change isn't all that high. This ties in well with measured values, although it is somewhat less than theory predicts.

Hence, this relatively simple model seems to be giving us some useful results. It appears to confirm the theories laid down by Arrhenius in the late 19th Century as to the logarithmic relationship between sea-level CO2 concentration and greenhouse effect. It cannot by its nature confirm or refute the complex feedbacks postulated by climate scientists to influence the climate-changing capabilities of CO2, but it can, I think, give us a fairly good understanding of its basic action. 

As usual I'll let you draw your own conclusions. Do by all means download the program code and experiment with it. If you feel you can improve on the model's accuracy, then that would be useful.