Cannot get model into state where simulation can run

About the development of the FEM module/workbench.

Moderator: bernd

Pinks
Posts: 3
Joined: Tue Sep 03, 2019 1:53 pm

Cannot get model into state where simulation can run

Postby Pinks » Wed Sep 04, 2019 12:17 pm

Dear all,

I am a long time user of FreeCAD, and I have usually been able to somehow get the FEM module to work even though it always required at least one day of adjustments even for simple models.

I am now required to perform a thermomechanical simulation on a slightly more complex part, which you can see here:

Image

I have spent the better of two full work days to simply get the meshing and materials into a state where the .inp file can even be written instead of spending 1600 seconds and telling me it fails. Gmsh appears to be unsuitable in my case, for the mesh result has many elements with non-positive jacobians. I have therefore reverted to using the Netgen mesher.

Anyways, the model is now in a state where the .inp file can be written, which takes around 8 minutes. However, no matter what I do, I cannot get the simulation to run without errors, not even an extremely basic mechanical one with only a single movement constraint. I would highly appreciate it if someone could attempt to run the simulation in the file and let me know if the problem is real, or just caused by some quirk of my local environment. You can download it here.

The error appears to be related to non-positive jacobians, but I am at a loss as to what I can do to perform meshing in a way that does not produce non-positive jacobians. See the first line in this error output from the Report view:

Code: Select all

CalculiX returned an error due to nonpositive jacobian determinant in at least one element
Use the run button on selected solver to get a better error output.
Error() 
We will load the ccx frd and dat result file.
Read ccx results from frd file: C:\Users\magla\AppData\Local\Temp\fcfemsolv_rontsnqf\FEMMeshNetgen.frd
We have nodes but no results in frd file, which means we only have a mesh in frd file. Usually this happens for analysis type 'NOANALYSIS' or if CalculiX returned no results because of nonpositive jacobian determinant in at least one element.
Traceback (most recent call last):
  File "C:\Users\magla\Desktop\FreeCAD_0.19\Mod\Fem\femguiobjects\_ViewProviderFemSolverCalculix.py", line 308, in calculixFinished
    self.fea.load_results()
  File "C:\Users\magla\Desktop\FreeCAD_0.19\Mod\Fem\femtools\ccxtools.py", line 1122, in load_results
    self.load_results_ccxfrd()
  File "C:\Users\magla\Desktop\FreeCAD_0.19\Mod\Fem\femtools\ccxtools.py", line 1131, in load_results_ccxfrd
    importCcxFrdResults.importFrd(frd_result_file, self.analysis, 'CCX_')
  File "C:\Users\magla\Desktop\FreeCAD_0.19\Mod\Fem\feminout\importCcxFrdResults.py", line 192, in importFrd
    return res_obj
UnboundLocalError: local variable 'res_obj' referenced before assignment
FreeCAD info:
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18024 (Git)
Build type: Release
Branch: master
Hash: 9cc8f6eb666b0a0ae2dc256f7bc0beb8c987710c
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Pinks
Posts: 3
Joined: Tue Sep 03, 2019 1:53 pm

Re: Cannot get model into state where simulation can run

Postby Pinks » Wed Sep 04, 2019 12:57 pm

Dear all,

An update: I have managed to get rid of the negative jacobians by using the Gmsh mesher and setting Element Order = 1st in the Data tab.
However, a new problem has occurred:

Code: Select all

Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 7 : Unknown variable 'group'
Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 7 : syntax error ())
Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 8 : Unknown variable 'group'
Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 8 : syntax error ())
Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 9 : Unknown variable 'group'
Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 9 : syntax error ())
Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 10 : Unknown variable 'group'
Error   : 'C:\Users\magla\AppData\Local\Temp\fcfemgmsh_593cfd358404\shape2mesh.geo', line 10 : syntax error ())
Warning : Unknown element type for UNV export (MSH type 15) - output file might be invalid
Warning : Unknown element type for UNV export (MSH type 15) - output file might be invalid
Warning : Unknown element type for UNV export (MSH type 15) - output file might be invalid
....This warning repeats 45 times....
Gmsh appears to do fine in spite of these errors, and produces a mesh. However, when attempting to write the .inp file, the following error comes up:

Code: Select all

Count finite elements as sum of constraints:   13208
Count finite elements of the finite element mesh: 13212
ERROR: femelement_table != count_femelements
Error in get_femelement_sets -- > femelements_count_ok() failed!
What in the world does this mean, and what can be done about it?
User avatar
bernd
Posts: 9003
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Cannot get model into state where simulation can run

Postby bernd » Wed Sep 04, 2019 2:23 pm

There was a regresion in FreeCAD FEM 0.19 for a few days. My fault :oops: It is fixed in latest FreeCAD 0.19

It is generally a good idea to simplificate as much as needed to get a model which runs. Than start and make it more complex. This is what you did :-)

nonpositve jacobians are still an very annoying problem. The easiest solution are smaller maximum element size. But this makes the modells biiiig. Gmsh has an optimizer, which can be accessed.

It is better to have the file in the forum ...

Module.FCStd
(814.72 KiB) Downloaded 11 times
User avatar
bernd
Posts: 9003
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Cannot get model into state where simulation can run

Postby bernd » Wed Sep 04, 2019 2:45 pm

you do not need to define a constraint. Just use frequency with no constraint ... By the use of 5 mm maximal element size I get 5 nonpositive jacobian from Gmsh. This is not much, which means just give ccx a try .... It hangs with the multiple materials. If only one material is defined the analysis runs. I have no idea yet why FreeCAD hangs with the mutliple materials ...

attached the modell with cleared mesh.

Module_freq.FCStd
(67.09 KiB) Downloaded 11 times

screen.jpg
screen.jpg (626.7 KiB) Viewed 387 times
User avatar
bernd
Posts: 9003
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Cannot get model into state where simulation can run

Postby bernd » Wed Sep 04, 2019 4:02 pm

bernd wrote:
Wed Sep 04, 2019 2:45 pm
It hangs with the multiple materials. If only one material is defined the analysis runs.
FreeCAD does not hang, it does just take looooong ...

But it can be speed up by factor 100 ... Activate the analysis, than mesh, than check the mesh in property editor, it should have 6 groups. With this FreeCAD does not search for the node ids for the materials it just uses the mesh groups. Input file writing needs a few seconds ...


Module_freq2.FCStd
(62.76 KiB) Downloaded 11 times

Screenshot_20190904_175838.png
Screenshot_20190904_175838.png (824.55 KiB) Viewed 376 times
User avatar
bernd
Posts: 9003
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Cannot get model into state where simulation can run

Postby bernd » Wed Sep 04, 2019 4:04 pm

ahh welcome to FreeCAD FEM.
User avatar
Kunda1
Posts: 6402
Joined: Thu Jan 05, 2017 9:03 pm

Re: Cannot get model into state where simulation can run

Postby Kunda1 » Thu Sep 05, 2019 12:16 am

Pinks wrote:
Wed Sep 04, 2019 12:17 pm
@Pinks thank you for your tenacity and perseverance along with @bernd's knowhow and help we get to see beautiful things like this in the forum:

Image
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
Pinks
Posts: 3
Joined: Tue Sep 03, 2019 1:53 pm

Re: Cannot get model into state where simulation can run

Postby Pinks » Thu Sep 05, 2019 7:23 am

I have to laugh, my model has been turned into modern art. Beautiful.
bernd wrote:
Wed Sep 04, 2019 4:02 pm
But it can be speed up by factor 100 ... Activate the analysis, than mesh, than check the mesh in property editor, it should have 6 groups. With this FreeCAD does not search for the node ids for the materials it just uses the mesh groups. Input file writing needs a few seconds ...
Bernd, how do I "check the mesh in the property editor"? Is the mere act of doing this enough to speed up .inp file writing?
EDIT:
Of course, the property editor right below the tree viewer... My bad :oops:
Well, I gave this a test. I clicked the [...] on the "Mesh groups" property and selected the 7 components which my model consists of (POM base, four nylon screws, one bottom aluminum part and one top aluminum part). Writing the .inp file still took hundreds of seconds, I did not notice and speed increase.
User avatar
bernd
Posts: 9003
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Cannot get model into state where simulation can run

Postby bernd » Tue Sep 10, 2019 5:55 am

- download my model
- start FreeCAD
- change to FEM
- in FreeCAD FEM preferences activate group meshing
- load my file
- aktivate the analysie (this is important)
- double click on the mesh
- mesh
- check report prints (there should be something in the regard of groups)
- check property editor tab data, the mesh should have groups
- if not write again, I will post some screens

bernd
User avatar
bernd
Posts: 9003
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Cannot get model into state where simulation can run

Postby bernd » Tue Sep 10, 2019 6:03 am

Code: Select all

...
  Group meshing for analysis.
  {'SolidMaterial': ['Solid7'], 'SolidMaterial001': ['Solid1', 'Solid2', 'Solid3', 'Solid4'], 'MechanicalSolidMaterial001': ['Solid5', 'Solid6']}
...
Screenshot_20190910_075825.jpg
Screenshot_20190910_075825.jpg (133.3 KiB) Viewed 202 times