This repository is designed for learning about CalculiX (an open-source Finite Element Analysis solver) and using Python to automate and enhance post-processing. accessible and programmable.
The goal is to build a set of tools to read, analyze, and visualize FEA results directly in Python, allowing for custom workflows beyond standard GUI pre/post-processors.
This project uses uv for dependency and Python version management.
-
Install uv Follow the instructions at docs.astral.sh/uv.
-
Setup Python Install Python 3.12.2 and create the virtual environment using this version:
uv python install 3.12.2 uv venv --python 3.12.2
-
Install Dependencies Install the project dependencies into the virtual environment:
uv sync
To launch a Jupyter Notebook environment with access to the project's dependencies:
uv run --with jupyter jupyter notebookYou can run the provided example scripts directly:
uv run src/example.pyTo run the project's test suite:
uv run pytest .\tests\examples/1_simple_plate_static: A basic static analysis of a shell element plate. Includes the.inpfile for CalculiX and Python scripts to visualize the results (Von Mises stress, etc.).
The Python codebase (src/) provides the following functionality:
-
Model Reading (
model/):- Parse CalculiX Input files (
.inp). - Extract Nodes, Elements (Shell 4-node, Truss 2-node, Tetrahedral 10-node), and Shell Thicknesses.
- Parse Materials (
*MATERIAL,*ELASTIC,*DENSITY) and Solid Sections (*SOLID SECTION). - Utility to find nodes along lines/coordinates.
- Parse CalculiX Input files (
-
Result Reading (
results/):- Parse CalculiX Result files (
.frd). - Extract multiple Steps, Time/Increments, and nodal data (Displacement, Stress, Force, Strain, etc.).
- Truss Force Calculator: Compute axial forces in truss members based on displacements and element properties.
- Utilities to map node results to coordinates for plotting (
get_nodes_results). - Result comparison logic (e.g., ratio of Von Mises stress between two analyses).
- Parse CalculiX Result files (
-
Visualization (
plotting/):matplotlib-based plotting engine.- Plot mesh geometry (Shells as patches, Trusses as lines).
- Visualize field variables (Stress, Displacement) as heatmaps (Shells).
- Deformed Shape Plotting: Visualize truss deformation with scaled displacement.
- Compare results between two models with ratio plotting.
- Configurable plotting (custom ranges, highlighting neutral values, etc.).