CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

looking for a smart interface matlab fluent

Register Blogs Community New Posts Updated Threads Search

Like Tree17Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 26, 2007, 06:46
Default looking for a smart interface matlab fluent
  #1
chary
Guest
 
Posts: n/a
Hey,

I just started to use fluent. To encounter a diffusion/permeation problem an udf has been written. Now I would like to know wether it is possible to use an interface with which data can be exported to be used in matlab. once these are optimised they should be able to be reimported in fluent for the next simulation. Is there any possiblity of a matlab fluent interchanging interface?

chaitanyaarige and Richard Hu like this.
  Reply With Quote

Old   May 10, 2013, 09:34
Default
  #2
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi chary,

I see that your question stayed unanswered for years...

Just in case you are still interested you can use Fluent aaS (as a Server). It is available on Fluent versions starting Release 14.

See my blog on http://www.ansys-blog.com/tag/matlab/ for more information and a sample of Matlab coding.


Sorin
Sorin is offline   Reply With Quote

Old   October 4, 2013, 22:08
Default
  #3
New Member
 
Wang
Join Date: Nov 2011
Posts: 9
Rep Power: 14
M201170944 is on a distinguished road
Quote:
Originally Posted by Sorin View Post
Hi chary,

I see that your question stayed unanswered for years...

Just in case you are still interested you can use Fluent aaS (as a Server). It is available on Fluent versions starting Release 14.

See my blog on http://www.ansys-blog.com/tag/matlab/ for more information and a sample of Matlab coding.


Sorin
Hi Sorin,
I am interested in the data exchange between fluent and matlab. I have got the pressure data from fluent and write a code to calculate it in matlab. Now my problem is how to import the data in matlab to fluent??
Thank you so much
M201170944 is offline   Reply With Quote

Old   October 9, 2013, 12:28
Default
  #4
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi Wang

I will need more information to help but I will just make some assumptions, for simplicity of the blog post:

Assumption 1: Matlab is running on a Windows 64 bits machine
Assumption 2: Fluent is running on the same machine or on a network accessible remote machine
Assumption 3: Fluent version is R14.5
Assumption 4: You have a resonable understanding of Fluent UDFs, rpvars or parameters
Assumption 5: you have administrative rights on the Matlab machine
Assumption 6: Fluent client (no license required) is installed on the Matlab machine

Let me know if your specific case is different.

Step1: Modify your Fluent case such that all entities that you want in Matlab are mapped to Fluent rpvars or Fluent parameters
- rpvars are requiring a little bit more advanced Fluent skills, but they have the benefit that they can be used on both a UDF running on the Fluent machine and Matlab running on the Matlab machine
- parameters are easier to use and more stable. They are accesible in Fluent GUI and Matlab but not in the UDF (unless you map one to an rpvar)
Step2: start Fluent on Fluent machine in server mode. Do not start a journal (-i option) because you will do the journaling from Matlab. To start fluent in server mode you will have to add in the command line the -aas option.
For example instead of running "fluent 3ddp" you will execute "fluent 3ddp -aas".
Step3: collect the Fluent session key from the Fluent machine and transfer it to the Matlab machine. the Fluent session key is stored in a file called aaS_FluentId.txt
Step4: make sure that the Fluent client is registered on the Matlab machine
You will have to run a command like the following:
regsvr32 "C:/Program Files/ANSYS Inc/v145/fluent/fluent14.5.0/addons/corba/win64/COMCoFluentUnit.dll"

Step5:Start Matlab
Step6:Connect Matlab to Fluent. You will have to run a Matlab script like the following:
fluent = actxserver(‘ANSYS.CoFluentUnit.1′);
tui=fluent.getSchemeControllerInstance();
fid=fopen(‘aaS_FluentId.txt’,'r’)
fluentkey=fscanf(fid,’%s’)
fclose(fid)
fluent.ConnectToServer (fluentkey)

Step7: Execute you Matlab-Fluent program.

You have two Matlab objects (fluent and tui) that you can use drive Fluent.

If you want to do Fluent journaling from matlab, you can use
tui.DoMenuCommand(tuiCommand)
this will have Fluent execute the tuiCommand with no return
tui.DoMenuCommandToString(tuiCommand)
this will have Fluent execute the tuiCommand and return the output
tuiCommand is pretty much any valid command that you put in a Fluent journal file
Example:
tui.DoMenuCommand('solve iterate 10')
report=tui.DoMenuCommandToString('report summary no')

If you want to set or get the value of a rpvar, you can use
tui.GetRpVar(rpvarName)
this will have Fluent returning the value of the rpvar
tui.SetRpVar(rpvarName,stringifiedRpVarValue)
this will have Fluent set the value of a rpvar
Example
valuePressureRelax=tui.GetRpVar('pressure/relax')
tui.GetRpVar('pressure/relax','0.5')

If you want to set or get the value of a parameter, you can use
fluent.GetOutputParameterValueByname(parameterName )
this will have Fluent returning the value of the parameter
tui.SetInputParameterValueByName(parameterName,par ameterValue)
this will have Fluent set the value of a parameter
Example
valueAvgTemperature=fluent.GetOutputParameterValue ByName('avgtemperature')
fluent.SetInputParameterValueByName('massflowrate' ,0.5)

Of course you will need to have an output parameter called 'avgtemperature' and an input parameter called 'massflowrate' previously configured in the Fluent case.

Please let me know if this post was helpful to you. If you give me your e-mail, I will contact you.

I tried my best to have the code examples syntactically correct, but there might be some typos. You can refer to Fluent documentation or you can mention the issue to me and I will figure it out.

Thank you

Sorin
Sorin is offline   Reply With Quote

Old   November 12, 2013, 08:56
Default How about Linux?
  #5
New Member
 
RA
Join Date: Sep 2013
Posts: 1
Rep Power: 0
ras1981 is on a distinguished road
Hi Sorin!
does this work on a Linux-mashine as well?
Thank You
ras1981 is offline   Reply With Quote

Old   November 13, 2013, 10:07
Default
  #6
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Yes,

Yes, this works on Linux as well. The Matlab code and the set-up are slightly different though and problem specific.

I will contact you in private since this might require specific information about your environment.

Then I will try to provide a generic example of Matlab to Fluent cosimulation on a Linux environment on this blog.

Thank you

Sorin

Quote:
Originally Posted by ras1981 View Post
Hi Sorin!
does this work on a Linux-mashine as well?
Thank You
momahadi30 likes this.
Sorin is offline   Reply With Quote

Old   January 28, 2014, 09:44
Default Progress in using Fluent as a Server on Linux?
  #7
New Member
 
Dominik Herrmann
Join Date: Jan 2014
Posts: 1
Rep Power: 0
Dominik is on a distinguished road
Hi Sorin
Did you make any progress using aas with Linux?

As obvious I couldn't find a dll in the Linux installation folder :-)).

So I think I have to compile the idl file myself, but I do not know which compiler should be used to drive Fluent-aas from Matlab.

In my System:

Matlab is running on a Linux 64 bit machine.
Fluent is running on a 64 bit network accessible remote machine.
Fluent Version is 15.0

Thanks for youre help in advance.

Dominik
Dominik is offline   Reply With Quote

Old   February 7, 2014, 02:08
Default Help
  #8
New Member
 
Iman Haji Gholami
Join Date: Feb 2014
Posts: 2
Rep Power: 0
iman h is on a distinguished road
Hi sorin.

I have done all instruction but when Matlab wants to run tui.DoMenuCommand I have an error.

Error using
Interface.COMCoFluentUnit_1.1_Type_Library.ICoFlue ntSchemeController/DoMenuCommand
Invoke Error, Dispatch Exception: Unspecified error



Error in second (line 9)
tui.DoMenuCommand('aaS.pause');



I don't know what should I do?
iman h is offline   Reply With Quote

Old   July 2, 2014, 07:14
Default
  #9
Senior Member
 
Join Date: Jan 2012
Posts: 197
Rep Power: 14
itsme_kit is on a distinguished road
Hi Sorin

Do you have any idea in writing a subroutine in connecting TRNSYS and Fluent for data exchange

Thanks in advance


Quote:
Originally Posted by Sorin View Post
Hi chary,

I see that your question stayed unanswered for years...

Just in case you are still interested you can use Fluent aaS (as a Server). It is available on Fluent versions starting Release 14.

See my blog on http://www.ansys-blog.com/tag/matlab/ for more information and a sample of Matlab coding.


Sorin
itsme_kit is offline   Reply With Quote

Old   March 23, 2016, 04:23
Default
  #10
New Member
 
Zeng Liyue
Join Date: Sep 2014
Posts: 21
Rep Power: 11
soriyoshi is on a distinguished road
Quote:
Originally Posted by itsme_kit View Post
Hi Sorin

Do you have any idea in writing a subroutine in connecting TRNSYS and Fluent for data exchange

Thanks in advance
Hi itsme_kit
I saw you posted this long time ago. If you solved this problem, could you please share some useful materials about how to connect TRNSYS and fluent? Or could you provide the procedures for realizing this coupling? Thanks in advance.
soriyoshi is offline   Reply With Quote

Old   April 8, 2016, 02:57
Default
  #11
New Member
 
Join Date: Jun 2015
Posts: 3
Rep Power: 10
NikoP is on a distinguished road
Hello Sorin and other CFD people,

Thank you for the nice guidelines provided for the Fluent-Matlab coupling.

Is it possible to change the material properties of a combustible particle remotely from Matlab? For example a devolatilization model called the Two-Competing-Rates, which I'd like to adjust with matlab, has multiple input values that have to be given by the user.

The figure below the shows the panel in Fluent. The values have to be directly provided by the user in the GUI so is there any way to remotely change these in Matlab?
Attached Images
File Type: jpg reactparameters.jpg (114.4 KB, 78 views)
NikoP is offline   Reply With Quote

Old   April 19, 2016, 00:40
Default
  #12
New Member
 
Join Date: Sep 2013
Posts: 1
Rep Power: 0
ravi_12186 is on a distinguished road
Hi
my email id is ravi_12186@yahoo.co.in..I need a help regarding linking between fluent and matlab. It'll be very helpful if u can do that.
Thanks is advance
ravi_12186 is offline   Reply With Quote

Old   December 2, 2016, 03:22
Cool
  #13
New Member
 
DU Shen
Join Date: Nov 2016
Posts: 14
Rep Power: 9
tiancaidushen is on a distinguished road
Thank you so much Sorin,

Because of your illustration here, I made a progress in my program.
Here, I just want to ask a question about execute-on-demand.

I have a interpreted UDF(DEFINE_ON_DEMAND), the name is readData. When I try to execute it from MATLAB code, it gives me an error:
Error: eval: unbound variable
Error Object: read_porosity

The code I wrote is :
tui.DoMenuCommand('define user-defined execute-on-demand "readData" ')

Can you help me to solve this problem.
Thank you in advance.

SHEN




Quote:
Originally Posted by Sorin View Post
Hi Wang

I will need more information to help but I will just make some assumptions, for simplicity of the blog post:

Assumption 1: Matlab is running on a Windows 64 bits machine
Assumption 2: Fluent is running on the same machine or on a network accessible remote machine
Assumption 3: Fluent version is R14.5
Assumption 4: You have a resonable understanding of Fluent UDFs, rpvars or parameters
Assumption 5: you have administrative rights on the Matlab machine
Assumption 6: Fluent client (no license required) is installed on the Matlab machine

Let me know if your specific case is different.

Step1: Modify your Fluent case such that all entities that you want in Matlab are mapped to Fluent rpvars or Fluent parameters
- rpvars are requiring a little bit more advanced Fluent skills, but they have the benefit that they can be used on both a UDF running on the Fluent machine and Matlab running on the Matlab machine
- parameters are easier to use and more stable. They are accesible in Fluent GUI and Matlab but not in the UDF (unless you map one to an rpvar)
Step2: start Fluent on Fluent machine in server mode. Do not start a journal (-i option) because you will do the journaling from Matlab. To start fluent in server mode you will have to add in the command line the -aas option.
For example instead of running "fluent 3ddp" you will execute "fluent 3ddp -aas".
Step3: collect the Fluent session key from the Fluent machine and transfer it to the Matlab machine. the Fluent session key is stored in a file called aaS_FluentId.txt
Step4: make sure that the Fluent client is registered on the Matlab machine
You will have to run a command like the following:
regsvr32 "C:/Program Files/ANSYS Inc/v145/fluent/fluent14.5.0/addons/corba/win64/COMCoFluentUnit.dll"

Step5:Start Matlab
Step6:Connect Matlab to Fluent. You will have to run a Matlab script like the following:
fluent = actxserver(‘ANSYS.CoFluentUnit.1′);
tui=fluent.getSchemeControllerInstance();
fid=fopen(‘aaS_FluentId.txt’,'r’)
fluentkey=fscanf(fid,’%s’)
fclose(fid)
fluent.ConnectToServer (fluentkey)

Step7: Execute you Matlab-Fluent program.

You have two Matlab objects (fluent and tui) that you can use drive Fluent.

If you want to do Fluent journaling from matlab, you can use
tui.DoMenuCommand(tuiCommand)
this will have Fluent execute the tuiCommand with no return
tui.DoMenuCommandToString(tuiCommand)
this will have Fluent execute the tuiCommand and return the output
tuiCommand is pretty much any valid command that you put in a Fluent journal file
Example:
tui.DoMenuCommand('solve iterate 10')
report=tui.DoMenuCommandToString('report summary no')

If you want to set or get the value of a rpvar, you can use
tui.GetRpVar(rpvarName)
this will have Fluent returning the value of the rpvar
tui.SetRpVar(rpvarName,stringifiedRpVarValue)
this will have Fluent set the value of a rpvar
Example
valuePressureRelax=tui.GetRpVar('pressure/relax')
tui.GetRpVar('pressure/relax','0.5')

If you want to set or get the value of a parameter, you can use
fluent.GetOutputParameterValueByname(parameterName )
this will have Fluent returning the value of the parameter
tui.SetInputParameterValueByName(parameterName,par ameterValue)
this will have Fluent set the value of a parameter
Example
valueAvgTemperature=fluent.GetOutputParameterValue ByName('avgtemperature')
fluent.SetInputParameterValueByName('massflowrate' ,0.5)

Of course you will need to have an output parameter called 'avgtemperature' and an input parameter called 'massflowrate' previously configured in the Fluent case.

Please let me know if this post was helpful to you. If you give me your e-mail, I will contact you.

I tried my best to have the code examples syntactically correct, but there might be some typos. You can refer to Fluent documentation or you can mention the issue to me and I will figure it out.

Thank you

Sorin
tiancaidushen is offline   Reply With Quote

Old   December 2, 2016, 15:19
Default
  #14
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi Shen,

I think that you just need escape the special characters in your command.

Try using
tui.DoMenuCommand('define user-defined execute-on-demand \"readData\"')

instead of
tui.DoMenuCommand('define user-defined execute-on-demand "readData" ')

Regards

Sorin
Quote:
Originally Posted by tiancaidushen View Post
Thank you so much Sorin,

Because of your illustration here, I made a progress in my program.
Here, I just want to ask a question about execute-on-demand.

I have a interpreted UDF(DEFINE_ON_DEMAND), the name is readData. When I try to execute it from MATLAB code, it gives me an error:
Error: eval: unbound variable
Error Object: read_porosity

The code I wrote is :
tui.DoMenuCommand('define user-defined execute-on-demand "readData" ')

Can you help me to solve this problem.
Thank you in advance.

SHEN
Sorin is offline   Reply With Quote

Old   December 2, 2016, 15:33
Default
  #15
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi ras1981,

That specific example would work if connecting Windows-Matlab with Linux-Fluent. the limitation is simply mainly due to the fact that the aaS connection is using actxserver, a Matlab command available on Windows only.

That approach is not anymore the ANSYS preferred way to access an ANSYS solver from Matlab.

There is a more efficient way to access Fluent and/or ANSYS Mechanical APDL running on all ANSYS supported platforms (Windows/Linux) from Matlab running on any Matlab supported platforms.

Please read my blog at http://www.ansys-blog.com/how-to-mak...ys/#more-15509

You will need download a Matlab "helper" from support.ansys.com. It is free but you must have an account on that website.

Sorry for the late reply

Sorin
Quote:
Originally Posted by ras1981 View Post
Hi Sorin!
does this work on a Linux-mashine as well?
Thank You
Sorin is offline   Reply With Quote

Old   December 2, 2016, 19:16
Thumbs up
  #16
New Member
 
DU Shen
Join Date: Nov 2016
Posts: 14
Rep Power: 9
tiancaidushen is on a distinguished road
Thank you so much, Sorin.

Hopefully that I can meet you here.
Thank you again.

SHEN


Quote:
Originally Posted by Sorin View Post
Hi Shen,

I think that you just need escape the special characters in your command.

Try using
tui.DoMenuCommand('define user-defined execute-on-demand \"readData\"')

instead of
tui.DoMenuCommand('define user-defined execute-on-demand "readData" ')

Regards

Sorin
tiancaidushen is offline   Reply With Quote

Old   December 2, 2016, 19:18
Thumbs up
  #17
New Member
 
DU Shen
Join Date: Nov 2016
Posts: 14
Rep Power: 9
tiancaidushen is on a distinguished road
Thank you so much, Sorin.

Hopefully that I can meet you here.
Thank you again.

SHEN



Quote:
Originally Posted by Sorin View Post
Hi Shen,

I think that you just need escape the special characters in your command.

Try using
tui.DoMenuCommand('define user-defined execute-on-demand \"readData\"')

instead of
tui.DoMenuCommand('define user-defined execute-on-demand "readData" ')

Regards

Sorin
tiancaidushen is offline   Reply With Quote

Old   December 2, 2016, 20:26
Talking
  #18
New Member
 
DU Shen
Join Date: Nov 2016
Posts: 14
Rep Power: 9
tiancaidushen is on a distinguished road
Hello Sorin,

By the way, can i ask you to correct these two commands:

tui.DoMenuCommand('solve initialize compute-defaults all-zones')

tui.DoMenuCommand('solve initialize compute-defaults velocity-inlet inlet') or tui.DoMenuCommand('solve initialize compute-defaults velocity-inlet 9')



SHEN







Quote:
Originally Posted by Sorin View Post
Hi Shen,

I think that you just need escape the special characters in your command.

Try using
tui.DoMenuCommand('define user-defined execute-on-demand \"readData\"')

instead of
tui.DoMenuCommand('define user-defined execute-on-demand "readData" ')

Regards

Sorin
tiancaidushen is offline   Reply With Quote

Old   March 24, 2017, 08:34
Default
  #19
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi Shen,

The commands seem to be syntactically correct, but they might be invalid depending on the status of Fluent. I would recommend trying to type the commands on Fluent.

Even better, you can catch the exceptions from Fluent and read the content. Follow the instructions in my recent blog:
http://www.ansys-blog.com/ansys-fluent-matlab-example/

Quote:
Originally Posted by tiancaidushen View Post
Hello Sorin,

By the way, can i ask you to correct these two commands:

tui.DoMenuCommand('solve initialize compute-defaults all-zones')

tui.DoMenuCommand('solve initialize compute-defaults velocity-inlet inlet') or tui.DoMenuCommand('solve initialize compute-defaults velocity-inlet 9')



SHEN
Sorin is offline   Reply With Quote

Old   November 6, 2017, 04:32
Default
  #20
New Member
 
Join Date: Nov 2017
Posts: 1
Rep Power: 0
Taes is on a distinguished road
I had to use
Code:
actxserver('ANSYS.CoFluentUnit.1.1')
in Matlab with ANSYS 18.
Taes is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ansys 12.1 - Create Rotor/Stator Interface for Fluent opm ANSYS Meshing & Geometry 21 May 23, 2016 08:29
Interface boundary, Fluent natantyt FLUENT 2 October 18, 2011 07:46
Fluent & matlab Fabio FLUENT 5 August 24, 2009 13:16
interface reconstruction algorithm in Fluent VOF > daniel Main CFD Forum 0 May 4, 2006 03:25
Call Fluent from Visual Basic 6 interface AbuKhawlah FLUENT 0 June 5, 2005 14:53


All times are GMT -4. The time now is 05:54.