Lemma is an ElectroMagnetics Modelling API

Trevor Irons and M. Andrew Kass and others

Originally Lemma was intended as a recursive acronym standing for Lemma is an ElectroMagnetics Modelling API. As the breadth of the project has expanded, the name has remained appropriate in a more liteal sense. Lemma is a flexible cross-platform library delivering an expressive API that can be used to easily create versatile programs. Lemma is not itself a program, instead it is a collection of building blocks to make applications. We retain this name because:

  • In mathematics a Lemma is a proven proposition which is used as a stepping stone to a larger result rather than as a statement in-and-of itself.
  • In addition to the electromagnetic modelling, some other facilities are provided such as numerical optimization and inversion capabilities. These tools are also considered stepping stones to final products.

We feel that this is a partucularily approprate name, as Lemma's API can be leveraged create powerful applications such as forward modelling and inverting frequency and time-domain surveys of arbitrary survey design, sNMR surveys, CSAMT and more.


Why another Geophysical EM project? For starters, there aren't that many quality open source packages out there. Those that do exist are generally specialized to perform a single task and extending them is a major undertaking. Lemma's approach is much different, by providing a set of general tools users can easily assemble applications that suite their needs.


In the long term, we have many goals for this software project. Due to its design, Lemma can be built upon and extended easily. The initial aim is to provide flexible 1D and 3D EM modelling in the time and frequency domains. The project is still in beta, but we have made a lot of progress already. We will release our first non-beta release as soon as the following are supported.

Frequency-domain forward modelling

Lemma was initially called EMMODFD: Electromagnetic Modelling in the Frequency Domain. As such this is the most mature area of Lemma.

Frequency domain solutions to electrical and magnetic dipoles can be computed quasi-analytically in 1D. Calculations can be made in or above the layered media, and complex electrical conductivity and magnetic susceptibility are supported according to the Cole-Cole model. Sources may be embdedded in the media or in the resisitive air layer. Lemma can also can compute fields due to arbitrarily shaped ungrounded wire loops, topography of the loops is also supported. Two separate approaches to solving the Hankel transform, one based on Anderson's digitial filtering technique, and another based on Gaussian quadrature.

A fast 3D solver that can modify the 1D results based on arbitrary electrical conductivity model is nearing completion.

future work

We are also planning on supporting grounded wires in the near future.

Time-domain forward modelling

A 1D time-domain solution has been implemented that utilises both a dipole source as well as a wire loop. Currently, only one receiver is modelled at a time, but will be generalised. In addition, utilities to read in data files for modelling have been implemented. We would like to offer 3D time domain support, but this will not be provided before our first stable release.

Data Formats

The EM community is plagued with myriad data formats. Often each equiptment manufacturer provides their own data format and interoperability is a constant struggle. We are working on a flexible data format based on the XML format that can be adapted to many types of data. The template for this format will be publically released and we hope it catches on in the community. At the least, it will provide a mechanism to compare datasets and datatypes within Lemma.


Due to Lemma's design, it is easy to extend the platform. In some cases this extension results in adding functionality that is not directly related to ElectroMagnetics. The following modules utilise parts of Lemma to provide their functionality.


  • Tutorial - Basic intruduction to Lemma, including aquiring and compiling the code, class structure, and building your own applications.
  • Extending Tutorial on how to extend Lemma.

Development and design

Ths package was initially developed by the Center for Gravity, Electrical, and Magnetic Studies (CGEM) at the Colorado School of Mines (CSM), the United States Geological Survey (USGS), and Broken Spoke Development, LLC. Where it drew on work by many others including Ki Ha Lee, and Walt Anderson. All new work and interfaces are written entirely in C++. Several small external projects are included, which are written in standard C, and FORTRAN 77. We adapt a modern, test driven, object oriented, C++ framework. More recent development has been undertaken at the University of Utah through the Energy and Geoscience Institute.



The following copyrights apply to the source. Most of the code was developed either by Trevor Copyright (C) 2008-2010 Trevor Irons trevo.nosp@m.r.ir.nosp@m.ons@l.nosp@m.emma.nosp@m.softw.nosp@m.are..nosp@m.org or M. Andrew Kass Copyright (C) 2010 mkass.nosp@m.@usg.nosp@m.s.gov.

The 1D EM solver was derived (but updated heavily) from a Fortran programme written by Ki Ha Lee in 1984. We have communicated with Ki Ha, and he assured us that this code is in the public domain.

A Gaussian quadrature hankel transform originally written by Alan Chave was ported to C++. This code is in the public domain, and the source code was published in Geophysics.

A digital filtering approach to the Hankel transform written by Walt Anderson was also rewritten for Lemma. The original Fortran code is also in the public domain.

Please note that Ki Ha Lee and Walt Anderson had no part in this work, and the above should not be interpreted as any sort of endorsement by those parties.


This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Suggestions and contributions

We welcome contributions and suggestions. Feel free to email the development team at info@.nosp@m.lemm.nosp@m.asoft.nosp@m.ware.nosp@m..org. Under the terms of the MPL, if you modify a Lemma file, you are obligated to share those contributions back with the community.

Useful links