PCB thermal analysis revisited

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
easyw-fc
Veteran
Posts: 3629
Joined: Thu Jul 09, 2015 9:34 am

Re: PCB thermal analysis revisited

Post by easyw-fc »

I tried to run the analysis and I had these errors:

Code: Select all

10:07:49  Write elmer input files to: C:\Users\xxxx\AppData\Local\Temp\fem2xvsgphu
10:07:49  The FreeCAD standard unit schema mm/kg/s is used. Elmer sif-file writing is however done in SI units.
10:07:49  Exception in thread Thread-28:
10:07:49  Traceback (most recent call last):
10:07:49    File "C:\FreeCAD\bin\lib\threading.py", line 932, in _bootstrap_inner
10:07:49      self.run()
10:07:49    File "C:\FreeCAD\bin\lib\threading.py", line 870, in run
10:07:49      self._target(*self._args, **self._kwargs)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\task.py", line 118, in protector
10:07:49      self.run()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\tasks.py", line 87, in run
10:07:49      w.write_solver_input()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\writer.py", line 93, in write_solver_input
10:07:49      self._writeSif()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\writer.py", line 918, in _writeSif
10:07:49      sif.write(fstream)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 219, in write
10:07:49      writeSections(self.sections, stream)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 101, in writeSections
10:07:49      _Writer(ids, sections, stream).write()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 293, in write
10:07:49      self._writeSection(s)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 298, in _writeSection
10:07:49      self._writeSectionBody(s)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 314, in _writeSectionBody
10:07:49      self._writeAttribute(key, s[key])
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 325, in _writeAttribute
10:07:49      scalarData = self._getOnlyElement(data)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 337, in _getOnlyElement
10:07:49      return it.next()
10:07:49  AttributeError: 'list_iterator' object has no attribute 'next'
kamocat
Posts: 17
Joined: Mon Jul 11, 2022 10:39 pm

Re: PCB thermal analysis revisited

Post by kamocat »

easyw-fc wrote: Wed Jul 20, 2022 8:09 am I tried to run the analysis and I had these errors:

Code: Select all

10:07:49  Write elmer input files to: C:\Users\xxxx\AppData\Local\Temp\fem2xvsgphu
10:07:49  The FreeCAD standard unit schema mm/kg/s is used. Elmer sif-file writing is however done in SI units.
10:07:49  Exception in thread Thread-28:
10:07:49  Traceback (most recent call last):
10:07:49    File "C:\FreeCAD\bin\lib\threading.py", line 932, in _bootstrap_inner
10:07:49      self.run()
10:07:49    File "C:\FreeCAD\bin\lib\threading.py", line 870, in run
10:07:49      self._target(*self._args, **self._kwargs)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\task.py", line 118, in protector
10:07:49      self.run()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\tasks.py", line 87, in run
10:07:49      w.write_solver_input()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\writer.py", line 93, in write_solver_input
10:07:49      self._writeSif()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\writer.py", line 918, in _writeSif
10:07:49      sif.write(fstream)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 219, in write
10:07:49      writeSections(self.sections, stream)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 101, in writeSections
10:07:49      _Writer(ids, sections, stream).write()
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 293, in write
10:07:49      self._writeSection(s)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 298, in _writeSection
10:07:49      self._writeSectionBody(s)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 314, in _writeSectionBody
10:07:49      self._writeAttribute(key, s[key])
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 325, in _writeAttribute
10:07:49      scalarData = self._getOnlyElement(data)
10:07:49    File "C:\FreeCAD\Mod\Fem\femsolver\elmer\sifio.py", line 337, in _getOnlyElement
10:07:49      return it.next()
10:07:49  AttributeError: 'list_iterator' object has no attribute 'next'
Yes, I ran into that too and submitted a PR to fix.
https://github.com/FreeCAD/FreeCAD/pull/7183
kamocat
Posts: 17
Joined: Mon Jul 11, 2022 10:39 pm

Re: PCB thermal analysis revisited

Post by kamocat »

I'm still having trouble getting reasonable results. Calculix even told me there were non-positive elements in the jacobian matrix!
I suspect this is a meshing issue, since thermal simulations work fine with simpler geometry.
I guess I need to make a simpler PCB to test my workflow.
kamocat
Posts: 17
Joined: Mon Jul 11, 2022 10:39 pm

Re: PCB thermal analysis revisited

Post by kamocat »

Looks like the workflow is fine.
Does anyone know how to get good meshes on complex geometry?

Here I made a PCB with a voltage regulator and no other components, and applied 400K to two of the traces and 300K to the ground plane on the back side. I notice that Elmer converges much faster when I use fixed temperatures, although I realize this isn't very realistic. Also note that the heat is applied uniformly to the whole trace, so we can't see the effects of the via or the trace width.
pcb1.png
pcb1.png (81.99 KiB) Viewed 1579 times
Attachments
pcb1.FCStd
(514.65 KiB) Downloaded 56 times
kamocat
Posts: 17
Joined: Mon Jul 11, 2022 10:39 pm

Re: PCB thermal analysis revisited

Post by kamocat »

Strangely, if I add just a little bit of complexity, the results go out the window.
pcb2.png
pcb2.png (48.71 KiB) Viewed 1556 times
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: PCB thermal analysis revisited

Post by Kunda1 »

@realthunder I know your busy with the toponaming and Link stuff. Just wanted to put this on your radar as an JFYI. ;)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: PCB thermal analysis revisited

Post by uwestoehr »

kamocat wrote: Tue Aug 02, 2022 7:12 pm I'm still having trouble getting reasonable results. Calculix even told me there were non-positive elements in the jacobian matrix!
This message is from Gmsh. Since your geometry is simple, change in the mesh settings to 1st order mesh (default is 2nd).

Then you must use for the mesh a submesh region where the cells are much smaller than at the PCB:
https://wiki.freecadweb.org/FEM_MeshRegion
kamocat
Posts: 17
Joined: Mon Jul 11, 2022 10:39 pm

Re: PCB thermal analysis revisited

Post by kamocat »

uwestoehr wrote: Thu Aug 04, 2022 2:59 am
This message is from Gmsh. Since your geometry is simple, change in the mesh settings to 1st order mesh (default is 2nd).

Then you must use for the mesh a submesh region where the cells are much smaller than at the PCB:
https://wiki.freecadweb.org/FEM_MeshRegion
Ah, you're right. Now Elmer and Calculix give similar results.
elmer_pcb2.png
elmer_pcb2.png (66.21 KiB) Viewed 1384 times
Calculix_pcb2.png
Calculix_pcb2.png (67.13 KiB) Viewed 1384 times
Although, Elmer seems to be rather finicky. I re-meshed and tried again, and got weird results. Now I can't seem to get my original mesh back.
kamocat
Posts: 17
Joined: Mon Jul 11, 2022 10:39 pm

Re: PCB thermal analysis revisited

Post by kamocat »

It seems that the best way to avoid meshing issues is to remove all curves and use first-order meshing.
However, KiCAD doesn't really allow me to remove the rounded edges on the copper pours or the thermal reliefs (despite the pour settings implying it).
Is there a macro I can use to remove fillets or replace them with chamfers?
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: PCB thermal analysis revisited

Post by Kunda1 »

kamocat wrote: Fri Aug 05, 2022 6:46 pm Is there a macro I can use to remove fillets or replace them with chamfers?
x-post this to the Python and macro subforum for better exposure ;)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply