Compiling UDF in FLuent
Hi,
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).\n\nThe 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: Code:
#include "udf.h" I tried both serial and parallel and got same error. I have installed the latest version of visual studio Restarted the machine I tried to launch Fluent from the VS command window I have set up the Path in the environment variable correctly as below: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools; C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC; C:\Program Files\ANSYS Inc\v192\fluent; I get help from Ansys Community and CFD-online and links below: https://www.researchgate.net/post/UD..._to_avoid_this https://www.cfd-online.com/Forums/fl...df-windows-10- a.htmlhttps://www.youtube.com/watch?v=xt2hnE9_LdM&lc=z230wdny3yqwdf2y004t1aokgot sclzxfp5jetjrb2a3rk0h00410.1540346039732132 BUT still facing the same problem ! Could you please guide me how to get this error solved. Please note that I am using Fluent v19.2 running parallel processor and Visual Studio v2019. Many Thanks. |
1 Attachment(s)
Hi Ekha,
I have some suggestions for your code. Please find the attached file. Hope this help, |
when compiling: push BUILD button, not load
best regards |
Quote:
I do BUILD the UDF before Loading it, It builds successfully but I face the problem when trying to load it. However, even I am getting this error, I found a 'libudf' file in the directory but the UDF does not come out in the drop down menu in heat flux boundary condition dialog box.:confused: |
it means your UDF is not compiled
try again and put here FULL log best regards |
Hi,
It works! I used visual studio 2017 instead of 2019 since the latter is not compatible with ANSYS 19.2. |
Hi,
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 modified the UDF based on your suggestions, so that each cell on the bottom layer has different random number of heat flux, srand function is used. Here is the UDF I used: #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 |
All times are GMT -4. The time now is 03:18. |