# Adding Source Terms to K epsilon equation

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

 January 31, 2018, 13:12 Adding Source Terms to K epsilon equation #1 New Member   ashi Join Date: Jan 2017 Posts: 6 Rep Power: 9 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

 February 1, 2018, 02:51 #2 Senior Member   Join Date: Nov 2013 Posts: 1,965 Rep Power: 26 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.

 February 1, 2018, 06:25 #3 New Member   ashi Join Date: Jan 2017 Posts: 6 Rep Power: 9 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

 February 1, 2018, 06:48 #4 New Member   ashi Join Date: Jan 2017 Posts: 6 Rep Power: 9 I checked again and the issue is with the velocity of the water phase. they are getting too large all of a sudden.

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