Python Libraries to Add to Your Civil Engineering Toolbelt

Jakub Rybicki
5 min readSep 28, 2021

--

Python Assisted Design

If you’ve dabbled with Python, then you’ve probably realized what a powerful tool it can be for numerical analysis and data visualization. The vast number of libraries and modules that Python offers can make every step of the design process easier. Popular libraries such as Pandas, Numpy, Scipy and Matplotlib aide us in data collection/ cleaning, mathematical analysis and plotting and are extremely useful from project conception to construction.

As I learn more and more about data science and using Python in general, I’ve come across multiple libraries I wish I had learned about earlier in my career. Below is a list of libraries and modules that I found to be especially useful to any civil engineers.

Disclaimer: Some of these libraries are in early development but still recommend checking them out.

1. Groundhog

As a Geotech, I had to put this first on the list.

From: http://snakesonabrain.com/docs/groundhog/index.html

Groundhog is a Python package that provides functionality for dealing with any onshore or offshore geotechnical design. It focuses on:

· Flexible input parameter validation: Predefined parameter ranges are defined for most functions, based on the range of soil parameters for which the function was originally developed. This validation can be overridden by the user but requires explicit definition of the modified parameter ranges;

· Multiple outputs: Groundhog functions return a Python dictionary including intermediate results or derived quantities;

· Data standardisation: Possibility to read multiple input file formats (e.g. CPT data);

· Soil profiles: Easy encoding and manipulation of soil profiles.

But it also goes beyond that. It does the analysis and design of both deep and shallow foundations. It considers settlement, negative skin friction and differential stress distributions. As it is constantly being developed so more functionality can be expected.

2. LiquPy and ObsPy

Depending on where you are in the world, liquefaction may be a major concern when designing any structure. It tends to occur in areas where the soil is loosely compacted, uniformly graded and has a high water table. When working in areas where liquefaction may be a concern, then I highly recommend checking out Liqupy. It’s an open source Python library for soil liquefaction and lateral spread that uses borehole data to conduct and plot your analysis. The resulting plots are what you’d expect from any stand alone program that analyzes liquefaction but Python gives you the freedom to tweak it as you see fit. Below are some examples of LiquPy analyses(directly taken from github.com/mhviraf/LiquPy):

Liquefaction Analysis based on borehole SPT data
Lateral Spread Analysis

The majority of my engineering designs have been in New York State so seismisity is usually not a concern but I believe ObsPy deserves a mention for anyone that deals with seismic design regularly.

From: https://github.com/obspy/obspy/

This is one I’m keeping in my backpocket for when I do need to conduct a seismic analysis. ObsPy is an open-source project that provides a Python framework for processing seismological data. It interprets and analyzes seismic data and provides resulting values to be used in design. It also houses a worldwide database of seismic records from the past few decades.

3. PyNite

From: https://github.com/JWock82/PyNite

Finite Element Modeling (FEM) is probably some of the most in-depth analysis you can do on almost any civil engineering project. Typically it’s done in areas close to critical structures or less than ideal soil conditions. It’s when you need your design to be as accurate as possible because you’re confined to a very minimal margin of error. Plaxis is the most popular software for it although I’ve personally used FLAC3D for my models (technically it’s a finite difference analysis but the concept is generally the same). The issues with these programs is that they take a long time to model, they’re expensive and have a very steep learning curve.

PyNite is a 3D structural engineering finite element analysis library for Python. Since it’s an easier to use simplified version, it’s analysis is slightly less accurate than that of Plaxis of FLAC3D. Nobody is inputting pinpoint accurate parameters into these models anyway (it’s impossible to quantify exact, real world forces when designing behind a desk, especially not in geotech) so it’s definitely worth using in your design especially considering the amount of time and money you save by doing this in Python.

4. ArcPy

There are many great mapping Python libraries and they all essentially do the same general thing with some added functionality depending on which one you’re using. gisgeography.com does a great job going over some of the more popular ones and their utility. I have personally been using ArcGIS so I was glad to find a Python library specifically for that program, ArcPy.

From: pro.arcgis.com/en/pro-app/latest/arcpy/get-started/what-is-arcpy-.htm

ArcPy is a Python site package that provides a useful and productive way to perform geographic data analysis, data conversion, data management, and map automation with Python. It’s taking the already powerful ArcGIS program and essentially gives it more functionality while making it easier to manage, plot and organize all your data. Great add-on if you are already utilizing ArcGIS.

To sum things up…

The above Python libraries are what I personally plan to add to my roster and would recommend exploring to any civil engineer. You can always add to or modify these libraries if there’s some functionality or information you would want for future designs. Most of the libraries listed here are open-source so if there’s something you feel would be a beneficial addition, then you can contribute and help improve the tool for other engineers. There’s so many libraries that, aside from CAD drawings, you can do most of your engineering design and analysis using Python.

--

--