Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

domhnallmorr/pycfem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyCFEM - CalculiX + Python Post-Processing

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.

Installation & Setup

This project uses uv for dependency and Python version management.

  1. Install uv Follow the instructions at docs.astral.sh/uv.

  2. 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
  3. Install Dependencies Install the project dependencies into the virtual environment:

    uv sync

Usage

Running Jupyter Notebooks

To launch a Jupyter Notebook environment with access to the project's dependencies:

uv run --with jupyter jupyter notebook

Running Examples

You can run the provided example scripts directly:

uv run src/example.py

Running Tests

To run the project's test suite:

uv run pytest .\tests\

Examples

  • examples/1_simple_plate_static: A basic static analysis of a shell element plate. Includes the .inp file for CalculiX and Python scripts to visualize the results (Von Mises stress, etc.).

Capabilities

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.
  • 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).
  • 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.).

About

Calculix

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages