# Fluent UDF - Random Noise

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 18, 2008, 11:28 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="" "/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.

 March 19, 2008, 07:38 Re: Fluent UDF - Random Noise #2 Tanner Guest   Posts: n/a I have managed to hook the UDF I wanted using the compile function rather than the intrepreted function. My only concern now is how often the UDF is updated. I want a random profile at each time step NOT iteration. I have found that including an "if (first_iteration)" statement produces works for unsteady PISO but is this suitable for NITA? How frequently are profiles updated for NITA? How can I tell it to update at the start of each time step?

 May 29, 2014, 03:27 #3 Senior Member   Svetlana Tkachenko Join Date: Oct 2013 Location: Australia Posts: 144 Rep Power: 5 looking at your code, it looks like U is "1.0 + random noise" on the first time step, and "2.0 + random noise" on next time steps. Would you happen to know how to make it "U_old + random noise" instead please?

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Lior FLUENT 0 November 8, 2004 04:07 Yong FLUENT 3 April 6, 2004 03:52 Yong FLUENT 0 April 1, 2004 21:13 David FLUENT 0 September 6, 2002 10:49 jon FLUENT 0 March 18, 2002 05:18

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