Elmer electrostatics FEM

About the development of the FEM module/workbench.

Moderator: bernd

HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Elmer electrostatics FEM

Post by HoWil »

Dear Uwe,
I currently do not have the time to follow your posts in detail. Sorry about that.
But what I know is that you can select mkgs as unit system in Elmer and than you should get the correct values in ISO units.

Otherwise FC uses e.g. mm as internal unit, all variables will be converted to ISO on export and you will get results in ISO units. These results can be recalculate to mm by using e.g. the Python quantities package.


BR
Howil
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer electrostatics FEM

Post by uwestoehr »

HoWil wrote: Mon Mar 21, 2022 7:02 am But what I know is that you can select mkgs as unit system in Elmer and than you should get the correct values in ISO units.

Otherwise FC uses e.g. mm as internal unit, all variables will be converted to ISO on export and you will get results in ISO units. These results can be recalculate to mm by using e.g. the Python quantities package.
Hi Howil, the issue was that when one used e.g. the FEM units scheme, which is mm-based, the case.sif input file was written in mm-based units. This broke the usability of Elmer almost, because:
- as average FreeCAD user, you just install Elmer and then use FreeCAD. You don't make any settings to Elmer (and this is also not necessary and not advised in our Wiki).
- you could not exchange our case.sif files with others. But to participate e.g. in the Elmer forum, you often have to share your case.sif file
- the Results Elmer delivered were wrong. For example when you set in our capacity example the base plane to 1 V and the maximum potential to 9 V, you got out output values in the range 1e6 to 9e6 - when either using the FEM or standard unit scheme. With the MKS unit scheme, you got it correct.

Now I only changed that the case.sif files get in every case pure SI units. Now the simulation results are correct, independent of the used unit scheme and you can exchange your case.sif files.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Elmer electrostatics FEM

Post by HoWil »

One thing to mention is that Elmer does not 'only' use ISO units. One has to deside which unit system to use and mmkgs is legitimate one. You 'simply' have to be consistent. The trouble starts when you see that e.g. Volt is depending on the dimension of length.

If we stick to ISO than I am also ok.
But please consider when designing e.g. a cantilever in mm and calculating the deformation you than get meters! This is also not consistent.

BR
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer electrostatics FEM

Post by uwestoehr »

HoWil wrote: Mon Mar 21, 2022 3:47 pm If we stick to ISO than I am also ok.
But please consider when designing e.g. a cantilever in mm and calculating the deformation you than get meters! This is also not consistent.
I looked around and could not find a single cas.sif file where eg.. the gravity, vacuum permittivity etc. is not given in SI units.

I don't understand what you mean with "in mm". I mean I design the cantilever with a certain length. Here is an example with a 8 m long beam:
CantileverFaceload-CCX.FCStd
(83.04 KiB) Downloaded 51 times
I get a max Z-displacement of 87.6 microns. And this is correct. In the output I get also

Code: Select all

18:41:49  The FreeCAD standard unit schema mm/kg/s is used. Elmer sif-file writing is however done in SI units.
What I will do now is to add a note that all outputs from Elmer will be in SI units.

In the attached example I also used CCX and its out put is 86 m (sic!) so the CCX solver has a unit problem.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer electrostatics FEM

Post by uwestoehr »

uwestoehr wrote: Mon Mar 21, 2022 6:27 pm I don't understand what you mean with "in mm".
I understand now. The fix is to scale the mesh. For example when I write

Code: Select all

Mesh.ScalingFactor=0.001
in the file shape2mesh.geo I get for the cantilever example correct results.

The solution is just to write the mesh coordinates with a factor of 0.001 into the mesh.nodes file.
I am stuck since since I don't know what part in the code does this. Can you please tell me where in the code the mesh.nodes file is written?
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Elmer electrostatics FEM

Post by HoWil »

I am sorry but I do not have the time to explain it in detail (which needs a lot of time to do so).

The unit system always has to be consistent. What you try will mix up the systems. FC usually uses mm internally.
The easiest way to get ISO-units is to switch the unit-system of FC to mkgs. I do not understand why this is/could be a problem. Yes, this was for sure not well documented but it was consistent and worked for all sorts of units like from electrostatics, electromagentics, mechnics, thermal and flow.

The scaling factor alone is not the solution.
I am not sure if your changes did mix things up. Could not have a look until now and do not have the time within the next 3 weeks.

The export of the mesh is done via .unv when I remember correctly. See also https://forum.freecad.org/viewtopic.php ... 1f#p195056

BG
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer electrostatics FEM

Post by uwestoehr »

HoWil wrote: Tue Mar 22, 2022 8:22 pm IThe easiest way to get ISO-units is to switch the unit-system of FC to mkgs. I do not understand why this is/could be a problem. Yes, this was for sure not well documented but it was consistent and worked for all sorts of units like from electrostatics, electromagentics, mechnics, thermal and flow.
But this is why I acted. Setting a potential of 1.0 V lead to a result of 1e6 V. This is hard to understand. Depending on what you want to simulate this can quickly become a nightmare. At least for me I spent almost a full day to understand what is going on. As I wrote, in the Elmer forum they recommend to use SI units consistently and one needs to be able to share his case.sif file with others..
HoWil wrote: Tue Mar 22, 2022 8:22 pm The scaling factor alone is not the solution.
Not alone. What we have now is a case-sof file that contains in every case pure SI units. What is now missing is to scale the mesh. I found this solution yesterday also in FEM forums. They explicitly set a Gmsh scaling factor of 0.001 and then take this as input mesh. I tried this out yesterday and this works perfectly. No matter what unit system I used and no matter what I simulate, electrical or mechanical, with the combination of SI units in the case.sif + the scaled mesh I got correct results.
HoWil wrote: Tue Mar 22, 2022 8:22 pm The export of the mesh is done via .unv when I remember correctly. See also https://forum.freecad.org/viewtopic.php ... 1f#p195056
Thanks. I will have a look.
user1234
Veteran
Posts: 3345
Joined: Mon Jul 11, 2016 5:08 pm

Re: Elmer electrostatics FEM

Post by user1234 »

I know, i do not use Elmer and i am a little bit dull, but
HoWil wrote: Tue Mar 22, 2022 8:22 pm The easiest way to get ISO-units is to switch the unit-system of FC to mkgs.
this is not good way to work. Generally the system settings should be always the preferred display and input units, but in the background when i enter mm, it should be mm and not depend on the system setting. A similar problem is here https://forum.freecad.org/viewtopic.php?t=66238, where the output depends on the unit system, which is also (in my opinion) wrong.

Greetings
user1234
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer electrostatics FEM

Post by uwestoehr »

OK, I implemented a solution. Maybe someone will maybe beat me for this, but as it was, Elmer was not useable and it took me hours to understand.

The solution is simple I think:

1. use consistently SI units, no matter what unit scheme is used in FC. As I wrote this assures not only consistency, but you can also share your simulation files with others and I haven't see a single case.sif file around where e.g. the vacuum permittivity is not given in SI units.

2. since Gmsh writes the mesh in mm units, independent of the used unit system, we need to scale the mesh to meters. The mesh is written using Elmer's "ElmerGrid" program, that has the option "-scale" exactly for this purpose: https://www.nic.funet.fi/index/elmer/do ... Manual.pdf
The nice side effect is that you can also share your mesh.nodes file with other Elmer users.

3. the result will of course be in the mesh coordinates, therefore we need to scale it back when displaying the result in FC. I implemented therefore a Scale property.. By default new result Meshes will get a lael with "Elmer" in is, therefore we know we only need to scale these results, not the CalculiX results. Nice side effect CalculiX mesh results can now be scaled if you want, which might be useable for some showcases.

Advantages:
- you get now correct results for Electrical and mechanical simulations. To test this, here are my test files:
electro:
Electrostatics2.FCStd
(498.95 KiB) Downloaded 50 times
mechanical:
CantileverFaceload-CCX.FCStd
(218.13 KiB) Downloaded 50 times
- the result is independent on the used FreeCAD unit system

Anybody interested, please test it out using latest FC master or using the next weekly build.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Elmer electrostatics FEM

Post by bernd »

Post Reply