Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

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 in FreeCAD - Tutorial Challenge - Tutorial 4

Post by uwestoehr »

We need here air as material and the specific heat in the air material card is wrong. Here is the fix: https://github.com/FreeCAD/FreeCAD/pull/4648
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

Post by uwestoehr »

Since today, FreeCAD can handle the Electric Conductivity. So we can now define the material properties of the tutorial using the material editor.

So this is what we have so far for as FreeCAD file for the tutorial:
Crucible-heating.FCStd
(628.43 KiB) Downloaded 68 times

The next step is to check how the units have to be transferred to Elmer.
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

Post by RatonLaveur »

Hey all of this looks great, I have not had the leisure to get back to it, but I will.
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

Post by RatonLaveur »

Hi, I am just now having some time to keep at it, today I had to decide whether to keep the discussion going here or move on to the next tutorial.
I decided this one is not quite yet done.
uwestoehr wrote: Fri Mar 26, 2021 3:51 am Since today, FreeCAD can handle the Electric Conductivity. So we can now define the material properties of the tutorial using the material editor.

So this is what we have so far for as FreeCAD file for the tutorial: Crucible-heating.FCStd

Thanks to uwestoehr, raback and bernd we now have:
- Improved material card handling with new properties more adequate for multi-physics
- Improved understanding of the current unit system

@uwestoehr: something I do not understand; if I open your file crucible-heating.FCStd, I see this:
2021-04-10 17_43_28.png
2021-04-10 17_43_28.png (15.66 KiB) Viewed 1646 times
- why are the ccx tools included in the file? (forgot to delete or a bug when I open the file?)
- no equations and no bc : i supposed because you chose to write in the .sif directly.


I'll keep working on this tutorial to list as adequately as possible what we lack.
uwestoehr wrote: Fri Mar 26, 2021 3:51 am The next step is to check how the units have to be transferred to Elmer.
Currently, my understanding is based on the writer.py file for Elmer. It checks the global unit system of FC to apply a mm to m conversion or not.

The rest is Elmer. As Raback explained, Elmer is unit agnostic, therefore it will solve properly provided that the units are homogeneous.
By definition the rule of thumb has been to feed S.I. units to Elmer. There are, to my understanding, a few cases where the Elmer cases published online were done using the MEMS unit system, which is deprecated and very specific to MEMS element.

As we stand now, here, today, if we input everything properly in FreeCAD FEM GUI, and do not mess with the .sif file regarding units, the simulations work as is. But since we currently have to work over the .sif files, we essentially must make sure that any value we input follows the <Active FreeCAD global units system> converted to <Elmer Writer.py conversion>.

Essentially, currently the only conversion that Writer.py does, is coordinate scaling

from **\Mod\Fem\femsolver\elmer\writer.py

Code: Select all

 def _handleSimulation(self):
        self._simulation("Coordinate System", "Cartesian 3D")
        self._simulation("Coordinate Mapping", (1, 2, 3))
        if self.unit_schema == Units.Scheme.SI2:
            self._simulation("Coordinate Scaling", 0.001)
            Console.PrintMessage(
                "'Coordinate Scaling = Real 0.001' was inserted into the solver input file.\n"
            )
Which essentially means if the SI2 unit system (m/kg/deg/s) is used in FC, then the writer will apply a coordinate scaling 10^-3 to make it mm.


Example, in the current nonGUI tutorial 1 (eigen values of a beam)

The Elmer documentation suggests the use of 2330 kg/m3 as the density of Silicon
The FreeCAD example, as setup by bernd (well done by the way) states:
2021-04-10 18_09_08.png
2021-04-10 18_09_08.png (3.45 KiB) Viewed 1649 times
The sif file, as written states:

Code: Select all

Material 1
  Density = Real 2.33e-06
  Poisson ratio = Real 0.3
  Youngs Modulus = Real 100000000.0
End
....and now I'm confused as I write this. My FC is set in SI1 (mm/kg/deg/s), which means Writer.py did not trigger any conversion. So I have no clue when the conversion occured from Real 2330 (kg/m3) to Real 2.33e-6 (kg/mm3)...no clue at all :D
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

Post by RatonLaveur »

Okay, now moving forward:

We have assessed through this tutorial the following:

We can set the boundary conditions already in FreeCAD.

Example from the original test file in OP:

Code: Select all

Boundary Condition 1
  Name = String "Edge21"
  Potential 1 = Real 0.0
	Potential 2 = Real 0.0
	Temperature = 293
End
This can be produced using the temperature and electrostatic potential BCs in FreeCAD:
And sif writing generates:

Code: Select all

Boundary Condition 1
  Name = String "Edge21"
  Potential = Real 0.0
  Temperature = Real 293.0
End
Now I'm only slightly confused that the values found in the tutorial stipulate Potential 1 and Potential 2. If someone has an explanation for why how that works I'm all ears. My best guess is that you this is an indexation of the potentials for each model solver (Potential solver and Heat equation).
Since they use the same potential we may be able to make do with a single indexed.

We do not have suitable equations/models/solvers accessible in FreeCAD.

The sif file provided by the Elmer team specifies StatMagSolve as the solver to use

Code: Select all

Solver 1
	Equation = Potential Solver
	Variable = Potential
	Variable DOFs = 2
	Angular Frequency = Real 50.0e3
	Calculate Joule Heating = Logical True
	Calculate Magnetic Flux = Logical True
	Desired Heating = Real 3.0e3
	Procedure = "StatMagSolve" "StatMagSolver"
	Linear System Solver = Iterative
	Linear System Iterative Method = BiCGStab
	Linear System Max Iterations = 300
	Linear System Convergence Tolerance = 1.0e-10
	Linear System Preconditioning = ILU1
	Linear System ILUT Tolerance = 1.0e-03
	Linear System Residual Output = 1
	Nonlinear System Max Iterations = 1
	Nonlinear System Convergence Tolerance = 1.0e-6
	Nonlinear System Relaxation Factor = 1
	Steady State Convergence Tolerance = 1.0e-6
End
More to the point it specifies

Code: Select all

Angular Frequency = Real 50.0e3
	Calculate Joule Heating = Logical True
	Calculate Magnetic Flux = Logical True
	Desired Heating = Real 3.0e3
There is currently no equation in FreeCAD that offers the option to calculate joule heating, maybe one for flux in the Flux equation.
Concomitantly, there is no field to specify "angular frequency" or "desired heating"

More "alarming" is that "Desired Heating" in the ElmerModelsManual is linked to two solvers that are specified as obsolete...
Notably the StatMagSolve that I used originally, based on the provided file.

So what' next?

My opinion is that we should try to replicate this case using non-deprecated solvers (i.e. update the Elmer tutorial for the Elmer team as well as for the FreeCAD team).

Since the main objective of this case is to calculate the joule heating (process the powder thermally by using an induction coil), I first seek out the solvers that have Joule Heating as an option:

StatCurrentSolve: Model 17 Static Current Conduction--> has no calculation of flux

MagnetoDynamics: Model 18 Computation of Magnetic Fields in 3D --> has a plethora of options...most promising since flux will be considered

BSolver: Model 22 Computation of Magnetic Fields in 2D --> unfortunately this specific subroutine is also noted as obsolete by Elmer (it works, since I made it work in the tutorial, but I feel like we should try to do things in the more up-to-date way).
2021-04-10 19_41_13.png
2021-04-10 19_41_13.png (17.74 KiB) Viewed 1634 times
StatMagSolve: Model 72 Magnetoquasistatic approximation for axial symmetry --> Is considered obsolete by Elmer team.

Temporary conclusion:
I will explore the BSolver situation more in detail see why it is considered obsolete in a solver that is not.

Note on these explorations:
I am a bit overwhelmed by the number of solvers and keywords accessible and I really wonder how to make the FreeCAD implementation as capable as possible whilst not trying to replicate everything 1:1
Even the Elmer team says about their GUI, that it only accesses the most common solver options, and for the rest requires FreeTextInput
I feel more and more that the FreeTextInput options for FreeCAD is a must have:
---It would enable the user to apply BCs, Solver options and Solver types with complete freedom, while using FreeCAD to design the case, mesh the case and target the elements of the cases with the FreeTextInput.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

Post by uwestoehr »

RatonLaveur wrote: Sat Apr 10, 2021 4:19 pm I decided this one is not quite yet done.
I think we needs more weeks until it is done. I mean I tried it, then I encountered a bmunch of material card issues, then GmsH issues, then the missing unit.
All Gmsh issues I found are now fixes, also the specific heat is now understood by FC. But there are still several material card issues and I have to reply on Bernd to have a look.

In my opinion this Challenge should be taken to iron out the various FEM issues.
RatonLaveur wrote: Sat Apr 10, 2021 4:19 pm @uwestoehr: something I do not understand; if I open your file crucible-heating.FCStd, I see this:
2021-04-10 17_43_28.png
- why are the ccx tools included in the file? (forgot to delete or a bug when I open the file?)
- no equations and no bc : i supposed because you chose to write in the .sif directly.
I could that time not include an equation because FC was not ready for this. Now it is. Could you please post your file that you created using latest FC?
Note that you have to change the material cards because the material cards I created are typical values for e.g. graphite, not exactly the ones Elmer uses in the callenge.
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

Post by RatonLaveur »

Oh hey Sir! So nice to see your here. Having a good week? (yes I'm having some wine, sue me!)

Here the latest file (I have not reviewed it, will do that sometimes this week).
Tuto4_InductionHeating.FCStd
(242.54 KiB) Downloaded 61 times
Careful this file is a very re-modified from the original, I basically butchered it to try new things.
The SIF file in OP is still the more important thing.
uwestoehr wrote: Wed Apr 14, 2021 6:47 pm I think we needs more weeks until it is done.
To some extent that's what I like about it. I initially thought I'd just make all tutorials as "lacunar" cases, showing all the pitfalls. Instead I just pointed at a hill and said "wouldn't it be nice to just walk over there?" and you guys actually followed and we struggle together to climb it, and when we get it, "hey let's go over that one now!" :D I'm enjoying the journey.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Elmer in FreeCAD - Tutorial Challenge - Tutorial 4

Post by uwestoehr »

Since today this challenge (in 2D) can done directly in FreeCAD. The 3D version is already a pending PR hoping to get this merged the next days.

To try the challenge in 2D, see this post: viewtopic.php?t=75888
Post Reply