Open source power analysis tool?

I would oppose this. Integrated tools help people to improve those instead of creating their own forks, and allows better integration. For Signal Integrity, there exists for example https://github.com/jcyrax/pcbmodelgen, but from what I heard from a college, it does not really produces correct geometries sometimes. I assume one reason for this is that this is a standalone-tool which does not utilize existing parser and geometry code of KiCad.

In my opinion, the development map for this feature should be look like this:

  1. integrate a finite element mesh generator like Gmsh which is able to export 2D and 3D meshes of pcbs for tools like openEMS and sparselizard. This alone allow people to do SI and PI more easily.

    I assume that meshing is quite complex in itself, because it heavily influences accuracy and simulation speed. Different type of analysis can require different meshes.

  2. select a proper multiphysics FEM library which provides all capabilities KiCad will likely need in long term. I assume electromagnetic and intercoupled thermal simulation should be enough. This should allow based on my limited knowledge at least:

    • Calculating Resistance between two Points
    • Calculating Capacitance between two Nets
    • Calculating Impedance of a Track
    • DC power analysis coupled with thermal simulation (voltage drop, current density, track temperature)
    • S-Parameter calculation of e.g. microstrip lines
    • Crosstalk simulation
    • Antenna simulation

    I would say openEMS does not make sense to be integrated inside KiCad, because it does not have thermal simulation, and from my past experiments is not easy to use. sparselizard looks quite good, because it is C++ only and crossplatform? The examples look quite easy as well. Would be interesting to see what other libraries exists which are also capable of Co-simulation.

Whoa you really have a long term plan and it is a good one. It seems that my vision is a bit short term and narrow.

Here we go.

I’ve got a simple layout:


Pad on lower left has potential of 0 V and from R1 we expect 2A current to flow. How much voltage drop are we going to have across thick trace on the bottom layer?

  1. Import the copper to FreeCad. Preferably thicker than actual (I use 0.2mm for 0.035mm actual thickness). This can be accounted for by setting the current bigger for the same ammount

  2. Set the material (For resons unknow you can not set thermal conductivity bigger then 2000W/mm/K. The copper conductivity is 59600A/mm/V. So you set the conductivity to 596. You need to account for this by decreasing the heat flux (current) for a factor of 100

  3. For FEM analysis you have to prepare the model

    1. Select all the parts then Part Workbench/Split/Boolean Fragments
    2. In the data tab change Boolean fragments mode from Standard to CompSolid
    3. Select all then Part Workbench/Compound/Compound Filter
  4. Set the temperature (voltage) of the pad (you can only select one or more of the side faces)

  5. Set the heath flux (current) of the other pad (again you can only select side faces. Increase the current by the same factor as you increased the thickness of the copper. Then divide the current by 100.

  6. generate mesh.

Voila the results:

As you can see the voltage drop on 10mm long, 2mm wide and 0.035mm thick copper trace with 2A flowing through it is about 0.005 V (0.0105 - 0.0055). Which is about what KiCad’s calculator gives:

So DC PDN is doable but there is a lot of manual work and the presentation of the results is somewhat spartan.

4 Likes

Has anyone tried https://www.fastfieldsolvers.com/software.htm ? It seems to provide a FreeCAD workbench.

This would be the EM workbench maui and I were talking about. From what I’ve seen it is just a workbench to draw geometry that can be exported directly for FastHenry/FastCap solvers.

The fast field solvers are great as you get inductance or capacitance directly so there is no need for postprocessing. But they support only limited basic geometry types. So I don’t see much use for them beyond getting the inductance of a PCB coil as was already mentioned.

I agree, but till (if) this feature won’t be implemented an external path would be useful.

Hi @MitjaN
would you mind to post your KiCAD project and FreeCAD file?
I would like to see if there is a way to reduce the manual work creating some FreeCAD macros.

2 Likes

I would also like to see a much simpler way to integrate the 2. Removing as many steps in the chain as possible would be a good start. E.g. hide it all behind a UI or similar. It exports what is needed and sets up freecad as much as it can for the task.

Materials like FR4 and copper and there thicknesses if possible could be prefilled with a way to override.

V5.99 has Stackup Editor already, so the user can define the materials/thicknesses in KiCad.

What I mean is a freecad material for simulation, with parameters like thermal conductivity, expansion coefficient, electrical resistivity, etc. by prefilling to known materials would remove that entire step. as freecad straight from download does not actually have a copper material.

Here you go. I did use external program (gmesh) to generate and import mesh. The FreeCad build I am on (18.4) generates ridiculously thick mesh and UI for mesh control is somewhat lacking.
FreeCad_project.zip (1.0 MB)
KiCad_project.zip (5.2 KB)

I am pretty sure that a GUI can be buld within FreeCad, which would either automate or at least make the UI more user friendly. But the presentation of the results is still somewhat lacking (there is no probing, you get temperature(voltage) only. But heat flux (current density) would also be nice to see.

Also note that with more complex projects via simplification (https://github.com/realthunder/fcad_pcb/issues/22#issuecomment-585599239) is a must.

As you are one of the few authors who developed an extension for KiCad and FreeCad, how would you compare developing an action plugin for KiCad to developing a workbench for FreeCad. I am toying with an idea to start developing extensions.

1 Like

I really think this is over complicated for the vast majority of cases. There are undoubtedly cases where a full 3d simulation of a structure is needed however most of the time a simple 2d is plenty good enough.

FEMM is my 2d solver of choice, its main thrust is magnetics but it also has electrostatic, thermal and current flow solvers. You can have planar or axisymmetric structures.

The flow is simple:
Export layout as DFX
Import DXF in to FEMM
Setup the problem - units, plane depth (in our case Cu thickness) etc
Assign materials, sources(s) etc.
Simulate - the default mesh is generally good enough but is very easy to tweak if you want to

For the example above you can get an answer in probably 15 minutes start to finish. If the via resistance is really important then model that separately as an axisymmetric model and add it in

Stair

I feel people are after it with no real care to begin with if it is 2D or 3D, with 3D being a big bonus.

At the moment for your solver, is there anything that could be done to reduce that 15 minutes of setup, that would be the goal for integration, e.g. from next version stackup manager getting the thickness, having the right units, already having the materials set, and knowing what voltages and currents are sourcing and sinking at specific pins, to get to the point where you could practically hit export on a plugin, it calls the solver and displays the results.

If, and I would say that is a big if, full integration with a solver happens in the foreseeable future then great, hard to compete with that but at the moment going via FreeCAD is still quite an effort.

FEMM supports LUA scripting, this topic gives an idea

https://groups.io/g/femm/topic/using_femm_via_activefemm/71070994?p=,,,50,0,0,0::recentpostdate%2Fsticky,,,50,2,0,71070994

Just as a simple FEMM example, an arbitrary 2 layer track connected with via, 1A source top left to 0V bottom left. Showing current vectors and voltage

Well the example is simple with a reason. And as such can obviously be solved much easier with simpler tools. Again with Pad2Pad plugin you can get the resistance between R1-Pad2 and J2-Pad1 in seconds without any work (the answer is 0.0065 Ohm).

I know FEMM, but with regards to KiCad I am skeptical how much traction it would get, as it is not a cross platform solution.

Also when dealing with PDN, what I found was that with two layer boards I did not find the reason for doing it one single time. Where it really comes into play is with 4+ layer boards. There you could do with 2D solution but you would need to hack it into 2.5D so in the end full 3D is just easier from the process point of view. More costly from the resources required to solve but the process is much easier. Additionally if you are dealing with power electronics, with currents above 10 A, the via resistances come into play. And I imagine the same holds for AC PDN. Then you will find out that you want to automate exporting geometries from KiCad to FEM program. And at the moment FreeCad with fcad_pcb is by far the easiest option in my opinion.

thx a lot! :smiley:

would you mind to use FC0.19 … FEM has been improved a lot and FC 0.19 is going to be in feature freezing so to become the next stable release…

Thx I will take it into account

IMO it is easier and more stable to work with FC python interface… Anyway I would be very happy to see what you are toying with and may be collaborate with you :slight_smile:

@MitjaN would it be possible to have also the FreeCAD and KiCAD projects for thermal simulation you showed me in PM?
I would like to play with thermal simulation a bit too…

1 Like

Hi, I am the person who presented sparselizard at FOSDEM 2020 (general multiphysics c++ FEM software).


www.sparselizard.org
General 2D/3D magnetic/electric/EM physics (+ magnetic/electric forces if you have interest in that) are supported. Any mechanical/thermal/ other multiphysics coupling as well. Circuit coupling however is not there yet but it is scheduled to be added by end of July. The simulation code is very straightforward to write and robust to run.
6 Likes

Nice, this is very helpful. I go the same question, thank you!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.