Elmer solver writer unit handling

About the development of the FEM module/workbench.

Moderator: bernd

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

Re: Elmer solver writer unit handling

Post by uwestoehr »

bernd wrote: Mon Jul 11, 2022 2:07 pm How about this?
Hi Bernd, welcome back!

Concerning the change to pure SI units for Elmer, in some discussions, I imagined how the people fighting for SI 150 years back felt :lol: - some only see their use case.

Elmer boosts FreeCAD's simulation ability since it can do real multi-physics. For example solving Navier-Stokes equation in combination with thermal diffusion.
To be able to use this power one needs a proper unit systems so that the same Analysis leads to the same results on all PCs and, also important, that one can exchange his setup with others.
My favorite example is this one: (https://forum.freecadweb.org/viewtopic. ... d6#p604853)
* Voltage is in Volt:______kg·m2·s−3·A−1
* Conductivity is in S/m:_kg−1⋅m−3⋅s3⋅A2
* Permittivity is in F/m:__A·s·V−1·m−1

Following a unit scheme that uses another unit for the length than meter becomes a nightmare. And exactly for this the SI exists.
When I simulate e.g. a parallel plate capacitor and set one plate to 1V and the other one to 0V, I need to see a "1" as maximal voltage, not 1e6 or something depending on the unit system on a special PC.

Also when you have problems or collaborate with others, you need to share your case.sif file. Looking in the Elmer forum, you see that the vast majority of .sif files there use SI units.

All in all, now that it is in, some bugs in this regards could be fixed. As it is, Elmer is quite usable I hope and I am happy about this since selfish me :), I use it and therefore spent many hours of spare time to bring it to the current state.

-------------------------------
My plans:

- enable multi-threading for Elmer. I think I succeeded just today with this: https://github.com/FreeCAD/FreeCAD/pull/7159
- this use case unveiled for example some missing features: https://forum.freecadweb.org/viewtopic. ... d6#p607368
(There are still some bugs in the handling of fluid materials. Also the fluid constraints are not in the shape as the other constraints. We don't have a constraint for a bulk pressure, e.g. the pressure of air in a vessel.)
- first when the first points are done, more Elmer features should be added (equations but also settings like the convergence level)

-----------------------------
What has been done for FC 0.20

- I tried to fix as many pipeline bugs as possible
- Werner made a great job in fixing issues and also polishing existing features
- almost all basic FEM features are now described in the Wiki
- https://wiki.freecadweb.org/Release_not ... _Workbench :)
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer electrostatics FEM

Post by uwestoehr »

bernd wrote: Mon Jul 11, 2022 1:52 pm FEM solvers work the way in the regard of units you get out what you put in. Would you read https://github.com/FreeCAD/FreeCAD/blob ... py#L69-L92
I read there:
The unit system which is used at Guido Dhondt's company: mm, N, s, K
Statements like these is why I disagree. We try to do physics - and this is the same everywhere, independent of a company. This should be the main consensus.
For example my company has departments all over the world. I need to send colleagues a file and when he runs it, he must get the same result, no matter if he uses microns as base length unit or inches. Even having an agreement to use the same system in a company is a NoGo. We all know the Nasa rocket crash where some departments used SI for their calculations (and simulations) some not.
bernd wrote: Mon Jul 11, 2022 1:52 pm In Calculix we do not write SI-units by design. The same was in elmer. But for sure before January one could change elmer writer to force writing SI units. If it not worked there was a bug. We should fix the bug and not remove all smart unit code from elmer writer.
I also disagree here. There is no benefit to fiddle around with special unit handling as the world speaks SI for all the reasons I already pointed out.
E.g. in EU projects you must use pure SI units for the same reasons. I already spent many hours in exchanging files with collaborators who e.g. used mil for their photomasks as base unit. Only stress for no benefit! Allowing users to use their own unit system only has disadvantages. Please tell me an advantage.

What we need instead is to display the unit in the pipeline output and giving the user the feature the show Pa as kPa etc. But internally everything should be pure SI.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Elmer solver writer unit handling

Post by bernd »

Just some short hints: I need to exchange with noone. I need to make a structural analysis in a fast and save way. Thus the use of the unit system used by Guidos company has some advantages in FreeCAD. A few years age this was even more the case.

I need to work with proper result units. I must admit if we could change the units in the result pipe line this would be possible too. May be even smarter. I need to think about this. But I will not able to change this.

Anyway IMHO we need to add some unit tests in this regard to secure the Elmer units.

BTW: Guidos company has a few thousand workers worldwide. It is one of the biggest engine company on earth. They might exchange data too.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer solver writer unit handling

Post by uwestoehr »

bernd wrote: Mon Jul 11, 2022 7:15 pm Just some short hints: I need to exchange with noone. I need to make a structural analysis in a fast and save way. Thus the use of the unit system used by Guidos company has some advantages in FreeCAD. A few years age this was even more the case.
Sure we invest our personal spare time because we use FreeCAD and we likely do it the way it suits us. But the personal use is only one aspect since FreeCAD should be suitable for everybody.

In general, collaborative work is crucial, even it it doesn't affect you. Then take my use case - partner in several EU research projects with dozens of project partners, companies, universities, administrations like firefighters. In my company I have to exchange data every day with our worldwide branches, but also with suppliers (send out CAD data to toolshops, ordering photomasks, performing CNC cuts according to CAD I get from customers, order laser cuttings, exchange calculation results, writing collaborative reports...)

I don't know who Guido is, but this doesn't matter since FreeCAD should not be to suit a certain company. Personally, I will not build something to please my company.
bernd wrote: Mon Jul 11, 2022 7:15 pm I need to work with proper result units. I must admit if we could change the units in the result pipe line this would be possible too. May be even smarter. I need to think about this. But I will not able to change this.
What is your problem with the SI units? For mechanics you use Pascal not Pond etc., right? Elmer gives you the result in Pascal so nothing changed for you and CCX was not touched yet.
When you deal with stresses you might like to see in the pipeline result MPa instead of 1e9 Pa. This is just a convenience thing, both representations are SI and equal.
Adding a factor for the result mesh is not a big deal. For the display we have fixed the color gradient bar already so that the numbers fit to all screens - big thanks to Werner for this! This can be extended to display also the unit. We can also add options where people can define how they would like to see the units etc.

However, I think my post: https://forum.freecadweb.org/viewtopic. ... 43#p609343 explained why it is so important to perform calculations with SI base units. Elmer pushes FEM to multi-physics so we need a framework that suits everybody, the fluidics guys as well as the electrical engineers or architects.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Elmer solver writer unit handling

Post by bernd »

uwestoehr wrote: Tue Jul 12, 2022 1:59 am ...
What is your problem with the SI units? For mechanics you use Pascal not Pond etc., right? Elmer gives you the result in Pascal so nothing changed for you and CCX was not touched yet.
When you deal with stresses you might like to see in the pipeline result MPa instead of 1e9 Pa. This is just a convenience thing, both representations are SI and equal.
Adding a factor for the result mesh is not a big deal. For the display we have fixed the color gradient bar already so that the numbers fit to all screens - big thanks to Werner for this! This can be extended to display also the unit. We can also add options where people can define how they would like to see the units etc.
No I do not use Pascal I use MPa in any case. FreeCAD was not able to show MPa. The simplest way to archieve this was to use these units for solver input as it has been done in CalculiX for years.

As I said if the result could be displayed in MPa it is another option too. May be a better one. I do not know yet. I have not seen or tested this. IMHO in any case the user should have the decision to use FreeCAD the way he would like to.

Anyway I would not like to change it back ATM. I am fine with Elmer writing on Standard preference SI units. I just would like to let the door open to be able to may be let Elmer write non SI units too if the user would like to do this. As it was before my break. This has been working proper for years for mechanical use. For sure if the user would like to use SI units Elmer should write proper SI units!
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Elmer solver writer unit handling

Post by bernd »

I am step by step guy. Thus IMHO first the obsolete unit Schema ...

There seems a consens in the following ...

The solver input units should not be controlled by the FreeCAD unit system. We all agree with this one. Thus the FreeCAD unit schema FEM is not needed anymore. It has no impact anymore as non solver uses it for adjusting units. Thus it might be removed. But Werner is needed for such a decision

wmayer wrote: Mon Jul 11, 2022 3:13 pm
@wmayer How about the unit sheme FEM. This is no longer needed anymore. It even could confuse people. Should this be removed?
Which exact test do you mean? You can give a GH link to the source code of the test function.
bernd wrote: Mon Jul 11, 2022 5:25 pm This unit schema is no longer needed at all. git commit 7852957623190

It was used to set special solver writer units for Elmer. This was removed, which is good. ...
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Elmer solver writer unit handling

Post by wmayer »

bernd wrote: Mon Jul 11, 2022 5:25 pm This unit schema is no longer needed at all. git commit 7852957623190

It was used to set special solver writer units for Elmer. This was removed, which is good. The setting should be done separately from FreeCAD unit system.
OK, feel free to do so or open a PR.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer solver writer unit handling

Post by uwestoehr »

bernd wrote: Tue Jul 12, 2022 9:10 am No I do not use Pascal I use MPa in any case.
;) So you use Pascal just prefer engineering notation over scientific notation. Me too by the way.
bernd wrote: Tue Jul 12, 2022 9:10 am FreeCAD was not able to show MPa. The simplest way to archieve this was to use these units for solver input as it has been done in CalculiX for years.
This was a, sorry to be honest, strange approach. Only because one prefers the engineering notation of the mechanical stress result one introduced many troubles.
At the university every professor told us "calculate in base SI, with the result you can later do what you want". And this is true. Also I taught my students the same. For example when to calculate a velocity, consequently use base SI units to avoid any problems with combined units like for the drag and pressure. Once you have the result, you can express it in e.g. "ul/min" if it is the flow in a blood vessel and ul/min this is the common unit in this field of science.

So the key point is that calculating is different from expressing the result.
bernd wrote: Tue Jul 12, 2022 9:10 am the user should have the decision to use FreeCAD the way he would like to.
Sure. Therefore we need more features that one can setup the result display (what notation, scientific or engineering, what units for what result types, etc.)
bernd wrote: Tue Jul 12, 2022 9:10 am This has been working proper for years for mechanical use.
For mechanics yes, but mechanics is a small portion of physics. We need methods that suits all scientific fields, meaning different result types, no matter if the simulation result is the speed of sound, a conductivity or whatever.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer solver writer unit handling

Post by uwestoehr »

wmayer wrote: Tue Jul 12, 2022 9:51 am OK, feel free to do so or open a PR.
+1
Post Reply