CFD Online Logo CFD Online URL
Home > Forums > FLUENT

UDF's - linearizing a negative source term

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

LinkBack Thread Tools Display Modes
Old   March 16, 2001, 12:12
Default UDF's - linearizing a negative source term
Steve Howell
Posts: n/a
Dear all,

I'm trying to write my own implementation of the k-e turbulence model using Fluent's User Defined Functions. I am trying to solve a simple 2D jet flow, and my UDF-implementation predicts a solution which is very similar to the Fluent-implementation solution, provided I use the Fluent solution as the initial field. If I use a uniform field as the initial field, then the solution procedure diverges.

The problem is that both the k- and e-equations contain dissipation terms which are negative. If these are simply included in the source term, then the k- and e-fields diverge: k goes large and negative, whereas e goes large and positive.

I have written my own code in the past, and I solved this problem by dividing the dissipation term by the appropriate variable and then adding this to the ap-coefficient, i.e. for the k-equation, don't add the dissipation term to the source term, instead divide it by k and add it to the ap-coefficient in the discretised k-equation.

Unfortunately, I can't figure out how to do this successfully using the Fluent UDF's. I have identified some variables in the header files - C_UDSI_AP(c,t,i) from sg_mem.h, and C_UDSI_S(c,t,i) from mem.h, which I presume are the ap-coefficient and source term respectively. I have also identified the function C_NEGATIVE_SOURCE_LINEARIZE from sg.h which should linearize the source terms as required. However, all attempts to use the above approaches have failed due to several reasons 1)segmentation errors, 2)divergence detected in the amgif solver, 3)getting a significantly different prediction to the Fluent-implementation solution.

I've tried all the reasonable approaches that I can think of. Does anyone else have experience with this type of problem, or can anyone help in any way?

Thanks in advance,

Steve Howell.
  Reply With Quote

Old   March 18, 2001, 17:21
Default Re: UDF's - linearizing a negative source term
Posts: n/a

Have you used the dS[] variable inside your DEFINE_SOURCE macro? This is supposed to hold the implicit part of the source term, so you can use it to impose a negative linearization. I've implemented the k-epsilon model by using something like:



real k = MAX(C_UDSI(c,t,0),1.e-10);

real d = MAX(C_UDSI(c,t,1),1.e-10);

real inv_t = d/k;

. . .

dS[eqn] = -C_R(c,t)*inv_t;

return Production - C_R(c,t)*d;




real k = MAX(C_UDSI(c,t,0),1.e-10);

real d = MAX(C_UDSI(c,t,1),1.e-10);

. . .

dS[eqn] = -2.*C_EPS_2*C_R(c,t)*d/k;

return C_EPS_1*Production*d/k - C_EPS_2*C_R(c,t)*d*d/k;


Here k and epsilon are stored as user-defined scalars 0 and 1 respectively. This has worked pretty well.

  Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
gradient source term UDF ak6g08 Fluent UDF and Scheme Programming 0 July 9, 2009 06:37
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00
Adding a momentum source term segersson OpenFOAM Running, Solving & CFD 5 March 3, 2006 00:06
UDF Source Term Units? Brian FLUENT 1 October 24, 2005 09:15
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43

All times are GMT -4. The time now is 20:36.