When I was first learning programming languages at university, I found them very tedious. It seemed pointless performing a task in a language I didn’t really understand, to make something appear on the screen which would have been much quicker with a pen, paper and calculator. Programming was very frustrating; the wrong number of spaces, incorrect use of seemingly randomly distributed punctuation, cryptic and infuriating error messages, which would often helpfully tell you the error was located on a line 3 lines away from the actual error. I quickly decided programming was not for me.

In my first job I had to manipulate data between formats to translate between programmes or to post process results. The tasks were very manual and repetitive and prone to error if I got broken off in the middle of a task or lapsed in concentration. I saw the appeal to making computers perform these tasks as they could do them much faster and with fewer errors, saving me time and effort. With the help and support of colleagues, I started to write simple Python scripts to automate these processes, making them faster and with inbuilt error checking more accurate. As a result Python has become a very valuable tool for me, which can be very powerful in engineering and tasks.

Python scripts can be a very useful way to automate repetitive tasks for lots of engineering applications, particularly within FE and Abaqus has the added advantage of a built in Python API making it very easy to access and use Abaqus functions from a Python script. However, not every engineer is comfortable using and modifying scripts, or working from the command line without graphical interaction. In this aspect Abaqus excels as it offers a Python interface (API) to the CAE graphical user interface (GUI) which makes it possible to develop an entirely customisable CAE environment, adding or removing buttons and modules etc.  This functionality means it is also very easy to create dialogue boxes with buttons and drop down lists etc. These can be used to control any Python script and can open up the power and potential of any Python script developed, for engineers that are happier with the point and click environment of CAE than the command line interface.

I have created several of these CAE based plug-ins for use at Pelamis and shared the most useful of these on the SSA site for anyone who wants to use them, or modify and extend them for their own use. There is a fatigue tool which uses DNV SN curves to post process stress time history models and plot contours of fatigue life. A tool for applying bolt preload to multiple instances of the bolt in assemblies quicker and easier than manually applying the preloads individually, and a tool to turn off adjusting the slave surface node positions in all tie constraint instances in a model, to prevent mesh quality issues resulting from the movement of slave nodes.

Python in Abaqus is very easy to get started with, Simulia provide Introducation to Python within Abaqus and a wealth of information tutorials on the internet. Python being an open source language is free and people regularly make available for download, libraries of Python tools for specific tasks such as graph plotting, report generation, data manipulation and complex algebra, which can be used to perform a lot of tasks with only a couple of lines of script, without having to write the tools functionality for yourself. Abaqus itself provides a plug-in called RSG which helps with the building of GUI’s and linking them to simple scripts. The jnl file created with every CAE file records a list of all the actions performed in CAE in Python, which can be invaluable in finding out which Python command you need and a great place to start.

I’m glad to have proven myself wrong about the usefulness and frustrations of programming. Getting a script working to automate what was a tedious task can be very satisfying so I would recommend everyone gives Python scripting a go.

Previous
Tyre Simulation for Snow Traction
Next
Why have we Certified our way of working against ISO 9001 and 14001?
About TECHNIA

We’re forward-thinking problem-solvers, and we love working with ambitious clients. For us, it’s about making sure companies overcome barriers on their way to breakthroughs.

It’s about bringing smarter products to market faster.

Want to receive more content like this?
  • Related news and articles straight to your inbox
  • Hints, tips & how-tos
  • Thought leadership articles
Hints & tips

Learn how to work better together with world-leading PLM knowledge that keeps your engineering design, simulation, and manufacturing ahead of the curve.