
Hydrology and groundwater science hidden in a well that has flowed for four thousand years.
The Desert
The valley of Makkah is one of the harshest places on Earth. It sits in a cleft between barren granite hills in western Saudi Arabia, where summer temperatures soar past 50°C and rain falls perhaps two or three times a year. Nothing about this landscape suggests water. The rocks are dry. The soil is dust. The sky is an unbroken blue from horizon to horizon.
And yet, in the heart of this valley, inside the most sacred mosque in Islam, there is a well that has produced water continuously for over four thousand years.
Hajar’s Search
The story begins with a mother’s desperation. According to Islamic tradition, the Prophet Ibrahim (Abraham) brought his wife Hajar (Hagar) and their infant son Ismail (Ishmael) to this barren valley and left them there, trusting in God’s plan.
Hajar had a small skin of water. It ran out quickly. Her baby cried from thirst. She did what any mother would do — she searched for help. She climbed the small hill of Safa and scanned the horizon. Nothing. She ran to the hill of Marwa and looked again. Nothing. She ran back and forth seven times, growing more desperate with each pass.
When she returned to Ismail, she saw something extraordinary. Where the baby had been kicking the ground with his heels, water was bubbling up from the earth. A spring, emerging from the barren desert floor.
Hajar cupped her hands around the spring to contain it, saying "Zam! Zam!" — "Stop! Stop!" — fearing the water would run away. The spring held. It became a well. And that well attracted travellers, then traders, then settlers. A city grew around it. That city is Makkah.
The Well Today
The Well of Zamzam still flows. It sits 20 metres east of the Kaaba, the cube-shaped structure at the centre of the Grand Mosque. Today it is accessed through underground taps rather than the original open shaft, but the water comes from the same source it always has: a fractured rock aquifer in the Wadi Ibrahim valley.
The well has been tested by the Saudi Geological Survey. It produces approximately 18.5 litres per second — enough to fill a bathtub every seven seconds. During the Hajj pilgrimage, when millions of people drink from it, the well is pumped at rates exceeding 8,000 cubic metres per day. The water level drops, but it recovers within hours when pumping stops.
How? How does a well in one of the driest places on Earth produce water endlessly? The answer lies underground — in the science of hydrology and groundwater.
Where the Water Comes From
Rain that falls on the hills surrounding Makkah does not stay on the surface long. Most of it evaporates. But a fraction seeps into cracks in the rock, percolating downward through fractures and porous zones until it reaches a layer of saturated rock called an aquifer. There, it joins a slow-moving underground reservoir that feeds the well.
The Zamzam aquifer is not a single pocket of water. It is a network of fractured crystalline rock — alluvium, weathered granite, and metamorphic rock — that stores and transmits water over an area of several square kilometres. The water that emerges from the well today may have entered the ground as rain years or even decades ago. It has been filtered through rock, purified by time, and enriched with minerals along the way.
This is the story of all groundwater. It is the story of a hidden, patient cycle: rain becomes rock-water becomes spring becomes life.
The end.
Choose your level. Everyone starts with the story — the code gets deeper as you go.
Here is a taste of what Level 1 looks like for this lesson:
# Darcy's Law Calculator
K = 0.001 # hydraulic conductivity (m/s)
A = 500 # cross-section area (m²)
h1 = 50 # upstream head (m)
h2 = 48 # downstream head (m)
L = 100 # distance between points (m)
Q = K * A * (h1 - h2) / L # m³/s
Q_litres = Q * 1000
print(f"Hydraulic gradient: {(h1-h2)/L:.4f}")
print(f"Flow rate: {Q:.4f} m³/s = {Q_litres:.1f} L/s")
print(f"Daily flow: {Q * 86400:.0f} m³/day")
# Compare to Zamzam's 18.5 L/s
print(f"Zamzam produces: 18.5 L/s")
print(f"Our aquifer: {Q_litres:.1f} L/s")This is just the first of 6 coding exercises in Level 1. By Level 4, you will build: Build a Groundwater Flow Simulator.
By Level 4, enrolled students build: Build a Groundwater Flow Simulator
Free
Level 0: Listener
Stories, science concepts, diagrams, quizzes. No coding.
You are here
Level 0 is always free. Coding levels (1-4) are part of our 12-Month Curriculum.
The science of underground water — aquifers, porosity, Darcy’s law, and sustainable water management.
The big idea: "The Well of Zamzam" teaches us about Hydrology & Groundwater — and you don't need to write a single line of code to understand it.
Dig a hole in wet sand at the beach. What happens? Water seeps in from the sides and fills the bottom. You have just discovered groundwater — water that fills the spaces between soil particles and rock fragments beneath the surface.
About 30% of the world’s freshwater is groundwater (the rest is mostly locked in ice). It exists almost everywhere beneath the surface, filling the tiny gaps in sand, gravel, and fractured rock. The top of the saturated zone — where every space is filled with water — is called the water table.
An aquifer is a body of rock or sediment that stores and transmits groundwater. The best aquifers are made of materials with lots of connected spaces: sandstone, gravel, fractured limestone. Poor aquifers are made of materials with few or unconnected spaces: solid granite, dense clay.
The Zamzam well taps into an aquifer of fractured crystalline rock. Rain falling on the hills around Makkah seeps into fractures and slowly migrates downward and sideways until it reaches the well. The journey from raindrop to Zamzam may take years or decades.
Check yourself: If you drilled a well on a hilltop, would the water table be at the same depth as a well in the valley below? (Hint: the water table roughly follows the land surface, but smoother.)
Key idea: Groundwater fills the spaces in soil and rock beneath the surface. The water table marks the top of the saturated zone. An aquifer is a rock formation that stores and transmits water effectively.
Fill a jar with marbles. Now pour water into it. The water fills the spaces between the marbles. The fraction of the jar’s volume that is empty space is called porosity. For marbles (or well-sorted gravel), porosity is about 30-40%.
Now try the same thing with a jar of mixed-size gravel — large pebbles, small pebbles, and sand. The small particles fill the gaps between the large ones, leaving less empty space. Porosity drops to maybe 15-25%. This is why a beach of fine sand holds less water per cubic metre than a beach of uniform coarse gravel.
But porosity alone is not enough. The spaces also need to be connected so water can flow through. Permeability measures how easily water flows through a material. Gravel has high permeability — big, connected spaces. Clay has high porosity (up to 60%) but very low permeability — the spaces are so tiny that water cannot squeeze through them. Clay is like a sponge you cannot wring out.
The Zamzam aquifer has moderate porosity (5-15% in fractured rock) but good permeability because the fractures are connected. Water flows through a network of cracks rather than through the rock itself.
Try this: Take two clear bottles. Fill one with coarse gravel, the other with fine sand. Pour the same amount of water into each and time how long it takes to flow through. Gravel drains fast (high permeability). Sand drains slowly (lower permeability). Both hold water (both have porosity), but their ability to transmit it differs dramatically.
Key idea: Porosity is the fraction of rock that is empty space. Permeability is how easily water flows through those spaces. A good aquifer needs both — plenty of space AND connected pathways for flow.
Access all 130+ lessons, quizzes, interactive tools, and offline activities
In 1856, a French engineer named **Henry Darcy** was designing a water filtration system for the city of Dijon. He filled columns with sand and measur...
The Zamzam well has survived for millennia in one of the driest places on Earth. How? The answer is a balance between **recharge** (water entering the...