
[Sponsors] 
March 1, 2007, 13:16 
linking matlab and fluent

#1 
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".


March 1, 2007, 15:16 
Re: linking matlab and fluent

#2 
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 

March 2, 2007, 05:58 
Re: linking matlab and fluent

#3 
Guest
Posts: n/a

Have a look at this. http://www.dansis.dk/download/Fuldautomatisk%20Optimering%20%20Steen%20Lauridsen.pdf


March 2, 2007, 08:03 
Re: linking matlab and fluent

#4 
Guest
Posts: n/a

hi!
here are two other links, that may help: http://www.cfdonline.com/Forum/flue...cgi?read=35447 http://www.cfdonline.com/Forum/flue...cgi?read=45383 Ralf 

March 2, 2007, 13:27 
Re: linking matlab and fluent

#5 
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 CairoEgypt 

March 2, 2007, 15:04 
Re: linking matlab and fluent

#6 
Guest
Posts: n/a

Thanks for all these responses. I will try to do it with fluent journal as it seems to work.


March 20, 2007, 23:20 
Re: linking matlab and fluent

#7 
Guest
Posts: n/a

i am intersted to do the fluent matlab link can u say the procedure
thanks 

March 20, 2007, 23:31 
Re: linking matlab and fluent

#8 
Guest
Posts: n/a

can u post the pdf file again please


March 21, 2007, 03:13 
Re: linking matlab and fluent

#9 
Guest
Posts: n/a

sorry. It has been removed.


April 6, 2013, 05:11 
Fluent data and MATLAB

#10 
New Member
SF
Join Date: Apr 2013
Posts: 1
Rep Power: 0 
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. 

October 4, 2013, 21:47 

#11  
New Member
Wang
Join Date: Nov 2011
Posts: 9
Rep Power: 6 
Quote:
Have you worked out the problem mentioned above? I am using the Matlab to work with Fluent and meet the problem as yours too? 

October 9, 2013, 14:08 

#12  
New Member
Sorin Munteanu
Join Date: Apr 2013
Posts: 18
Rep Power: 6 
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 cfdonline post: looking for a smart interface matlab fluent 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 Cellcentered 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 xvelocity yvelocity zvelocity () no') buffer=tui.DownloadFileToBuffer('report.txt') The last option in the file export command has to be no for Node values and yes for Cellcentered 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 xcoordinate ycoordinate zcoordinate zvelocity yvelocity xvelocity 1 1.152879596E01 2.031999975E01 6.634064950E03 2.968966030E02 3.717783093E01 4.227112606E02 2 1.195714250E01 2.031999975E01 1.100432387E18 8.820794523E03 3.445040882E01 7.459304482E02 3 1.135978848E01 2.031999975E01 7.346584965E19 1.874569058E02 3.483363688E01 5.241509899E02 4 1.295439452E01 2.031999975E01 5.346933380E03 7.882571779E03 3.145299554E01 6.067820266E02 5 1.315185130E01 2.031999975E01 1.831980064E18 5.455949809E03 3.054272830E01 6.991569698E02 6 1.255449653E01 2.031999975E01 1.466206277E18 1.139550121E03 3.258269727E01 8.162691444E02 7 1.502135396E01 2.031999975E01 6.340762600E03 9.426723234E03 4.359190762E01 2.245260961E02 8 1.554126740E01 2.031999975E01 3.295075624E18 4.237215500E03 4.635384083E01 2.144469880E02 9 1.494391263E01 2.031999975E01 2.929301734E18 4.789047409E03 4.064534009E01 2.660968900E02 10 1.713656485E01 2.031999975E01 6.717640907E03 5.333635490E03 4.887778759E01 7.551581133E03 11 1.733332872E01 2.031999975E01 4.392397295E18 2.691901056E03 4.850952923E01 4.341949709E03 12 1.673597544E01 2.031999975E01 4.026623405E18 2.609958639E03 4.897836149E01 9.937736206E03 13 1.412532330E01 2.031999975E01 6.340762600E03 1.354721840E02 3.258499205E01 3.310972080E02 14 1.434655935E01 2.031999975E01 2.563527844E18 6.097615231E03 3.381870687E01 3.366776928E02 15 1.374920458E01 2.031999975E01 2.197753954E18 7.280339953E03 3.002582788E01 4.857731238E02 16 1.576804668E01 2.031999975E01 6.340762600E03 6.822485011E03 4.780743122E01 1.799257658E02 17 1.613862067E01 2.031999975E01 3.660849515E18 2.887216164E03 4.864223301E01 1.562698744E02 18 1.773391813E01 2.031999975E01 6.717640907E03 5.844513420E03 4.801833332E01 2.978647826E03 19 1.793068349E01 2.031999975E01 4.758171185E18 3.179352498E03 4.687085152E01 1.482679625E03 20 1.886768490E01 2.031999975E01 5.854124669E03 2.533855848E03 4.385802746E01 6.194453221E03 21 1.912539154E01 2.031999975E01 5.489718966E18 4.006652161E04 4.160143435E01 1.083826553E02 22 1.852803677E01 2.031999975E01 5.123945075E18 2.511465689E03 4.431619346E01 7.344217505E03 23 1.646601856E01 2.031999975E01 7.317313924E03 5.943228491E03 4.892514646E01 1.254611928E02 24 1.229127571E01 2.031999975E01 5.863120314E03 5.249480251E03 3.434669673E01 6.091181561E02 25 1.355963051E01 2.031999975E01 5.199092906E03 1.269620750E02 3.007976115E01 4.804949090E02 26 1.833213121E01 2.031999975E01 7.256622892E03 5.729522556E03 4.623973966E01 1.315846923E03 27 1.458099633E01 2.031999975E01 5.491864402E03 1.017787773E02 3.759089112E01 2.729051746E02 28 1.937100142E01 2.031999975E01 5.562217906E03 1.522899955E03 4.181340933E01 7.305184379E03 29 1.614051610E01 2.031999975E01 1.945968345E02 1.262411010E02 4.887210429E01 1.180070359E02 30 1.658221632E01 2.031999975E01 1.482590381E02 1.012255251E02 4.906893969E01 1.141436677E02 31 1.599482596E01 2.031999975E01 1.268152520E02 1.048206538E02 4.860492051E01 1.469715778E02 32 1.404936016E01 2.031999975E01 2.799759991E02 1.532310992E02 4.606435299E01 4.372561816E03 33 1.349518895E01 2.031999975E01 3.111136146E02 4.375991877E03 4.634742439E01 1.976985298E02 ....... Sorin Quote:


January 23, 2014, 02:28 

#13 
New Member
shahed Malekipour
Join Date: Dec 2011
Posts: 5
Rep Power: 6 
what does "i" do?
! fluent 2ddp i "C:\xxxx.jou" Last edited by shahed.malekipour; January 23, 2014 at 10:02. 

January 28, 2014, 11:29 

#14 
New Member
Sorin Munteanu
Join Date: Apr 2013
Posts: 18
Rep Power: 6 
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 

May 1, 2015, 01:57 
Matlab & Fluent

#15 
Member
Shane
Join Date: Oct 2009
Posts: 52
Rep Power: 8 
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 

May 1, 2015, 09:42 

#16 
New Member
Sorin Munteanu
Join Date: Apr 2013
Posts: 18
Rep Power: 6 
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 slowdown 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 Matlabgenerated 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 lookup table should also be relatively easier than option 2. If you are using ThirdParty 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 

May 27, 2015, 04:56 
Thanks

#17  
Member
Shane
Join Date: Oct 2009
Posts: 52
Rep Power: 8 
Quote:
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 

April 5, 2016, 03:48 
Hi Khairy

#18  
New Member
Endashaw Tesfaye
Join Date: Feb 2016
Location: Stavanger, Norway
Posts: 1
Rep Power: 0 
Quote:
i also call up on everyone who has the experience and willing to help! thanks in advance! 

April 30, 2016, 09:40 

#19 
New Member
shadi
Join Date: Feb 2015
Posts: 3
Rep Power: 3 
why don't you use ansys workbench?you can easily model your fsi problem.you can couple ansys and fluent.


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
looking for a smart interface matlab fluent  chary  FLUENT  11  April 19, 2016 00:40 
Creating UDF file in MATLAB for Fluent  ppa381  Fluent UDF and Scheme Programming  1  October 10, 2013 09:27 
How to link Fluent and MATLAB and exchange data?  z701531118  FLUENT  3  October 9, 2013 14:26 
How to start Fluent with Matlab??  Jay Hu  FLUENT  5  October 9, 2013 14:20 
Creating UDF file in MATLAB for Fluent  ppa381  FLUENT  0  July 13, 2009 14:33 