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/)
-   -   Error in compiling UDF (https://www.cfd-online.com/Forums/fluent-udf/218348-error-compiling-udf.html)

kirti verma June 18, 2019 03:36

Error in compiling UDF
 
Hi all!
I am trying to define the rate of reaction using UDF, i tried to interprete the UDF but it didn't work so I have been trying to compile it.
I have opened fluent through x86 Native Tools Command Prompt for VS 2017, now I changed the working directory to the folder where my case data and udf file has been stored. I then tried to compile, it shows following:

Copied Z:\Desktop\All Simulations\udf reaction try_files\dp0\FFF-1\Fluent/New Text Document.c to libudf\src
udf_names.c and user_nt.udf files in 3ddp_host are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v193\fluent"\fluent 19.3.0\src\udf\makefile_nt.udf "libudf\win64\3ddp_host\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_host")
udf_names.c and user_nt.udf files in 3ddp_node are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v193\fluent"\fluent 19.3.0\src\udf\makefile_nt.udf "libudf\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_node")
Done.


and on Loading it, this error shows:

Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).\n\nThe system cannot find the file specified.
\n\nZ:\Desktop\All Simulations\udf reaction try_files\dp0\FFF-1\Fluent\libudf\win64\3ddp_host\libudf.dll
Error Object: #f



I have tried changing from parallel to serial as well, but it doesn't work, Please someone help me I would be very Grateful :)

AlexanderZ June 18, 2019 04:00

make any change in source file (press space and delete it)
recompile

best regards

kirti verma June 18, 2019 04:03

Thankyou for the prompt reply, I have checked making changes in source files, I am getting the same result. The problem still persists.

This is my UDF Code:
#include "udf.h"

DEFINE_VR_RATE(vol_reac_rate,c,t,r,wk,yk,rate,rr_t )
{
real ci, prod;
int i;

/* Calculate Arrhenius reaction rate */

prod = 1.;

if (FLUID_THREAD_P(t) && THREAD_VAR(t).fluid.porous)

for(i = 0; i < r->n_reactants; i++)
{
ci = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];
prod *= pow(ci, r->exp_reactant[i]);
}
*rate = r->A * exp( - r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) *
pow(C_T(c,t), r->b) * prod;

else
*rate = 0.;

*rr_t = *rate;

/* No "return..;" value. */
}

AlexanderZ June 18, 2019 23:58

Code:

#include "udf.h"

DEFINE_VR_RATE(vol_reac_rate,c,t,r,wk,yk,rate,rr_t )
{
real ci, prod;
int i;

/* Calculate Arrhenius reaction rate */

prod = 1.;

if (FLUID_THREAD_P(t) && THREAD_VAR(t).fluid.porous)
{
for(i = 0; i < r->n_reactants; i++)
{
ci = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];
prod *= pow(ci, r->exp_reactant[i]);
}
*rate = r->A * exp( - r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) *
pow(C_T(c,t), r->b) * prod;
}
else
*rate = 0.;

*rr_t = *rate;

/* No "return..;" value. */
}

I've compiled it with no errors

this is output you should get
Code:

Copied path_to_working_folder.        temp_delete.c to temp_delete\src
udf_names.c and user_nt.udf files in 3ddp are upto date.
(system "copy "fluent_path"temp_delete\win64\3ddp\makefile" ")
        1 file(s) copied.
(chdir "temp_delete")(chdir "win64\3ddp")# Generating ud_io1.h
temp_delete.c
# Generating udf_names.c because of makefile temp_delete.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj temp_delete.obj
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

  Creating library libudf.lib and object libudf.exp

Done.


kirti verma June 19, 2019 02:39

Can you please answer a few doubts, it will be really helpful for me as i am a beginner, this is what is shows to me:

Copied Z:\Desktop\All Simulations\compilation_files\dp0\FLU\Fluent/New Text Document.c to libudf\src
udf_names.c and user_nt.udf files in 3ddp_host are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v193\fluent"\fluent 19.3.0\src\udf\makefile_nt.udf "libudf\win64\3ddp_host\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_host")udf_names.c and user_nt.udf files in 3ddp_node are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v193\fluent"\fluent 19.3.0\src\udf\makefile_nt.udf "libudf\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_node")



1. Did you open Fluent from VS Prompt or simply from workbench?
2. Did you tried it with some boundary conditions/ geometry or geometry doesn't have any affect of compilation?
3. Did you select Parallel or Serial processing?
4. Can you send a link where the method of compilation that you used is mentioned, I have tried many methods but none worked.

I will be really grateful to you and this platform for this. I have tried all the possible combinations of methods of compilation.

kirti verma June 19, 2019 03:06

As far as I can conclude, there must be some problem in setting up environment variables. I haven' t done it because I don't have admin access. Will you please let me know the procedure?

AlexanderZ June 20, 2019 00:41

Quote:

1. Did you open Fluent from VS Prompt or simply from workbench?
2. Did you tried it with some boundary conditions/ geometry or geometry doesn't have any affect of compilation?
3. Did you select Parallel or Serial processing?
4. Can you send a link where the method of compilation that you used is mentioned, I have tried many methods but none worked.
you should run fluent from VS Prompt (or SDK prompt, depending on your software)

it doesn't matter what settings or geometry you have for compiling process. It doesn't matter single or parallel regime you are using (but you should know, if your compile in parallel regime -> you will get UDF for parallel only, same for serial)

as I told you, Fluent consider your source file is up to date. So Fluent doesnt compile it. You should make any change in source file, save it and compile (click BUILD)

if you are not sure about your software, you may use following link https://www.cfd-online.com/Wiki/Flue...ows_7_64bit.3F

best regards

kirti verma June 27, 2019 06:17

1 Attachment(s)
Hey! I have tried these solutions, added environment variables from the "Advanced System Settings" too but it didn't work. I am working on the following system.

Fluent Version - ANSYS 2019 R1
Windows 10, 64 bit
Microsoft Visual C++ 2017

I have attached the screenshot of the error I am getting, basically the file "libudf.dll" is not being formed in the folder.

Copied Z:\Desktop\All Simulations\compilation_files\dp0\FFF\Fluent/New Text Document.c to libudf\src
udf_names.c and user_nt.udf files in 3ddp_host are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v193\fluent"\fluent 19.3.0\src\udf\makefile_nt.udf "libudf\win64\3ddp_host\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_host")'nmake' is not recognized as an internal or external command,
operable program or batch file.
udf_names.c and user_nt.udf files in 3ddp_node are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v193\fluent"\fluent 19.3.0\src\udf\makefile_nt.udf "libudf\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_node")'nmake' is not recognized as an internal or external command,
operable program or batch file.

Done.


This is after Build command,
and the screenshot is of after the Load command.

Please let me know if I have to reinstall Visual Studio and make it work with the Fluent or what steps to follow. I would be very grateful.
Thanks

melj February 6, 2020 12:42

Hello Kirti Verma

I am facing the same issue. Could you please let me know the correction if you have figured it out?

vinerm February 6, 2020 14:40

Command prompt or udf.bat
 
nmake not recognized means the paths are not set properly. Either you have to ensure that udf.bat is able to execute properly without any error. This is location in Fluent's installation directory. Other solution is to start Fluent from the command prompt of VS or VC++ or MS SDK.

melj February 7, 2020 11:32

Apologies! Kindly ignore this message. I have sent the correct message again.

melj February 7, 2020 11:39

Thank you very much. I have got it corrected.

One question. I loaded a udf for drag model. I chose the respective drag model in the respective dialogue box. I saved the file. When I read the case and data file later, I can see in the console window that the udf is read. However, when I check the drag model dialogue box, it just shows user defined instead of the name of the new drag model.

Is this how it should be?

vinerm February 9, 2020 15:02

That's alright
 
If Fluent shows UDF instead of in-built drag models, then UDF is selected. If it is shows blank, it implies that Fluent expectes and UDF but the UDF library is not loaded.


All times are GMT -4. The time now is 13:47.