pycon logo

PyCon 2011 Atlanta

March 9th–17th

Log in or Sign Up

Python for Hydro-Geo-Chemical Modeling

log in to bookmark this presentaton

Novice / Poster
Modeling of chemical processes in the subsurface is very important for a the investigation of environmental problems. The leading modeling software in this field is PHREEQC. When combined with Python new applications such as comprehensive scenario analysis, construction of phase diagrams, or multi-dimensional reactive transport modeling become possible.

Abstract

Mine water drainage, landfill drainage, or abandoned industrial plants cause many environmental problems. To solve these problems complicated chemical processes in the subsurface have to be examined.

Numerical modeling has been established as viable method to describe and predict the hydro-geo-chemistry of complex systems. PHREEQC, a Public Domain program by the United States Geological Survey, is probably the worldwide most used software for this type of modeling. The reasons for its popularity are the numerous processes it can handle as well as the very flexible text-based input format.

Python is very powerful when it comes to string processing and hence can be used to programmatically generate input files for PHREEQC. After running PHREEQC with help of the module subprocess the modeling results can be easily read with Python. This simple technique opens up the possibility for a wide range of new applications.

Previously nearly impossible tasks become simple. Hydro-geo-chemists with only a little Python experience can quickly automatically assemble input files and run hundreds or thousands of calculations without any manual effort. Phase diagrams can easily be constructed using this technique. Multi-dimensional, reactive transport modeling is surprisingly simple using Python. Two programs, a flow-and-transport software and PHREEQC are sequentially run with Python. Constructing input files and reading output files combined with the appropriate conversions of data in Python can be used to create a new model without changing the original programs. Even though this involves some more programming and demands more Python expertise, it is much less laborious than coupling the models with compiled languages.

Publication-quality diagrams can be generated from the modeling results with matplotlib. Once automated, the workflow of changing input values, rerunning the calculations, and displaying the results is much faster than the traditional spreadsheet-base approach.