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

UDF for reading velocity values and adding random perturbation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2016, 01:46
Post UDF for reading velocity values and adding random perturbation
  #1
New Member
 
Join Date: Jun 2015
Location: Australia
Posts: 15
Rep Power: 11
Jomid is on a distinguished road
Hi,

I have a pipe whose inlet has 3312 elements. Inlet velocity at each cell is different than the others so that I have all those velocities. I would like to write a udf which reads all the velocity inlet data given in a text file, with 1 column and 3312 rows, and add them to random numbers generated by a wave equation, available in the same udf. Note that the random number generated by the wave equation varies as time elapses so at different time steps the code adds different numbers to the velocity inlet profile values. Then, the code takes the 3312 new velocities as new inlet velocities for the corresponding cells.
The code can be interpreted and works without any errors. However, I realised that, it is malfunctioning. I guess the problem is that it does not read the 3312 initial inlet profile values or does not add them with the value computed by the wave equation so that the velocity at the inlet is just a small value generated by the wave equation.
Here is my Code:

#include "udf.h"

double Velocity[3312];
FILE *fp;
DEFINE_INIT(read_data, d)
{
int i;
fp=fopen("velocit.txt","r");
for (i=1;i<3312;i++)
{
fscanf(fp,"%ld", &Velocity[i]);
}
fclose(fp);
}

DEFINE_PROFILE(temporal_wave, thread, position)
{
real coord[ND_ND];
real x;
face_t f;
real t = CURRENT_TIME;
int i = t;
begin_f_loop(f, thread)
{
F_CENTROID(coord,f,thread);
x=coord[1];
F_PROFILE(f, thread, position) = Velocity[i] + 0.003*sin(500.*t);
}
end_f_loop(f, thread)
}

Could you please have look at my code and let me know where the potential error(s) is coming from.
Regards
Joe
Jomid is offline   Reply With Quote

Reply

Tags
perturbation, reading text file, udf, variable velocity


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
How I can introduce my power heat (W) in chtMultiRegionFoam? aminem OpenFOAM Pre-Processing 32 August 29, 2019 03:23
adding values to transportProperties in interFoam dgadensg OpenFOAM Programming & Development 15 April 16, 2019 09:29
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 23:38
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 16:45
Adding all the values in a post register Cb Siemens 3 March 11, 2005 14:40


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