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

Adding Source Terms to K epsilon equation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 31, 2018, 14:12
Default Adding Source Terms to K epsilon equation
  #1
New Member
 
ashi
Join Date: Jan 2017
Posts: 6
Rep Power: 9
arashk is on a distinguished road
hello,

I am having some troubles in using UDF to add a source term to k equation in turbulent model.

here is my udf which is for a multiphase flow. It is a bubble column filled with water with a simple inlet of air at the bottom.

#include "udf.h"

DEFINE_SOURCE(k_BIT, cell, pri_th, dS, eqn)
{

Thread *mix_th, *sec_th;
mix_th = THREAD_SUPER_THREAD(pri_th);
sec_th = THREAD_SUB_THREAD (mix_th, 1);

real diam;

real CD, Re, abs_v;

real x_vel_a, x_vel_w, y_vel_a, y_vel_w, slip_x, slip_y,slip_z, z_vel_a,
z_vel_w, rho_a, rho_w, mu_w, sigma, betastar, Liquidtef, K1, K;

real void_a, Eo, uC, SrcK;

x_vel_w = C_U(cell, pri_th);
y_vel_w = C_V(cell, pri_th);
z_vel_w = C_W(cell, pri_th);
x_vel_a = C_U(cell, sec_th);
y_vel_a = C_V(cell, sec_th);
z_vel_a = C_W(cell, sec_th);

void_a = C_VOF(cell, sec_th);

slip_x = x_vel_a - x_vel_w;
slip_y = y_vel_a - y_vel_w;
slip_z = z_vel_a - z_vel_w;

sigma=0.072; /*surface tension*/
rho_w = 997;
rho_a = 1.185;
mu_w = 0.00089;
diam = 0.003;
abs_v = MAX(sqrt(slip_x*slip_x +
slip_y*slip_y+slip_z*slip_z),0.00000001);
Re=rho_w*abs_v*diam/mu_w;
Eo = 9.81*(rho_w-rho_a)*diam*diam/sigma;


CD = 1;
uC = MIN(0.184*pow(Re,0.229),1);

SrcK = uC*0.75*(CD/diam)*void_a*rho_w*pow(abs_v,3);

dS[eqn] = 0

return SrcK;

}


I will have a divergence after few iteration at first time step. I could not solve the problem so far.

That would be great if you could guide me through this.

Many thanks in advance

Ashkan
arashk is offline   Reply With Quote

Old   February 1, 2018, 03:51
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
If you are getting divergence with the UDF, and no problems without the UDF (you tested this, right?), then it must be that your UDF is returning problematic values.

Test this by printing the values.
So directly above your return statement, set
Code:
Message("SrcK = %f\n",SrcK);
Just see what values you see there, and if it is what you expect.

If the values are unexpectedly high or low (as in a factor 1000 too high or too low, not just 10%), print intermediate values to see where the problem comes from.

If the returned value is correct, I can't help you.
pakk is offline   Reply With Quote

Old   February 1, 2018, 07:25
Default
  #3
New Member
 
ashi
Join Date: Jan 2017
Posts: 6
Rep Power: 9
arashk is on a distinguished road
Hello pakk

Thanks a lot for the reply.

Exactly ... I get a huge number. I have tried the same expression in CFX and I got results without problem. I tried to compute the values even manually ... logically it should not get that high.

Do you think I have defined thread variables wrong?

My case is a multiphase case and I add these source in cell zone condition tap and to the liquid phase.

is the source term that I have defined applicable to multiphase case? I have been using this type of UDF for single phase without problems so far but for mutiphase I am not sure if I am missing some thing.

I appreciate it if you could guide me a little bit more.

Thanks
arashk is offline   Reply With Quote

Old   February 1, 2018, 07:48
Default
  #4
New Member
 
ashi
Join Date: Jan 2017
Posts: 6
Rep Power: 9
arashk is on a distinguished road
I checked again and the issue is with the velocity of the water phase. they are getting too large all of a sudden.
arashk is offline   Reply With Quote

Reply

Tags
multiphase flow, source terms, turbulence kinetic energy, udf code


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
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 04:04
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 13:41
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59
Adding source terms to turbulent models makaveli_lcf OpenFOAM Running, Solving & CFD 0 June 8, 2009 10:34
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08


All times are GMT -4. The time now is 04:43.