Assignment 7: Percolation
Percolation models are concerned with whether a porous media can be traversed from one end to the other. This could model e.g. oil in a reservoir, melting snow on compact soil, or brewing drip coffee.
Our percolation model here consists of a two-dimensional lattice, \(N\) cells high by \(M\) cells wide. Some cells are 'filled', others are 'empty'. The assignment of emptyness is random, such that any cell has a probablity \(p\) to be empty.
Next, we introduce a "walker" in each of the empty top row cells. In subsequent time steps, the walker moves one cell to left, right, down or up with probability \(l\), \(r\), \(d\), and \(u\), respectively, which depend on a positive parameter \(g > 1\) (representing the downwards tendency):
$$ l = \frac{1}{z} $$
$$ r = \frac{1}{z} $$
$$ u = \frac{1}{gz}$$
$$ d = \frac{g}{z} $$
where \(z\) is such that \(l+r+u+d=1\) [Note this previously mistakenly said that z=l+r+u+d]. However, the walker cannot move to a filled cell nor outside of the lattice. Impossible moves should be illiminated by setting the corresponding probablity to zero (note: this also affects \(z\)).
There is no interaction between the walkers. [Added as a clarification on March 21, 2025]
To improve statistics, we repeat the process \(K\) times, i.e., we start \(K\) walkers in each empty top row cell. Set a maximum number of steps of any given walker to \(S(M^2+N^2)\) but stop advancing walkers that have reached the bottom row.
Your assignment is to write an application that performs this simulation given the parameters \(M, N, p, g, S\), and the random seed.
- The simulation should determine the fraction of walkers that made it to the bottom.
- There should be modules for:
- handling the command line with input parameters,
- setting up the porous media array, and
- performing the simulation for a single walker,
in addition to the driver routine.
- Use rarray and C++'s random library.
- As usual, git version control should be used.
- The code should be well-commented.
- The Makefile should also contains a 'run' command that performs the simulation for these parameters: \(M, N, p, g, K, S = 200, 200, 0.7, 2.0, 25, 20\) and a specific seed of your choice.
- Provide a README document as well that explains which modules are need and how to compile and run the application. (It should be able to run on the Teach cluster, but submitting a job is not yet required.)