One of the main difficulties when simulating a PCB using FEM is converting the PCB design into a simulation ready geometry. Especially when using open source tools. When using tools like KiCad the STEP export does not include copper features like traces and pads. While this is perfectly fine for mechanical design, they are required for meshing and simulation.
The fabrication data (gerber files) contains the information needed to create the physical PCB, but converting it to a 3D model that is usable for meshing/simulation is non trivial.
In this post we will take a look at how we can use free and open source tools to convert gerber files to STEP files that are defeatured and ready for meshing.
After the mesh is created we can simulate the PCB (e.g. a patch antenna) to see current flow, reflection coefficients (S-parameters), near and far field patterns, etc.
The figure below shows the two PCBs we will work with in this post. On the left, fig. 1a a real square patch antenna and on the right, fig. 1b an antenna in the form of the cerbsim logo.
To convert from gerber to STEP we will use a free browser based tool I have worked on as a side project at work. It runs locally in the browser so no files are uploaded to any server. We will discuss how it works in the section below.
To get the STEP files we can use the following workflow:
After downloading the STEP file, we can import it into our meshing or FEM software and start simulating.
Fig. 2 shows the resulting geometry on the left (2a) and the corresponding mesh on the right (2b). Note that internal layers are also included and meshed.
When converting Gerber files to STEP for simulation, a few common issues can lead to failed imports or meshing problems:
The gerber to STEP converter is built using python and runs in the browser using the open source ngapp framework.
Internally Netgen and Open Cascade are used to draw the geometry based on the gerber files. To eliminate small edges that stem from rounding errors in the gerber files splines are fitted and small adjacent edges are merged. Subsequently all overlapping faces are unified and a STEP file suitable for simulation is created.
The web app itself runs locally in the browser so no files are uploaded or shared. The downside to this is that running a full python environment in the browser is slower than running it natively.
Fig. 3 shows the web app after loading a design. In the top left a 2D preview of the selected layer is displayed. Below it a 3D preview of the whole PCB. On the right the detected and assigned layers are listed.
Loading the files should not take long. If the progress bar stalls, make sure you have only uploaded the files discussed above. Drill files must be in GerberX2 format, no "empty" files, no silkscreen etc.
For simulation purposes it is a good idea to simplify the geometry where possible (defeaturing). This means no text in the copper layer because it looks cool!
If you want to try it out, head over to the Gerber-To-STEP webapp and sign in via e.g. GitHub. The example files used in this post can be found in the download section below.
Working directly with the fabrication data, we can rebuild the full PCB geometry including traces, pads, and internal layers and make it usable for meshing without a lot of manual cleanup.
Using the Gerber to STEP web app makes it easy to locally convert Gerber files to STEP format for simulation. All features relevant for FEM are included while small edges are removed.
We are therefore not tied to a specific toolchain. You can use whatever PCB design software you prefer and combine it with both open-source and commercial simulation tools.
The content published on this page (with exceptions) is published under the CC Attribution-NonCommercial 3.0 Unported License. You are free to share on commercial blogs/websites as long as you link to this page and do not sell material found on blog.hirnschall.net/* or products with said material.