Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run examples #38

Open
j2l opened this issue Jan 16, 2024 · 8 comments
Open

Cannot run examples #38

j2l opened this issue Jan 16, 2024 · 8 comments

Comments

@j2l
Copy link

j2l commented Jan 16, 2024

I tried example 2:
Downloaded the zip, opened the freecad file, adapted a little bit to freecad 2024.104 (freecad-realthunder), added beso_fc_gui.py and run it from Macro.
I select analysis /home/pm/Downloads/input_and_results/file057_state1.inp
I can generate and edit beso_conf.py:

# This is the configuration file with input parameters. It will be executed as python commands
# Written by beso_fc_gui.py at 2024-01-16 20:48:29.361423

path_calculix = '/snap/freecad-realthunder/124/usr/bin/ccx'
path = '/home/pm/Downloads/input_and_results'
file_name = 'file057_state1.inp'

elset_name = 'MaterialSolidSolid'
domain_optimized[elset_name] = True
domain_density[elset_name] = [4.43e-15, 4.43e-09]
domain_material[elset_name] = ['*ELASTIC\n0.114, 0.33\n*DENSITY\n4.43e-15\n*CONDUCTIVITY\n6.7e-06\n*EXPANSION\n8.6e-12\n*SPECIFIC HEAT\n553.0\n',
                               '*ELASTIC\n1.14e+05, 0.33\n*DENSITY\n4.43e-09\n*CONDUCTIVITY\n6.7\n*EXPANSION\n8.6e-06\n*SPECIFIC HEAT\n5.53e+08\n']

mass_goal_ratio = 0.4
filter_list = [['simple', "auto"],
               ]

optimization_base = 'stiffness'

mass_addition_ratio = 0.015
mass_removal_ratio = 0.03
ratio_type = 'relative'

I click on the big square button, and it throws:

20:50:01  Traceback (most recent call last):
20:50:01    File "/home/pm/Downloads/input_and_results/beso_fc_gui.py", line 944, in on_click24
20:50:01      self.on_click23()  # run optimization
20:50:01    File "/home/pm/Downloads/input_and_results/beso_fc_gui.py", line 940, in on_click23
20:50:01      exec(open(os.path.join(beso_gui.beso_dir, "beso_main.py")).read())
20:50:01    File "<string>", line 51, in <module>
20:50:01  FileNotFoundError: [Errno 2] No such file or directory: 'beso_conf.py'

Everything is in /home/pm/Downloads/input_and_results/, including beso_conf.py, so I don't get what is wrong.

@fandaL
Copy link
Collaborator

fandaL commented Jan 19, 2024

You have selected file057_state.inp which is a resulting mesh exported from 57th iteration. You should use FEMMeshGmsh.inp or new name if you generate new inp file by FreeCAD. In the GUI check if you have selected correctly design domain (called by the name of the material which corresponds to the elements which will be removed).

But the error
No such file or directory: beso_conf.py
might be due to something else. I assume that you tried already example 4.

@j2l
Copy link
Author

j2l commented Jan 19, 2024

Thank you @fandaL
Unfortunately, the problem is not the inp but it cannot find beso_conf.py, while same location as beso_fc_gui.py:
image
image
image

Yes, I'm following example 4 with example 2 data.

Edit:
I modified beso_fc_gui.py to show the path:

# path
        label53 = QLabel('path: '+self.beso_dir, self)
        label53.move(10, 580)

and the path is showing right:
image

so I don't get what is wrong.

Edit2:
At line 776, modifying the filename to with open(os.path.join(self.beso_dir, "/beso_conf.py"), "w") as f: seems to push a little bit further, now I get a new error:

18:48:12  Recompute failed!
18:49:16  Traceback (most recent call last):
18:49:16    File "/home/pm/Downloads/input_and_results/beso_fc_gui.py", line 947, in on_click24
18:49:16      self.on_click21()  # generate beso_conf.py
18:49:16    File "/home/pm/Downloads/input_and_results/beso_fc_gui.py", line 776, in on_click21
18:49:16      with open(os.path.join(self.beso_dir, "/beso_conf.py"), "w") as f:
18:49:16  PermissionError: [Errno 13] Permission denied: '/beso_conf.py'

FreeCad is running as my user (pm) and permissions are set as 777 (all allowed) for the test.

I guess it's a path issue, was it tested on linux?

@fandaL
Copy link
Collaborator

fandaL commented Jan 22, 2024

It used to work on Linux as well, but the example is older then the gui. Hopefully, I will look at it during the week.

@fandaL
Copy link
Collaborator

fandaL commented Jan 28, 2024

I tried with FreeCAD 0.21.2 on Ubuntu. beso_fc_gui crashes FreeCAD when there is some problem instead of printing error message. But I passed on a simple example with volume mesh and another example with shells. I modified example 2 for FreeCAD 0.21.2 (newly created material objects, mesh with size 7 mm, and new solver), generated inp file (only one file, not splitting it to several). When using beso_fc_gui with just one design domain, it works.
input_freecad0.21.2.zip

That file is not compatible with Real Thunder's FreeCAD 2024.104.0, did you modify the old one for this version? If you can share it, I can try to run it here.

@j2l
Copy link
Author

j2l commented Jan 29, 2024

Did you try on Linux?
Here's my modified example for you to try beso_fc_gui on Ubuntu:
2024_freecad_model.FCStd.zip

@fandaL
Copy link
Collaborator

fandaL commented Jan 31, 2024

Yes. I have opened your model in FreeCAD 2024.104.0 on Ubuntu 22.04.3, reselected faces for loads, remeshed with 7 mm minimum and maximum element size. Wrote inp file. This file is running in beso_fc_gui without troubles (just rough settings to obtain some result quickly).

@j2l
Copy link
Author

j2l commented Feb 1, 2024

Thank you @fandaL
Hmm, so I don't get what is wrong on my PC.

@rmeissn
Copy link

rmeissn commented Aug 2, 2024

I'm on Fedora 40 with FreeCAD 0.21.2 (Flatpak). I've loaded the file from @j2l , reselected the load faces, created a mesh, ran the solver and exported the inp file.
On running beso, FreeCad crashes without any message.
The beso log file shows:
FEMMeshGmsh.log

Is there something I can do to not crash FreeCad?

EDIT: If I'm correcting the ccx path in the conf file to path_calculix = '/var/lib/flatpak/app/org.freecadweb.FreeCAD/x86_64/stable/e27cc82ee56a94ced0944fd2a7f6d494f2e8b3eb76491bc7a2ff1272248e6572/files/bin/ccx' I can run beso_main.py from the shell, which iterates and finishes. Still, it's not usable from within FreeCAD, where FreeCAD complains about:

12:10:35  CalculiX solver input writing...
12:10:35  Input file:/home/rmeissner/Downloads/beso_test/FEMMeshGmsh.inp
12:10:35  One monster input file.
12:10:35  Writing time CalculiX input file: 0.173 seconds.
12:11:02  Traceback (most recent call last):
12:11:02    File "/home/rmeissner/.var/app/org.freecadweb.FreeCAD/data/FreeCAD/Macro/beso_fc_gui.py", line 940, in on_click23
12:11:02      exec(open(os.path.join(beso_gui.beso_dir, "beso_main.py")).read())
12:11:02    File "<string>", line 159, in <module>
12:11:02    File "/home/rmeissner/.var/app/org.freecadweb.FreeCAD/data/FreeCAD/Macro/beso_lib.py", line 68, in import_inp
12:11:02      line = f.readline()
12:11:02             ^^^^^^^^^^^^
12:11:02    File "<frozen codecs>", line 322, in decode
12:11:02  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position 10: invalid continuation byte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants