|
[Sponsors] |
Running Fluent from Python: UDF Compilation problems |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 12, 2020, 11:10 |
Running Fluent from Python: UDF Compilation problems
|
#1 |
New Member
-
Join Date: Oct 2020
Posts: 22
Rep Power: 6 |
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. |
|
November 16, 2020, 00:35 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
November 16, 2020, 04:26 |
|
#3 |
New Member
-
Join Date: Oct 2020
Posts: 22
Rep Power: 6 |
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 |
|
November 16, 2020, 05:35 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
lets start with this question:
why do you need to compile UDF for each new case?
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 16, 2020, 05:51 |
|
#5 |
New Member
-
Join Date: Oct 2020
Posts: 22
Rep Power: 6 |
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! |
|
November 16, 2020, 07:12 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |