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/)
-   -   Changing Pressure at specifird location in domain (https://www.cfd-online.com/Forums/fluent-udf/221777-changing-pressure-specifird-location-domain.html)

ebrahem October 30, 2019 03:11

Changing Pressure at specifird location in domain
 
Hello everyone, i would like to know that how can we change the pressure in a transient run simulation at some specified location e.g after some time in simulation i want to increse or decrease the pressure in domain at specified location. Please look at my work and suggest.
i am using DEFINE_ADJUST but its not working



# define domain_ID 7
/* Pressure calculations */
DEFINE_ADJUST(my_adjust,d)
{

real del_p = 0;
real p_operating = RP_Get_Real ("operating-pressure");
Thread *t;
cell_t c;
face_t f;
t=Lookup_Thread(d, domain_ID);
d = Get_Domain(domain_ID);

if(CURRENT_TIME == 0.1)
{

del_p = -5;
}
else
del_p = 0;



thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
real pressure = C_P(c,t);
C_P(c,t) = pressure + del_p + p_operating;
}
end_c_loop(c,t)
}

thread_loop_f(t,d)
{
begin_f_loop(f,t)
{
real pressure = C_P(c,t);
C_P(c,t) = pressure + del_p + p_operating;
}
end_f_loop(f,t)
}

if(CURRENT_TIME == 0.1)
{

del_p = -5;
}
else
del_p = 0;



thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
real pressure = F_P(f,t);
F_P(f,t) = pressure + del_p + p_operating;
}
end_c_loop(c,t)
}

thread_loop_f(t,d)
{
begin_f_loop(f,t)
{
real pressure = F_P(f,t);
F_P(f,t) = pressure + del_p + p_operating;
}
end_f_loop(f,t)
}
}

AlexanderZ October 31, 2019 00:16

it depends on the way, how you will define location

ebrahem October 31, 2019 02:29

Thank u so much for replying
By using f_centroid we can restrict location but question am I right?

AlexanderZ October 31, 2019 23:14

yes, using f_centroid you can control coordinates on faces, to control coordinates in cells you need C_centroid macro

ebrahem October 31, 2019 23:37

Thank you so much.
But my problem is I am unable to see any changes in pressure field. Looks like I am doing something wrong

AlexanderZ November 1, 2019 02:59

firstly, compile your code, It has several errors.

your statement time == 0.1 most likely will never be true

ebrahem November 1, 2019 03:04

UDF is compiling and giving no error and current time ==0.1 means that it will execute at flow time 0.1. but when I see pressure contours at 0.1flow time nothing happened.

AlexanderZ November 1, 2019 05:05

code above is wrong, show the code you are using with no errors....
del_p = -5; could be negligibly small, cause normal pressure is 101325 ,check it

if(CURRENT_TIME == 0.1) is only 1 moment time and it is possible, that fluent will never have exactly 0.1 time inside solver, it is possible to get 0.09999999999

ebrahem November 1, 2019 06:26

Once again really appreciated your insight.
My time step size is 0.001 so surely 0.1 comes in it's progression

Regarding dp=-5 I have just replaced my equation with this constant 5 value to make my point. Actually in that equation I am using C_Centroid to restrict the location of pressure change. In actual equation it will surely have effect prominent enough if it works properly. Because I have solved it manually and its value is compareble to 101325.

pakk November 4, 2019 10:31

Quote:

Originally Posted by ebrahem (Post 748632)
Once again really appreciated your insight.
My time step size is 0.001 so surely 0.1 comes in it's progression

No, not surely. Mathematically yes, 100*0.001=0.1, so after 100 time steps you should be exactly at that time. But numerically, no, because computers work with binary numbers, not decimal. You might want to learn something about floating point arithmetic.

But you fail to see that, even if you happen to hit exactly time 0.1 on time step 100, you don't have it anymore at time step 101. So the pressure changes for only one millisecond in your simulation.

I suspect that you don't want that. I suspect that you want the pressure to be changed for all times after 0.1 seconds. In that case:
Code:

if(CURRENT_TIME > 0.1)

ebrahem November 4, 2019 20:15

Quote:

Originally Posted by pakk (Post 748841)
No, not surely. Mathematically yes, 100*0.001=0.1, so after 100 time steps you should be exactly at that time. But numerically, no, because computers work with binary numbers, not decimal. You might want to learn something about floating point arithmetic.

But you fail to see that, even if you happen to hit exactly time 0.1 on time step 100, you don't have it anymore at time step 101. So the pressure changes for only one millisecond in your simulation.

I suspect that you don't want that. I suspect that you want the pressure to be changed for all times after 0.1 seconds. In that case:
Code:

if(CURRENT_TIME > 0.1)

Actually I am increasing velocity at specified location and time by adding x and y momentum source. Obviously for increasing in velocity there will be decrease in pressure I want to compensate that pressure drop at that time.

ebrahem November 4, 2019 20:27

Quote:

Originally Posted by AlexanderZ (Post 748628)
code above is wrong, show the code you are using with no errors....
del_p = -5; could be negligibly small, cause normal pressure is 101325 ,check it

if(CURRENT_TIME == 0.1) is only 1 moment time and it is possible, that fluent will never have exactly 0.1 time inside solver, it is possible to get 0.09999999999

Please watch this video and tell me what is happening to pressure contours at 16s in video time which is 0.1s in simulation
https://youtu.be/IvIzLIqN29w

pakk November 5, 2019 01:53

Quote:

Originally Posted by ebrahem (Post 748892)
Please watch this video and tell me what is happening to pressure contours at 16s in video time which is 0.1s in simulation
https://youtu.be/IvIzLIqN29w

It looks like the pressure dropped by 5 Pa for a very short moment. Isn't that what you wanted?
Is this your simulation?
If so, why did you say that the UDF was not working?

ebrahem November 5, 2019 02:04

yes this is my simulation of vortical gust impinging to the cylinder i have generated the vortical gust by source term implementation in x and y momentum source through UDF.


according to my little understanding yes by increasing velocity at a point the pressure will be drop to compensate it . But i dont want to see the pressure drop thats why i am trying to use DEFINE_ADJUST UDF to compensate that pressure loss (UDF is compiling and giving no error i have hooked it in function hook but i am unable to see it effect i dont know how to check if UDF is effecting or not. if i only apply DEFINE_ADJUST UDF there is no change in lift, drag, pressure or residuals.)

pakk November 5, 2019 03:40

You have been told already a few times why you see no effect.

I worry a bit about your statement
Quote:

But i dont want to see the pressure drop...
You understand that physically there has to be a pressure drop, but you don't want to see it... Why do you want to fool yourself?

ebrahem November 5, 2019 04:00

by introducing the vortical gust in domain there is a change in velocity and vorticity contours at localize location but in pressure contours whole inlet domain is disturbed. that is what bothering me.

pakk November 5, 2019 06:09

Well, it can be physical or non-physical.

If it is physical, then you should accept it, because it's just what it is. You should not use a UDF to change the result just because you don't like it.

If it is non-physical, something is wrong in your simulation. You should find out what is wrong. What is the cause of this non-physical thing. Don't write a UDF to suppress the effect, but find the cause and get rid of it.

So you see, whatever it is, your UDF is not what you need.


All times are GMT -4. The time now is 09:20.