Export PCB board to OpenEMS?

Hello all,

Recently I’ve discovered OpenEMS and I would like to use it to simulate some RF board that I’ve created using Kicad. But seems that there are a big hole between those tools.

Perhaps the way to go would be to create a python script that reads the .kicad_pcb file and generates a octave/mathlab .m file for OpenEMS ?

Anyone had some experience doing that ?


Hi @chrishawk

I don’t have experience with generating an .m file but I do have experience with reading and manipulating KiCAD PCB files in C++. The PCB file format is based on S-expressions and simple to parse. You could also do this in Python.

An alternative route would be to generate a Hyperlynx ASCII file and import that using hyp2mat. Although I couldn’t find a specification for the Hyperlynx file format, a couple of projects use it so I expect the information is out there somewhere.


My colleague showed me this tool recently, seems pretty handy for simulations :slight_smile:
I found Eagles implementation here: https://github.com/plusea/EAGLE/blob/master/ulp/hyperlynx.ulp
Perhaps it could be ported to kicad and python? Even cooler would be an addition kinda like the NGspice engine, but that probably way out in the future (and more minded on the devs list)

1 Like

The FOSS layout editor pcb-rnd can load a kicad layout and can export a layout in hyperlynx format, allowing a Kicad user to get to hyperlynx format.

The hyperlynx export code was written by the same guy who wrote hyp2mat.

pcb-rnd can be also invoked as a headless cli utility, allowing scripted or batch conversion with the right command line flags, so there wouldn’t be too much preventing a pretty seamless solution.

Alternatively, you could look at the hyperlynx export code


to help in rolling your own implementation.




thanks @erichVK5 for the info…
OpenEMS is a great tool and it would be very nice to have a Kicad integration…

do you know which is the license for this exporter?

EDIT it is GPL 3 :smiley:


Hi. I’ve written small software to convert KiCAD PCB files to use in openEMS.
It converts PCB file to Octave/Matlab function file that can be used directly with openEMS
structures. Additional feature is it can generate automatic mesh lines for PCB
geometry. There are some other functions, but all is not documented completely.

Here is the link to project: pcbmodelgen


that is awesome!!
Ill have a look at it in the upcoming days :slight_smile:
do you think this could be added to the Export menu inside PCBnew?

Probably it could be done, but my program needs configuration file, at least for
some of the functions. Now you must pass JSON configuration with it.
There are many options that are not PCB related, but more for FDTD.

For example, you can set if copper layers are simulated as real material with
thickness or zero thickness polygon (one mesh line) .

Hmm could be a extremely nice addition :slight_smile:
And welcome to the forums, some first entry!

very nice though!
What do you use to build it?
Do you think it would be possible to port it to python to avoid the compiling?

1 Like

Build is with cmake. It should be very straight forward.
Only few command lines.

Porting probably would be very much work. It depends on TinyXML2 and a lot of C++ STL.
Also minor Boost usage.

You are on Linux aren’t you?
On win it would be more difficult :wink:

Yes I’m using Linux :slight_smile:
Maybe I’ll create binary for windows, if I have time.

I suppose the settings could go in a dialog with an export button :slight_smile:

I’m trying to build it on MSYS2 chain (the one from KiCad winbuilder)
I could install both:
TinyXML2 and TCLAP
I also made the config to complete
cd pcbmodelgen
cmake -G "MinGW Makefiles" -DTINYXML2_INCLUDE_DIR==../../../../../../mingw64/mingw32/include/ -DTINYXML2_LIBRARY=../../../../../../mingw32/lib -DTCLAP_INCLUDE_DIR=../tclap-1.2.1/include
but the command make just fails…
@jcyrax would you give me a tip?

@maui I think you need to run cmake in new build directory that is not project directory.
Create directory build and from there run:
cmake [all parameters] …/

If it doesn’t work, please include what output do you get from running make.

1 Like

tried to create a build dir and run the command… still the same error…
here the Makefile created, with the CMakeLists.txt slightly modified
Makefile.zip (5.8 KB)

@maui can you post the error text here?

here the log and errors
CMakeOutput-log.zip (4.9 KB)

@maui I made some changes in code and CMakeLists.txt it may be the fix, but not sure.
Tried, also, to compile on Win, but my MinGW has some bug with c++11 support.
Hope this helps.