CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   How do i create time dependent flows on UDF? (http://www.cfd-online.com/Forums/fluent-udf/82953-how-do-i-create-time-dependent-flows-udf.html)

 nha1g08 December 9, 2010 16:22

How do i create time dependent flows on UDF?

How do I create this conditon using a UDF?

I want the velocity at the pipe inlet to be 10m/s from t=0 to 5

then i want the v=20m/s from t=5 to 6,

then i want the velocity again to be 10m/s from t =6 to 11

How do i set the time ticking ticking on the UDF? and what is the varaible for time?

Thanks

 ComputerGuy December 9, 2010 20:56

nha1g08,

Try something like this. Inevitably I'm missing a semicolon in the following, but it should be relatively simple to fix. Interpret (or better, compile) this UDF, then hook it to your face velocity boundary condition. This loops over all cell faces at the inlet boundary and sets them to the given velocity depending on the simulation time.

Make sure you run transient!

Regards,
ComputerGuy

DEFINE_PROFILE(velocity_magnitude, t, i)
{
real velocity;
real the_current_time;
face_t f;

the_current_time = CURRENT_TIME;

if ((the_current_time>=0) && (the_current_time<5))
{
velocity=10;
}
if ((the_current_time>=5) && (the_current_time<6))
{
velocity=20;
}
if ((the_current_time>=6))
{
velocity=10;
}

begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = velocity;
}
end_f_loop(f,t)
}

 bright181 December 12, 2010 04:20

I want the pressure of the pressureinlet to be 0 form 0 to 5 second
and the pressure of 8Mpa from 5 to 6 second
is it similar?

 ComputerGuy December 12, 2010 09:24

bright181,

Yes. You have to change the udf slightly and hook it to a different place on the inlet boundary conditions panel, but it's effectively the same. I have changed variable names for clarity.

ComputerGuy

Code:

```#include "udf.h" DEFINE_PROFILE(pressure_magnitude, t, i) { real pressure_mag; real the_current_time; face_t f; the_current_time = CURRENT_TIME; if ((the_current_time>=0.0) && (the_current_time<5.)) { pressure_mag=0.0; } if ((the_current_time>=5.0) && (the_current_time<6.0)) { pressure_mag=8.0e6; } begin_f_loop(f,t) { F_PROFILE(f,t,i) = pressure_mag; } end_f_loop(f,t) }```

 nuengao January 5, 2011 00:42

Dear computerGuy

how to hook your codes to Fluent and how to set time in fluent

thank

 nuengao January 5, 2011 00:48

Could I have one question?

I'd like to know that how to define current time at fluent ?

 sakshi1632 June 17, 2013 03:03

I want to inject a fluid at every 6 mins. I prepared a code, but ther seems to be an error in line 10 saying:" line 10: invalid type for integral binary expression: double % int."
Can anyone give me a solution to this?
Thankyou.:)
Here's the code:

#include "udf.h"

{ face_t f;

{
real t = RP_Get_Real("flow-time");

if (t%360==0)

else

 lomba June 17, 2013 06:06

get cell value

Hi,
I would like to retrieve the value in a cell in the liquid phase and compared with a set value. Depending on the value found, I modified the condition of gas inlet. like a regulation loop.
Here is the UDF I wrote but I am having acces_violation.
the coordenates of the cell where i want get mass fraction value are x=0.08 and y=0.015

I get acess violation when i compiled my UDF.

Best regards!!!
Sorry for my english level!
/*---------------------------------------------------------------*/

#include "udf.h"

{

face_t f;
cell_t c;
real YH, Rhol, ConsH, pH, pH1, cent,YH1, x, y;
real xc[ND_ND];

/*--------------------------------------------------------------------*/

/*--------------------------------------------------------------------*/

/*---mesurement---*/
/*--------------------------------------------------------------------*/
/*to get cell YI value*/

{
x=xc[0];
y=xc[1];

if( x=0.08. && y=0.015.) /*probe position*/

}

pH=-log(ConsH);

/*--------------------------------------------------------------------*/

/*---injection CO2---*/
/*--------------------------------------------------------------------*/
{

if(pH >7)

else