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/)
-   -   How to change flow direction during a transient analysis? (https://www.cfd-online.com/Forums/fluent-udf/187862-how-change-flow-direction-during-transient-analysis.html)

kaufparkangucker May 17, 2017 04:04

How to change flow direction during a transient analysis?
 
Hello forum community,

I want to reverse the direction of flow of water in a pipe after a certain time. At the beginning water flows from the inlet through the tube to the outlet for 20 seconds. Afterwards the flow direction turns and it flows water 40 seconds from the outlet to the inlet. That is what I want.

I have tried whether I can enter negative values ​​for the speed at the velocity-inlet. That's no problem. As a result, the water flows from the outlet towards inlet.

I also tried to interrupt the calculation and during this break I changed the boundary conditions of the velocity_inlet into a pressure_outlet and the pressure_outlet into a velocity_inlet. Then I have the calculation run further. When I look at the result in the CFD postprocessor the velocity vectors change according to the direction - so this works also. Although I do not have streamlines in the animation to look at. For some reason the calculation of the streamlines takes eternally.

After these tests and the realization that it seems possible to change the flow direction, I have tried to use a customized UDF for it:

Code:

#include "udf.h"
DEFINE_PROFILE (inlet_velocity, thread, position)
{
Real t, v;
Face_t f;

begin_f_loop (f, thread)
{
T = RP_Get_Real ("flow-time");
{
If (t> 0 && t <= 20)
{
V = 1.5;
}
Else if (t> 20 && t <= 60)
{
V = -1.5;
}
}
F_PROFILE (f, thread, position) = v;
}
end_f_loop (f, thread)
}

Unfortunately this does not work. The direction of flow does not change after 20 seconds.

I would be very happy if you can help me to adjust the UDF.



Thanks and regards


Kauf

Светлана May 17, 2017 18:17

Try to use lowercase 'v' and 't' everywhere?

kaufparkangucker May 18, 2017 04:51

Sorry, this is a spelling error. In the source text I have noticed the case sensitivity.

The code I use is:

Code:

#include "udf.h"
DEFINE_PROFILE(inlet_velocity, thread, position)
{
real t, v;
face_t f;

begin_f_loop(f,thread)
{
t = RP_Get_Real("flow-time");
{
if(t > 0 && t <= 20)
{
v = 1.5;
}
else if(t > 20 && t <= 60)
{
v = - 1.5;
}
}
F_PROFILE(f,thread,position) = v;
}
end_f_loop(f,thread)
}

Is it maybe not possible to change flow direction after some Seconds from x to -x?


Any ideas?

kaufparkangucker May 28, 2017 03:12

As a beginner, I have no idea if it is possible to reverse the flow direction during a transient analysis in Fluent. Maybe there is also a solution other than UDF?

Is it possible, for example, to first solve a transient solution for the flow direction in +x direction through a pipe and then use this solution as the starting condition of a new transient solution, where I change the position of the inlet and outlet so the new flow direction is now in -x direction?

I would like to see how the liquid behaves in a tube when the flow direction turns suddenly by 180°.

I am grateful for all tips and hints.

venturi May 29, 2017 08:04

Are you trying to look the streamlines at CFD-Post?

If so, a possible problem could occur if you select the inlet as starting point for the streamlines and tried to integrate "forward" while the flow is reversed.

Try making the streamlines in a center plane, or uniformly distributed in all the domain if this is the problem.

kaufparkangucker May 30, 2017 11:41

Thanks Venturi - but that's not what I'm trying.

I would like to see the turbulence image that is produced when the direction of flow in the pipe change the direktion.

For that, I'm trying to make a flow simulation through a simple pipe.
The entrance is say "left" and the exit is "right".
The input e.g. a Velocity input and the output is a pressure output. At the beginning the flow velocity should be + 2m / s for 10 seconds. Subsequently, the flow velocity should be -2 m/s for 10 seconds.

The velocity in the pipe should be:
10 secounds +2 m/s
and than
10 secounds - 2 m/s

Has some of you an idea how to do that?

venturi May 30, 2017 11:58

Oh I'm sorry then. That is what I understood from your first post.

Quote:

Originally Posted by kaufparkangucker (Post 649194)
When I look at the result in the CFD postprocessor the velocity vectors change according to the direction - so this works also. Although I do not have streamlines in the animation to look at. For some reason the calculation of the streamlines takes eternally.


kaufparkangucker May 31, 2017 06:48

Yes, I have certainly expressed something ambiguous. I hope you understand my problem now and have an idea how I can solve it.

kaufparkangucker June 22, 2017 11:24

Nobody any idea how to change flow direction during a simulation in ansys fluent?

Светлана June 22, 2017 20:29

Add x, F_CENTROID
 
This version works for me with added x variable and F_CENTROID function call,

Code:

#include "udf.h"
DEFINE_PROFILE(inlet_velocity, thread, position)
{
real x[ND_ND];    // added
real t, v;
face_t f;

begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread); // added
t = RP_Get_Real("flow-time");
{
if(t > 0 && t <= 20)
{
v = 1.5;
}
else if(t > 20 && t <= 60)
{
v = - 1.5;
}
}
F_PROFILE(f,thread,position) = v;
}
end_f_loop(f,thread)
}



All times are GMT -4. The time now is 06:01.