# Changing Pressure at specifird location in domain

 Register Blogs Members List Search Today's Posts Mark Forums Read

 October 30, 2019, 03:11 Changing Pressure at specifird location in domain #1 New Member   MEK Join Date: Oct 2016 Posts: 27 Rep Power: 5 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) } }

 October 31, 2019, 00:16 #2 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,206 Rep Power: 20 it depends on the way, how you will define location __________________ best regards ****************************** press LIKE if this message helped you How to ask questions: https://www.cfd-online.com/Forums/si...tml#post612025

 October 31, 2019, 02:29 #3 New Member   MEK Join Date: Oct 2016 Posts: 27 Rep Power: 5 Thank u so much for replying By using f_centroid we can restrict location but question am I right?

 October 31, 2019, 23:14 #4 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,206 Rep Power: 20 yes, using f_centroid you can control coordinates on faces, to control coordinates in cells you need C_centroid macro __________________ best regards ****************************** press LIKE if this message helped you How to ask questions: https://www.cfd-online.com/Forums/si...tml#post612025

 October 31, 2019, 23:37 #5 New Member   MEK Join Date: Oct 2016 Posts: 27 Rep Power: 5 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

 November 1, 2019, 02:59 #6 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,206 Rep Power: 20 firstly, compile your code, It has several errors. your statement time == 0.1 most likely will never be true __________________ best regards ****************************** press LIKE if this message helped you How to ask questions: https://www.cfd-online.com/Forums/si...tml#post612025

 November 1, 2019, 03:04 #7 New Member   MEK Join Date: Oct 2016 Posts: 27 Rep Power: 5 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.

 November 1, 2019, 05:05 #8 Senior Member   Alexander Join Date: Apr 2013 Posts: 1,206 Rep Power: 20 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 __________________ best regards ****************************** press LIKE if this message helped you How to ask questions: https://www.cfd-online.com/Forums/si...tml#post612025

 November 1, 2019, 06:26 #9 New Member   MEK Join Date: Oct 2016 Posts: 27 Rep Power: 5 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.

November 4, 2019, 10:31
#10
Senior Member

Join Date: Nov 2013
Posts: 1,451
Rep Power: 20
Quote:
 Originally Posted by ebrahem 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)`

November 4, 2019, 20:15
#11
New Member

MEK
Join Date: Oct 2016
Posts: 27
Rep Power: 5
Quote:
 Originally Posted by pakk 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.

November 4, 2019, 20:27
#12
New Member

MEK
Join Date: Oct 2016
Posts: 27
Rep Power: 5
Quote:
 Originally Posted by AlexanderZ 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

November 5, 2019, 01:53
#13
Senior Member

Join Date: Nov 2013
Posts: 1,451
Rep Power: 20
Quote:
 Originally Posted by ebrahem 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?
If so, why did you say that the UDF was not working?

 November 5, 2019, 02:04 #14 New Member   MEK Join Date: Oct 2016 Posts: 27 Rep Power: 5 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.)

November 5, 2019, 03:40
#15
Senior Member

Join Date: Nov 2013
Posts: 1,451
Rep Power: 20
You have been told already a few times why you see no effect.

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?

 November 5, 2019, 04:00 #16 New Member   MEK Join Date: Oct 2016 Posts: 27 Rep Power: 5 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.

 November 5, 2019, 06:09 #17 Senior Member   Join Date: Nov 2013 Posts: 1,451 Rep Power: 20 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.