← All projects

Project

Monte Carlo Photon Transport

I built a Monte Carlo photon-transport model to explore how a cloud's optical thickness and absorption affect the light passing through it. The project began as my computational physics midterm at UMBC in spring 2017; the browser explorer here reconstructs that problem.

Interactive reconstruction

Send photons through a cloud

Choose how thick the cloud is and whether collisions scatter or absorb. Watch sample photon paths, see what share gets through, bounces back, or is absorbed, and then see how that estimate settles as more photons are simulated.

Three fates for every photon

The illustration shows the three possible outcomes. Start the simulation to follow photons through the cloud.

A photon that enters the cloud either passes out the bottom, is turned back out the top, or is absorbed on the way. Monte Carlo answers how often each happens by simulating many random photon histories and counting.

Without scattering, the share that passes straight through is exp(−τ): about 61% for a thin cloud (τ = 0.5), 14% for a medium one (τ = 2), and 0.7% for a thick one (τ = 5). Scattering changes that picture, and the explorer shows how.

Interactive reconstruction of my 2017 PHYS 220 cloud-transport project.

How this reconstruction works

Everything shown here comes from freshly generated runs of an idealized model, written for this page. These are not the archived 2017 results. The original was a midterm project for PHYS 220 in spring 2017 and made simpler modelling choices than the version here; its files are unchanged and are not published on this site.

The model

  • A uniform slab of cloud, measured in optical depth from z = 0 at the top to z = τ at the bottom. Optical depth is dimensionless; it measures extinction along a path, not distance in metres. The slab extends indefinitely sideways, so photons can escape only through its top or bottom.
  • Every photon enters at the top travelling straight down. Its flight to the next event is exponential: s = −ln U with U drawn strictly between 0 and 1.
  • The boundary is checked before any collision is placed. A flight that would cross the top counts as reflected; one that would cross the bottom counts as transmitted.
  • Otherwise the photon collides. A separate random draw absorbs it with probability 1 − ω; if not absorbed, it scatters in a new random direction, uniform over the full sphere.
  • ω is the probability of scattering per collision, also called the single-scattering albedo. ω = 0 means every collision absorbs; ω = 1 means nothing is ever absorbed. It is not the fraction of incoming light reflected by the whole cloud.

Scattering is isotropic here: all directions are equally likely. Real cloud droplets scatter preferentially forward. This model isolates the roles of scattering, absorption and optical depth without representing a particular cloud or wavelength.

The data

  • Your chosen optical depth (0.01–10) and scattering probability (0–1) are simulated in your browser. Each setting has three independently seeded runs of 50,000 photons, with tallies recorded at 100, 300, 1,000, 3,000, 10,000, 30,000 and 50,000 photons.
  • Each setting also has a reference run of 200,000 photons with its own seed. It is a reference estimate with its own sampling uncertainty, not exact truth.
  • The closed-form checks used here cover the limiting cases. With ω = 0 the transmitted fraction is exp(−τ), nothing is reflected, and the rest is absorbed. With ω = 1 nothing is absorbed. In every other case exp(−τ) is only the unscattered direct beam, not the total transmission.
  • Uncertainty bands are 95% Wilson score intervals, computed separately for each outcome, so they are not simultaneous. Checkpoints within one run share photons and are correlated. Every photon is counted exactly once.
  • The sample paths are the first 1–100 photons from a separately seeded stream, recorded as they are generated and clipped where they cross a boundary. Entry points are spread across the top using a separate random stream; horizontal position does not affect transport in this laterally uniform slab. They were not drawn by hand or chosen for appearance. The picture is a two-dimensional projection of three-dimensional motion.

The browser uses fixed seeds with a xorshift32 random generator, so repeating settings reproduces the same paths and estimates. It implements the same transport rules as the original Python reference generator, with different random streams. Download the nine-setting Python reference dataset (JSON); this static file does not contain your current browser run.

Background: Wilson interval, NIST/SEMATECH e-Handbook of Statistical Methods · Monte Carlo simulation of light transport, Scratchapixel.

Following the light

Monte Carlo methods estimate a result by repeatedly sampling possible events. Here, each photon enters a uniform cloud layer from above, traveling straight down.

Optical depth describes how much opportunity the layer presents for an interaction (a dimensionless measure of extinction). Single-scattering albedo gives the probability that an interaction scatters the photon instead of absorbing it. Together, these determine the fractions of incoming light transmitted through the bottom, reflected through the top, or absorbed.

The model samples the distance to the next interaction from an exponential distribution in optical-depth coordinates. If a boundary is reached first, the photon leaves the layer; otherwise, it is absorbed or scattered into a new direction.

The model assumes a flat, laterally infinite layer and isotropic scattering (all directions in three dimensions are equally likely). Real cloud droplets scatter preferentially forward.

Paths and estimates

The explorer pairs a projection of sampled photon paths with statistics from three independent runs of 50,000 photons each. The paths make individual scattering events visible; the larger runs estimate the outcome fractions. Changing the number of animated paths leaves those statistical samples unchanged.

A separate Monte Carlo run of 200,000 photons provides the comparison reference. As the sample grows, uncertainty intervals generally narrow, but estimates can still move toward or away from that reference at successive checkpoints.

There is also an exact quantity to compare: the fraction passing through without any collision is exp(-optical depth). Scattered photons can also reach the bottom, so this direct fraction is only part of total transmission when scattering is present.

From notebook to browser

I wrote the original notebook with Python, NumPy, and Matplotlib. Later, as a teaching assistant for the same course, I graded other students’ implementations of the assignment. The present browser implementation is a new reconstruction with checks for count conservation, limiting cases, and statistical agreement with an independently implemented Python reference at nine settings.

The explorer’s “How this reconstruction works” note explains the method, and the nine-setting Python reference dataset is available to download.

Skills & tools