Pycalculix – Build FEA Models in Python

hole-in-plate-quarter_Sxdam_S3compr-rotor_Sz

Pycalculix is a tool I wrote which lets users build, solve, and query mechanical engineering models of parts. The tool is a Python3 library, which uses the Calculix program to run and solve finite element analysis models. With it you can see and understand part stresses, strains, displacements, and reaction forces.

Pycalculix Strengths:

It is great for design studies. You could run many versions of your part where you change a fillet, or wall thickness, and record the stress impact. It is also good for calculating stress concentration factors. In the example below, Pycalculix was used to re-create the tension hole in a plate Kt graph, and it was accurate to Peterson’s answer to within 1.5%. Because simplicity is minimized, Pycalculix is a good educational introduction to FEA.

Pycalculix Technical Capabilities:

  • Model Type: structural
  • Element Types: plane stress, plane strain, axisymmetric
  • Element Shapes: triangles, and quadrilaterals
  • Element Order: 1 (corner nodes only) and 2 (corner nodes and midside nodes)
  • Geometry: build part geometry, including straight lines, arcs, and fillets/blends
  • Loads: apply pressures, gravity, rotational speed, water pressure, forces
  • Constraints: apply displacements
  • Contact: define linear contact between multiple parts.
  • Time Steps: multiple steady state time steps supported
  • Meshing: Calculix CGX or GMSH are run in the background to mesh your part, you don’t need t know how to use them
  • Solving: Calculix CCX is used to solve the model in the background
  • Results Viewing/Querying: FRD results file is read in and all results are accessible in python
    • Can query nodal max and min
    • Can select elements connected to points, lines, areas, parts
    • Can plot nodal and element results
  • Cost: Free (GPL license)
  • Pycalculix Release Date: December 23, 2014, written by Justin Black

Example Problems:

Gallery Images:

hole-in-plate-quarter_Sxdam_S3compr-rotor_Szhole-kt-study_ktshole-kt-study_errorpipe_crush_utot

Pycalculix Documentation + Links :

Documentation

Github project

Pypi project

Installation:

Mac

WIndows

Linux

Walk-through, Building and Solving a Model:

In this pdf, we’ll walk through all the normal steps. We’ll build our model geometry, apply loads, mesh the model, solve it, then view and query the results.

hole-in-plate-quarter_A0hole-in-plate-quarter_A0chunkedhole-in-plate-quarter_elemhole-in-plate-quarter_constrhole-in-plate-quarter_presshole-in-plate-quarter_Sx

 

Related Links:

  • Calculix(Free GPL FEA solver that pycalculix uses)
  • Gmsh (Free GPL mesher that pycalculix uses)
  • Anaconda (distribution which includes Python, Numpy, Matplotlib, and many other Python libraries)
  • Python (what pycalculix was written in)
  • Numpy (Python library focused on matrices)
  • Matplotlib (Python graphing library)
  • Agros2D (Free GPL 2D FEA that has a GUI, Python interface, multiphysics, and supports mesh refinement)
  • Sfepy (Python fea, applied but verbose)
  • Fipy (Python fea, very academic)
  • Freecad (great free modeling/cad program, has python interface and integrates Calculix)
  • Salome-Meca (very full featured free FEA program with python interface, some steps in French)
  • Elmer (very full featured FEA program, user friendly for one part 3D model)

25 thoughts on “Pycalculix – Build FEA Models in Python

  1. Hi Justin,

    I’ve found you project pyCalculix. This is a realy good idea to create python api and pre/post processor for calculix. Do you have any plan to extend you project on 3D models?

    • I agree that developing a python interface in 3d would be a good next step. I don’t plan on taking it right now. If I did, I’d probably want to use openscad, pyopengl, gmsh 3d internals, or pythonocc http://www.pythonocc.org
      (pythonocc looks like the best option)

  2. Installed Anaconda and then py calculix. But do not know how to run your example. Can you kindly describe how to run a simple example. Youtube video would be very useful. Put your work details in yahoo calculix forum

  3. Justin,

    I conduct research in structural design optimization (under uncertainty). Your pyCalculix is exactly what I have been looking for the optimization of small problems and for my students to get started easily.

    I have a couple questions for you:
    -Why did you decide to use Python 3 and not Python 2? I wrote my optimization and uncertainty analysis tool using Python 2 and was curious on the advantages of version 3. Do you know if it is possible to “mix” 2 and 3, i.e. optimization tool with 2 and structural-mechanical analysis in 3.
    -What are your plans for the tool? Do you plan on moving to three-dimensional analysis?

    Greetings from Munich
    Erich

  4. Say, given that you all are familiar with calculix…can I ask a question? I am trying to find out if I can do 2D thermal analysis with Calculix and I am having a very hard time finding any information about it.

    thanks

    • Yes, Calculix supports 2D thermal analysis. I haven’t added the functionality in pycalculix yet, but I’ll add it in the next release.
      In the Calculix manual, look up *HEAT TRANSFER, Calculix comes with a number of example files. For me they are at: C:\Program Files\Calculix27\ccx_2.7.1_tests
      In those files look at the examples: beamhtcr.inp, oneel20fi.inp, oneel20rs.inp

  5. Hi Justin
    Good work. We wonder is it possible for you to show us a demo (a short video on youtube) of how to run an example in powershell.
    We find it very easy to install via anaconda but we don’t know hoe execute your examples.

    • Linda, I’ll have some examples up soon. I’m working on getting the Linux version working out of the box, and then I’ll post tutorial videos. To execute the examples you need to run them using python.
      Windows:
      Make sure .py files are associated with python, then
      Double click the example.py file to run it
      Linux:
      cd to the directory with the example file in it, then run
      python3 example.py

  6. Hi. This is very nice.
    I have a question. Well, I want to use CalculiX instead of Abaqus. Abaqus write and read A LOT in disk, and I have to run some code like 20000 times at least. You think in create something to read a inp file and than you have your model without have to code?

    • I don’t understand your question. You could be asking can I use your library without coding? Nope, it’s purely a programming library. But if you have to do analysis 2000 times, automating it with a script is the easiest way to do it. If you look at the pycalculix examples, I think that you’ll find them easy to understand. Good luck.

  7. Hi when I do pip install pycalculix in the command prompt window I get the message ‘No Distributions at all found for pycalculix’. I am using Python 3.4.3. Does pycalculix work only till python Python 3.4.2?

    • Pypi was having indexing issues and was not pointing to their hosted libraries correctly. Pypi download should work right now. Or you can download the github repository and install from there.

  8. Great goods from you, man. I’ve understand your
    stuff previous to and you’re just extremely fantastic.
    I really like what you have acquired here, really like what you are saying and the
    way in which you say it. You make it entertaining and you still take
    care of to keep it wise. I cant wait to read far more from you.
    This is really a terrific web site.

  9. Python 3 highest Version is today 3.5.2.

    Is 3.5.2 icompatible to version 0.9.3 or is python 3.4.5 better ?

    Next Version with Heat transfer solution. I see some thermal things in the code.
    Much work to do last parts, time plan about it?

  10. hi again,

    an update to calculix 2.10 in win (available by beconverged) and gmsh 2.13 (64bit win available) could also improve future possibilities

    great work this pycalculix

    and hope for more

  11. Hi, Justin!

    Please, what libraries did you used to make the 2D images in python?
    I want to make a similar software in python with 3D visualization…
    Can you help me?

  12. Hi Justin,

    Great work on this Python3 library, I’m not familiar with CalculiX and I was up and running within a few hours. I followed your quarter plate with a hole example because I have to do a FEA demo for a group of other graduate students and the professor is very familiar with CalculiX but I’m familiar with another commercially available option – I compared the same model with very similar mesh densities and the results are very close (thanks!).
    Are you planning to add more documentation about the different modules (Mesh, Part, Geometry, etc.)? Most of my struggle was meshing the part and also re-drawing the geometry (from a vertical plate to a horizontal one).
    Great work man! Keep the project moving – this is great work!

  13. Good Morning,
    I am a student at the State University of Ceará – Brazil. I wonder if Pycalculix can be used to solve problems involving heat transfer in batch reactors?

    • Hello Pedro. Pycalculix only supports structural analysis at this time, so no. The solver Calculix does support 2d and 3d heat transfer analysis though.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.