I want to build a hydrogeology model program

Hi everyone.

I’m not really sure how to preface this. so I guess I’ll just provide my background, and my reason for wanting to try and build something useful in Julia for my usage.

I recently finished my master’s degree in geophysics – specifically in geodesy in time-series analysis. I couldn’t find a job in my area of study, so I ended up taking a job at a local environmental resource and engineering consulting firm. I’m very grateful for the job. They’re a small business with a great local reputation in my area.

However, my job is mostly focused around source water protection and hydrogeology. Both of which I have very minimal knowledge in. I can tell you what a watershed is, and give a decent technical explanation of an aquifer, but beyond that, I’m pretty clueless.

Part of my job is providing ground water models for public water systems where we provide long term (20-50 year) conservative projections for sources of contamination in the groundwater (PFAS for example).

The software we use currently is called the Wellhead Analytic Element Model (WhAEM). Positives of this software is that it is free, it is somewhat easy to use in terms of entering the parameters, and it relatively fast at running the model. it’s GUI and “quality of life” usage, is not all that great.
You cannot run iterations for multiple years in one go. You cannot pan around the map to view things easily. You cannot use standard .shp, or other file types, but instead use these .bbm formats only available (as far as I know) on the EPA website. And the coordinate system is limited to UTM, which is crazy to me.

My reasoning for wanting to make something on my own is two-fold. One, having to write the code and figure out how to get it to work will increase my knowledge in this area, and two, I don’t have a hobby and thought it might be fun to challenge my self to try something I haven’t done before.

I used Julia extensively throughout grad school for geodesy with the GenericMappingTool wrapper, GMT.jl, as well as general data cleaning and manipulation, but most of what I wrote myself would probably be considered fairly simply scripts.

I guess this is my long-winded way of saying: I don’t really know where to start. I know what I would like to do, conceptually. Nice maps from existing databases. Modern data presentation. Robust and accurate calculations for the groundwater models. Not limited to a single coordinate system/reference frame. Intuitive parameterization.

This feels like an overly-ambitious project, but I have to remind myself this isn’t really FOR work and I can take all the time in the world to work on this as a hobby that just would happen to eventually benefit my career as well.

I guess I’m just looking for some advice, and what would be a good place to start in terms of packages and organization?
Any and all advice is welcome, and I hope to keep the Julia community in the loop as I attempt to make progress on my little hobby project here.

  • Rob
1 Like

I know that Homepage - Enabling Delta Life  | Deltares is modelling all the water above and below ground in NL using Julia. If you write them an email, perhaps they can give you a contact who might be able to provide some ideas?

They developed the GitHub - Deltares/Wflow.jl: Hydrological modeling package.

3 Likes

Sweet, thanks for the information. I’ll give them a shout.

There is no better way to learn a language than a project like this where you confront puzzles with a concrete goal, rather than just more stuff.

Groundwater—don’t sweat it. Permeability, porosity and Thiel’s equation will get you most of the way there.

Data tools—DataFrames is the Swiss army knife for tabular data. Bring it in via CSV or, if you are stuck with it Excel. Clean syntax for subsetting and subtotaling. Spring up PostgresSQL for a data back end. LibPQ provides clean query tools and if you are going to be dealing with biggest data, you’ll want it. Plus more, in a bit. BBM are “just” DLG plaintext files converted to binary. Both formats are evolutionary dead ends. I haven’t been able to find enough documentation to know what is in them besides the geometry. If it’s just the geometry, QGIS may be able to parse it outside Julia.

Surface mapping—Start with GeoDataFrames, which can read shapfiles into DataFrames as IGeometry types in ArchGDAL. The other formats, such as GeoJSON, are all easy to bring in also. Use GeoMakie with a CairoMakie back end to plot. GeoMakie will take a CRS string argument or ESPS codes for projections. ArchGDAL provides lots in the way of geocomputation, but consider PostGIS extension to Postgres, which provided optimized storage of geometries in Well Known Binaries.

Subsurface mapping—Here you will want GeoStats.jl which is specifically geared to 3D. Since I work primarily in 2D, I have’t found it congenial, but that’s where I’d go for 3D.

Modelling—You’ll find a lot to work from under the general heading of “mass transfer.” earthsciml.github.io has advection, SedTrace does sediment transport models. GMD - SedTrace 1.0: a Julia-based framework for generating and running reactive-transport models of marine sediment diagenesis specializing in trace elements and isotopes JutulDarcy.jl for porous media modelling, DPFEHM.jl for vadous flow, Anasol.jl for groundwater contamination transport flow, WFlow.jl for runoff. All sorts of stuff for dealing with differentials.

As you advance go to https://cran.r-project.org/ and look at the Task Views page for Hydrology, which has a bunch of stuff. R translates readily into Julia for rolling your own and you can call R from Julia, although it can be tricky.

I’m sure there’s more, but those are the ones I know about.

2 Likes

Is it PFAS?

Yes, sorry. Typo.

Thank you for all the insight and info! I’m familiar with a few of the packages you mentioned (DataFrames, Makie), but will definitely look into the others you mentioned I’ve not used before!

1 Like

Yes, it is. There are two aspects to it.

First, it is highly ambitious even if you just view it as a software project, especially if one of your aims is to produce something which could be useful for other people. You might learn more and produce more useful results and get more fun and/or frustration if you join some existing project (especially if you have no supercomputer in your garage :wink:).

Second thing is GIGO. Without good understanding of the science behind (either in your own head, or having some expert involved), “GI” is going to occure. And as you told us, in the subject area you are

pretty clueless

Personally I were to model PFAS contamination, I’d probably start by working through a textbook on soil chemistry. Which would presuppose some knowledge of general organic and inorganic chemistry.

I don’t think what I’m trying to compute will require anywhere near “super computer” capabilities. EPA’s WhAEM software runs on the very modest work computer perfectly fine.

I think looking to other projects as a reference, as well as collaboration will definitely be useful, but I don’t know that joining a project is necessarily the route I want to pursue.

Soil chemistry isn’t necessary at all. Soil is a surface property, and not considered in most geophysical studies. Aquifers are confined by lithology usually 10-100’s of feet deep.

I am reading through a textbook currently, though. Groundwater and Wells, by Robert J. Sterret, Ph.D. It has been an interesting and fun read.

3 Likes

Thanks for the shout out. Yes we are using Ribasim to model all the surface water. Though for the subsurface we rely on an online coupling with MODFLOW 6, which is a widely used groundwater model that we help to develop with the USGS, and is written in Fortran. (I did at one point make Deltares/ModflowInterface.jl)

I am not aware of any analytical element method (AEM) code in Julia, would be great to have one. I should tag my colleague @Huite who’s been hacking on both AEM code & QGIS plugins for them as well as Julia simulation, just not both in the same project yet :wink:

2 Likes

I have some python code for an AEM here: GitHub - vcantarella/study_project: rbf aem modelling script. I have been trying to find the time to port and update this to julia. Would love to contribute to groundwater modelling tools. I have some sketches myself.

FWIW the page for EarthSciML is at a different URL: Home · EarthSciML. We’re friendly!