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

Fluent UDF - Random Noise

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   March 18, 2008, 10:28
Default Fluent UDF - Random Noise
  #1
Tanner
Guest
 
Posts: n/a
I am trying to implement a constant time dependent (step) velocity normal to the boundary at the inlet of my simulation. I would also like to include some random nosie with zero mean. I am not an expert in C but i patched together the script below:

#include "udf.h"

#include "stdlib.h"

DEFINE_PROFILE(Velocity_profile,thread,index) {

face_t f;

double Flow_Time;

double U;

double Random_Number_Array[100000] = {0.0};

double Mean = {0.0};

int Number_of_Face_Nodes;

int i;

int Counter = {0};

//Find number of nodes on face//

Number_of_Face_Nodes = F_NNODES(f,thread);

//Find simulation time//

Flow_Time = RP_GET_REAL("flow-time");

if (Flow_Time < 1.0)

U = 1.0;

else

{

U=2.0;

}

//Generate Random numbers for each node on inflow face//

//The range is set to -0.5 to 0.5//

for (i=1 ; i < Number_of_Face_Nodes ; i++)

{

srand();

Random_Number_Array[i] =(((double) rand()/(double) RAND_MAX)-0.5)*((double) 2);

Mean = Mean + Random_Number_Array[i]; }

Mean = Mean/(double) Number_of_Face_Nodes;

//Ensure that mean is zero//

for (i=1 ; i < Number_of_Face_Nodes ; i++)

{Random_Number_Array[i] = Random_Number_Array[i] - Mean;}

begin_f_loop(f,t)

{

Counter = Counter + 1;

//Velocity at each node is U + differenc Random fluctuation//

F_PROFILE(f, thread, index) = U + Random_Number_Array[Counter];

}

end_f_loop(f,t) }

I think this is a good start though I cannot get fluent (6.3.26) to interpret it. I get the error:

cpp -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/src" -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/cortex/src" -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/client/src" -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/multiport/src" -I. -DUDFCONFIG_H="<udfconfig.h>" "/work/tanner/LES_Unsteady/OCPS2_Forced/test.c" In file included from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/stdlib.h:33: stddef.h: No such file or directory In file included from /usr/include/sys/types.h:31,

from /usr/include/stdlib.h:433,

from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/bits/types.h:31: stddef.h: No such file or directory In file included from /usr/include/stdlib.h:433,

from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/sys/types.h:147: stddef.h: No such file or directory In file included from /usr/include/stdlib.h:606,

from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/alloca.h:25: stddef.h: No such file or directory Error: /usr/include/stdlib.h: line 108: syntax error. cpp: output pipe has been closed

I would certainly appreciate some help. I'm not sure how to get fluent to find the stdlib.h though it is installed on my computer. Many thanks.

  Reply With Quote

 


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
Random Injections Lior FLUENT 0 November 8, 2004 03:07
how to call the random function in Fluent Yong FLUENT 3 April 6, 2004 03:52
random number in Fluent Yong FLUENT 0 April 1, 2004 21:13
Could Fluent simulate random process? David FLUENT 0 September 6, 2002 10:49
NEW flow-induced noise module in FLUENT 6?? jon FLUENT 0 March 18, 2002 04:18


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