CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   varying velocity inlet (http://www.cfd-online.com/Forums/fluent-udf/71874-varying-velocity-inlet.html)

andore January 18, 2010 15:56

varying velocity inlet
 
Hi!

I have a multi-phase flow in an pipe where the velocity varies with time. Here goes my UDF

#include "udf.h"

DEFINE_PROFILE(inlet_velocity, thread, index)
{
real x[ND_ND];
real y;
face_t f;

double veloc[8]= {0.0159,0.0146,0.0135,0.0087,0.0079,0.0079,0.0159, 0.0159};

double time[8]= {0,0.42,1.32,1.8,2.4,2.724,2.736,3.18};

int i=0;

int current_time = CURRENT_TIME;

double inlet_vel;


while( time[i] <= current_time )
{
i = i + 1;
}

inlet_vel = ((veloc[i] - veloc[i-1]) / (time[i] - time[i-1]))*current_time + veloc[i-1];

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, index) = inlet_vel;
}
end_f_loop(f, thread)
}

My velocity changes linearly in time. The thing is that the UDF looks for the current simulation time and compares with the time array and if its smaller than the time array keeps increasing the current time till gets there and when it gets its should calculate the velocity.

When it reaches the 3 element from the arrays, I change the fluid.

However it dosent seem to be working.

Can anyone give me a hand?

Thanks a lot


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