ehkh
Subscriber

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 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