Heat source does not respect Coordinate scaling

Numerical methods and mathematical models of Elmer
Post Reply
uwestoehr
Posts: 38
Joined: 05 Aug 2022, 14:42
Antispam: Yes

Heat source does not respect Coordinate scaling

Post by uwestoehr »

Dear Elmer community, I am a programmer of FreeCAD's Elmer support.

I stumbled over a problem I cannot resolve and need to know if this is either a bug in Elmer or if I have to edit my case.sif:

The mesh coordinates in FreeCAD are in mm. Therefore we pass to Elmer:

Code: Select all

Coordinate Scaling 0.001
(and scale the result mesh back to present the users the correct mesh size)

This works well (electrostatics, stresses, flux etc.), except for the heat source.

I made the Elmer Tutorial 1 "3D – Temperature field of a solid object". When I input to FreeCAD the case.sif that ElmerGui generated, I get no temperature difference.
I only get the desired temperature difference wither:
- if I omit

Code: Select all

Coordinate Scaling 0.001
- or if when I change the Heat source from

Code: Select all

Heat Source = Real 0.01
to

Code: Select all

Heat Source = Real 10000.0
So it seems when Elmer calculates the mass out of the given density and mesh, it is not taking into account that the mesh was scaled.
Is this a bug in Elmer or do I have to tell the heat equation about the scaling?

Since the aim of FreeCAD is to provide full access to Elmer, we try that people can take a case.sif from other Elmer users and get the same results, i would like to avoid that FreeCAD has to recalculate the heat source by a factor of 1e6 and write this to the case.sif file to get the correct result because then an ElmerGUI user will get wrong results since his mesh is not scaled.

For reference here is the case.sif that FreeCAD generates for the heat tutorial case:
case.sif
(2.5 KiB) Downloaded 46 times

I tested with this Elmer version:

Code: Select all

Version: 9.0 (Rev: Release, Compiled: 2022-08-02)
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source does not respect Coordinate scaling

Post by raback »

Hi

Elmer does not keep track of any units. So you need to provide consistent unit system yourself. Some natural constants also have default values given in SI units. So permeability of vacuum, stefan boltzmann constant, unit charge etc. may need to be given if you don't want to use SI units (none of these are needed for elasticity).

FreeCAD operates on "mm" by default. So you have two choices:
1) Scale the mesh by 1e-3 and use SI units.
2) Do not scale and use units where length is given also in "mm".

What unit system do you use in FreeCAD usually?

No the annoying thing with 1) is that the result files are also in the scales system. For this purpose we added keyword for VTU output an additional keyword "Coordinate Scaling Revert = Logical True". This makes it possible that if you visualize with FreeCAD you could have the same scaling and still use SI units for the actual computation. This could be also added to other postprocessing utilities of Elmer.

What result files do you read from Elmer?

-Peter
uwestoehr
Posts: 38
Joined: 05 Aug 2022, 14:42
Antispam: Yes

Re: Heat source does not respect Coordinate scaling

Post by uwestoehr »

Let's first FreeCAD aside and use ElmerGUI:
- take the Tutorial 1 (here is the ElmerGui project: https://github.com/donovaly/FreeCADInst ... -Tuto1.zip)
- run the simulation
result: you get around 600 K as max temperature as you should
- now edit the case .sif and add the line

Coordinate Scaling = Real 0.001

to the simulation section

result: you don't get any temperature difference

So the mesh scaling changes the result and this is in my opinion the bug because I don't observe the same with other setups.

--------------
raback wrote: 05 Aug 2022, 18:04 What unit system do you use in FreeCAD usually?
Since FreeCAD 0.20 for Elmer the SI system is used, no matter what unit system you use for the rest of FreeCAD.
So we assure that every value written to the case.sif file is in base SI units.

Since the mesh is in mm, we use your method 1) and scale the result mesh back by a factor of 1000.
This works fine so far, the only reported problem is with the Elmer Tutorial 1. We write the body heat source as "0.01" to teh case.sif. Therefore the case.sif is pure base unit SI.
raback wrote: 05 Aug 2022, 18:04 No the annoying thing with 1) is that the result files are also in the scales system. For this purpose we added keyword for VTU output an additional keyword "Coordinate Scaling Revert = Logical True". This makes it possible that if you visualize with FreeCAD you could have the same scaling and still use SI units for the actual computation. This could be also added to other postprocessing utilities of Elmer.

What result files do you read from Elmer?
We scale the mesh back with our own code. But
"Coordinate Scaling Revert = Logical True"
works so I will use this in future. (Is however independent of the body heat issue).

Where is the keyword documented? I cannot find it in the latest manual.
By thew way, many thanks for the new models manual! I like its structure.

I FreeCAD we read in the VTU file from Elmer.

many thanks and regards
Uwe
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source does not respect Coordinate scaling

Post by raback »

Hi

Whether the scaling has an effect depends on the equation. Take the heat equation which is basically

-div(k*grad(T)) = h

When you scale x->c*x the coordinates the differential operator d/dx scales as 1/c. On the r.h.s. there is no such operator. The end effect is that if you use mm you should scale the r.h.s. with factor 1000^2 - as you correctly observe. If you have just Dirichlet conditions and no heat source any length unit is ok.

Now the tutorial 1 is a little funny because it uses the original size of the system - which really does not make much sense. The only excuse is that for us it was a mathematical equation just showing the basic steps and not trying to solve anything realistic. It would probably be good idea to include the scaling in the tutorial as well.

-Peter
uwestoehr
Posts: 38
Joined: 05 Aug 2022, 14:42
Antispam: Yes

Re: Heat source does not respect Coordinate scaling

Post by uwestoehr »

raback wrote: 08 Aug 2022, 12:00 When you scale x->c*x the coordinates the differential operator d/dx scales as 1/c.
Thanks. I understand now. However, I thought when I tell Elmer about the scaling, it scales the r.h.s. automatically. Could this feature be implemented in a future Elmer release?
raback wrote: 08 Aug 2022, 12:00 Now the tutorial 1 is a little funny because it uses the original size of the system
I even think the result of the tutorial is strange:

- the object has a volume of 2.272 liters (calculated directly from the step file that comes with Elmer)
- since its density is 2700 kg/m³ its weight is 6.134 kg
- we input 0.01 W/kg as body heat, so in total 0.06 W

And just 0.06 W is enough to heat the body up to 600 K? This is suspicious for me. I mean Aluminum has a c_p of about 0.9 kJ/kg/K, so in vacuum we would have to input 5.5 kJ to heat the body up just 1 K.
Last edited by uwestoehr on 10 Aug 2022, 21:24, edited 1 time in total.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source does not respect Coordinate scaling

Post by raback »

uwestoehr wrote: 08 Aug 2022, 20:48 Thanks. I understand now. However, I thought when I tell Elmer about the scaling, it scales the r.h.s. automatically. Could this feature be implemented in a future Elmer release?
No ;-)

Scaling the r.h.s. to correspond to user specified length unit is not as simple. If we would consider non-consistent length unit in one solver why not do it also in other solvers? We have maybe ~100 modules around, and ~2000 keywords. For each keyword and FE operator we should mark down how they scale with length (i.e. usually some power -2, -1, 0, 1, 2). A significant percentage of keywords and also the operators (grad, div, curl etc.) depend on length unit. Just to have somebody mark down this power everywhere would be a daunting task. And for most users it would bring no additional value.

I understand that whole CAD community is used to "mm" as base unit. That's ok since there is not usually an endless number of parameters. But in conjunction with multiphysics FE codes I think the logic "change to SI units -> compute -> revert to original units" makes most sense.

-Peter
uwestoehr
Posts: 38
Joined: 05 Aug 2022, 14:42
Antispam: Yes

Re: Heat source does not respect Coordinate scaling

Post by uwestoehr »

raback wrote: 09 Aug 2022, 13:11 We have maybe ~100 modules around, and ~2000 keywords....
Hello Peter,

thanks. I understand and I will adapt FreeCAD accordingly.

What about that just 0.01 W/kg can heat the body up to 600 k?

------------------

I am proud to announce FreeCAD 0.20.1 that comes with tons of fixes and improvements especially for the support of Elmer:

https://github.com/FreeCAD/FreeCAD/releases/tag/0.20.1
(official announcement will be done when there are packages available for all OSes)
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source does not respect Coordinate scaling

Post by raback »

Hi,

We cannot use our intuition for objects that are large in size. Without the scaling the piece is huge, hundreds of metres long. I have no reason to question the correctness of the solution. The HeatSolver has been tested over and over. But I certainly agree that adding the scaling there would be a good thing to do!

-Peter
uwestoehr
Posts: 38
Joined: 05 Aug 2022, 14:42
Antispam: Yes

Re: Heat source does not respect Coordinate scaling

Post by uwestoehr »

raback wrote: 10 Aug 2022, 16:49 We cannot use our intuition for objects that are large in size. Without the scaling the piece is huge, hundreds of metres long.
I am not suspecting the Heat solver but the input of the body heat to it.

Let's only take ElmerGUi, so no scaling:
- take the step file and inspect it with a program of your choice
result: the part has a volume of 2.7 liters.

Also, the size of the body does not matter much because the body heat is relative to the weight. Per kg there is only 20 mW -> physically few mW cannot heat a kg of aluminum. (just look at the heat capacity of Aluminum to see that)

Therefore, can you please check if there is a bug in the input of the body heat to the heat solver?

thanks and regards
Uwe
Post Reply