Overview 
A photon injected into a cloud layer can travel a certain distance  the so called mean free path  before getting absorbed or scattered. If scattered the photon changes direction, travels again a small distance and has again the option to be scattered or absorbed. This sequence will continue until it finally gets absorbed (or ejected from the cloud layer). All these events  absorption, scattering as well as the drawing of a new direction  are determined by key parameters of the cloud layer and by certain probability distributions. Hence, if the interaction of a photon is calculated over and over again  as done in a MonteCarloSimulation  it is possible to statistically determine the amount of photons that are
In this way, the irradiance that is transmitted and reflected by a cloud can be calculated.
As stated it is possible to describe the likelihood of what is happening to a photon inside a cloud by evaluating the uniform probability distributions of the possible events. In their book Fundamentals of Atmospheric Radiation (Bohren and Clothiaux 2006, Ch. 6.3) explains in great detail how to set up the necessary equations and density functions to perform this MonteCarlo simulation. Here are only the basics summarized:
Describing the set up
For the calculation a homogeneous cloud layer of a certain height is used. The cloud bottom is confined by the xyplane and the cloud top is parallel to this plane. Photons are injected at the top at (x=0, y=0, z=cloudheight) under an incident angle α. This is the angle between the positive zaxis and the incident beam that lies in the xzplane.
Determine travelling distance of a photon
The distribution for the photon path length x with a total mean free path mfp can be written as
With the following equation (and by using a uniform random number generator rand) it is possible to calculate a photon path length that fit this distribution:
Determine if photon is absorbed or scattered
The so called singlescattering albedo controls how likely a photon is scattered within the cloud. Since the singlescattering albedo sca represents the fraction of the photons that are scattered, a sca=1 means that all photons are scattered and sca=0 means that all are absorbed.
Determine scattering direction of a photon
For a scattered photon the azimutal angle φ is in all direction equally likely, so that its calculation is simply :
The scattering angle θ is a little bit more tricky, since not all direction are equally likely. By using the Henyey–Greenstein phase function, which has the so called asymmetry parameter g as single parameter, it is possible to incorporate a weighting difference between the forward and backward scattering direction. Thereby the asymmetry parameter g, which is the mean cosine of the scattering angle, determines the weighting of the scattering directions (g=1 for just forward scattering, g=1 for just backward scattering and g=0 for equal likely scattering directions).
Through following equation it is possible to draw the scattering angle θ:
These angles just give the change of direction in the local coordinate system of each photon. To set it in a global scale a transformation as follows is necessary:
Determine reflection from ground
Whether a photon  that is ejected at the bottom of the cloud  is reflected or not, is determined by the albedo of the ground. The albedo parameter ag basically represents the fraction of the photons that are going to be reflected. Hence it is between ag=0 (no reflection) and ag=1 (always reflection).
Since there is no information about the surface incorporated, the azimuthal angle φ as well as the polar angle θ for reflection at the ground are purely randomly distributed:
The programming framework root 6 was used to implement the simulation and to display its results. As indicated above the simulation depends strongely on random number generation. In this case the TRandom3 random number generator for drawing uniform distributed numbers was used. The program code has to be executed in a root 6 session with .x photon.C. Due to a basic menu structure (fig.1) it is possible to easily set cloud and initial parameters to start the simulation and to explore the outcome in several ways. Note that after drawing the result diagrams, it is possible to go back to the main menu by calling the function photon().
Figure 1: Main menu structure
The following parameters control the simulation and can be changed from their default value interactively.
Table 1: Simulation Parameters.
Parameter

Description

Default value


nphotons

Photon numbers

100

cloudheight

Cloud height

1

meanfreepath

Mean free path

0.02

asymmetryparameter

Asymmetry parameter

0.85

singlescatteringalbedo

Single scattering albedo

0.0

incidentbeamangle

Incident beam angle

180

groundalbedo

Ground albedo

0.0


root file name

"mc_photons.root"

The raw data is stored as a root tree and is available in a root file for further analysis. Note that the data is stored as calculated, that means, all iteration steps (over all photons) are depicted. Hence, the variables after a scattering event x are shown.
In addition, the root file contains the run parameters, the calculated results as well as all plots that were viewed with this data set. The complete file structure is shown in table 2:
Table 2: Root file structure.
Tree

Branch

Description


tdata

photon

Contains photon number

px,py,pz

Photon position in cartesian coordinates


nbottom

Number of photons ejected at cloud bottom


ntop

Number of photons ejected at cloud top


nreflected

Number of photons reflected at ground


nabsorbed

Number of photons absorbed within cloud


iscrossingtop

Photon crossed cloud top


iscrossingbottom

Photon crossed cloud bottom


dirx,diry,dirz

Photon direction in cartesian coordinates


travellingdistance

Photon traveling distance before scattering event


deviationangle

Scattering deviation angle at scattering event


scat_event

Number of scattering event




tresults

downirradiance

Calculated downward irradiance (normalized)

upirradiance

Calculated upward irradiance (normalized)


total_travellingdistance

Sum of all travelling distances over all photons


total_deviationangle

Sum of all deviation angles over all photons


mean_travellingdistance

Mean travelling distance of all photons


mean_deviationangle

Mean deviation angle of all photons




tparameter

nphotons

Calculation settings: photon numbers

cloudheight

Calculation settings: cloud height


meanfreepath

Calculation settings: mean free path


asymmetryparameter

Calculation settings: asymmetry parameter


bottomalbedo

Calculation settings: bottom albedo


singlescatteringalbedo

Calculation settings: singlescattering albedo


incidentbeamangle

Calculation settings: incident beam angle

The main interest of the simulation is the irradiance that is transmitted and reflected by the cloud. Both irradiances are displayed right after each simulation run. However, beside these results, the simulation yields information on the photon behaviour inside the cloud. For instance the traveling distance or the deviation angle between two successive scattering events. Since several photons are calculated with each simulation run, it is feasible to display histograms on these variables. Such histograms on the traveling distance and the deviation angles are shown in fig. 2 (bottom). In addition, the figure displays the zdistribution of scattering events (top right) and provides information on how many photons are absorbed in the cloud, ejected on the top (=reflected back up), ejected on the bottom (=transmitted) and reflected back from the ground (top left; notice that the set 'reflected back from the ground' is a subset of 'ejected on the bottom').
Figure 2: Photon histograms.
The program simulates the path of a photon through the cloud and it is possible to display the trajectories of single photons as shown in fig. 3.
Figure 3: Photon trajectories.
In most cases a photon will get ejected on the top or on the bottom of the cloud. An overview where this ejection takes place is provided by two polar plot representing the cloud top and bottom surface (fig. 4). The incident beam hits the cloud top in the center.
Figure 4: Photons at cloud surfaces.
Basic information of the amount of scattering events per photon as well as an quick impression of the xy and zdistribution of the scattering events are provided in fig. 5.
Figure 5: Photon scattering.