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

February 21, 2018, 08:45
#1
New Member

G Ionut
Join Date: Sep 2016
Posts: 29
Rep Power: 8
Hello,
I need some help to calculate the streamwise pressure gradient for my UDF in Ansys Fluent.

I have considered two 2D cases: Case A, a horizontal pipe and Case B, a tilted pipe (as in the figures below).
The two cases have the same geometry, mesh and coordinate system, the difference is that the second pipe is tilted.

For Case A the streamwise pressure gradient is found using the C_P_G(c,t)[0] function from fluent, the pressure gradient along the x-axis.

For Case B the above function is not valid. How can the streamwise pressure gradient can be calculated for the considered case?
Attached Images
 2D pipe cases.jpg (16.4 KB, 15 views)

 February 21, 2018, 11:19 #2 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 25 Just use the definition of streamwise pressure gradient. The streamwise pressure gradient is the inner product between the pressure gradient and the unit vector in the direction of the flow. How do you calculate the unit vector in the direction of the flow? Divide the velocity vector by its magnitude. Code: ```real UVDF[ND_ND]; /*UVDF = unit vector in direction of Flow */ real flowmag; ... flowmag=sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t)+C_W(c,t)*C_W(c,t)); UVDF[0]=C_U(c,t)/flowmag; UVDF[1]=C_V(c,t)/flowmag; UVDF[2]=C_W(c,t)/flowmag;``` And then take the inner product with the pressure gradient: Code: ```real SPG; /* SPG = streamwise pressure gradient */ ... SPG = UVDF[0]*C_P_G(c,t)[0]+UVDF[1]*C_P_G(c,t)[1]+UVDF[2]*C_P_G(c,t)[2];``` This can all be combined into one line of code, but I'll leave that to you (and it might be easier to understand if you don't do that).

February 21, 2018, 11:43
#3
New Member

G Ionut
Join Date: Sep 2016
Posts: 29
Rep Power: 8
Quote:
 Originally Posted by pakk Just use the definition of streamwise pressure gradient. The streamwise pressure gradient is the inner product between the pressure gradient and the unit vector in the direction of the flow. How do you calculate the unit vector in the direction of the flow? Divide the velocity vector by its magnitude. Code: ```real UVDF[ND_ND]; /*UVDF = unit vector in direction of Flow */ real flowmag; ... flowmag=sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t)+C_W(c,t)*C_W(c,t)); UVDF[0]=C_U(c,t)/flowmag; UVDF[1]=C_V(c,t)/flowmag; UVDF[2]=C_W(c,t)/flowmag;``` And then take the inner product with the pressure gradient: Code: ```real SPG; /* SPG = streamwise pressure gradient */ ... SPG = UVDF[0]*C_P_G(c,t)[0]+UVDF[1]*C_P_G(c,t)[1]+UVDF[2]*C_P_G(c,t)[2];``` This can all be combined into one line of code, but I'll leave that to you (and it might be easier to understand if you don't do that).
thank you very much pakk, your idea works flawlessly.