Python framework for CalculiX

Hello everyone,

as I have written in the thread Boolean-like parameters in ccx input keywords, I’m currently working on a python framework, called Pygccx, for building and solving 3D solid CalculiX models.
Now my project has reached a certain level and I would like to make it open source under GPL V3.

Here is my GitHub repo:
https://github.com/FrozenWinterheart/pygccx_project.git
Up to now, I have tested the project only under windows 10.

I would appreciate if someone wants to take a look or give it a try. Maybe someone would like to contribute? There is still a lot to do:
Implementing new keywords, writing tests, writing more and/or better documentation, refactoring, improving usability and a lot of discussion.

To get a first impression, look at the files in the examples folder.
In the folder doc/pygccx you can find an auto generated html documentation of all classes.

If there are any questions, I will do my best to help.

Looking forward for feedback.
Greetings, Matthias

8 Likes

Dear Matthias,

Thank you for developing tools for CalucliX! Please, would you join CalculiX organization on GitHub? I’ve send the invitation.

Ihor

1 Like

Hello Ihor,
Many thanks for the invitation. I have joined in.

Dear Matthias,

Thank you for joining! Would you like to host your project in the Calculix Github group? URL github.com/calculix/pygccx could be yours.

Hello Ihor,
that would be great! Can you create the repository? At the moment I’m still working on a parser for frd and dat files. When that’s done, maybe in one or two weeks, I’m happy to move the project to the new repo.

Hi Mattias,

Yes, I can create the repo, but it is not needed. Much simpler is to transfer your repo directly to the organization.

By the way, while you’re working on FRD and DAT parsers for CalculiX, please have a look on those projects:
ccx2paraview - module reader.py is a FRD parser,
CCXStressReader - is a DAT parser for Calculix.

1 Like

Hi Ihor,
i have transfered my project to Calculix organisation. Thank you!
It seems i have limited access now. Can you please rename the repo from “pygccx_project” in “pygccx”.
Many thanks!

2 Likes

Thank you, Matthias! You’re admin and have full control over the repo. Sorry for some delay. Please, check permissions again.

Thank you Ihor! Now the permissions are set correctly.

Looks very interesting! I like the idea of making simple 3D meshes with just a few inputs. I seem to be getting the following error when running the beam.py example though:

[hussaif1@delltower48 beam]$ python3.10 beam.py
Traceback (most recent call last):
  File "/home/hussaif1/pygccx/examples/beam/beam.py", line 34, in <module>
    from pygccx import model as ccx_model
  File "/home/hussaif1/.local/lib/python3.10/site-packages/pygccx/model.py", line 31, in <module>
    from . import mesh as msh
  File "/home/hussaif1/.local/lib/python3.10/site-packages/pygccx/mesh/__init__.py", line 24, in <module>
    from . import mesh_factory
ImportError: cannot import name 'mesh_factory' from partially initialized module 'pygccx.mesh' (most likely due to a circular import) (/home/hussaif1/.local/lib/python3.10/site-packages/pygccx/mesh/__init__.py)
[hussaif1@delltower48 beam]$ 

Hi!
Thank you for your feedback! I was able to reproduce and fix your error.
The problem was, you downloaded the latest development version from the master branch and not from the releases.

The master branch is the latest, but may contain some issues.
The releases are more stable and tested.

or

Please download the latest version from there, install it via pip and try again.
Maybe you have to uninstall your current version of pygccx first.

1 Like

Thanks. I removed the pygccx/ folder then did another,

git clone https://github.com/calculix/pygccx.git

and it now works! I also was able to add a model.show_gmsh_gui() to the beam.py example and it brought up the gui. I just now need to figure out how to export images of the geometry with the surface numbers on them. Perhaps I will ask on the gmsh forum if you are not sure off-hand.

A good starting point for the Gmsh Python API is here:

To export a figure:
model.get_gmsh().write('my_image.png')
if you want to export an image w/o opening the gui, call first
model.get_gmsh().fltk.initialize()

You can also set the camera view angles per code

1 Like

Hi. I installed the release version 0.1.0, but it still shows some errors. (Just a preface: I’m new to CalculiX, so I figured the build you made with python would be an easy jump for me to understand the code).

I ran the beam.py example, which seems to have a type error.

Could there be some issue with the coupling.py file?

Hi!
I have tried to reproduce your error but with no luck.
I have set up a new virtual env (Python 3.10.5), downloaded the release 0.1.0 and installed it with pip. Then i ran beam.py and it worked.
The error says, object ElementSurface has no attribute ‘type’, but when i hook in the debugger at line 84 in beam.py, the attribute is there (variable load_surf).

Can you please give me some information which OS you are using and which python version?

I am using Python 3.10.0. Ran beam.py.
OS: Windows 10 version 20H2.

I did see the attribute present there, which is why I got confused if there is a compiler mismatch or if I am using a wrong version of python.

I shall try the virtual env with python 3.10.5 as well.

EDIT: Tried python 3.10.5 with virtual env. Didn’t work there as well.

Thanks, I was able to export figures! However, when I run the beam.py example the model does not seem to converge. See:

 *ERROR: too many cutbacks
 best solution and residuals are in the frd file

::::::::::::::
beam.sta
::::::::::::::
SUMMARY OF JOB INFORMATION
  STEP      INC     ATT  ITRS     TOT TIME     STEP TIME      INC TIME
     1          1     1U    4  0.000000E+00  0.000000E+00  0.100000E+01
     1          1     2U    4  0.000000E+00  0.000000E+00  0.250000E+00
     1          1     3U    4  0.000000E+00  0.000000E+00  0.625000E-01
     1          1     4U    4  0.000000E+00  0.000000E+00  0.156250E-01
     1          1     5U    4  0.000000E+00  0.000000E+00  0.390625E-02
     1          1     6U    4  0.000000E+00  0.000000E+00  0.976562E-03

You can see my beam.inp file here. And here is my beam.py with very minor modifications.

Hi,
i have ran your inp file directly as well as your beam.py. Both with calculix_2.19_4win\ccx_static.exe and it converges fine.
Which ccx version did you use? Maybe its an issue with ccx?

::::::::::::::
beam.sta
::::::::::::::
SUMMARY OF JOB INFORMATION
STEP INC ATT ITRS TOT TIME STEP TIME INC TIME
1 1 1 5 0.100000E+01 0.100000E+01 0.100000E+01

::::::::::::::
beam.cvg
::::::::::::::
SUMMARY OF C0NVERGENCE INFORMATION
STEP INC ATT ITER CONT. RESID. CORR. RESID. CORR.
EL. FORCE DISP FLUX TEMP.
(#) (%) (%) (%) (%)
1 1 1 1 0 0.8655E+03 0.1000E+03 0.0000E+00 0.0000E+00
1 1 1 2 0 0.9683E+03 0.1715E+02 0.0000E+00 0.0000E+00
1 1 1 3 0 0.1378E+03 0.2910E+01 0.0000E+00 0.0000E+00
1 1 1 4 0 0.4458E+01 0.1139E+01 0.0000E+00 0.0000E+00
1 1 1 5 0 0.4961E+00 0.4462E+00 0.0000E+00 0.0000E+00

2 Likes

Thanks for confirming. Yes , I have it working now. I was using 2.18 and thought I got the same error with 2.19 but was mixing up the versions…