- **FLUENT**
(*http://www.cfd-online.com/Forums/fluent/*)

- - **UDF's - linearizing a negative source term
**
(*http://www.cfd-online.com/Forums/fluent/28314-udfs-linearizing-negative-source-term.html*)

UDF's - linearizing a negative source term
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. |

Re: UDF's - linearizing a negative source term
Steve,
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: DEFINE_SOURCE(k_source,c,t,dS,eqn) { 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; } DEFINE_SOURCE(eps_source,c,t,dS,eqn) { 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. Keith |

All times are GMT -4. The time now is 18:50. |