Simulation has always been the dream of PCB design. In most cases, it hasn’t been practical – Either in the domain of expensive or esoteric tools that are compute-cycle hungry and limited in scope. But we’re at a turning point.
This is the process for current carrying / voltage potential simulations with KiCad and ElmerFEM.
Inspired mostly by some tweets by Daniel Giesbrecht, whereupon I picked his brain a bit.
https://x.com/DanSGiesbrecht/status/1787223477977837972
https://x.com/DanSGiesbrecht/status/1810312545242378332
There’s also this two-hour long youtube video by Lukas Henkel that goes over the exact procedure I’ll be describing. Coincidentally, he also just did a cool podcast episode of The Amp Hour.
This is an abbreviated set of notes, mostly for myself, but it’s possible that others will benefit, so I’m hitting the “publish” button.
I’m doing this test on the large comb-like trace in the centre of this PCB. The purpose doesn’t matter, and the test parameters are fake.
The process is a bit tedious, and uses four different software packages. But it’s already way better than it was, even last year. KiCad’s new export formats have eliminated the need for a whole other software package.
I’ll be using Windows for this, but other than different download links, I believe this process is fully cross compatible.
Let’s begin.
Software number one:
Newer version of KiCad (Currently nightlies 8.99, but likely mainlined starting KiCad 9) allow exporting in more formats than ever before. XAO is recommended for usage in Salome.
- Download KiCad 8.99 development, as of this writing.
- Open up the PCB file
- Go to File->Export->Step / GLB / BREP / XAO / etc
- Change the top left box to XAO
- Initially, use simple settings to test process, and not test your CPU
- Uncheck “Export board body / components”
- Export tracks, vias, pads, zones
- Fuse shapes
- Use the Net Filter box to only export your copper of interest (again, for now)
- Choose a filename and hit export
Software number two. Download Salome:
- In Salome, go to geometry workbench and import XAO
- Unhide geometry
- Right click geometry in tree->Create group
- Change it to flat plane, name in “input”, select input faces, add, apply
- Same for outputs
- Important for later: Click on output in the sidebar, then at the top, Inspection->Basic Properties. Take note of the Surface. In my case, 1.168319. This is in mm^2
- Save
- Go to mesh workbench
- Create mesh, 1D-2D-3D strategy, add hypothesis
- Max and min need to be played with, in millimetres – 02 / 0.08 worked well. Defaults were okay for me, but too fine.
- Apply out of that, right click mesh->Calculate
- right click the mesh in the sidebar, export to UNV
You’re done in Salome!
Onto software number three, ElmerFEM (GUI, No MPI).
- In Elmer, file->open the UNV
- Equation->add static current conduction
- IF THIS ISN’T HERE
- File->Definitions->Append
- edf/statcurrent.xml
- Close out of that, add new equation
- In static current conduction:
- Active, Apply to Body Property 1
- Click “Edit Solver Settings”
- Solver Specific Options->Calculate Joule Heating and Calculate Volume Current
- Apply, Update, and OK out of that menu
- Material->Add->Static Current Conduction
- Select copper (generic) from material library
- Change electric conductivity to 47.00e6, Apply to body
- Boundary condition->Add
- Call it “Input” at the bottom
- Static current conduction->Potential: 12V? Whatever
- Hit new, name it Output, Static current conduction->Current density
- It is in A/m^2 – grab the previously calced surface area (1.168319mm^2), convert to m^2 -> 1.168319e-6
- Divide 0.5A / 1.168319e-6 = 427965
- Current flows OUT, therefore = -427965
- OK out of both windows
- Find the boundary conditions (input/output) on the sidebar in Geometry->Boundary. Double click, set appropriate input or output for both.
- Save
- Sif->Generate. Sif->View log is also the main sim input settings, useful for debugging.
- Run->Start Solver
- If the solver doesn’t converge to near-zero (probably), then:
- In the sidebar, open up the Equation, then Edit Solver Settings
- Iterative->BiCGStabl
- Convergence Tolerance->1.0e-8
- Preconditioning->ILU2
- Hit Update, generate Sif, check the Sif file if desired
- Start solver
- If it converges to approximately zero (like, 1x10e-18), then it was successful! A .vtu file should have been saved.
At this point, the solver should complete. In my case, I first used the built-in ElmerVTK to view the output.
Who knew? Probably shouldn’t slam 500mA through a single via.
I recommend playing around with ElmerVTK within ElmerGUI for a bit. It wasn’t too hard to get it to display heatmaps based on my solver parameters. The results weren’t incredibly aesthetic, but they were simple to get results from.
But then if you want something prettier, move onto software number four: ParaView. Also no MPI.
The settings are mostly the same as ElmerVTK, just more complicated. Open up the .vtu file, find the same settings, and admire.
Future steps:
I have not done any research on what the preconditioning parameter above is, and that seems like an important topic to investigate.
This was originally done with an eye to creating a one-click KiCad plugin, but considering the multitude of softwares and settings used, there isn’t an obvious avenue to attack to lower the barrier to entry on this. This will remain in the back of my mind.
I may attempt to replace the Salome meshing steps with Gmsh. Gmsh is more lightweight, and should be able to do everything with the command-line, which would help with automation.
There are also a few ElmerFEM solvers that merit more investigation. Electrostatics, RF, and thermal solvers are all very relevant, depending on the project.
Adding in all of the other traces, signals, FR4, and embedding it in atmosphere is the very next step, for better thermal simulation.