CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for Pulsed flow (https://www.cfd-online.com/Forums/fluent-udf/120576-udf-pulsed-flow.html)

Vahidehzare1367 July 10, 2013 03:08

UDF for Pulsed flow
 
Hi all ,I’m new in fluent and particularly UDF, I want to model a system that a gas is inlet and it flows for 3s and doesn’t flow for 3s alternatively and continuously. I wrote a udf for this problem But it don't do correctly.
Please, guide me.
Thank you very much

#include"udf.h"
DEFINE_PROFILE(inlet_x_velocity, t, position)
{
face_t f;
real flow_time = RP_Get_Real(
"flow-time");
int i;
begin_f_loop(f, t)
{
for(i=0; i<=flow_time; i++)
{
if(flow_time >= i*6 && flow_time <= i*6 +3)
F_PROFILE(f,t ,position)=0;
else
F_PROFILE(f,t,position)=0.58425;
}
}
end_f_loop(f, t)
}

blackmask July 10, 2013 04:33

Try this one.

Code:

#include"udf.h"
DEFINE_PROFILE(inlet_x_velocity, t, position)
{
face_t f;
real flow_time = RP_Get_Real(
"flow-time");
int i = (int)(flow_time/3.0)%2;
begin_f_loop(f, t)
{

if( i)
F_PROFILE(f,t ,position)=0;
else
F_PROFILE(f,t,position)=0.58425;
}
end_f_loop(f, t)
}


Vahidehzare1367 July 10, 2013 05:09

Thank you very much in advance.

regards

Vahidehzare1367 July 16, 2013 02:19

Hi Blackmask, if I want to model a system that a gas is inlet and it flows for 0.05s and doesn’t flow for 0.05s alternatively and continuously, What do I do?

blackmask July 16, 2013 02:59

Change

int i = (int)(flow_time/3.0)%2;

to

int i = (int)(flow_time/0.05)%2;

Vahidehzare1367 July 16, 2013 03:17

I change this but the udf can't do correctly

blackmask July 16, 2013 03:31

Please explain in more details. What is the time step you choose in your calculation? Make sure that the time step is at least one order smaller that the period of the pulsating flow.

Barzanoni July 16, 2013 03:35

Hi Dear Vahideh
please see Chapter 8 of the ANSYS FLUENT UDF Manual.

/************************************************** *********************
vprofile.c
UDF for specifying steady-state velocity profile boundary condition
************************************************** **********************/
#include "udf.h"
DEFINE_PROFILE(inlet_x_velocity, thread, position)
{
real x[ND_ND]; /* this will hold the position vector */
real y, h;
face_t f;
h = 0.016; /* inlet height in m */
begin_f_loop(f,thread)
{
F_CENTROID(x, f, thread);
y = 2.*(x[1]-0.5*h)/h; /* non-dimensional y coordinate */
F_PROFILE(f, thread, position) = 0.1*(1.0-y*y);
}
end_f_loop(f, thread)
}

/************************************************** ********************
unsteady.c
UDF for specifying a transient pressure profile boundary condition
************************************************** *********************/
#include "udf.h"
DEFINE_PROFILE(unsteady_pressure, thread, position)
{
face_t f;
real t = CURRENT_TIME;
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = 101325.0 + 5.0*sin(10.*t);
}
end_f_loop(f, thread)
}

adnan1000 June 10, 2016 04:44

udf
 
Hi all ,I’m new in fluent and particularly UDF, I want to model a system that a gas is inlet and it flows for 3s and doesn’t flow for 3s alternatively and continuously in steady state. I wrote a udf fo r this problem But it don't do correctly.
Please, guide me.
Thank you very much.


#include"udf.h"
DEFINE_PROFILE(inlet_x_velocity, t, position)
{
face_t f;
real flow_time = RP_Get_Real("flow-time");
int i = (int)(flow_time/1.0)%2;
begin_f_loop(f, t)
{

if( i)
F_PROFILE(f,t ,position)=0;
else
F_PROFILE(f,t,position)=0. 2;
}
end_f_loop(f, t)
}

Bruno Machado June 10, 2016 05:37

Quote:

Originally Posted by adnan1000 (Post 604246)
Hi all ,I’m new in fluent and particularly UDF, I want to model a system that a gas is inlet and it flows for 3s and doesn’t flow for 3s alternatively and continuously in steady state. I wrote a udf fo r this problem But it don't do correctly.
Please, guide me.
Thank you very much.


#include"udf.h"
DEFINE_PROFILE(inlet_x_velocity, t, position)
{
face_t f;
real flow_time = RP_Get_Real("flow-time");
int i = (int)(flow_time/1.0)%2;
begin_f_loop(f, t)
{

if( i)
F_PROFILE(f,t ,position)=0;
else
F_PROFILE(f,t,position)=0. 2;
}
end_f_loop(f, t)
}

you want to run a steady state or a transient case? you say one thing, but your problem suggests something different.

adnan1000 June 11, 2016 03:38

The Model is a tube being inside water intermittent (pulse), but when I use the code is not there is a change in the results, When change my time
I do not know how or where I put the time flow

andreas_wan1 March 20, 2018 12:30

hello, i'm currently try your code.. but it seems not working. could you please teach me how to write udf...?

pakk March 20, 2018 14:33

"It seems not working" is not very helpful. Please be more detailed.

(Does it give errors? Warnings? Wrong results? Fluent crashes? Your computer destroyed in a fire? Nothing happened?)

andreas_wan1 March 20, 2018 22:30

Thank you for you reply Sir..
so i was trying to simulate gas-solid fludized bed dryer with pulsed flow... 0.2 m/s inlet velocity in +y direction, frequency 1 Hz (
0s -> 0.5s it flow 0.2m/s
0.5s -> 1s the flow stop at 0 m/s
1.0s -> 1.5s the flow again at 0.2m/s , repeat continously

and when i simulate the volume fraction..it doesn't show any pulsed effect..more likely constant velocity..
i'm also trying to change the frequency into 3s flow...3s stop just to see wether the udf code is working properly or not..and it show the same..

here the copy of my udf code for 3S flow..3S stop flow
==================================

#include"udf.h"
DEFINE_PROFILE(inlet_y_velocity,t,position)
{
face_t f;
real flow_time = RP_Get_Real("flow-time");
int i = (int)(flow_time/3)%2;
begin_f_loop(f,t)

{
if (i)
F_PROFILE(f,t,position)=0;
else
F_PROFILE(f,t,position)=0.2;
}

end_f_loop(f,t)
}

===============================
note: i still very beginner in fluent, especially in udf... so i don't know wether when we have to add "space" "." or ";" , and anything about coding


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