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

Fluent-Matlab Linking

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 5, 2020, 17:06
Default Fluent-Matlab Linking
  #1
New Member
 
Mohammadreza
Join Date: May 2019
Posts: 5
Rep Power: 6
mohammadreza75 is on a distinguished road
Hello,

I want to run Fluent with Matlab and read a journal file with it. so I write this command in Matlab file:

system('"D:\program file\Ansys 18.2\ANSYS Inc\v182\fluent\ntbin\win64\fluent.exe" 2d -t5 -i ******');

where ****** is the name of my journal file.

The journal file contains a UDF compiling step. when I run Fluent in my system without using Matlab everything works fine, but when I using the Matlab, Fluent can't compile the UDF file properly.

What's the problem?

thanks,
mohammadreza75 is offline   Reply With Quote

Old   March 6, 2020, 03:29
Default Fluent in Matlab
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Fluent requires access to C compiler for compilation of UDF. This has to be made available when starting Fluent from within Matlab. I am not sure Matlab is up for it. So, there are at least two solutions

1. Compile the UDF a priori and let Fluent load it
2. Interpret the UDF, provided the UDF does not have elements that require compilation, such as structures

Though not directly relevant, may I know the objective of linking Matlab and Fluent?
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 6, 2020, 05:38
Default
  #3
New Member
 
Mohammadreza
Join Date: May 2019
Posts: 5
Rep Power: 6
mohammadreza75 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Fluent requires access to C compiler for compilation of UDF. This has to be made available when starting Fluent from within Matlab. I am not sure Matlab is up for it. So, there are at least two solutions

1. Compile the UDF a priori and let Fluent load it
2. Interpret the UDF, provided the UDF does not have elements that require compilation, such as structures

Though not directly relevant, may I know the objective of linking Matlab and Fluent?
Thanks, vinerm.

I have a CFD optimization problem so I want to link them.
Do you know how I can compile a UDF with Visual Studio before using it in Fluent?
I try it but VS could not compile a UDF.
mohammadreza75 is offline   Reply With Quote

Old   March 6, 2020, 05:58
Default UDF compilation
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
VS is required to compile the UDF but VS alone cannot do it. Solution is to start Fluent from the VS Command Prompt and then compile it. Once compiled, you can use it any time.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 6, 2020, 06:14
Default
  #5
New Member
 
Mohammadreza
Join Date: May 2019
Posts: 5
Rep Power: 6
mohammadreza75 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
VS is required to compile the UDF but VS alone cannot do it. Solution is to start Fluent from the VS Command Prompt and then compile it. Once compiled, you can use it any time.
I have a parameter in the UDF that must be changed in the optimization procedure so, in every iteration, I have a different UDF!
mohammadreza75 is offline   Reply With Quote

Old   March 6, 2020, 08:12
Default Little more work
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Then, you have to start VS Command Prompt from Matlab and start Fluent from within that.

Another option is to ensure that Fluent can find VS compiler. Fluent uses a file udf.bat that has paths given for VS compiler. If the path in the file is correct, Fluent started from anywhere can compile a UDF. If it is not, then Fluent has to be started from within VS prompt.

A more sophisticated solution would be to define that variable as rp-var in Fluent. UDF can pick value of rp-var. That way, you don't have to compile the UDF again and again. Same UDF will work with different values of variable; that's the objective of coding, isn't it
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 9, 2020, 01:11
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
use rpvar as parameter, so you don't need to recompile your code
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
Interfacing Matlab & Fluent: Loading case file srsel6 FLUENT 4 November 15, 2023 16:26
linking matlab and fluent Nair FLUENT 23 January 12, 2020 18:55
Method to set environment variables for linking ANSYS Fluent 19.1 and visual studio 1 renrenxiong ANSYS 0 November 13, 2019 07:17
force to wait MATLAB for running parallel fluent in batch mode a.latifi Main CFD Forum 1 May 9, 2013 16:44
Compiling and linking UDS in FLUENT 4.5 Raja Banerjee FLUENT 1 August 3, 2000 00:07


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