CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF to apply a Spanwise velocity wave on a whole 3D rectangular channel domain (http://www.cfd-online.com/Forums/fluent-udf/116436-udf-apply-spanwise-velocity-wave-whole-3d-rectangular-channel-domain.html)

 QBeast April 18, 2013 21:38

UDF to apply a Spanwise velocity wave on a whole 3D rectangular channel domain

Hi guys,

I'm modelling a doubly periodic channel flow of rectangular section, to summerize, it's:

orientation:
x streamwise (mean flow direction-set to periodic)
y wall normal (non-slip Boundary condition)
z spanwise (periodic)

flow direction: x
x and z periodic
and non-slip condition at the upper and bottom wall,

I need some help to write an UDF to impose a spanwise velocity forcing wave travelling downstream which is likely to be coordinate and time dependent like A(z).Sin(Kx.x+Ky.y).Sin(w.t), on the whole domain and update every timestep, I've been looking around but found a 3 yers old thread dealing with roughly the same thing (tank with cg motion).

I've already worte UDFs generating waves at the inlet but did that only on Velocity_inlet boundary condition, Is there a way to perform the same thing to a whole domain ie every single node will have its spanwise velocity forcing contribution changing every timestep.

I'm wondering if the DEFINE_SOURCE macro is an option for pointing out every cell and adding/updating y momentum?
found this on the forum

http://www.cfd-online.com/Forums/flu...urce-term.html

 QBeast April 19, 2013 18:06

thanks trying, need some help please?

 QBeast April 19, 2013 21:04

here is a shot at it

I've written an udf dealing with the spanwise perturbation as a source of y momentum here is the code based on fluent udf guide page 131:

Code:

```#include "udf.h" DEFINE_SOURCE(ymom_source,c,t,dS,eqn) { /*#if !RP_HOST*/ real x[ND_ND]; real  flow_time= CURRENT_TIME; real beta,alpha,a,con, source; alpha=1.02; /*streamwise wave number*/ beta=0.45;/*spanwise wave number*/ int omega=10;/*time revolution frequency*/ a=0.05;/*perturbation amplitude*/ C_CENTROID(x,c,t); source=100*a*(1-x[2]*x[2]/0.000225)*sin(alpha*x[0]+beta*x[1])*cos(omega*flow_time);/*y momentum source term*/ dS[eqn]=100*beta*a*(1-x[2]*x[2]/0.000225)*cos(alpha*x[0]+beta*x[1])*cos(omega*flow_time);/*y momentum source term derivative with respect to y??*/ return source; /*#endif*/ }```
you can see above a parabola in z multiplied by a space dependent wave in x & y varying in time with a revolution frequency omega

as I understood from the udf manual, user have to provide the source term derivative with respect to "the momentum source direction" here I have y-direction momentum added

One other question: I'm gonna get a time dependent resulting y-velocity since y-momentum is taken in n/m3 this gonna generate a force applied to every volume cell if the cell's mass is m, f the force resulting in the momentum source contribution and gamma the acceleration then according to // m x gamma=f=CellVolume x MomentumSource(n/m3)=== which gives a time dependent velocity

is there a way to impose explicitly "kinetically" the velocity rather than a momentum "dynamically" generating a variable velocity?

you can see above that I commented the parallel execution directives... should I place these if !rp_host..endif elsewhere ?

please would you have a look inside, thank you

 QBeast April 21, 2013 21:45

hi,

I've read almost all posts related to source term setup, the above udf works it gives a periodic spanwise velocity wave BUT there is a problem regarding magnitude?

Could someone please explain to me how to get the desired velocity in m/s value since the momentum source term has a N/m3 volume force dimension

Once a again I got confused working on fluent udf manual page 131 "adding xmomentum source y dependent" since they gave a Vx dependent term and the derivative with respect to the x-velocity Vx?

thank you

The term 'dS' is used to accelerating the solution procedure. If you have heard of Newton-Raphson method then it should not be difficult for you to figure out how this term is calculated. It is always safe to assign zero to this term.

I am not sure what you really want to do but for a wave-like equation you should modify the domain of dependence only and not the domain of influence. Try to formulate the physical problem you described into mathematical formulation, then you probably could solve the problem by your own.

 QBeast April 22, 2013 02:39

Thanks, finally someone took some time to answer,:)

it's simple I just wanna modify the flow by adding a sinuous perturbation to the usual parabolic profile since the geometry is periodic I have no access to velocity inlet UDF, so instead, I'm trying to find a way to impose every cell's velocity over the whole domain.

I have run some tests with the above a modified version of the above udf, but the y-velocity keeps increasing and exceeds the desired perturbation amplitude which means that the source term keeps adding momentum to every cell Vy component, sounds natural since the source is taken in N/m^3 which is a "dynamical" quantity "force/volume" compared to "kinematic" velocity m/s, I think.

here is my big question: is there a way to add a fluctuating velocity component while having periodic boundary conditions as described above?

Quote:
 for a wave-like equation you should modify the domain of dependence only and not the domain of influence
Can you explain this? does it mean that I'm "overriding" the calculated solution?

here's a description of the velocity profile I wanna include:
the mean flow is parabolic like Uc*(1-z²/h²), h: is the channel half height
for the spanwise direction v=A.sin(alpha*x) is the periodically fluctuating component.

There was no problem including this profile in a velocity_inlet/pressure_outlet channel but here I'm constrained with the periodicity to develop the sinuous mode instability, I can't do it without using periodic boundaries.

It sounds like an eigenvalue problem to me rather than a wave propagation problem as I thought before. Either way I think the disturbance should be introduced from one side of the boundary, say z=-1. I am sorry that I can not help you because I am not familiar with this kind of problem.

 QBeast April 22, 2013 12:48

Nice suggestion

of course you're right it's an eigenvalue problem, usually treated using higher order spectral methods performing dns, here you gave me an idea using the bottom wall, and impose a sinuous velocity across the z=-1 wall since this gonna drive the boundary in the same motion.

meanwhile I used the DFEINE_SOURCE macro to access the C_V(c,t) which is the y velocity component and set it to sinuous value, the trick generates the sinuous profile but breaks convergence:confused:, here what I did:

I set the source term and its derivative to 0, and since fluent loops over all cells it can be possible to give a value to y velocity of every cell by doing:

Code:

```C_V(c,t)=a*sin(alpha*x)*cos(omega*t); source=0; dS[eqn]=0;```
when viewing the instantaneous y velocity contours the plane view shows a sinuous spanwise profile, I'm not sure this is the right thing to do since the convergence blows up:confused:.

I think I'm gonna start a new thread asking how to access and patch "mem.h" stored variables like C_V(c,t) to get desired velocity profile.

best regards

 JouleBrayton October 15, 2013 05:10

Finally how did you solve this problem?? Is time dependent cell condition possible to define ? Thanks.

 All times are GMT -4. The time now is 03:24.