A Guide to FDTD Simulation with OpenEMS: Setup on Linux
Categories:
3 minute read
OpenEMS is an open-source Finite-Difference Time-Domain (FDTD) simulator that has seen some significant adoption. As I go through the setup for the second time, I’m noting down all the steps, common pitfalls, and useful resources to help others get up and running quickly. In this guide, I’ll walk you through the installation process, highlight some useful tools, and share the sections that stumped me.
It is a fully featured (although unpolished) software suite. I’m keeping a running list of FDTD options in this gist.
Alternatives
I should mention that there are other FDTD and EM simulator options available. I’m keeping a running Gist that includes various tools for electromagnetic field simulation.
Useful Links
- Forum (it’s active)
- Meta Repo w/ Dependencies: The project uses subrepos to keep dependencies up to date with a given release.
- OpenEMS Repo
- Official Documentation
- Installation Steps
- Open Imaging
- Python Wrapper: pyems Focuses on simulating PCB structures.
- Tutorials & Examples
- FreeCAD OpenEMS Plugin
- Blog Posts on OpenEMS Use
- Youtube Series: Excellent examples for using the FreeCAD interface with OpenEMS.
Installation
Package Manager
OpenEMS and AppCSXCAD are both available in Debian. As of writing (November 2024) version 0.0.35 is available on Ubuntu 22.04 but no version is available on 24.04.
sudo apt install openems appcsxcad
This method is quick and easy, but you may not get the latest version.
Docker
One of the easiest ways to set up OpenEMS is using Docker, especially if you already have Docker set up on your system. The OpenEMS Docker project provides a convenient way to run OpenEMS inside a container. However, I ran into issues with the default update functionality in that repo, so I’ve created a modified version that uses a more explicit installation process.
The OpenEMS Docker project offers a simple way to run OpenEMS in a container. However, I ran into some issues with the default update functionality in this repo, so I’ve created a modified version that uses a more explicit installation process.
Running An Example
Once OpenEMS is installed, you can try running one of the example simulations. The easiest way to test the setup is by running the Simple_Patch_Antenna example using the following command:
make run
This will execute the default Python script located in (examples/Simple_Patch_Antenna). I ran into some initial difficulties with this because the example code was doing some cleanup that obscured the results. I made a few modifications to preserve the simulation results and ensure that the XML configuration file is generated, which is useful for debugging and visualization.
Octave Interface & Linux
We’re using an Ubuntu Docker image so we only care about that here. The Octave & Matlab interface relies on finding and calling executables. Out of the box this fails to find the files locally or on the path so I edited the searchBinary function in CSXCAD to just return the name of the binary. This fixes the AppCSXCAD and openEMS issue. A pull request is probably in order.
Next Steps
My current focus is on simulating Time Domain Reflectometry (TDR) measurements for soil moisture and conductivity analysis. I’m planning to put together a selection of tests that can be confirmed from analytic analysis and some field tests to get comfortable.