## Elmer Static current equation

About the development of the FEM module/workbench.

Moderator: bernd

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

### Elmer Static current equation

This is a brief summary what I have currently done in regard of Elmers Static current equation/solver for FC-FEM.
I implemented the basic stuff for using the static current equation/solver from Elmer in FC. Please see: https://github.com/HoWilgh/FreeCAD/tree ... tatcurrent

Currents and Joule-heating are computed (hopefully correctly).
Whats still needed to implement the full Non-Gui Tutorial 9 "Thermal actuator driven with electrostatic currents" is:

An extra Body-force- element is needed to hand over the computed Joule-heating to the heat-equation.
See https://www.nic.funet.fi/index/elmer/do ... nonGUI.pdf page 39-41

In the tutorial a temperature dependent electric conductivity is implemented .... no idea how to do that in FC!
The case.sif should look like:

Code: Select all

``````...
Material 1
Electric Conductivity = Variable Temperature
Real
298.0   4.3478e10
498.0   1.2043e10
698.0   5.1781e9
898.0   2.7582e9
1098.0  1.6684e9
1298.0  1.0981e9
1683.0  1.0
2000.0  1.0
End
...
``````
I attach the model for testing and documentation:
Attachments
Screenshot from 2020-07-21 22-01-52.png (227.15 KiB) Viewed 738 times
Screenshot from 2020-07-21 22-01-58.png (232.02 KiB) Viewed 738 times
thermal_cleared-mesh.FCStd
bernd
Posts: 10956
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: Elmer Static current equation

HoWil wrote:
Wed Jul 22, 2020 7:40 pm

In the tutorial a temperature dependent electric conductivity is implemented .... no idea how to do that in FC!
The case.sif should look like:

Code: Select all

``````...
Material 1
Electric Conductivity = Variable Temperature
Real
298.0   4.3478e10
498.0   1.2043e10
698.0   5.1781e9
898.0   2.7582e9
1098.0  1.6684e9
1298.0  1.0981e9
1683.0  1.0
2000.0  1.0
End
...
``````
Me nither, because there is no data structure ATM. We would need to implement one first. https://forum.freecadweb.org/viewtopic.php?f=38&t=32942
HoWil
Posts: 1199
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

### Re: Elmer Static current equation

Workaround: How about an (textdocument) element which simply adds or replaces some text in the .sif?
This would also help with other customizations or e.g. transient simulations.

E.g. find and replace the

Code: Select all

``````Material 1
Electric Conductivity = xyz
``````

generated by FC with the following

Code: Select all

``````Material 1
Electric Conductivity = Variable Temperature
Real
298.0   4.3478e10
498.0   1.2043e10
698.0   5.1781e9
898.0   2.7582e9
1098.0  1.6684e9
1298.0  1.0981e9
1683.0  1.0
2000.0  1.0``````
Will see if I can find Python snippets. I think I have done something similar some years ago without any incorporation into the GUI.
bernd
Posts: 10956
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: Elmer Static current equation

No do not replace something in the sif after the sif was writer by elmer writer. This would not be a hack, this would be a haaaack.

If these values will not change like the vakuum permitivity you could just hard code them in elmer writer. As we had the constants before I moved them out of the writer in a gerneric FEM constants module. This would be not smart, but it would be a start and it is more a workaround than a hack. If they do change we could add the most common ones to the elmer writer.

How does this sounds?
RatonLaveur
Posts: 811
Joined: Wed Mar 27, 2019 10:45 am

### Re: Elmer Static current equation

I actually like this, kindof like a config file for elmer with the default values.

May I ask, why you do not want to edit the .sif file after the fact? there is still the EDIT button in the SolverElmer Task pannel (granted at the moment it does not work ). But i wonder if there is a technical reason not to do that or you simply do not want to encourage it, in order to foster integration instead of a combination of manual hacks.
raback
Posts: 58
Joined: Fri May 08, 2020 4:02 pm
Location: Finland
Contact:

### Re: Elmer Static current equation

A challenge in Elmer is that there are quite many keywords to control the simulation. Some of them are combinations. For example, for any field any module, say "fieldname", we can have boundary condition that makes the field constant (yet unknown) by "fieldname constant = logical true". Because of these combinatorial keywords an exhaustive GUI would be a stretch. Still, probably 95% of simulations are ok with a small subset of keywords (like Dirichlet and Neumann BCs only).

In ElmerGUI this challenge has been addressed by having "free text input" in most sif file sections. This way also more esoteric cases can be defined by the GUI. Maybe there could be something similar in FreeCAD Elmer interface. In ElmerGUI the datatype is actually always plain text. This way you don't have to make the GUI to be aware of the internal workings of ElmerSolver.

I'm not saying how to do this in FreeCAD but this is how it was done in ElmerGUI. (ElmerGUI does not have any geometry creation tools so in that respect it will be always limited in ways that FreeCAD is not.)

-Peter
HoWil
Posts: 1199
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

### Re: Elmer Static current equation

bernd wrote:
Thu Jul 23, 2020 9:01 am
No do not replace something in the sif after the sif was writer by elmer writer. This would not be a hack, this would be a haaaack.

If these values will not change like the vakuum permitivity you could just hard code them in elmer writer. As we had the constants before I moved them out of the writer in a gerneric FEM constants module. This would be not smart, but it would be a start and it is more a workaround than a hack. If they do change we could add the most common ones to the elmer writer.

How does this sounds?
The idea of search and replace came up because the solver-framework checks on export if all essential elements like a definition of the material are present. So, simply exporting a standard material and replacing it afterwards was the first thought..... yes its a haaaaack

BUT, now I see it a bit more openly ... a combination of Bernds and Peters comments is maybe the best solution. Yes, like the element for vacuum permittivity we need 'generic' or 'free text input' elements for the equation(s), the boundary-condition(s), the body-force(s), material(s) and so on which override the usual .sif element creation.
Each of this elements simply has a text field where the 'experienced' user can input the needed information for e.g. the BC. The basic test if all required types of information mesh, equation, material are present can still happen. If the information inserted into the free-text-input wrong than Elmer will complain.

But this way one can still use Freecad to create a complete model with all benefits from mesh-creation and bc-asignment while holding all important information (as text) without haaaacking around and getting an undefined state where nobody knows what was changed by whom and when.

If we see that some of the text-blocks are used oftener than we can create a extra Gui element and writer section for it.

EDIT: BTW: this would instantaneously make all tutorial examples work with FreeCAD
raback
Posts: 58
Joined: Fri May 08, 2020 4:02 pm
Location: Finland
Contact:

### Re: Elmer Static current equation

A note to the "free text input": the main difference in ElmerGUI is that you don't just give the r.h.s. value of the keyword but you give both the keyword and its expression. You can even give several keywords assuming provided that the free text is multiline. So just one "free text input" per section is enough.

I also like the fact that you can have the case fully specified. Also, if the ElmerSolver modules change and get new keywords you don't have to have immediate reaction by FreeCAD developers but the new keywords can be treated by the free text input. Exactly the way we do in ElmerGUI since ElmerSolver is always way ahead of the user interface.

-Peter
bernd
Posts: 10956
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: Elmer Static current equation

I totall agree with you guys, the sif file should be editable by the user. The edit should be even saved somehow, but that is another story.

In the regard of replacing by code. The writer class should write the sif. That‘s it. Noone else should . If we start to replace things after the writer class has finisched we will end up with a mess. If there is a bug ATM it is somewhere in the writer class. But if we start to allow editing afterwards where would I look for a bug if I do not know who else does write into the sif file.

I am not a professional but the above just makes sense to me from developing point of view.
HoWil
Posts: 1199
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

### Re: Elmer Static current equation

So, how to start

We need task panels with a possibility to select e.g. a solid and where one can inset text which is stored and handled in a specific way, e.g. it is handled as body force-element. Similar for bcs, equations and material.

writer.py has to know that this extra body-force has to be handled differently and "just" exports the given text to the selected/chosen body.

### Who is online

Users browsing this forum: Bing [Bot] and 1 guest