gprMax is a freely-available set of electromagnetic wave simulation tools based on the Finite-Difference Time-Domain (FDTD) numerical method. Initially developed in the mid-1990s it has been widely used, principally to simulate Ground Penetrating Radar (GPR), for applications in engineering and geophysics. The original C-based code has been rewritten using Python, NumPy, and Cython with OpenMP.
gprMax (http://www.gprmax.com) was originally developed in 1996 when electromagnetic numerical modelling using the FDTD method was in its infancy. Since then a number of commercial and other freely-available FDTD-based solvers have become available, but over the past 18 years gprMax has been one of the most widely used simulation tools in the GPR community. It has been successfully used for a diverse range of applications in academia and industry. gprMax is cross-platform and was originally written using C, with the resource intensive parts – the main FDTD solver loops – parallelised using OpenMP. It uses a simple text-based input file where users specify all the parameters for a simulation, e.g. model size, discretization, time window, geometry, materials, excitation. This allows gprMax to be very flexible and scriptable and also allows it to run in high-performance computing (HPC) environments. To facilitate the implementation of new more advanced features and to lay the foundation for future developments, the code has been rewritten using a combination of Python, NumPy and Cython with OpenMP.
The initial process for building a FDTD model involves creating and configuring materials, geometry, and excitation sources, all of which fit quite well into an object-based programming model. Using Python rather than C has enabled these initial processes to be more easily and elegantly implemented, and has allowed much more complex functionality to be added. After this initial stage, but before the main FDTD calculation can begin, there are a number of element-by-element manipulations and operations that are carried out on large 3D arrays. Here, NumPy has been utilised, for example to carry out 3D Fast Fourier transform (FFT) functions. The main FDTD solving calculation is the most computationally intensive part of the code and for this reason these parts of the code have been written and parallelised using Cython. Initial testing of the new version of gprMax has shown near equivalent performance compared with the original C code. It has also demonstrated much simpler pathways to implementing new advanced features such as multi-pole dispersive material modelling, anisotropic material modelling, and the ability to load complex pre-defined objects from Python modules.