ANSYS Fluent Customization and Automation

Rate this item
(40 votes)
08 January
File (s) are available for download. You must login to access the file(s).

Imagine you are working as a CFD Analyst/ Design Engineer in a leading automotive industry performing year round optimization studies on various aerodynamic aspects of car design. Definitely your job profile would be exciting and challenging but at the same time most of your tasks involve repetitive CFD procedures like same simulation strategy for various design changes. For such an CFD engineer automation and customization would be a great savior.

Since ANSYS Fluent is the most widely used CFD tool globally let us focus into various aspects of customization and automation in ANSYS Fluent. There are different ways in which ANSYS Fluent can be automated.

Some of the regularly used approaches are:

  • Automation through journal file
  • Automation through Scheme programming
  • Automation through UDF (user defined functions)

What is a Journal file ?

A journal file is a text file that contains a set of commands, which when read in ANSYS Fluent would process those commands sequentially. There are 2 ways to create a journal file.

1. Recording journal file from GUI(Graphical User Interface): File > Write > Start Journal

While setting up a case file we can record all commands we gave with GUI or TUI, and we can playback recorded file later on to give same setup. Simplest example is if we create 2 mesh for one geometry (one is fine mesh and another coarser) then we can record journal file while setting up the first case and then we can use this recorded journal file for the second case setup.

2. Writing journal file with TUI (Text User Interface) commands:

In ANSYS Fluent, the menus and commands which are available from GUI are also accessible from TUI, we can write a TUI command in console or else we can write all commands to be executed in a text file and save it with extension .jou and read it as a journal file.

File > Read >Journal

Beginners would find it easy to automate ANSYS Fluent by recording journal file from GUI and writing journal file using TUI commands as these are easiest way compared to other possible automation methods.

Scheme programming:

Scheme is a high level language and a dialect of programming language Lisp. Dialect of programming language is variation or extension of language that does not change its intrinsic nature. Scheme supports operations on structured data such as strings, lists, and vectors, as well as operations on more traditional data such as numbers and characters. While Scheme is often identified with symbolic applications, its rich set of data types and flexible control structures make it a truly versatile language.

Scheme programming can be very effectively used for automation of ANSYS Fluent. We can use it for post processing purpose, to automate whole process of simulation and report creation, as well as it can handle file read/write operations. A recorded journal file follows the syntax of scheme, as it is based on scheme programming itself.

UDF (User defined functions):

A UDF is a program written in ‘C’ language which can be used for implementing additional functions into ANSYS Fluent software during its use. It is basically used to enhance standard features of solver. Using UDF we can give boundary conditions varying with time, execute commands on demand, execute commands at the end of iteration or time step, adjust computed values on once per iteration basis and many more. Simplest example of automation using UDF is changing time step size depending on real flow time or some other property.

Various applications of programming in ANSYS Fluent

Let us discuss the extent of automation that can be done using the above mentioned streams of automation. Using automation a CFD engineer can do the case setup, perform the simulation, collect results, generate reports, analyze the data, carry out modifications in design, change setup, and run simulation again.

In short, a complete optimization study can be automated in Fluent, certainly customizing ANSYS Fluent as per the requirement.

Examples of Automations:

Automating process of taking images in transient simulations. For this we have 2 options, one is to take images after required number of time steps and secondly, save data files at required time intervals and after simulation open these data files to take pictures.

It is very useful to automate whole process of simulation and make it parametric for design of experiments (DOE). For this we need to make a parametric code so that we can change parameters as per our need. This will definitely save a lot of time.

ANSYS Fluent GUI menus or TUI menus can be customized using Scheme programming. ANSYS Fluent allows two-way communication between solver variables and users generated script. This can be effectively used for customizing ANSYS Fluent.

Following video will show you an example of ANSYS Fluent customization based on the above point. We have created one menu button named as ‘LearnCAx’ and in the drop down menu there is a sub menu named as ‘LearnCAx Website’ that on clicking opens LearnCAx website. This video also demonstrates an example of adding a button “Reset-Time” with which we can reset time in a transient simulation.


Demonstration on the use of “do loop” in ANSYS Fluent using Scheme programming

Test Case: Post processing of CFD simulation in ANSYS Fluent using Scheme programming (do loop)

Objective:

a) To create 150 iso-surfaces
b) To save 150 images of velocity contours

Scenario:

In this test case we will be using Scheme programming for post processing of CFD simulation. We have done a simulation of flow around buildings, and we need to create an animation of velocity distribution as we climb higher right from the ground. In order to achieve this, we will be taking something around 150 images of velocity contours at different heights and then merging them into a video file. So for this we require 150 iso-surfaces to be created and then to plot velocity contours on them for taking pictures.

Regular way vs smarter way:

Suppose, we do all these manually then it is a very tedious job to do and it’s very time consuming also. This would involve creation of iso-surface using iso-surface dialog box repeatedly. Similarly for displaying contours and saving pictures repetitive use of respective dialog boxes will be required.
But if we write a Scheme file using do loop to create surfaces, display contours and take pictures then it becomes a work of just few minutes.

Following line shows a code written in Scheme for creating 150 planes. For this we have used do loop which is actually similar to for loop of other programming languages.

(Do ((x 1 (+ x 1))) ((> x 150))
(Ti-menu-load-string (format #f "surface/iso-surface z-coordinate z-plane-~a () () ~a" x x))
)

Following Do loop is for displaying contours which are created in last do loop, and take pictures.

Do ((x 1 (+ x 1))) ((> x 150))
(Ti-menu-load-string (format #f "display/set/contours surface z-plane-~a ()" x))
(Ti-menu-load-string (format #f "display/contour/velocity-magnitude 0 5.0"))
(Ti-menu-load-string (format #f "display/save-picture/cont-plane-%4n.jpg"))
)

Following video explains the above written script.

 

Keep visiting this series as more will be coming soon !!!


Blog Co-Author:

Subhransu Majhi

Member of Technical Staff, 
LearnCAx
Inspire | Educate | Mentor

      

Website: LearnCAx.com | Email: This email address is being protected from spambots. You need JavaScript enabled to view it.


1) Scheme Programming by Mirko Javurek (German Document) : http://willem.engen.nl/uni/fluent/documents/external/scheme-programmierung.pdf
2) Translation of above German Document made by Tiago Macarios : http://hpc.hud.ac.uk/w/images/2/2b/Fluent_Scheme_Programming_Reference.pdf
3) ANSYS Fluent User Manual


 

The Author

subhransu-majhi

Subhransu is man of all treads. He has worked on almost all aspects of CFD. Started with CCTech's education brand LearnCAx, he is now moved into cloud based CFD simulation product. Subhranshu has unique combination of skill sets including strong knowledge of physcis, numerical methods and an excellent programming skill sets.

Subhranshu has extensively worked on CFD software customization and automation. He has worked on data center cooling software development. He has great passion for automation and customization and has written many blogs covering complex topic like UDF and CFD software automation.


 

The Author

Sanket-Dange

Sanket is working as a CFD engineer in CCTech. He has worked on numerous CFD projects in the filed of automobile and HVAC. He has worked as a tutor at LearnCAx and taught to students through LeanrCAx online as well as offline course modules.

Currently he is working in the field of CFD software development which is mainly based on ANSYS FLUENT. Sanket has written blogs on various topics in CFD. He also has interest in open source CFD technologies.

Sanket holds a Bachelors degree in Mechanical engineering from University of Pune.


Share thisShare on FacebookShare on Google PlusShare on TwitterShare on LinkedIn
Read 9550 times
ANSYS Fluent Customization and Automation - 4.9 out of 5 based on 40 votes

Latest from Sanket Dange

Add comment




Security code
Refresh

Comments  

 
+6 Akshay Bansal 2014-04-25 02:00
Thanks for these pointers! This certainly adds to the efficiency!
Quote
 
 
+2 CFDuser 2014-08-22 14:44
I really appreciate you for precious tips and sharing your experiences with others.
Quote
 
 
+1 K Cho 2014-09-24 20:54
This blog is very useful to students or researchers to use computational fluid dynamics(CFD).
Quote
 
 
0 Kushal 2015-05-11 13:08
Link for the translation of german language scheme program link is not working can you provide with working link.
Quote
 
 
0 Sanket Dange 2015-05-12 16:04
Hi Kushal,

Thank you for bringing this in to our notice (about the dead link).
We have updated the link in our blog.

This is the link which is working: http://hpc.hud.ac.uk/w/images/2/2b/Fluent_Scheme_Programming_Reference.pdf
Quote
 
 
0 sean 2016-01-12 10:18
Is it possible to iterate over a list of variables as opposed to using a counter?
Quote
 

Browse Knowledge Base

Recommended By

Get Instant Updates

Subscribe to get instant updates about CFD courses, projects, blogs, webinars, software tutorials & CFD jobs

Search Knowledge Base

By Keyword

By Author

By Tag