The (Technical) Kindness of ANSYS Fluent aaS, a Matlab Example

coding matlab ansys fluentMy friend, a fellow Romanian, just told me a funny story. She just relocated to the U.S. and was asking her dentist “When will I have the root channel treatment?”. The dentist kindly replied “Did you mean root canal, my dear?” 

Human kindness is a beautiful thing. As a software developer, I often wish that computer programs would be equally technically kind. Most of them are not. Many times, when a user mistypes a command, applications crash.

This is pretty common when driving ANSYS Fluent from a remote program like Matlab. The Fluent scripting language is contextual. Consequently, the syntactic rules are changing during the simulation. For instance, substantially different commands are available when the CFD solver is changing the state, for example from meshing mode to simulation mode.

Fortunately, the aaS interface supports technical kindness. Consequently, when a command seems to be incorrect or incomplete, Fluent will switch to a “kind” response. Ultimately, the kindness will be offered as a clarifying exception. The exception should help the Matlab user understand the context. At this point such user could correct or complete the command.

My friend is using Matlab to drive ANSYS Fluent, so I decided to demonstrate the technique in snippet of Matlab code for her. Here it is for you:

Matlab Code Driving ANSYS Fluent

disp('Start Example')
out='Report not received';
   disp('Requesting <report summary>');
   out = tui.doMenuCommandToString('report summary -?')
catch ex
   if strcmp(ex_id , 'MATLAB:Java:GenericException')
      if strcmp(ex_object_class,'class AAS_CORBA.EYesNoQuestion')
   if bIKnowHowToClarify==false;
if bIKnowHowToClarify==true
   disp('Answering <No> to the clarification question...');
   disp('Requesting <report summary no>');
   out = tui.doMenuCommandToString('report summary no -?');

Program output

Start Example
Requesting <report summary>
write to file? [no]
Answering <No> to the clarification question...
Requesting <report summary no>
Version: 2d, dp, pbns, lam (2d, double pre....

Additionally, I would like to note something in the code. Adding  the suffix “-?” to a command indicates that suggestions are welcomed. Similarly, the absence of “-?” will turn off Fluent “kindness”.

Finally, Fluent supports a set of four clarifying exceptions. Of course, they are properly documented in ANSYS manuals. Just search for “aaS” keyword.

For more information about Matlab Fluent cosimulation please check out How to Make Matlab Apps for ANSYS.


4 thoughts on “The (Technical) Kindness of ANSYS Fluent aaS, a Matlab Example

  1. Sorin Munteanu, I want to ask about integration Matlab and Ansys. I have some project ( ) where I use Rozenbrock optimization algorithm written in Matlab, to optimize Ansys model using IronPython. My approach allows to use iterative, adaptive optimization, step by step, make setting of optimization parameters on every next iteration. But now my app looks like kinder: It uses only one algorithm and usability also leaves much to be desired. But I took this topic for my master work and now I faced the big problem when read that Ansys has some integration things from box. It makes my job is useless…

    Could say please, is there Ansys+Matalb integration things allow do the same from box, without effortlessly? It is very important for me to know it.

    P.S. Maybe you can give me some advises about my master work. I think you are more aware man in optimization things.
    Actually my master subject is “Integration of solution in Ansys and Matalb packages”. Maybe is there some things in Ansys are now implemented yet, but which are interesting…

    Thanks a lot for advanced for your help!

  2. Hi Eugene,

    I presume that by Ansys you mean the ANSYS Mechanical APDL solver a.k.a the MAPDL solver. The MAPDL supports the same aaS functionality as Fluent. Then the answer is Yes.

    I would encourage you to visit my blog from 2016, “” and review the small piece of Matlab code that can drive remote ANSYS sessions of Workbench, Mechanical APDL and Fluent.

    It seems to me that the aaS functionality in ANSYS is something for you to consider. aaS goal is to to provide best in class access to ANSYS solvers from third party programs (Matlab included, but most OO programming languages are supported, e.g. Java,Python,C++,…).

    ANSYS aaS implements concepts as
    – frugality( e.g. the amount of Matlab code required to connect is less than 10 lines)
    – polyglotism (clients can be developed in multiple programming/scripting languages)
    – technical kindness (some aspects covered in this blog)
    – remote access (this giving the ability to drive a large simulation running on a compute cluster/ cloud)
    – virus safe (no ANSYS executables or dlls are required to develop a client)

    Therefore if you use ANSYS aaS, your effort to co-simulate will be substantially minimized and you will be to concentrate more on the optimization, machine learning or control algorithms that you might want to develop in Matlab.

    Regarding your thesis I would gladly provide suggestions and guidance.

    Thank you


  3. Sorin has always been “technically” and personally kind to my requests for showing me how to drive ANSYS’s Fluent using aaS from MATLAB. Every single time when I have had issues with this amazing tool that he created – especially in understanding the exceptions – he has kindly explained in details what they meant. Thank you Sorin.

  4. So I am looking into using Matlab with Ansys Icepak software for a project, and I can’t find much information on how to do this. I can open Icepak from my Matlab script, but I haven’t been able to find out what commands I can send to the Icepak file. Do you know what the capabilities of Matlab for running Icepak are, and where could I find documentation to learn how to do this? Any help you could give me on this would be very much appreciated; thank you.

Comments are closed.