Building Automation Tools for Mechanical/Structural Analysis and Pre-Processing with HyperMesh/SolidWorks/CATIA
TCL or Tool Command Language is very popular among mechanical engineers and CAE/CAM experts. Today, all the industries rely on Finite Element Analysis (FEA) results to validate their product's structural integrity. Based on the FEA results, the product design is finalized and drawings are prepared for production.
Problems faced in Finite Element Analysis
The problem with FEA is the time spent behind pre-processing of model. To perform FEA on any object, a large number of load-combinations and load-steps have to be defined in HyperMesh. This is a very time consuming process for any analyst. When such analysis is done in an industrial level, it involves a large number of elements in a single body. Also for performing correlation testing between FEM analysis and experimental results, engineers have to spend a considerable amount of time to organize and validate data. Generating load-combinations and load-steps manually caused many errors and was very time consuming as the number of combinations and cases are very large.
During my internship at Bombardier Transporatation, I had developed a tool with Python to solve this problem by automating the data cleansing and data feed process by taking input from MS Excel sheets, preparing which is less time consuming.
Python is our savior!
This task can be automated by using TCL (Tool Control Language) script, which is the only script that is recognized by the Altair HyperWorks. This script also works on a variety of simulation softwares like Dassault Systems SolidWorks and CATIA. The Python code takes the inputs from a CSV file containing the load case combinations in a pre-set format and generates a TCL script. The TCL script when executed in HyperWorks, generates the required load cases automatically.
It might appear a little easy to build such an tool, but the problem had its own challenges...
Upgrading an existing prototype
Migrating from CSV to Excel Workbook
Interpreting TCL scripts (I was new to FEA then!)
Being choosy - PyQt or wx? / OpenPyXl or xlrd?
During this talk, I'll walk you through my experience in building this automation tool.
Rinsing our data and preparing it for export to TCL script
Getting started with PyQt
Building rich-UI to deliver the best experience for my fellow mechanical engineers (Yeah I made their lives easier!)
Error reporting (because IT people can't assist all the time!)
Optimizing performance for large datasets (because power is priceless...)
Sticking to the Zen of Python
Python for a reason...
Rich collection of libraries
Painless UI design
Easier to code (and for someone else to read as well)
and the obvious reason...
- Cross Platform. 100% Guaranteed!
The company uses different operating systems. Data was fed into Excel using a linux system, pre-simulations were carried on a Mac and analysis was done on a Windows machine with HyperMesh. In order to enable the same experience across all platforms, I had to resort to Python!
Overview of the tool's logic
Prepare the unit load/pressure collectors in HyperMesh
Prepare the Excel Sheet with scaling factors for each load-case combination
Data Interpretation with Python and generate TCL script
Inject script into HyperMesh for the load combinations to be generated automatically
I would like to thank the developers of xlrd, pyinstaller, PyQt, openpyxl for their valuable libraries!
A big hug to Bo Milanovich - Pluralsight course instructor (Twitter: @PythonBo) for his Python lessons.
Basics of TCL scripting (not mandatory, I myself learnt it only after building the tool!)
Short video clip on my proposal:
Find my work on:
Rahul Pon is a Software Engineering Intern at Bombardier Transportation, Hyderabad. He is a pre-final year engineering student at Loyola-ICAM College of Engineering and Technology. Rahul has been programming in Python since the age of 16 and has volunteered in organizing workshops, classes and lectures for students. He is also a freelancer and develops websites and applications with Web2PY and PyQt respectively.