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 pulsating pressure inlet (https://www.cfd-online.com/Forums/fluent-udf/118525-udf-pulsating-pressure-inlet.html)

Tarano May 29, 2013 06:17

UDF pulsating pressure inlet
 
Hi there,

I have a 2d fluent simulation with 3 pressure inlets 1 in x direction and 2 y direction. Now i I am trying to create a pulsating pressure inlet with a pressure of 1,3 bar in the Y direction for transit simulation.

It has to pulsate at a frequency of 50 Hz (thus 50 pulsation per seconde)

I know i need to use a UDF for this but i have looked through the manual but i find it very confusing.

If anyone is willing to help thank you very much

blackmask May 29, 2013 06:37

You are no more confused than I am. What do you want?

Tarano May 29, 2013 06:52

Thank you for your reply, what i want is an UDF or something that will help me achieve a not constant inlet pressure in the Y direction i want the Y direction inlet pressures to pulsate (or give a burst of pressure 50 times a second). The pressure burst will have a pressure of 1,3 bar or 131.7225 kPa.

What you should image i am simulation is a valve opening en closing 50 times a second and just letting a small bit of air through. (btw this is not what i am trying to simulation but will help me achieve my goals it just to give a picture to what i want)

I looked through the UDF manual and came past a this UDF which i edited, but it doesn't seem to do anything atm at all. Though i might have gone the totally wrong way with this UDF

#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) =131.7225*sin(100*t);
}
end_f_loop(f, thread)

It might be usefull to know the Y direction inlets are opposite each other and should both pulsate at 50 times a second but at opposite intervals thus at 0.01 t the one should pulsate an at 0.02 the other one should pulsate. What i am trying to achieve is an airflow that is oscillating

blackmask May 29, 2013 07:01

Note that the angular frequency should be 2*pi*f = 2*3.14159*50 = 314.159.
If the amplitude is 131 with an averaged value of 131k, it would be
Code:

F_PROFILE(f, thread, position) =131.7225*(1000+sin(100*M_PI*t));

Tarano May 29, 2013 08:55

1 Attachment(s)
Thank you,

It did help its starting to do something now. I am still wondering when i plot this same equation in excel and make a graph of it with time steps of 0.01 i i looked like the image below. Thus actually not beeing a normal sin wave but a constantly increasing sin wave? I might be totally wrong about this but this is confusing to me.

blackmask May 29, 2013 09:23

Gee. The period is 0.02s, so 0.01s is half the period. You need minimum 20 points per period so please reduce time step to 0.001s or smaller.

Tarano May 29, 2013 10:05

OMG, sometime i amaze myself at how obvious my mistakes are, thank you for pointing it out once you said it i realized what i did wrong :D.

Tarano May 29, 2013 10:58

I still having problems to pulsate at different intervals. My current UDF is shown below (point out this does not represent the time step i actually want to achieve but i rather first try and get it in a bigger time step then a smaller one because then i can monitor the flow easier i find anyway once it works i will increase the frequency again). I have notice that the first one unsteady_pressure seems to work ( i can't really figure out if its pulsation correctly but it seems to work), but the bottom one doesn't seem to do anything atm it just ignores it and no pressure is put in through that inlet. any idea what is the problem.

Mathematically to have an sin wave oscillate in the opposite direction you would - the amplitude (i don't know if this would work in fluent though) if you know another way of off setting the sin without - the amplitude but delaying the sin wave by 180 degrees this could also work.

#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) =7*(1000+sin(2*M_PI*t));
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(unsteady_pressure2, thread, position)
{
face_t f;
real t = CURRENT_TIME;
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) =-7*(1000+sin(2*M_PI*t));
}
end_f_loop(f, thread)
}

blackmask May 29, 2013 19:41

The line
Code:

F_PROFILE(f, thread, position) =-7*(1000+sin(2*M_PI*t));
should be changed to
Code:

F_PROFILE(f, thread, position) =7*(1000-sin(2*M_PI*t));

Tarano May 30, 2013 10:27

Thank you for all your help. But it seems somehow it is still not working. I have now run the simulation multiple times but i have noticed that it actually doesn't pulsate at all and just acts as a constant pressure inlet :S. i have tried first letting the flow develop in steady case and then going over to transit and also straight o transit both had no effect. The code i am using is

#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) =(7*(1000+sin(2*(22/7)*t)));
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(unsteady_pressure2, thread, position)
{
face_t f;
real t = CURRENT_TIME;
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) =(7*(1000-sin(2*(22/7)*t)));
}
end_f_loop(f, thread)
}

I saved it as a .c file in notepad en loaded it into fluent through interpreted. and then i assine it as a boundary coditions inlet pressure and the name unsteady_pressure to it instead of a number. I don't notice any change in pressure at the inlet static or total and i don't see any difference in velocity. I went as far as to replace the constant inlet with this one to have a bigger inlet to exame but i can't see it working. Is there any way of checking if fluent has loaded the code correctly? or can anyone see a grave mistake i have made in the UDF.

PS. for those who do not no 22/7 is another way of defining PI as i though that might have been the problem

Tarano May 31, 2013 13:20

Oke i figure out what i did wrong for anyone interested don't forget the . after the number very important.


All times are GMT -4. The time now is 13:11.