Topology optimization

About the development of the FEM module/workbench.

Moderator: bernd

m0n5t3r
Posts: 51
Joined: Fri Feb 03, 2017 2:55 pm

Re: Topology optimization

Postby m0n5t3r » Sat Jul 20, 2019 4:58 pm

Getting it to run without hardcoding the git checkout path is easy: put this in the macro directory, and put the python files in Macro/beso: https://gist.github.com/m0n5t3r/07aa246 ... 74b395cab2

To make it usable it would need some sort of parameter GUI replacing beso_conf.py, and some code changes (hint:

Code: Select all

exec(open("beso_conf.py").read())
is not a good way to get settings, and beso_main.py should be a function (maybe several, if functionality can be broken up) - this way you can get input parameters from the command line, from a configuration file, or from the macro GUI thingy)

I couldn't make it work with the first example (I can't run any calculation and I don't know why - missing material? but I can't add a material either, so...); it may well be a PEBKAC situation since I have very little experience with the FEM workbench (and zero experience with FEM in general, I only ever played with a model of my MPCNC's table)

I can try to make the code interact with the world more easily if you accept pull requests ;)

OS: Ubuntu 16.04.6 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.1.
Build type: Release
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
fandaL
Posts: 333
Joined: Thu Jul 24, 2014 8:29 am

Re: Topology optimization

Postby fandaL » Sun Jul 21, 2019 11:19 pm

Thanks for the comments.
What I want to do (hopefully within two weeks) is to make a simple GUI which would write beso_conf.py with parameters for very basic task so that user would not need to touch the code. By now, for more advanced use (or more experimental since whole implementation is quite experimental) I would leave it to a user to modify the configuration file.
m0n5t3r wrote:
Sat Jul 20, 2019 4:58 pm
I couldn't make it work with the first example (I can't run any calculation and I don't know why - missing material? but I can't add a material either, so...); it may well be a PEBKAC situation since I have very little experience with the FEM workbench (and zero experience with FEM in general, I only ever played with a model of my MPCNC's table)
Working FE model is necessary before starting optimizaton. Better to start with pure FEM tutorial, e.g. https://www.freecadweb.org/wiki/FEM_Module#Tutorials
m0n5t3r
Posts: 51
Joined: Fri Feb 03, 2017 2:55 pm

Re: Topology optimization

Postby m0n5t3r » Mon Jul 22, 2019 5:45 am

fandaL wrote:
Sun Jul 21, 2019 11:19 pm
What I want to do (hopefully within two weeks) is to make a simple GUI which would write beso_conf.py with parameters for very basic task so that user would not need to touch the code. By now, for more advanced use (or more experimental since whole implementation is quite experimental) I would leave it to a user to modify the configuration file.
if you insist on a python config file, at least do something like

Code: Select all

from beso_conf import *
this way, you can add the beso dir to sys.path in the fcmacro file and avoid the chdir nonsense, while preserving the current behaviour (when you run it from the same directory); a better way to do it is probably to use something like an ini file (or yaml, which is in fashion these days and is almost as easy to edit)

if I find some time this week I'll try to whip up a proof of concept and send you a pull request :)
Jee-Bee
Posts: 1940
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Topology optimization

Postby Jee-Bee » Mon Jul 22, 2019 6:14 am

m0n5t3r wrote:
Mon Jul 22, 2019 5:45 am

Code: Select all

from beso_conf import *
I'm not a python expert but as far as i know this method is not recommend...

here https://stackoverflow.com/questions/238 ... import-bad a bit more
m0n5t3r
Posts: 51
Joined: Fri Feb 03, 2017 2:55 pm

Re: Topology optimization

Postby m0n5t3r » Mon Jul 22, 2019 7:02 am

the current method is even worse ;)

that's why I said it's better to use a text config file (ini, yaml)
fandaL
Posts: 333
Joined: Thu Jul 24, 2014 8:29 am

Re: Topology optimization

Postby fandaL » Mon Jul 22, 2019 1:35 pm

Code: Select all

from beso_conf import *
does not work due to touching existing dicts but os.chdir can be avoided when using commited change
https://github.com/fandaL/beso/commit/a ... 0df4d9d7d1

Code: Select all

beso_dir = os.path.dirname(__file__)
exec(open(os.path.join(beso_dir, "beso_conf.py")).read())  
I don't persist to use python input file, it was just a split of inputs from one (originally short) script containing everything in the beginning.
joha2
Posts: 231
Joined: Tue Oct 11, 2016 9:48 pm

Re: Topology optimization

Postby joha2 » Fri Aug 02, 2019 7:20 pm

DMST1990 wrote:
Fri Jun 24, 2016 7:52 am
I have written my own optimizer which is open source. (in python)
In this case i use calculiX for solving the physical equation.
You can optimize any problem and model which run on calculiX.

There are different types of optimization:

Maximize Heat-Exchange.
Maximize Stiffnes.
Multi physic topology optimization. (Solving a problem for heat exchange and stiffnes)

https://github.com/DMST1990/ToOptiX

https://www.youtube.com/watch?v=o17b7C4N1uI

In the new version which is not up to date, you can simulate optimized crash profils.
Nice one! I am a bit too late for this, but this should not be too hard to be added to FreeCAD. (At least it should be possible to write a workbench which mimics your Blender addon and which reimports the STL file at the end.)

Keep up the good work! Best wishes
Johannes
shIxx
Posts: 28
Joined: Wed Mar 28, 2018 10:13 am
Location: Bavaria (Germany)

Re: Topology optimization

Postby shIxx » Sun Aug 04, 2019 6:25 pm

Excuse me for the late reply I was very busy last month.
DMST1990 wrote:
Fri Jul 19, 2019 8:58 am
Hello shlxx,

well I think you are using precompiled version of FreeCAD 0.18 with Python3. In that FreeCAD-Version the module "commands" is not included.
Additionally in FreeCAD 0.18 the API has changed a little bit, so that it wont run.

This Macro is working for FreeCAD 0.17 precompiled on Python2.

Best Regards

Martin
Yes I'm using FreeCAD_0.19.17300_x64_Conda_Py3QT5-WinVS2015
jmaustpc wrote:
Fri Jul 19, 2019 1:36 pm

Just a quick clarification, that is not correct which is one of the reasons why we always are telling people to post their version data in the manner explained in the forum rules. FreeCAD 0.18 supports Python 3 but can be compiled with Python 2, ,.....
Sorry for that.

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17300 (Git)
Build type: Release
Branch: master
Hash: 07d3423adda83e9bd013a52a1b1bd027ae9fa454
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)


Well I will wait for the GUI because I'm a really noob in coding at all