CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

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

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 18, 2013, 21:38
Default UDF to apply a Spanwise velocity wave on a whole 3D rectangular channel domain
  #1
New Member
 
Saâd Debbahi
Join Date: Oct 2010
Posts: 26
Rep Power: 15
QBeast is on a distinguished road
Send a message via Yahoo to QBeast
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

thanks in advance, best regards.

Last edited by QBeast; April 18, 2013 at 22:22. Reason: I've forgotten a detail
QBeast is offline   Reply With Quote

Old   April 19, 2013, 18:06
Default
  #2
New Member
 
Saâd Debbahi
Join Date: Oct 2010
Posts: 26
Rep Power: 15
QBeast is on a distinguished road
Send a message via Yahoo to QBeast
thanks trying, need some help please?
QBeast is offline   Reply With Quote

Old   April 19, 2013, 21:04
Default here is a shot at it
  #3
New Member
 
Saâd Debbahi
Join Date: Oct 2010
Posts: 26
Rep Power: 15
QBeast is on a distinguished road
Send a message via Yahoo to QBeast
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

Last edited by QBeast; April 20, 2013 at 00:47. Reason: errrors
QBeast is offline   Reply With Quote

Old   April 21, 2013, 21:45
Default try to help please
  #4
New Member
 
Saâd Debbahi
Join Date: Oct 2010
Posts: 26
Rep Power: 15
QBeast is on a distinguished road
Send a message via Yahoo to QBeast
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
QBeast is offline   Reply With Quote

Old   April 21, 2013, 22:38
Default
  #5
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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.
blackmask is offline   Reply With Quote

Old   April 22, 2013, 02:39
Default more about the issue
  #6
New Member
 
Saâd Debbahi
Join Date: Oct 2010
Posts: 26
Rep Power: 15
QBeast is on a distinguished road
Send a message via Yahoo to QBeast
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.

thanks trying Blackmask

Last edited by QBeast; April 22, 2013 at 02:43. Reason: data missing
QBeast is offline   Reply With Quote

Old   April 22, 2013, 05:00
Default
  #7
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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.
blackmask is offline   Reply With Quote

Old   April 22, 2013, 12:48
Default Nice suggestion
  #8
New Member
 
Saâd Debbahi
Join Date: Oct 2010
Posts: 26
Rep Power: 15
QBeast is on a distinguished road
Send a message via Yahoo to QBeast
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;
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.

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
QBeast is offline   Reply With Quote

Old   October 15, 2013, 05:10
Default
  #9
New Member
 
Flavio G.
Join Date: Sep 2013
Posts: 4
Rep Power: 13
JouleBrayton is on a distinguished road
Finally how did you solve this problem?? Is time dependent cell condition possible to define ? Thanks.
JouleBrayton is offline   Reply With Quote

Reply

Tags
channel, periodic, spanwise, udf, wave

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[waves2Foam] Waves2Foam Related Topics ngj OpenFOAM Community Contributions 660 August 20, 2018 12:39
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 18:29
Fluent UDF load and apply inlet velocity b.c. Knut Lehmann Main CFD Forum 2 June 29, 2007 04:53


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