CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Random function UDF for boundary condition (https://www.cfd-online.com/Forums/fluent/31162-random-function-udf-boundary-condition.html)

 Chris March 28, 2003 13:10

Random function UDF for boundary condition

Hi,

Does anyone know what to write in the UDF if I would like to generate a randomly varying pressure input? Is the command

rand()

or something?

 Chris March 28, 2003 14:08

Re: Random function UDF for boundary condition

Actually, I want to do this because I would like to obtain a frequency response of a probe that I am modeling...

I figured that if I subject the system to a random input, and generate some output files, I can process the data in MATLAB or something to plot the frequency response curve...

I hope this bit of background information helps whoever's able to give me advice!

Gracias!

 Alex Munoz March 28, 2003 14:28

Re: Random function UDF for boundary condition

Hi Chris

I have not used a random function in a UDF, however, you must be careful rand() function in C provides a uniform random number betweem 0 to RAND_MAX=32767 (always integer). Therefore I you want to generate a random number between 0 to 1 you have to divide the rand()/RAND_MAX. Don't know forget to feed somehow a seed generator for the random number srand()

In addition if you want to generate a normal distribution function a "bell" shape, you must to use another function, which potentially you could download.

Regards

Alex

 Chris March 28, 2003 14:39

Re: Random function UDF for boundary condition

 Alex Munoz March 28, 2003 16:38

Re: Random function UDF for boundary condition

My friend

type on google "random number generation in C" or something related to the type of distributio that you need gauss, binomial, poisson etc.

Regards

Alex

 All times are GMT -4. The time now is 00:18.