How To Make MATLAB Apps For Fluent

I have a friend, who is also an ANSYS Fluent user, who asked me a simple question: “Why, in an era when everything is running on the ‘cloud’, can’t I have Fluent running on the cloud and just check on it whenever I want from my own MATLAB® program?”

Actually, you can. It’s as simple as cooking. I promise. In fact, it’s a simple recipe you can cook up with less than 20 lines of MATLAB code. This will be a simple example showing how to request a summarized report and a picture of residuals from a remote running Fluent session. You can use it to create reduced order models or sophisticated controllers in MATLAB for components designed in ANSYS Fluent. Let’s begin:


  1. One piece of Fluent
  2. One piece of MATLAB


  1. One computer to run MATLAB
  2. One computer to run the Fluent (can be the same as the MATLAB machine)
  3. One network (only if you are using two computers. Internet will do)


  1. Start Fluent and load a case and have it iterate ten million iterations.
    1. Make sure that the command line includes –aas
      fluent 3ddp –aas
      > rc fluent.cas
      > solve it 1000000
  2. Grab the aas_FluentId.txt file from Fluent folder and transfer it to the MATLAB machine
    1. Use the transfer procedure of your choice: e-mail, ftp, friendly ANSYS RSM.
    2. This the “key” MATLAB needs to interact with Fluent.
  3. Now let’s do MATLAB coding and write the app. What should it do? Well, you can start by displaying the residuals. For expedience you can download the code from the link below the code to your MATLAB command window:

fluent = actxserver(‘ANSYS.CoFluentUnit.1’);
fluent.ConnectToServer (fluentkey)
tui.DoMenuCommand(‘display set hard-copy driver png’);
tui.DoMenuCommand(‘plot residuals’);
tui.DoMenuCommand(‘display hard-copy Residuals.png’);
tui.DownloadFileToFile(‘Residuals.png’, ‘Residuals.png’);
tui.DoMenuCommandToString(‘report summary’)

Due to the limitations of WordPress, please grab the Example Code Here.

Matlab-ANSYSWell, that wasn’t so bad was it? I made it in less than 20 lines of MATLAB code. In fact, I did it in 15!

By the way, if you didn’t notice, Fluent in this example has two users: One is the Fluent user that loaded the case and runs the 10 million iterations. It does not have to be a human; it can be just a journal file. The second one is the MATLAB program.

Fluent can have more than two users, just be nice and share the Fluent key with them. They do not have to be MATLAB apps, they can be Python apps, C++ apps, Java programs. They can change rpvars, parameters, load UDFs while Fluent is running, execute Scheme and TUI commands, upload or download files. There a few things that you cannot do yet, but we are working towards that.

MATLAB is registered trademark of The MathWorks, Inc.

This entry was posted in Tips & Tricks and tagged , by Sorin Munteanu. Bookmark the permalink.
Sorin Munteanu

About Sorin Munteanu

Sorin is a Lead Software Developer at ANSYS. His development role is to implement Special Methods for ANSYS mostly related to remote cosimulation including cloud, multiple user concurrent access and ROM technology. Sorin has a Ph.D. in Aerospace Engineering from the Arizona State University and a Master's of Science from Polytechnica University in Bucharest, Romania.

5 thoughts on “How To Make MATLAB Apps For Fluent

  1. Sorin,
    This is a great recipe for monitoring a long simulation. I hope it will not be too long before most ANSYS products can be monitored and controlled from a mobile device app.

  2. Well, as a matter of fact, monitoring a Fluent session from a mobile device should be possible as of today.

    You should also be able to monitor an MAPDL or a Workbench session, but that will require a larger amount of coding.

    Regarding mobile apps, I did not attempt to write a mobile app for Fluent, but I am planning to prototype one and post a follow-up article on the blog.

    Please contact ANSYS Tech support if you need help building such a mobile app, or you would like to know how to monitor MAPDL or Workbench.

    Thank you


  3. Hi Jay

    The feature is currently available for Fluent. It think it is possible to offer it for CFX after a reasonably small development.

    If the equivalent CFX feature is something that you or your company would like to have, I would suggest to contact ANSYS Sales or Support with your request. Please make a reference to this blog such that you request will be routed properly.

    Thank you


Comments are closed.