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

Error in program to generate fluctuating velocity

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 5, 2017, 02:41
Default Error in program to generate fluctuating velocity
  #1
New Member
 
Ashutosh Sharma
Join Date: Jan 2017
Posts: 11
Rep Power: 9
ashu@123 is on a distinguished road
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

main()
{
int step, i, k;
float I, Lxu, U, u, pi, A, B, t, dt, nUpper, nLower, dn, n, phi, Su, sum, Ak;
double r;
char filename[8];
FILE *fp;
/*================================================= ========*/
printf ("Enter name of file to write to:");
scanf("%s", filename);
fp = fopen(filename,"w");
printf ("Enter the streamwise mean velocity:");
scanf("%f", &U);
printf ("Enter the streamwise turbulent intensity (decimal):");
scanf("%f", &I);
printf ("Enter the streamwise integral length scale (m):");
scanf("%f", &Lxu);
printf ("Number of timesteps, maximum 20000:");
scanf("%d", &step);
printf ("Stepsize of time in second:");
scanf("%f", &dt);
pi = 3.141592654;
A = 4.0*I*I*Lxu*U;
B = 70.8*(Lxu/U)*(Lxu/U);
nUpper=1.0/2.0/dt;
nLower=0.001;
dn=(nUpper-nLower)/step; /* here taking N = M = step */
t = 0;
for (i=0; i<step; i++)
{
sum = 0.0;
srand48(time(NULL));
n = nLower+0.5*dn;
for(k=0; k<step; k++)
{
r = drand48();
phi=r*2.0*pi; /*phi to be randomly selected*/
Su = A/pow((1.0 + B*n*n),(5.0/6.0));
Ak = sqrt(Su*dn);
sum = sum + Ak*cos(2.0*pi*n*t + phi);
n = n+dn;
}
u = sqrt(2.0)*sum;
fprintf(fp,"%f\n",u);
t = t + dt;
}
fclose(fp);
}




Above program is to generate fluctuating velocity components.
While running above program, i am getting following error:

undefined reference to 'srand48'
undefined reference to 'drand48'

can anyone suggest me where is the problem in above program.
Thank You in advance.
ashu@123 is offline   Reply With Quote

Reply


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
[OpenFOAM] Annotate velocity of specific cell or point jwstolk ParaView 4 August 5, 2016 05:50
LES and TKE calculations MST Main CFD Forum 3 May 30, 2016 06:26
How to obtain the fluctuating velocity in Fluent ? wyungh FLUENT 1 January 22, 2016 12:12
Radial velocity and tangential velocity on centrifugal fan, johnnyp FLUENT 2 May 24, 2013 07:10
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 15:45


All times are GMT -4. The time now is 23:33.