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

LinkBack  Thread Tools  Display Modes 
April 18, 2013, 21:38 
UDF to apply a Spanwise velocity wave on a whole 3D rectangular channel domain

#1 
New Member

Hi guys,
I'm modelling a doubly periodic channel flow of rectangular section, to summerize, it's: orientation: x streamwise (mean flow directionset to periodic) y wall normal (nonslip Boundary condition) z spanwise (periodic) flow direction: x x and z periodic and nonslip 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.cfdonline.com/Forums/flu...urceterm.html thanks in advance, best regards. Last edited by QBeast; April 18, 2013 at 22:22. Reason: I've forgotten a detail 

April 19, 2013, 18:06 

#2 
New Member

thanks trying, need some help please?


April 19, 2013, 21:04 
here is a shot at it

#3 
New Member

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*(1x[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*(1x[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*/ } 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 ydirection momentum added One other question: I'm gonna get a time dependent resulting yvelocity since ymomentum 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 Last edited by QBeast; April 20, 2013 at 00:47. Reason: errrors 

April 21, 2013, 21:45 
try to help please

#4 
New Member

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 xvelocity Vx? thank you 

April 21, 2013, 22:38 

#5 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 13 
The term 'dS' is used to accelerating the solution procedure. If you have heard of NewtonRaphson 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 wavelike 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. 

April 22, 2013, 02:39 
more about the issue

#6  
New Member

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 yvelocity 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:
here's a description of the velocity profile I wanna include: the mean flow is parabolic like Uc*(1z²/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. thanks trying Blackmask Last edited by QBeast; April 22, 2013 at 02:43. Reason: data missing 

April 22, 2013, 05:00 

#7 
Senior Member
Join Date: Aug 2011
Posts: 315
Rep Power: 13 
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.


April 22, 2013, 12:48 
Nice suggestion

#8 
New Member

hi Blackmask,
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, 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; 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 

October 15, 2013, 05:10 

#9 
New Member
Flavio G.
Join Date: Sep 2013
Posts: 4
Rep Power: 5 
Finally how did you solve this problem?? Is time dependent cell condition possible to define ? Thanks.


Tags 
channel, periodic, spanwise, udf, wave 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Waves2Foam Related Topics  ngj  OpenFOAM Running, Solving & CFD  1417  March 27, 2017 12:26 
Velocity boundary condtion UDF help  victoryv  Fluent UDF and Scheme Programming  2  October 9, 2012 15:27 
Channel flow How to apply "Translational Periodicity"  Giorgitseli  CFX  3  May 30, 2011 06:17 
UDF velocity and temperature  Raj  FLUENT  3  February 1, 2009 19:29 
Fluent UDF load and apply inlet velocity b.c.  Knut Lehmann  Main CFD Forum  2  June 29, 2007 04:53 