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

Running Fluent from Python: UDF Compilation problems

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By AlexanderZ
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 12, 2020, 11:10
Default Running Fluent from Python: UDF Compilation problems
  #1
New Member
 
-
Join Date: Oct 2020
Posts: 22
Rep Power: 6
Ames is on a distinguished road
Hi all!

I am working on a 2D model in Ansys Fluent, which eventually I want to couple with a 1D model written in Python (multi-scale modelling). Therefore I am trying to run Fluent from Python. In Python I am able to launch Fluent as a server via a system command:

FluentArgs = 'fluent 2ddp -aas'
os.system(FluentPath + " " + FluentArgs)


Then I am able to connect Python with the Fluent server. The implementation is similar to the implementation for the Matlab-Fluent coupling as described in looking for a smart interface matlab fluent (step 6) by Sorin. I have first implemented it in Matlab, but I did get the same problem as with Python as described below. I switched to Python for the coupling with the 1D model.

I can drive Fluent by sending a journal file (via DoMenuCommand) to the Fluent Server, so that the server runs a certain case. But now I am trying to compile a UDF (written in C), but I receive the following error:

“ ‘nmake’ is not recognized as an internal or external command, operable program or batch file “

I know that this error has something to do with my UDF code not being compiled, as the nmake.exe file cannot be found. I have come across this problem before when I was trying to compile a UDF code from Fluent’s GUI and I have managed to solve this problem by installing Microsoft Visual Studio Community 2017 and running Fluent from Visual Studio’s Command Prompt, as has been suggested on several forums here.

As I am launching Fluent now as a server from Python, I don’t know how to solve this ‘nmake’ error. Does anyone have experience with running Fluent from Python and compiling UDF code in a Windows os?

I am working in Windows 10 (64-bit), Python 3.7 and I have installed Microsoft Visual Studio Community 2017. For Fluent I am using the Workbench’s student version 2020R2.

Any suggestions are welcome. Thanks for your help!

Edit: I am able to start Fluent from the Windows cmd and compile a UDF. However, when starting Fluent as a server from Python or from MS Visual Studio, I receive the same error about 'stdio.h: no such file or directory'.

Last edited by Ames; November 14, 2020 at 14:36.
Ames is offline   Reply With Quote

Old   November 16, 2020, 00:35
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I recommend you to change UDF, so you would not recompile it again.
you may read parameters from file or define rpvars and control values from journal
__________________
best regards


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

Old   November 16, 2020, 04:26
Default
  #3
New Member
 
-
Join Date: Oct 2020
Posts: 22
Rep Power: 6
Ames is on a distinguished road
Hi Alexander,

Thanks for your help! I will look into it to see if I can make it work for my case.

So if I understand it correctly, you mean by changing the UDF, replacing it by txt-files prescribing values at certain time points?
And what do you mean by recompiling? When I try to build a library and load the UDF into my case, I do make sure that the libary (libudf or something like that) does not exist yet.

/define/user-defined/compiled-functions compile libudf2 yes "3WK.c" "" ""
/define/user-defined/compiled-functions load libudf2
Ames is offline   Reply With Quote

Old   November 16, 2020, 05:35
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
lets start with this question:
why do you need to compile UDF for each new case?
Ames likes this.
__________________
best regards


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

Old   November 16, 2020, 05:51
Default
  #5
New Member
 
-
Join Date: Oct 2020
Posts: 22
Rep Power: 6
Ames is on a distinguished road
You are right that I don't need to compile the UDF for each new case, as the parameters etc. in the UDF will remain the same for all cases (for now). I am using the UDF to set the pressure at the outlet based on the flow at the outlet (Windkessel model).

However, is it possible to compile the UDF once from Python? So that I can load the same library for different cases.

I really appreciate your help!
Ames is offline   Reply With Quote

Old   November 16, 2020, 07:12
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
if the code is the same for cases, you don't need to compile UDF each time.
Compile once without python. Then you may just load precompiled library using python.

I don't know how to compile UDF from fluent aas
Ames likes this.
__________________
best regards


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

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
looking for a smart interface matlab fluent chary FLUENT 24 June 18, 2021 10:07
Compiling UDF in FLuent ekha FLUENT 6 July 3, 2019 04:02
The fluent stopped and errors with "Emergency: received SIGHUP signal" yuyuxuan FLUENT 0 December 3, 2013 23:56
Kubuntu uses dash breaks All scripts in tutorials platopus OpenFOAM Bugs 8 April 15, 2008 08:52
Problems in lauching FLUENT Lourival FLUENT 3 January 16, 2008 17:48


All times are GMT -4. The time now is 06:41.