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

linking matlab and fluent

Register Blogs Community New Posts Updated Threads Search

Like Tree14Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 1, 2007, 13:16
Default linking matlab and fluent
  #1
Nair
Guest
 
Posts: n/a
I have to do an optimization on wing planform. I would like to run the optimization on matlab and the flow simulation on fluent. Does a way exist to link these softwares? My aim is to use Matlab as a "master" program and fluent as a "slave".
  Reply With Quote

Old   March 1, 2007, 15:16
Default Re: linking matlab and fluent
  #2
Seeker Phil
Guest
 
Posts: n/a
You should be able to do it pretty easily by using the shell escape character. For example:

<code> !fluent.exe </code>

It depends on what you are tryin to do - Phil

  Reply With Quote

Old   March 2, 2007, 05:58
Default Re: linking matlab and fluent
  #3
Michael B
Guest
 
Posts: n/a
Have a look at this. http://www.dansis.dk/download/Fuldautomatisk%20Optimering%20-%20Steen%20Lauridsen.pdf

sumeetkotak likes this.
  Reply With Quote

Old   March 2, 2007, 08:03
Default Re: linking matlab and fluent
  #4
Ralf Schmidt
Guest
 
Posts: n/a
hi!

here are two other links, that may help:

http://www.cfd-online.com/Forum/flue...cgi?read=35447

http://www.cfd-online.com/Forum/flue...cgi?read=45383

Ralf
  Reply With Quote

Old   March 2, 2007, 13:27
Default Re: linking matlab and fluent
  #5
Khairy
Guest
 
Posts: n/a
Hi

i think you can write a fluent journal say c:\xxxx.jou with all steps needed to be measured in fluent

from matlab ! fluent 2ddp -i "C:\xxxx.jou"

also u can use pause function from Matlab to perform modification in journal file after each optimization process

i hope this useful

Khairy

Cairo-Egypt
  Reply With Quote

Old   March 2, 2007, 15:04
Default Re: linking matlab and fluent
  #6
nair
Guest
 
Posts: n/a
Thanks for all these responses. I will try to do it with fluent journal as it seems to work.

  Reply With Quote

Old   March 20, 2007, 23:20
Default Re: linking matlab and fluent
  #7
rajesh
Guest
 
Posts: n/a
i am intersted to do the fluent matlab link can u say the procedure

thanks
  Reply With Quote

Old   March 20, 2007, 23:31
Default Re: linking matlab and fluent
  #8
rajesh
Guest
 
Posts: n/a
can u post the pdf file again please

chaitanyaarige likes this.
  Reply With Quote

Old   March 21, 2007, 03:13
Default Re: linking matlab and fluent
  #9
Michael B
Guest
 
Posts: n/a
sorry. It has been removed.
  Reply With Quote

Old   April 6, 2013, 06:11
Default Fluent data and MATLAB
  #10
New Member
 
SF
Join Date: Apr 2013
Posts: 1
Rep Power: 0
Sheeren is on a distinguished road
Hi
I have a velocity field which I got through FLUENT. now I want to calculate the pressure using the velocity data on MATLAB. I have imported the fluent data in MATLAB. I am having difficulty to pick the correct velocity of the specific node as the data is not organized with respect of either x or y coordinate.
sumeetkotak likes this.
Sheeren is offline   Reply With Quote

Old   October 4, 2013, 22:47
Default
  #11
New Member
 
Wang
Join Date: Nov 2011
Posts: 9
Rep Power: 15
M201170944 is on a distinguished road
Quote:
Originally Posted by Sheeren View Post
Hi
I have a velocity field which I got through FLUENT. now I want to calculate the pressure using the velocity data on MATLAB. I have imported the fluent data in MATLAB. I am having difficulty to pick the correct velocity of the specific node as the data is not organized with respect of either x or y coordinate.
Hi Sheeren
Have you worked out the problem mentioned above?
I am using the Matlab to work with Fluent and meet the problem as yours too?
M201170944 is offline   Reply With Quote

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

I would recommend journaling Fluent from Matlab.

I will not copy/paste my other post but I will provide the link to my other cfd-online post: http://www.cfd-online.com/Forums/flu...ab-fluent.html

You will start Fluent on your preferred Fluent machine and Matlab on your preferred Matlab machine and have them connected. Follow the steps in the post referred above.

Then, of course, you will able to code standard Matlab script mixed with Fluent scripting lines.

Fluent scripting will be implemented trough either tui.DoMenuCommand or tui.DoMenuCommandToString

To get the velocity at node you will have to execute

tui.DoMenuCommand('file export ascii ...')

The "file export ascii ..." will return the values of velocity at specific coordinates.

One of the options of the command is Location/CellCentered?. If you set that option to no the node values for velocity will be returned. Otherwhise Cell-centered values will be returned.

I would recommend checking the command in Fluent's native console first.

Just for your reference, if you use the Fluent case in the first Fluent tutorial, the next Matlab command will generate a node location report of velocities on the surface with the surface id 1.

tui.DoMenuCommand('file export ascii report.txt 1 () no x-velocity y-velocity z-velocity () no')

buffer=tui.DownloadFileToBuffer('report.txt')


The last option in the file export command has to be no for Node values and yes for Cell-centered values.

The first Matlab command will ask Fluent to generate the report, space delimited, and the second one will retrieve the report from the Fluent machine into the Matlab machine.

The content of the Matlab variable called buffer will be:

nodenumber x-coordinate y-coordinate z-coordinate z-velocity y-velocity x-velocity
1 1.152879596E-01 2.031999975E-01 6.634064950E-03 -2.968966030E-02 3.717783093E-01 4.227112606E-02
2 1.195714250E-01 2.031999975E-01 1.100432387E-18 -8.820794523E-03 3.445040882E-01 7.459304482E-02
3 1.135978848E-01 2.031999975E-01 7.346584965E-19 -1.874569058E-02 3.483363688E-01 5.241509899E-02
4 1.295439452E-01 2.031999975E-01 5.346933380E-03 7.882571779E-03 3.145299554E-01 6.067820266E-02
5 1.315185130E-01 2.031999975E-01 1.831980064E-18 5.455949809E-03 3.054272830E-01 6.991569698E-02
6 1.255449653E-01 2.031999975E-01 1.466206277E-18 1.139550121E-03 3.258269727E-01 8.162691444E-02
7 1.502135396E-01 2.031999975E-01 6.340762600E-03 9.426723234E-03 4.359190762E-01 2.245260961E-02
8 1.554126740E-01 2.031999975E-01 3.295075624E-18 4.237215500E-03 4.635384083E-01 2.144469880E-02
9 1.494391263E-01 2.031999975E-01 2.929301734E-18 4.789047409E-03 4.064534009E-01 2.660968900E-02
10 1.713656485E-01 2.031999975E-01 6.717640907E-03 5.333635490E-03 4.887778759E-01 7.551581133E-03
11 1.733332872E-01 2.031999975E-01 4.392397295E-18 2.691901056E-03 4.850952923E-01 4.341949709E-03
12 1.673597544E-01 2.031999975E-01 4.026623405E-18 2.609958639E-03 4.897836149E-01 9.937736206E-03
13 1.412532330E-01 2.031999975E-01 6.340762600E-03 1.354721840E-02 3.258499205E-01 3.310972080E-02
14 1.434655935E-01 2.031999975E-01 2.563527844E-18 6.097615231E-03 3.381870687E-01 3.366776928E-02
15 1.374920458E-01 2.031999975E-01 2.197753954E-18 7.280339953E-03 3.002582788E-01 4.857731238E-02
16 1.576804668E-01 2.031999975E-01 6.340762600E-03 6.822485011E-03 4.780743122E-01 1.799257658E-02
17 1.613862067E-01 2.031999975E-01 3.660849515E-18 2.887216164E-03 4.864223301E-01 1.562698744E-02
18 1.773391813E-01 2.031999975E-01 6.717640907E-03 5.844513420E-03 4.801833332E-01 2.978647826E-03
19 1.793068349E-01 2.031999975E-01 4.758171185E-18 3.179352498E-03 4.687085152E-01 -1.482679625E-03
20 1.886768490E-01 2.031999975E-01 5.854124669E-03 2.533855848E-03 4.385802746E-01 -6.194453221E-03
21 1.912539154E-01 2.031999975E-01 5.489718966E-18 4.006652161E-04 4.160143435E-01 -1.083826553E-02
22 1.852803677E-01 2.031999975E-01 5.123945075E-18 2.511465689E-03 4.431619346E-01 -7.344217505E-03
23 1.646601856E-01 2.031999975E-01 7.317313924E-03 5.943228491E-03 4.892514646E-01 1.254611928E-02
24 1.229127571E-01 2.031999975E-01 5.863120314E-03 -5.249480251E-03 3.434669673E-01 6.091181561E-02
25 1.355963051E-01 2.031999975E-01 5.199092906E-03 1.269620750E-02 3.007976115E-01 4.804949090E-02
26 1.833213121E-01 2.031999975E-01 7.256622892E-03 5.729522556E-03 4.623973966E-01 -1.315846923E-03
27 1.458099633E-01 2.031999975E-01 5.491864402E-03 1.017787773E-02 3.759089112E-01 2.729051746E-02
28 1.937100142E-01 2.031999975E-01 5.562217906E-03 -1.522899955E-03 4.181340933E-01 -7.305184379E-03
29 1.614051610E-01 2.031999975E-01 1.945968345E-02 1.262411010E-02 4.887210429E-01 1.180070359E-02
30 1.658221632E-01 2.031999975E-01 1.482590381E-02 1.012255251E-02 4.906893969E-01 1.141436677E-02
31 1.599482596E-01 2.031999975E-01 1.268152520E-02 1.048206538E-02 4.860492051E-01 1.469715778E-02
32 1.404936016E-01 2.031999975E-01 2.799759991E-02 1.532310992E-02 4.606435299E-01 -4.372561816E-03
33 1.349518895E-01 2.031999975E-01 3.111136146E-02 4.375991877E-03 4.634742439E-01 -1.976985298E-02

.......



Sorin

Quote:
Originally Posted by Sheeren View Post
Hi
I have a velocity field which I got through FLUENT. now I want to calculate the pressure using the velocity data on MATLAB. I have imported the fluent data in MATLAB. I am having difficulty to pick the correct velocity of the specific node as the data is not organized with respect of either x or y coordinate.
sina_mech and ss_stardust like this.
Sorin is offline   Reply With Quote

Old   January 23, 2014, 02:28
Default
  #13
New Member
 
shahed Malekipour
Join Date: Dec 2011
Posts: 5
Rep Power: 15
shahed.malekipour is on a distinguished road
what does "-i" do?
! fluent 2ddp -i "C:\xxxx.jou"

Last edited by shahed.malekipour; January 23, 2014 at 10:02.
shahed.malekipour is offline   Reply With Quote

Old   January 28, 2014, 11:29
Default
  #14
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi Shahed,

You can do Fluent journaling in many ways. You can journal from Matlab directly or you can journal form a file (the "-i" option).

As a rule of thumb, if the interaction with Matlab is insignificant and the Fluent run takes a considerable amount of time, I would recommend using file journaling. This option typically will take a larger amount of Matlab coding, because you have Fluent writes the output into a file and then you have to parse it to extract the information

If the exchange of information between Matlab and Fluent is reasonable, I would advise Matlab journaling. This will take less time on Matlab coding since the output of command are delivered into Matlab.

Now, to answer your question:

The "-i <filename.jou>" option on Fluent start command instructs Fluent to read and execute as a Fluent TUI command every line in the file <filename.jou>. until the end of file.

If you are executing "!fluent 2ddp -i "C:\xxxx.jou" from Matlab all outputs or errors for all commands can be eventually retrieved from a transcript file. To process it in Matlab you will then have to parse the information in the transcript file.

I would advise you though to connect with Fluent directly from Matlab, because that way you can get the output of every command after it is executed.

Sorin
sircorp and shahed.malekipour like this.
Sorin is offline   Reply With Quote

Old   May 1, 2015, 02:57
Default Matlab & Fluent
  #15
Member
 
Shane
Join Date: Oct 2009
Posts: 52
Rep Power: 17
sircorp is on a distinguished road
Hi Guys

I am new to Fluent. I created a property program in Matlab. Can I call "Matlab" in Fluent UDF ? If so, how ?

For example Viscosity(Temperature, Pressure). I have a Matlab program that calculates viscosity of the material at any Temperature and Pressure. I just want to call the Matlab Function in Fluent ?

Shane
sircorp is offline   Reply With Quote

Old   May 1, 2015, 10:42
Default
  #16
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi sircorp,

I am not sure what are your specifics, but I will attempt based on some reasonable assumptions.

It seems like your call for property value might be called for every CFD cell, every iterations.

Assuming that you have a very small case of just 1000 CFD cells (this really very small), you will call your function 1000 times per iteration. For this small case Fluent will advance in less than 1 second that is equivalent of a 1 millisecond/CFD cell cost.

There ares several options if you want to execute the Matlab function:
1. launch Matlab from UDF, execute your Matlab function, put the result in a file, shutdown Matlab parse the output file and extract the viscosity value
2. launch Matlab before launching Fluent, modify the UDF to have fast access to the running Matlab session, connect to Matlab, execute tha matlab function and retrieve the viscosity
3. Convert you Matlab function in a C function and put that function in the UDF


My recommendation will be to pick option 2 or option 3. Option 1 will slow-down Fluent too much.

I have expertise on option 2 and I can help you if you want to proceed with that option.

You should pick option 2 or option 3 based on whichever requires less programming for you. Option 3 should be the fastest, but that depends on your implementation.

See below the details.

Option 1 will generate a tremendous performance degradation, launching and shutdown Matlab it will take probably 10 seconds, which will make your Fluent simulation 10000 times slower. If you compile the Matlab function into an executable, you will be able to reduce the Matlab processing to 1 second, but still you will slow down Fluent 1000 times. It depends on you tolerance to performance degradation, but in my opinion 100,000.00% is generally not acceptable.

Option 2 is definitely faster, but it will require some skilled programming on both Matlab and UDF, in addition to the Matlab function you have. Using this approach the call of the Matlab function could take one milliseconds or less. To obtain that you will probably have to connect Matlab ORB with the Fluent ORB. This way you will avoid any unnecessary Matlab or Matlab-generated executable launching, any file read/write operation. The performance degradation will probably be acceptable this way.
I have the expertise to help you pursuing this approach, but please contact me on the private chat.

Option 3
I cannot comment on the cost of Matlab to C conversion, without seeing your specific Matlab code.
If you are computing the value using a mathematical formula, its very easy (easier than option 2).
If you are extracting it from some sort 2 dimensional look-up table should also be relatively easier than option 2.
If you are using Third-Party Property service hooked into Matlab, you might want to consider option 2. Same think applies if you are using an optimization function or even the Matlab Optimization Toolkit.

Let me know if this helped

Sorin
Sorin is offline   Reply With Quote

Old   May 27, 2015, 05:56
Default Thanks
  #17
Member
 
Shane
Join Date: Oct 2009
Posts: 52
Rep Power: 17
sircorp is on a distinguished road
Quote:
Originally Posted by Sorin View Post
Hi sircorp,

I am not sure what are your specifics, but I will attempt based on some reasonable assumptions.

It seems like your call for property value might be called for every CFD cell, every iterations.

Assuming that you have a very small case of just 1000 CFD cells (this really very small), you will call your function 1000 times per iteration. For this small case Fluent will advance in less than 1 second that is equivalent of a 1 millisecond/CFD cell cost.

There ares several options if you want to execute the Matlab function:
1. launch Matlab from UDF, execute your Matlab function, put the result in a file, shutdown Matlab parse the output file and extract the viscosity value
2. launch Matlab before launching Fluent, modify the UDF to have fast access to the running Matlab session, connect to Matlab, execute tha matlab function and retrieve the viscosity
3. Convert you Matlab function in a C function and put that function in the UDF


My recommendation will be to pick option 2 or option 3. Option 1 will slow-down Fluent too much.

I have expertise on option 2 and I can help you if you want to proceed with that option.

You should pick option 2 or option 3 based on whichever requires less programming for you. Option 3 should be the fastest, but that depends on your implementation.

See below the details.

Option 1 will generate a tremendous performance degradation, launching and shutdown Matlab it will take probably 10 seconds, which will make your Fluent simulation 10000 times slower. If you compile the Matlab function into an executable, you will be able to reduce the Matlab processing to 1 second, but still you will slow down Fluent 1000 times. It depends on you tolerance to performance degradation, but in my opinion 100,000.00% is generally not acceptable.

Option 2 is definitely faster, but it will require some skilled programming on both Matlab and UDF, in addition to the Matlab function you have. Using this approach the call of the Matlab function could take one milliseconds or less. To obtain that you will probably have to connect Matlab ORB with the Fluent ORB. This way you will avoid any unnecessary Matlab or Matlab-generated executable launching, any file read/write operation. The performance degradation will probably be acceptable this way.
I have the expertise to help you pursuing this approach, but please contact me on the private chat.

Option 3
I cannot comment on the cost of Matlab to C conversion, without seeing your specific Matlab code.
If you are computing the value using a mathematical formula, its very easy (easier than option 2).
If you are extracting it from some sort 2 dimensional look-up table should also be relatively easier than option 2.
If you are using Third-Party Property service hooked into Matlab, you might want to consider option 2. Same think applies if you are using an optimization function or even the Matlab Optimization Toolkit.

Let me know if this helped

Sorin
Thanks

I do use Lookup table in Matlab. They are quickest way to get around. I found lookup tables in Matlab very friendly(except where property is not linear i.e. Supercritical transition point)

I have done testing for a system where temperature varies along height of the system. Also pressure varies along the height. This creates problem that I can not assign same Pressure and Viscosity parameters. However to simplify the system, I have slices the system into several segments and inserted porous disc along the height. This helps me to separate the system and set the value of temperature and viscosity along the height. It is not a true reflection of the testing I did but I don't have another option.


SHANE
sircorp is offline   Reply With Quote

Old   April 5, 2016, 04:48
Post Hi Khairy
  #18
New Member
 
Endashaw Tesfaye
Join Date: Feb 2016
Location: Stavanger, Norway
Posts: 1
Rep Power: 0
Endalk1234 is on a distinguished road
Quote:
Originally Posted by Khairy
;139713
Hi

i think you can write a fluent journal say c:\xxxx.jou with all steps needed to be measured in fluent

from matlab ! fluent 2ddp -i "C:\xxxx.jou"

also u can use pause function from Matlab to perform modification in journal file after each optimization process

i hope this useful

Khairy

Cairo-Egypt
it seems that you have a pretty nice skill of using fluent, its awesome . i would also like to get some tips about how to interface fluent and matlab for a transient fluid structure interaction problem. i am running the structural solution from matlab and the fluid solution using fluent fluid solver. extracting the pressure load from the fluid solver as a load for the structure and nodal displacement from matlab to deform the shape of the boundary in fluent is the objective. i manage to create the journal file and enter the scrip in matlab but running and finding the nodal values are the difficult part. could you suggest me how to do it?


i also call up on everyone who has the experience and willing to help!
thanks in advance!
Endalk1234 is offline   Reply With Quote

Old   April 30, 2016, 10:40
Default
  #19
New Member
 
shadi
Join Date: Feb 2015
Posts: 3
Rep Power: 11
shadi is on a distinguished road
why don't you use ansys workbench?you can easily model your fsi problem.you can couple ansys and fluent.
shadi is offline   Reply With Quote

Old   October 24, 2018, 01:12
Question Need help to interface fluent and matlab
  #20
New Member
 
Sumeet kotak
Join Date: Jun 2015
Posts: 13
Rep Power: 11
sumeetkotak is on a distinguished road
Quote:
Originally Posted by Sheeren View Post
Hi
I have a velocity field which I got through FLUENT. now I want to calculate the pressure using the velocity data on MATLAB. I have imported the fluent data in MATLAB. I am having difficulty to pick the correct velocity of the specific node as the data is not organized with respect of either x or y coordinate.
Hi sheeren,

I want to export fluent data of velocity of air over aerofoil and want3d to find out pressure variation using matlab . Can you guide how can I interface fluent and matlab.

Thanks in advance
sumeetkotak 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
How to start Fluent with Matlab?? Jay Hu FLUENT 8 November 9, 2022 07:30
looking for a smart interface matlab fluent chary FLUENT 24 June 18, 2021 10:07
Creating UDF file in MATLAB for Fluent ppa381 Fluent UDF and Scheme Programming 1 October 10, 2013 10:27
How to link Fluent and MATLAB and exchange data? z701531118 FLUENT 3 October 9, 2013 15:26
Creating UDF file in MATLAB for Fluent ppa381 FLUENT 0 July 13, 2009 15:33


All times are GMT -4. The time now is 03:52.