In the Martian, explain Mark’s water situation

In "The Martian," Mark Watney, the main character, finds himself stranded alone on Mars after his crew mistakenly assumes he died during a violent dust storm and leaves without him. One of the crucial challenges Watney faces is the availability of water, as sustaining life on a barren planet without access to water becomes a central issue for his survival.

Initially, Watney relies on his limited water supplies from the Hab, a habitat module designed for his crew's stay on Mars. He carefully rationed the remaining water, estimating that he had roughly 400 sols (Martian days) worth of water to survive. He also conserves water from various sources, for instance, recycling his crew members’ wastewater and extracting any moisture he can from within the Hab.

To extend his water supply, Watney also starts growing crops using the Martian soil, or regolith. Aware that he would require vast amounts of water for the plants to grow, he comes up with a plan to create a sustainable ecosystem within the Hab. He uses his chemistry expertise to produce water through a process called electrolysis, which involves splitting hydrogen molecules from the Hab's rocket fuel hydrazine. By burning hydrogen with oxygen from the Hab's life support system, he generates water.

Moreover, Watney encounters a fortuitous event when he discovers NASA's Pathfinder lander, an old probe, still operational on Mars. He repurposes the probe's radioisotope thermoelectric generator (RTG), a nuclear battery, to power the electrolysis process. This establishes a continuous supply of water to sustain the growing crops within the Hab, thereby creating an ecological cycle.

Throughout the story, Watney faces various water-related challenges, including a failed water reclaimer system, a breach that floods the Hab, and water scarcity as his crops fail. However, his resourcefulness and scientific knowledge enable him to find creative solutions to these obstacles, preventing dehydration and ultimately helping him survive on Mars until rescue becomes a possibility.