CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Problem in compiling fluent UDF lunched from MATLAB (https://www.cfd-online.com/Forums/fluent-udf/178468-problem-compiling-fluent-udf-lunched-matlab.html)

cfdman10 October 8, 2016 16:01

Problem in compiling fluent UDF lunched from MATLAB
 
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

pakk October 10, 2016 03:13

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.

Sorin October 10, 2016 16:54

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 (Post 620776)
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 October 13, 2016 12:42

Quote:

Originally Posted by pakk (Post 620868)
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

cfdman10 October 13, 2016 13:35

Quote:

Originally Posted by Sorin (Post 620940)
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

Sorin October 13, 2016 14:12

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 (Post 621389)
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 October 13, 2016 16:10

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 (Post 621396)
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


Abdelrahman91 December 4, 2019 04:51

could you give me your email please ?

Abdelrahman91 December 4, 2019 04:53

Sorin , i want your email address please

pakk December 4, 2019 04:53

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.

Abdelrahman91 December 4, 2019 05:08

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 December 4, 2019 05:21

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.

pakk December 4, 2019 09:31

You forgot to ask your question. Which step is giving you problems?

Abdelrahman91 December 4, 2019 09:39

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 December 4, 2019 09:41

So Could you please help me ?

AlexanderZ December 4, 2019 23:01

coupling technique through running fluent as server (fluent aas) works
google "fluent ass"
for instance https://www.ansys.com/blog/ansys-fluent-matlab-example

pakk December 5, 2019 05:32

Quote:

Originally Posted by Abdelrahman91 (Post 751499)
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.


All times are GMT -4. The time now is 08:09.