-
-
June 20, 2019 at 2:38 pm
ehkh
SubscriberHi,
I am facing errors while trying to do interpretation or compilation for a UDF in fluent.
I am simulating a 2D rectangular cavity with the following boundary conditions: adiabatic top layer, periodic side walls and rigid bottom with thermal heat flux and small random perturbations following this equation: dT/dy= -exp(-h)+ epsilon*[rand(x)-0.5] , where rand is a one dimensional array of random numbers uniformly distributed in the range of [0,1].
I used a UDF to assign the heat flux and perturbation to the bottom layer. When I used interpretation of UDF, I get an error notifying that:Â srand: undeclared variable.
When trying to compile it, I get an error notifying that: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).nnThe system cannot find the file specified. however, the UDF source files are in the directory that contains my case and data files.
Â
Following the UDF I am using to set up the boundary condition at the bottom layer:
Â
Â
#include "udf.h"
#include "stdlib.h"Â Â Â Â Â Â Â Â /* srand and rand */
#include "time.h"
#include "random.h"
Â
#define RAND_MAX 32767
Â
Â
DEFINE_PROFILE(Temp_rand_pertubation_bottom,thread,index)
{
Â
real x[ND_ND]; /* this will hold the position vector */
Â
face_t f;
Â
real time= CURRENT_TIME;
Â
Â
float h,E,r;
Â
srand((unsigned)time(NULL));Â Â Â Â /*Â this to specify a different random number at each cell */
k=0.6Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* thermal conductivity */
T=300Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Temp in Kelvin */
h = 0.5; /* cavity height */
E= 0.01; /* epsilon constant value */
Â
Â
 begin_f_loop_all(f,thread)
{
r= rand()/float(RAND_MAX);Â Â Â Â /* r is a 1D array of random numbers uniformly distributed in the range of [0,1] */
 Â
F_CENTROID (x,f,thread);
Â
F_PROFILE(f,thread,index) = k*T*(- exp(-h)+E*(r-0.5))/h;Â Â Â Â Â /* apply random perturbation */
}
 end_f_loop_all(f,thread);
Â
void srand(unsighned int seed);
}
Â
Â
Â
To avoid these errors, please advice me whether my UDF need to be corrected or modified, or its something to do with fluent itself.
Â
Many thanks
Esra'a
-
June 20, 2019 at 4:28 pm
Rob
Forum ModeratorCheck on the compiled error: is there something about "nmake" not being recognised?
-
June 21, 2019 at 3:42 am
ehkh
SubscriberCan you please give me more clarification what you meant by "nmake"?
If I understood you, I get nothing about "nmake", the error that I get is as follows:Â
The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).nnThe system cannot find the file specified.
However, even I am getting this error, I found a libudt file in the directory but the UDF does not come out in the drop down menu in heat flux boundary condition dialog box.
Â
-
June 21, 2019 at 8:18 am
DrAmine
Ansys EmployeeDo you have compiler installed? Can you check with a dummy Hello World dummy DEFINE_ON_DEMAND UDF.?
-
June 21, 2019 at 9:14 am
Rob
Forum ModeratorUDFs can fail to compile due to coding errors and/or lack of a compiler. The former usually gives a string of errors, the latter complains about nmake not being present/recognised. As there is then no libudf to load you get the error you're seeing.Â
-
June 24, 2019 at 3:23 am
ehkh
SubscriberHi,
Â
Thanks for your reply.
In order to solve the problem, I have installed the latest version of visual studio, restarted the machine, set up the Path in the environment variable correctly as below:
C:Program Files (x86)Microsoft Visual Studio2019CommunityCommon7Tools;
C:Program Files (x86)Microsoft Visual Studio2019CommunityVC;
C:Program FilesANSYS Incv192fluent; Â
BUTÂ still facing the same problem ! Â
Could you please guide me how to get this error solved. Â
Thanks
-
June 24, 2019 at 10:01 am
Rob
Forum ModeratorWhich means it's not compiling. Are you getting the "nmake" not recognised or a list of errors on the code? Check in the Installation section for the former (I think we're still using Visual Studio 2017).Â
-
June 24, 2019 at 11:11 am
ehkh
SubscriberThanks for your reply.
I don't get anything related to "nmake" or error in the code. the only error error I get exactly copied from the TUI:
Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).nnThe system cannot find the file specified.
nnF:esraworked simulations2Drayleigh benard convectionRectCavityHeatfluxPatterson2015RecyCavityHeatflux_filesdp0FFFMECHlibudfwin642ddp_hostlibudf.dll
Error Object: #f
Regarding Visual studio, I have installed v2019, do I need to install v2017 to be compatible with Fluent 19.2 ??
Â
Â
Â
-
June 24, 2019 at 3:19 pm
Rob
Forum ModeratorWhich just means the UDF isn't compiled. I'll move to installation, but please review the various threads on compilers as I suspect that'll resolve this problem.Â
-
June 24, 2019 at 9:26 pm
tsiriaks
Ansys EmployeePlease use Visual Studio 2017, the current ANSYS versions won't work with 2019 without certain modifications in the script.
Try VS 2017 and make sure that you don't have space anywhere in path, folder names, case and data files (I see you have plenty of them)
-
June 26, 2019 at 2:50 am
ehkh
SubscriberThanks for your reply.
Do you recommend to use ANSYS 19.2 or 18.2 to be compatible with VS 2017 ??
Â
Thanks
-
June 26, 2019 at 3:39 pm
tsiriaks
Ansys EmployeeANSYS 2019 R# is ok, no need for older versions.
Thanks,
Win
-
July 2, 2019 at 1:44 pm
ehkh
SubscriberIt works!! Thanks.
-
July 2, 2019 at 4:56 pm
tsiriaks
Ansys EmployeePerfect ! Thank you for the update.
Win
-
July 3, 2019 at 6:57 am
ehkh
SubscriberHi,
When using the UDF at the bottom layer, I supposed to see plumes or rolls on the temperature contour profile.
BUT I didn't, what I get is a simple diffusion problem.
I wrote the UDF so that each cell on the bottom layer has different random number of heat flux, I used the srand function.
Here is my UDF:
#include "udf.h"
Â
#include "stdlib.h"Â Â Â Â Â Â Â
/* srand and rand */
Â
#include "random.h"
Â
#include "time.h"
Â
/*#define RAND_MAX 32767*/
Â
#define k 0.6Â Â Â Â Â Â Â Â Â
/* thermal conductivity */
Â
#define T 300Â Â Â Â Â Â Â Â
/* Temp in Kelvin */
Â
DEFINE_PROFILE(Temp_rand_pertubation_bottom,thread,index)
Â
{
Â
real x[ND_ND];Â
/* this will hold the position vector */
Â
face_t f;
Â
real time = CURRENT_TIME;
Â
float h = 0.5;
float E = 0.01;
Â
srand((unsigned int) time);Â Â Â Â Â
/*this to specify a different random number at each cell*/
Â
begin_f_loop_all(f,thread)
Â
{
Â
float r = (rand() / RAND_MAX);Â Â Â Â
/* r is a 1D array of random numbers uniformly distributed in the range of [0,1] */
Â
F_CENTROID (x,f,thread);
Â
F_PROFILE(f,thread,index) = k*T*(- exp(-h)+E*(r-0.5))/h;Â Â Â Â Â
/* apply random perturbation */
Â
}
Â
end_f_loop_all(f,thread);
Â
Â
void srand(unsigned int seed);
Â
}
Â
please advice me whether I need to modify the code.
Â
Many thanks for your valuable help.
Esra'a
Â
Â
Â
Â
Â
-
July 3, 2019 at 2:52 pm
Rob
Forum ModeratorWhat is the material density?
-
July 4, 2019 at 12:21 am
ehkh
SubscriberI am using water as a fluid at 300K , so the density is 997 Kg/m3.
please not that I am using a laminar unsteady model.
Thanks
-
July 16, 2019 at 6:00 am
ehkh
SubscriberÂ
Â
Hi Â
I am still struggling with this...Â
Â
I modified My UDF so that each face on the bottom layer has different random number of heat flux, using the uniform_random() function and included this in the profile equation. Compiled successfully and hooked as a thermal boundary condition for heat flux. My UDF returns the correct value I am looking for.
Â
BUT still not getting plumes or rolls on the temperature contour profile, as I am using a laminar transient simulation with Rayleigh number equals to 10^9. I am expecting to see something similar to previous work done using SNS code. Please refer to Figure 6 in the Journal article (Hattori et. at, 2015)
https://doi.org/10.1016/j.ijheatmasstransfer.2015.03.060
Â
could you please advice me what is the correct setup for heat flux boundary condition. I went through the boundary conditions section in the manual but could not figure out an answer to my question.
Â
Thanks
Esra'a -
July 16, 2019 at 5:56 pm
tsiriaks
Ansys EmployeeYou may have to create a new thread in Physics Simulation -> Fluid Dynamics section , then include the url of this thread for reference. You should get more responses in that section.
Thanks,
Win
-
- The topic ‘UDF Compilation and Interpretation Error’ is closed to new replies.
-
6575
-
1906
-
1463
-
1311
-
1022
© 2026 Copyright ANSYS, Inc. All rights reserved.