Elmer solver writer unit handling

There have been happening a few commits in the regard of Elmer writer unit handling during last few month. Is there a forum topic about this?

Furthermore has there be some discussions about FreeCAD unit system and FEM units for solver writing? They might be different!

AFAIS there have been no changes CalculiX writer units? Is this true?

Cheers bernd

https://forum.freecadweb.org/viewtopic.php?p=581065#p581065

Some related commits:
361ea3367d
389ae0ab3
93d745235

cool, thanks werner



Sorry to say it might be not 100 % the right solution. 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/e24cd8f03ce917a7c2d5bd1c4b29c9011ed1d559/src/Mod/Fem/femsolver/calculix/writer.py#L69-L92

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 may have another look at this.

BTW: There is even a unit test for this. One writing the elmer sif in mm and one writing the elmer sif in SI - units. https://github.com/FreeCAD/FreeCAD/tree/e24cd8f03ce917a7c2d5bd1c4b29c9011ed1d559/src/Mod/Fem/femtest/data/elmer

I wonder what happened with the unit test … ???

related: https://forum.freecadweb.org/viewtopic.php?t=56681

comment in solver writer …

https://github.com/FreeCAD/FreeCAD/blob/e24cd8f03ce917a7c2d5bd1c4b29c9011ed1d559/src/Mod/Fem/femsolver/elmer/writer.py#L98-L120

At the time of writing the comment i was convinced FEM solver writer units should be the same as FreeCAD unit system. A few month later and still I do think this is totally wrong because these two pair of shoes (German saying for different things.)

IMHO we should be able to set the units which are used to write FEM solver input files, but we should not retrieve them from FreeCAD unit system. The FreeCAD unit system does not change anything it just presents the units to the user.

Where as the units used to write the solver input file have a huge impact on the output of the FEM solver. In a lot of cases the user would not like to have the same SI system for the output of FEM solver. I do not know about Fluid and Electro and Thermo FEM but in Mechanics this ist the case.

Thus like in many other situations we should let the user decide. IMHO we could use SI as default.

As I had spend hours on this the years befor 2022 I would again have a look at this.

How about this?

cheers bernd

Before any new changes are made a unit test for electrical or thermo-mechanical elmer is needed. Simple examples are needed … ?

related: https://forum.freecadweb.org/viewtopic.php?p=581190#p581190

Because of all the changes uwe made non of the FEM solvers does retrieve the units from FreeCAD unit system. I totally agree with this.

I may add some comments in elmer writer because there it still says some other opinion of mine … :blush:

wmayer How about the unit sheme FEM. This is no longer needed anymore. It even could confuse people. Should this be removed?

I wonder what happened with the unit test … ???

The top six commits in https://github.com/FreeCAD/FreeCAD/commits/master/src/Mod/Fem/femtest have adjusted some unit tests.

@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.

This unit schema is no longer needed at all. 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.

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 :laughing: - 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.php?p=604853&sid=c58d416f186cd8ccf8a5d6cf2540e5d6#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 :slight_smile:, I use it and therefore spent many hours of spare time to bring it to the current state.


My plans:


What has been done for FC 0.20

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.

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.

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.

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.

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.php?p=609343#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.

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!

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




OK, feel free to do so or open a PR.

:wink: So you use Pascal just prefer engineering notation over scientific notation. Me too by the way.

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.

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.)

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.

+1