The percolation problem is a classic problem in physics and mathematics that models the flow of fluids through porous materials. It is commonly used to study phenomena such as the flow of water through soil, the spread of contaminants in groundwater, and the conductivity of certain materials.
Imagine pouring liquid onto the top of a porous material. Will the liquid eventually make its way all the way through to the bottom? This is the fundamental question posed by the percolation problem.
To model percolation, we typically represent the porous material as a grid of cells. Each cell can either be open or closed. Liquid can flow through open cells but not through closed ones.
The percolation problem involves determining whether there is a path of open cells from the top of the grid to the bottom. If such a path exists, the liquid can percolate through the material.
One common approach to solving the percolation problem is to use a depth-first search (DFS) algorithm. Starting from the top of the grid, the algorithm explores neighboring cells to find a path to the bottom. If such a path exists, the material is said to percolate.
percolation.py
: Contains functions for determining whether percolation occurs and for flowing liquid through the material.percolationIO.py
: Handles input and output for visualizing percolation simulations.estimate.py
: Estimates the probability of percolation given certain parameters.parent.py
: Provides a mechanism for importing modules from the parent directory.
To use the code:
- Ensure you have Python installed on your system.
- Clone the repository containing the code.
- Run the desired Python script with appropriate command-line arguments to specify grid size, probability of cell openness, and number of trials.