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

Problem in compiling fluent UDF lunched from MATLAB

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Sorin
  • 1 Post By Sorin

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 8, 2016, 16:01
Post Problem in compiling fluent UDF lunched from MATLAB
  #1
New Member
 
Join Date: Oct 2016
Posts: 4
Rep Power: 9
cfdman10 is on a distinguished road
Hi friends,
I am not a very professional user of fluent. Here is the problem description:
I try to open fluent(+ a journal file) using MATLAB but the problem is that when the fluent lunches, the UDFs don't compile correctly and the libudf.dll file can not be created. Fluent states this error:

The UDF library you are trying to load (libudf) is not compiled for 2ddp on the current platform (win64).
The system cannot find the file specified.


I know what it is and I have installed visual studio and when I open fluent directly, I manage to compile UDFs manually and also there is nothing wrong with the journal file.
I guess there is probably something wrong with the fluent startup options I use in MATLAB. I would really appreciate if someone could help me.

FLUENT STARTUP OPTIONS IN MATLAB
Code:
 ! [fluent]  2ddp -wait -i [journal]
SOFTWARE
-OS: windows 7(64 bit)
-ANSYS Fluent v16.1 (64 bit)
-visual studio 2010 ultimate
-Microsoft .NET Framework 4.5.2
-I also have SDK

Thank you in advance for your helps
cfdman10 is offline   Reply With Quote

Old   October 10, 2016, 03:13
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
If you start up Fluent from the SDK shell (I guess that is what you call Visual Studio), then this shell knows where the compiler is.

If you start up Fluent from Matlab, you are in a different shell, and the Matlab shell does not know where the compiler is.
So there are three options I see logically:

1. Make sure that the Matlab shell knows where the compiler is and how to compile. I don't know how to do this.
2. In Matlab, open the SDK shell, and open Fluent from within this shell. Insert inception-joke here.
3. Compile the UDFs in Visual Studio (you said that worked), and only load them from Matlab.

If your work flow allows option 3, I would use that one because it is the most simple.
pakk is offline   Reply With Quote

Old   October 10, 2016, 16:54
Default
  #3
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi cfdman10,

I am not sure what is goal... I presume that you start Fluent from Matlab because you intend to exchange data between the two programs. Probably the data is exchanged either through journal/transcript file maybe or you haveco-simulation functionality in UDF. The mechanism you are using seems to require you to run Fluent and Matlab on the same machine.

My advise for you will be to use the aaS functionality in ANSYS, since it will give you more flexibility.

When using aaS (as a Server) you can start Fluent and Matlab separately. You can launch them even on two different machines with different platforms. Starting Fluent from Matlab is just a particular case. You will have to start Fluent in aaS mode (just add "-aas" to command line)

If you intent to have Matlab issuing Fluent commands, I will advise to start Fluent in idle mode (without the -i option) and then have Matlab connected and either load the journal (using aaS.read.journal command) or by executing the lines in the journal file one at the time.

When starting Fluent in idle + aaS mode (including -aas, but without -i), Fluent will generate an aaS key file (default name aaS_FluentId.txt) and wait for commands either from another program(Matlab in your case) or from its own UI.

The Matlab program will have to collect the aaS key from Fluent working directory, connect to Fluent and then issue the commands as needed.

As a matter of fact, it is easier to write the code than to explain the technique.

You will have to download a the ANSYS Matlab aaS toolbox.

I will advise you to start with the following blog post:

http://www.ansys-blog.com/how-to-mak...pps-for-ansys/

The post covers ANSYS Mechanical APDL aaS, ANSYS Fluent aaS and ANSYS Workbench aaS and includes code example (~20 lines of code) .

It includes also a reference to toolbox available for download from support.ansys.com.

Hope it helps

Sorin

Quote:
Originally Posted by cfdman10 View Post
Hi friends,
I am not a very professional user of fluent. Here is the problem description:
I try to open fluent(+ a journal file) using MATLAB but the problem is that when the fluent lunches, the UDFs don't compile correctly and the libudf.dll file can not be created. Fluent states this error:

The UDF library you are trying to load (libudf) is not compiled for 2ddp on the current platform (win64).
The system cannot find the file specified.


I know what it is and I have installed visual studio and when I open fluent directly, I manage to compile UDFs manually and also there is nothing wrong with the journal file.
I guess there is probably something wrong with the fluent startup options I use in MATLAB. I would really appreciate if someone could help me.

FLUENT STARTUP OPTIONS IN MATLAB
Code:
 ! [fluent]  2ddp -wait -i [journal]
SOFTWARE
-OS: windows 7(64 bit)
-ANSYS Fluent v16.1 (64 bit)
-visual studio 2010 ultimate
-Microsoft .NET Framework 4.5.2
-I also have SDK

Thank you in advance for your helps
Abdelrahman91 likes this.
Sorin is offline   Reply With Quote

Old   October 13, 2016, 12:42
Default
  #4
New Member
 
Join Date: Oct 2016
Posts: 4
Rep Power: 9
cfdman10 is on a distinguished road
Quote:
Originally Posted by pakk View Post
If you start up Fluent from the SDK shell (I guess that is what you call Visual Studio), then this shell knows where the compiler is.

If you start up Fluent from Matlab, you are in a different shell, and the Matlab shell does not know where the compiler is.
So there are three options I see logically:

1. Make sure that the Matlab shell knows where the compiler is and how to compile. I don't know how to do this.
2. In Matlab, open the SDK shell, and open Fluent from within this shell. Insert inception-joke here.
3. Compile the UDFs in Visual Studio (you said that worked), and only load them from Matlab.

If your work flow allows option 3, I would use that one because it is the most simple.
Hi pakk,
1.Well, actually I think if I could somehow address the environmental variables in matlab it would compile correctly. do you know how to do that(in matlab or in SDK)?
2.I have also thought about this method but I don't know how to command SDK in Matlab. Can you give me more explanation?
3.This one will definitely work! I guess i have to use this solution as the last one because it needs some efforts(number of cases are too much)
Also please take a look at my last reply, you can find more explanation about my problem.
Thanks for your reply

Last edited by cfdman10; October 13, 2016 at 13:43.
cfdman10 is offline   Reply With Quote

Old   October 13, 2016, 13:35
Default
  #5
New Member
 
Join Date: Oct 2016
Posts: 4
Rep Power: 9
cfdman10 is on a distinguished road
Quote:
Originally Posted by Sorin View Post
Hi cfdman10,

I am not sure what is goal... I presume that you start Fluent from Matlab because you intend to exchange data between the two programs. Probably the data is exchanged either through journal/transcript file maybe or you haveco-simulation functionality in UDF. The mechanism you are using seems to require you to run Fluent and Matlab on the same machine.

My advise for you will be to use the aaS functionality in ANSYS, since it will give you more flexibility.

When using aaS (as a Server) you can start Fluent and Matlab separately. You can launch them even on two different machines with different platforms. Starting Fluent from Matlab is just a particular case. You will have to start Fluent in aaS mode (just add "-aas" to command line)

If you intent to have Matlab issuing Fluent commands, I will advise to start Fluent in idle mode (without the -i option) and then have Matlab connected and either load the journal (using aaS.read.journal command) or by executing the lines in the journal file one at the time.

When starting Fluent in idle + aaS mode (including -aas, but without -i), Fluent will generate an aaS key file (default name aaS_FluentId.txt) and wait for commands either from another program(Matlab in your case) or from its own UI.

The Matlab program will have to collect the aaS key from Fluent working directory, connect to Fluent and then issue the commands as needed.

As a matter of fact, it is easier to write the code than to explain the technique.

You will have to download a the ANSYS Matlab aaS toolbox.

I will advise you to start with the following blog post:

http://www.ansys-blog.com/how-to-mak...pps-for-ansys/

The post covers ANSYS Mechanical APDL aaS, ANSYS Fluent aaS and ANSYS Workbench aaS and includes code example (~20 lines of code) .

It includes also a reference to toolbox available for download from support.ansys.com.

Hope it helps

Sorin
Hi Sorin,
More explanation: Actually there is a number of cases with different UDFs that I want to solve using Fluent. My goal is to manipulate the journal and UDF files with the help of Matlab in order to make changes automatically. Therefore, I open fluent in Matlab after making changes in UDFs and journal, but the version of fluent that Matlab opens is not capable of compiling UDFs. As I mentioned before, I have the required softwares to compile a UDF (not using matlab) from Fluent luncher. So logically there must be a way that will make Matlab recognize the compiler.(I don't want to use matlab as the compiler, I just want to open Fluent and run each case after making any changes in UDFs)

I was not familiar with the aaS, this feature seems very helpful, I'll read more about it.

best regards
cfdman10 is offline   Reply With Quote

Old   October 13, 2016, 14:12
Default
  #6
New Member
 
Sorin Munteanu
Join Date: Apr 2013
Posts: 27
Rep Power: 14
Sorin is on a distinguished road
Hi cfdman10,

It seems like aaS is your way to go, but I do not want to push in a direction you might not be comfortable with. Please accept my apology if I am offering unwanted information, but the information below might be useful to you:

Fluent aaS main feature is to offer a flexible mechanism to "manipulate a Fluent journal' as you say go along.

I will show you side by side, the procedure with aaS and without aaS:

Without aaS
  1. start Matlab
  2. for each Fluent TUI command
    • save it in journal file
  3. start Fluent with -i option and wait for Fluent to finish simulation
  4. interpret Fluent results from transcript
  5. I presume that you also create UDF file and restart Fluent multiple times and repeat some of the steps above


With aaS
  1. start Matlab
  2. start Fluent with -aas option (no -i option)
  3. Connect Matlab to Fluent
  4. for each TUI command
    • execute the command through aaS in Fluent(including commands that load/unload execute a UDF)
    • interpret the results of the command if you wish
    • execute any Matlab commands that you wish (including generating a UDF source file)
  5. shutdown Fluent through aaS if you do not needed anymore
  6. execute additional Matlab commands if you wish

Based on the result of a TUI or Matlab commands you can take execute additional TUI commands. You do not need to shutdown and restart Fluent from Matlab anymore since Matlab is a connecting process to Fluent, unlike in the non-aaS version where Matlab is the parent process of Fluent.

With aaS you will have the ability of essentially "modifying the journal file and the control the UDF" as you go along. I am adding the quotes, because there is no journal file anymore, the Fluent commands, instead of being in a separate file are bundled in your Matlab code.

You can have Fluent running on a remote machine. The environment of Fluent and of Matlab can be substantially different without conflicts.

Thank you

Sorin


Quote:
Originally Posted by cfdman10 View Post
Hi Sorin,
More explanation: Actually there is a number of cases with different UDFs that I want to solve using Fluent. My goal is to manipulate the journal and UDF files with the help of Matlab in order to make changes automatically. Therefore, I open fluent in Matlab after making changes in UDFs and journal, but the version of fluent that Matlab opens is not capable of compiling UDFs. As I mentioned before, I have the required softwares to compile a UDF (not using matlab) from Fluent luncher. So logically there must be a way that will make Matlab recognize the compiler.(I don't want to use matlab as the compiler, I just want to open Fluent and run each case after making any changes in UDFs)

I was not familiar with the aaS, this feature seems very helpful, I'll read more about it.

best regards
cfdman10 likes this.
Sorin is offline   Reply With Quote

Old   October 13, 2016, 16:10
Default
  #7
New Member
 
Join Date: Oct 2016
Posts: 4
Rep Power: 9
cfdman10 is on a distinguished road
Thank you very much for your detailed introduction of aaS. As I told you it seems a wonderful feature. I will read more about it and I will try to apply it to my case.

Quote:
Originally Posted by Sorin View Post
Hi cfdman10,

It seems like aaS is your way to go, but I do not want to push in a direction you might not be comfortable with. Please accept my apology if I am offering unwanted information, but the information below might be useful to you:

Fluent aaS main feature is to offer a flexible mechanism to "manipulate a Fluent journal' as you say go along.

I will show you side by side, the procedure with aaS and without aaS:

Without aaS
  1. start Matlab
  2. for each Fluent TUI command
    • save it in journal file
  3. start Fluent with -i option and wait for Fluent to finish simulation
  4. interpret Fluent results from transcript
  5. I presume that you also create UDF file and restart Fluent multiple times and repeat some of the steps above


With aaS
  1. start Matlab
  2. start Fluent with -aas option (no -i option)
  3. Connect Matlab to Fluent
  4. for each TUI command
    • execute the command through aaS in Fluent(including commands that load/unload execute a UDF)
    • interpret the results of the command if you wish
    • execute any Matlab commands that you wish (including generating a UDF source file)
  5. shutdown Fluent through aaS if you do not needed anymore
  6. execute additional Matlab commands if you wish

Based on the result of a TUI or Matlab commands you can take execute additional TUI commands. You do not need to shutdown and restart Fluent from Matlab anymore since Matlab is a connecting process to Fluent, unlike in the non-aaS version where Matlab is the parent process of Fluent.

With aaS you will have the ability of essentially "modifying the journal file and the control the UDF" as you go along. I am adding the quotes, because there is no journal file anymore, the Fluent commands, instead of being in a separate file are bundled in your Matlab code.

You can have Fluent running on a remote machine. The environment of Fluent and of Matlab can be substantially different without conflicts.

Thank you

Sorin
cfdman10 is offline   Reply With Quote

Old   December 4, 2019, 04:51
Default
  #8
New Member
 
Abdelrahman
Join Date: Dec 2019
Posts: 6
Rep Power: 6
Abdelrahman91 is on a distinguished road
could you give me your email please ?
Abdelrahman91 is offline   Reply With Quote

Old   December 4, 2019, 04:53
Default
  #9
New Member
 
Abdelrahman
Join Date: Dec 2019
Posts: 6
Rep Power: 6
Abdelrahman91 is on a distinguished road
Sorin , i want your email address please
Abdelrahman91 is offline   Reply With Quote

Old   December 4, 2019, 04:53
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I hope Sorin is smart enough not to give his email address. If you have questions, you should ask them here, then there are more people who can answer, and more people who can learn from the answer.
pakk is offline   Reply With Quote

Old   December 4, 2019, 05:08
Default
  #11
New Member
 
Abdelrahman
Join Date: Dec 2019
Posts: 6
Rep Power: 6
Abdelrahman91 is on a distinguished road
Okay i will make a post with my problem so everyone can see and learn from the answers ( i wish to get answers for it )
Abdelrahman91 is offline   Reply With Quote

Old   December 4, 2019, 05:21
Default
  #12
New Member
 
Abdelrahman
Join Date: Dec 2019
Posts: 6
Rep Power: 6
Abdelrahman91 is on a distinguished road
I have MATLAB Code and i need to take the output from MATLAB which is temperature value and use it as Input in ANSYS FLUENT at on specific boundary condition then i will solve ansys and get heat transfer coefficient (HTC) and i want to take the HTC value from ANSYS FLUENT and use it in MATLAB code again to get new value for the temperature and this is a repeated cycle.
Abdelrahman91 is offline   Reply With Quote

Old   December 4, 2019, 09:31
Default
  #13
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
You forgot to ask your question. Which step is giving you problems?
pakk is offline   Reply With Quote

Old   December 4, 2019, 09:39
Default
  #14
New Member
 
Abdelrahman
Join Date: Dec 2019
Posts: 6
Rep Power: 6
Abdelrahman91 is on a distinguished road
I want to know how to make this coupling using matlab toolbox ansysaas...i spent too much time to find any tutorial for this toolbox but unfortunately I didn't find any useful information except Sorine answers that's why I asked for his email but you told it's against the rules.
Abdelrahman91 is offline   Reply With Quote

Old   December 4, 2019, 09:41
Default
  #15
New Member
 
Abdelrahman
Join Date: Dec 2019
Posts: 6
Rep Power: 6
Abdelrahman91 is on a distinguished road
So Could you please help me ?
Abdelrahman91 is offline   Reply With Quote

Old   December 4, 2019, 23:01
Default
  #16
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
coupling technique through running fluent as server (fluent aas) works
google "fluent ass"
for instance https://www.ansys.com/blog/ansys-fluent-matlab-example
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 5, 2019, 05:32
Default
  #17
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Abdelrahman91 View Post
I want to know how to make this coupling using matlab toolbox ansysaas...i spent too much time to find any tutorial for this toolbox but unfortunately I didn't find any useful information except Sorine answers that's why I asked for his email but you told it's against the rules.
I never said it was against the rules. I said it is not efficient to ask for a mail address and then ask the question, it is smarter to ask it directly here.

Sorin posted this message more than three years ago, and posted his last message on this board more than two years ago. He might not visit this board anymore, or not work with the toolbox anymore.
pakk is offline   Reply With Quote

Reply

Tags
compile, fluent, libudf.dll, matlab


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
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 00:53
problem with compiling boundary condition udf in parallel mode chem engineer Fluent UDF and Scheme Programming 11 June 29, 2015 06:23
having problem in writing a UDF for specific heat in fluent 14.0 nands_bullwalker Fluent UDF and Scheme Programming 1 June 29, 2013 10:32
PROBLEM in UDF on parallel fluent mode rakadit Fluent UDF and Scheme Programming 0 July 13, 2012 06:51
Problem with compiling the UDF raghu mohan Fluent UDF and Scheme Programming 10 December 16, 2011 23:34


All times are GMT -4. The time now is 14:56.