How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

About the development of the FEM module/workbench.

Moderator: bernd

qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by qingfeng.xia »

Dear all,

I have been thinking of implementing a FluidicMaterial, adapted from MechanicalMaterial.py, but it means lot of code duplication, Geometry selection, is duplicated.

I have some plans and some initial implementation for plan A
taskpanelfemmaterial.png
taskpanelfemmaterial.png (66.35 KiB) Viewed 2779 times
I will soon share out this code, please do not try to compile these 3 files, they are just for demo
https://github.com/qingfengxia/FreeCAD/ ... rc/Mod/Fem
FemMaterialTaskPanel.py FemMaterialTaskPanel.ui FemMaterial.py


================================================
_MechancialMaterial.py and _FluidicMaterial.py as DocumentObject to hold data

Plan A: I have coded it
1) FemMaterialTaskPanel, adapted from MechanicalMaterialTaskPanel.py
2) add a catagory filed to FluidicMaterial, "Fluid, Solid" for FluidicMaterialTaskPanel
so it know where it should load standard material and make different toolbar item for each kind of
3) using tabs widget for each
either Mechancial or Fluidic + "Thermal, and ElectroMagnetic" properties are needed for both "Fluid, Solid"

pro: shared by all kind of FEA,
con: huge file size, not easy to maintain.



=================================================
Plan B: hard bite

1) split a base FemMaterialTaskPanel from MechanicalMaterialTaskPanel.py, for material loading, geometry selection functions
2) derived new MechancialMaterialTaskPanel or FluidicMaterialTaskPanel classes
3) add property setup in MechancialMaterialTaskPanel

pro: MechancialMaterial or FluidicMaterial are decoupled,
con: I am not sure it is possible to split one taskpanel *.ui into 2 *.ui.
The first one is for FemMaterial for material loading, geometry selection functions
The second one is for either CFD or SolidMechanics(FEM workbench), not sure it is possible to load another widget from ui.

Plan C: do not care code duplication and make it work first

https://github.com/jaheyns/FreeCAD/blob ... aterial.py
currently, thermal property is not added.

just adapt FluidicMaterialTaskPanel, adapted from MechanicalMaterialTaskPanel.py,
once shared code updated in MechanicalMaterialTaskPanel. copy to FluidicMaterialTaskPanel

================================================
I have not tried plan B, because I am not sure about implementation and I am not good at the refactoring/split and merge to official timely, I am not good at git.

In c++ I see an example of loading 2 ui/taskpanels into panel on the left, is that possible in python?
At least the material physical property value UI can be added programingly, but not a good way.


Please everyone vote a plan, or comes up with better plan?

Thanks
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by makkemal »

We have been looking at 1D thermo-hydrauli pipe network simutations.
http://feacluster.com/CalculiX/ccx_2.11 ... ode66.html
http://feacluster.com/CalculiX/ccx_2.11 ... ode90.html

We have already coded some properties for fluids and gasses.
We should not duplicate work
https://github.com/makkemal/FreeCAD/tre ... uidSection
gas.png
gas.png (58.3 KiB) Viewed 2772 times
fluid.png
fluid.png (54.55 KiB) Viewed 2772 times
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by qingfeng.xia »

I see your implementation and I am glad to see another trial, now shall we unit for a general CAE material model.

My concerns
1) why the class is called FluidSection. it should be called FluidMaterial.
So it can be used for both CFD and SolidMechanics. it is not intuitive to include a FluidSection obj in CFD. It is a name purely for one kind of FEA problem. not a general concept.

Is that possible for you to make your FluidSection as a FemConstraint, keeping a PropertyLInk to the FluidMaterial which is added without link to any geometry.

2) it is good to group Mechancial, Thermal, Fluidic and ElectroMagnetic properties, see my example of Tab widgets, for further extension for ElectroMagnetic. In property file, ini file or XML, it can be grouped.

3) In GUI only linear or constant properties is set ATM, fluid properties is very complicate, for gas density is a function of T, P, viscosity is very sensitive to T. etc. let is why I specify Viscosity method enum and combo box: constant, idealgasmodel, powerlower, etc.
e.g. for mechanical properties , fire another an "advanced" dialog may set temperature coeff for E, density ,etc.

4) tweak: remove
Calculix prefix for air.
Temperature is a kind of boundary condition/constraint, it is not a propeprty, set it with pipe geometry in FluidSectionConstraint

Thanks
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by bernd »

very good idea. I moved the MechanicalMaterial into a FemMaterial.

commit:
https://github.com/berndhahnebach/FreeC ... it/3a4c20b

branch:
https://github.com/berndhahnebach/FreeC ... its/femdev

This could be used for a TaskPanel which supports all different kind of material types as long as they do not involve complicated non linear behavior. I would use extra objects for such equations. See as an example the FEM nonlinear mechanical material object.

The move is not yet finished. The unit tests needs to updated and the FEM example from Start WB needs to be updated as well. These will be next on my TODO.

bernd
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by qingfeng.xia »

Great job. This is the moment I am waiting for a year. I did not take up such responsibility, because I am really bad in git to achieve such a big refactoring work.

Please leave the job of adding standard fluid material file to Johan's team, they have done a lot work on that. I hope they can submit their contribution directly to FreeCAD after your merge. They add a FluidMaterial folder in Mod/Material/

Makktel's radiobox seems better than my combobox, it clear and evident to see all kind of material.
My hunble opinion: Taskpanel and makeFemMaterial() should know the "Type" (or other name) of material before loading UI

And what is your proposed FemMaterial properties? grouped into PropertyDict?

For FcMat file, is that possible to group properties? "Mechancial, Fluidic Thermal and ElectroMagnetic"
Mechanical and Fluidic are exclusive, Thermal and ElectroMagnetic are meaningful to both solid and fluid

Do post us the progress, so we can contribute at least comments.

Another feature I hope to add:
---------------------------------------------
Add a property of PhysicalDomain into each FemSolver
https://github.com/qingfengxia/Cfd/blob ... dSolver.py
supported_physical_domains = ['Mechanical', 'Fluidic', 'Electromagnetic'] # to identify physical domains, "Coupled" in the future
then makeFemMaterial() can load the correct material type and default material, like air for CFD, steel for Mech

furthermore, meshing also know the favour of solver. I am not sure Elmer support secondary fem, but OpenFOAM (fenite volume) does not support
----------------------------------------------
bernd wrote:very good idea. I moved the MechanicalMaterial into a FemMaterial.

commit:
https://github.com/berndhahnebach/FreeC ... it/3a4c20b

branch:
https://github.com/berndhahnebach/FreeC ... its/femdev

This could be used for a TaskPanel which supports all different kind of material types as long as they do not involve complicated non linear behavior. I would use extra objects for such equations. See as an example the FEM nonlinear mechanical material object.

The move is not yet finished. The unit tests needs to updated and the FEM example from Start WB needs to be updated as well. These will be next on my TODO.

bernd
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by qingfeng.xia »

Continue on your refactoring work, I add the makeFluidMaterial method and command class

https://github.com/FreeCAD/FreeCAD/pull/429

The FluidMaterial taskpanel ui is redesigned, but py coding is yet done, but it does not break existent code and case.

Team of CSIR can merge you code into the _TaskPanelFemMaterial.py by a switch like

Code: Select all

if obj.hasProperty('Category') and obj.Category == 'Fluid':
    # you code 
obj.hasProperty('Category') can make previous case file loadable.
Screenshot_fluid_material.png
Screenshot_fluid_material.png (95.42 KiB) Viewed 2577 times
=====================================

1) taskpanel should init according to Category, show/hide Mechanical/Fluidic setting tab(group), load the default steel for solid air/water for fluid
which can be a radioButton group

2) Bernd has added 3 basic thermal , it is desired to add ElectroMagnetic 2 basic properties now into std mat file

3) Considering support for compressible flow, but it can be left until the date, CFD workbench needs
As we are going to suport compressible flow,
then "DensityType" ['Constant', 'IdealGas'],
"ViscosityType" ['Constant', 'PowerLow', ...]

4) design an icon file: fem-material-fluid.svg

5) for the ui, i think we may custom the loaded standard material into a new material, and save it back. just like Ansys Fluent, but feel free to delete the `name` value in basic propertiies group

==========================================
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by makkemal »

It is missing specific gas constant for caluclix gas calculations.
That is why we had gas a separate option
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by bernd »

I like a combo box much more than the radio buttons for choosing the material type. New material types or categories could be added much more simpler than with new radio buttons. We could have electricity and many more material types in the future. The task panel should change with material category and only show the needed properties. Have a look at the beam section object task panel for example.

bernd
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: How about a general FemMaterial.py to suport Mechancial, Thermal, Fluidic and ElectroMagnetic

Post by Jee-Bee »

bernd wrote:I like a combo box much more
bernd wrote:We could have electricity and many more material types in the future.
Does not the same problem exist with the fem analysis. also there are serval other analysis posible and also there are radio butons used...
Post Reply