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

Define new turbulence model in Fluent

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

Like Tree10Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 1, 2014, 15:27
Default
  #21
Member
 
Sheng
Join Date: Jun 2011
Posts: 58
Rep Power: 12
micro11sl is on a distinguished road
I don't think/know the production term and dissipation term can be replaced individually. This is also what I want to do before. I think this is one short coming of Fluent, i.e. it lets you add source term, but it doesn't allow you modify source term that have already been there. You probably need to define a new turbulence model. This may introduce a lot of work, although we just want to have a small change. If Fluent can hear me, I strongly suggest Fluent make it easier for the user to implement turbulence models. I have seen some researcher publish their work using their own turbulence model in Fluent, but I still don't manage to do it easily. When I get all the equations right in the code, the solver get divergence and I get frustrated and then give up. I may try it out later after my graduation, but at that time I may switch to other open source code as full control can be available from there. Good luck with your work!
behest likes this.
micro11sl is offline   Reply With Quote

Old   April 2, 2014, 06:53
Default
  #22
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Thank you very much for your answer. You are right, we can not play with source term that have already been in Fluent and it is a gap that could be covered in next version of the software.
Any way, you said that your implement model has not been converged. I do not know you change the under relaxation of your new trasport equation or not. You may control it by decreasing this value and it directly has affected on your convergence, too.
Moreover, I read your code in this thread, I think that it is beter to use DEFINE_TURBULENT_VISCOSITY instead of DEFINE_ADJUST for introducing eddy viscosity.
It would be appricated if you tell me more about your experiances. Now I just want to write k-w SST model in UDF and after that I got the same results with fluent, then I will change it.


Quote:
Originally Posted by micro11sl View Post
I don't think/know the production term and dissipation term can be replaced individually. This is also what I want to do before. I think this is one short coming of Fluent, i.e. it lets you add source term, but it doesn't allow you modify source term that have already been there. You probably need to define a new turbulence model. This may introduce a lot of work, although we just want to have a small change. If Fluent can hear me, I strongly suggest Fluent make it easier for the user to implement turbulence models. I have seen some researcher publish their work using their own turbulence model in Fluent, but I still don't manage to do it easily. When I get all the equations right in the code, the solver get divergence and I get frustrated and then give up. I may try it out later after my graduation, but at that time I may switch to other open source code as full control can be available from there. Good luck with your work!
behest is offline   Reply With Quote

Old   August 29, 2014, 17:20
Default
  #23
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
hi,
did you manage to get results from this UDF code?
particularly I am interested in tensor definitions:
for example:"S[m][i]=0.5*(puixj[m][i]+puixj[i][m]); //S is the stress tensor”
is it getting the right values of derivatives if you define like puixj[m][i] and puixj[i][m] derivatives they should give different values…in my case they are giving the same values…
thanks for help in advance!
Quote:
Originally Posted by micro11sl View Post
The third part deals with the source term of omega, I use the denotation of w in somewhere.

DEFINE_SOURCE(w_source, c, t, dS, eqn)
{
int i,j,m;
real G_k; // refers to the production of k
real G_w; // refers to the production of w
real Y_w; // refers to the dissipation of w
real alpha=1.0;
real beta_star=0.09; // the compressibility correction is not enabled for k
real betai=0.072; // the compressibility correction is not enabled for w

real Xw=0;
real Og[ND_ND][ND_ND], S[ND_ND][ND_ND], puixj[ND_ND][ND_ND];

puixj[0][0]= C_DUDX(c,t);
puixj[0][1]= C_DVDX(c,t);
puixj[1][0]= C_DUDY(c,t);
puixj[1][1]= C_DVDY(c,t);
if(ND_ND==3)
{
puixj[0][2]= C_DWDX(c,t);
puixj[1][2]= C_DWDY(c,t);
puixj[2][0]= C_DUDZ(c,t);
puixj[2][1]= C_DVDZ(c,t);
puixj[2][2]= C_DWDZ(c,t);
}
G_k = C_MU_T(c,t)*SQR(Strainrate_Mag(c,t)); // Bounsinesq hypothesis
G_w = alpha*C_UDSI(c,t,OMG)/C_UDSI(c,t,TKE)*G_k; // production of w, requiring G_k
for(m=0;m<ND_ND;m++)
{
for(j=0:j<ND_ND;j++)
{
for(i=0;i<ND_ND;i++)
{
Og[i][j]=0.5*(puixj[i][j]-puixj[j][i]); //Og is the rotation tensor
Og[j][m]=0.5*(puixj[j][m]-puixj[m][j]);
S[m][i]=0.5*(puixj[m][i]+puixj[i][m]); //S is the stress tensor
Xw = Og[i][j]*Og[j][m]*S[m][i]+ Xw;
}
}
}
Xw=abs(Xw/pow(beta_star*C_UDSI(c,t,OMG),3));
fbeta=(1+70*Xw)/(1+80*Xw);
Y_w = C_R(c,t)*betai*fbeta*pow(C_UDSI(c,t,OMG),2);
dS[eqn] = alpha/C_UDSI(c,t,TKE)*G_k-2*C_R(c,t)*betai*fbeta*C_UDSI(c,t,OMG);
return G_w-Y_w;
}
Kanarya is offline   Reply With Quote

Old   August 30, 2014, 06:34
Default
  #24
Member
 
Sheng
Join Date: Jun 2011
Posts: 58
Rep Power: 12
micro11sl is on a distinguished road
Hi Kanarya,
Sorry I didn't understand. Can you illustrate better?

Regards,

Quote:
Originally Posted by Kanarya View Post
hi,
did you manage to get results from this UDF code?
particularly I am interested in tensor definitions:
for example:"S[m][i]=0.5*(puixj[m][i]+puixj[i][m]); //S is the stress tensor”
is it getting the right values of derivatives if you define like puixj[m][i] and puixj[i][m] derivatives they should give different values…in my case they are giving the same values…
thanks for help in advance!
micro11sl is offline   Reply With Quote

Old   August 30, 2014, 06:46
Default
  #25
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
Hi,
thanks for the quick answer!
did you manage to get results from your code?
and it seems I am getting same values for puixj[i][m] and puixj[m][i] although they are with opposite indices?
do you have any idea why?
thanks!
Quote:
Originally Posted by micro11sl View Post
Hi Kanarya,
Sorry I didn't understand. Can you illustrate better?

Regards,
Kanarya is offline   Reply With Quote

Old   September 1, 2014, 04:47
Default
  #26
Member
 
Sheng
Join Date: Jun 2011
Posts: 58
Rep Power: 12
micro11sl is on a distinguished road
Yes and no. I manage to make it running. But I can't get it converged. Later I give up.
For that puixj[i][m], following the definition, they are derivatives so they are not necessarily the same? For example, partial u / partial y and partial v / partial x, they don't need to be the same?
I don't think you need to worry about this, as the code gets derivatives from FLUENT. If there is something wrong, it is due to FLUENT, rather than the code. And if that is the case, you need to calculate the derivative yourself instead of using FLUENT, i.e., write a part of code instead of using the built-in FLUENT macro.

Regards,

Quote:
Originally Posted by Kanarya View Post
Hi,
thanks for the quick answer!
did you manage to get results from your code?
and it seems I am getting same values for puixj[i][m] and puixj[m][i] although they are with opposite indices?
do you have any idea why?
thanks!
micro11sl is offline   Reply With Quote

Old   September 1, 2014, 06:40
Default
  #27
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
hi,
thanks!
I have convergence problem as well....do you thing i should initialize the tensors?
thanks!
Quote:
Originally Posted by micro11sl View Post
Yes and no. I manage to make it running. But I can't get it converged. Later I give up.
For that puixj[i][m], following the definition, they are derivatives so they are not necessarily the same? For example, partial u / partial y and partial v / partial x, they don't need to be the same?
I don't think you need to worry about this, as the code gets derivatives from FLUENT. If there is something wrong, it is due to FLUENT, rather than the code. And if that is the case, you need to calculate the derivative yourself instead of using FLUENT, i.e., write a part of code instead of using the built-in FLUENT macro.

Regards,
Kanarya is offline   Reply With Quote

Old   September 1, 2014, 12:28
Default
  #28
Member
 
Sheng
Join Date: Jun 2011
Posts: 58
Rep Power: 12
micro11sl is on a distinguished road
Hi Kanarya,
I have got a lot of work to do now. I can't provide a clear answer to you at this moment. I also tried to seek solutions for that convergence problem. What I can suggest is, if you have sufficient time, consider other opensource code you have access to. I am not saying FLUENT is not a good code. It is good but we know nothing about it, so when we have problems we have limited chance to know what is actually going on. On the contrary, with a code either your research group used for a long time or else, you have full control on any part of the code, so that investigating convergence and underlying mistakes in your implementation becomes possible. If you don't have time, one thing you can do might define a turbulence model that is available inside FLUENT first, so then you can at least compare the one you define and the one already in to see what is suspecting to be wrong. Boundary condition and other stuff, everything matters!

Regards,

Quote:
Originally Posted by Kanarya View Post
hi,
thanks!
I have convergence problem as well....do you thing i should initialize the tensors?
thanks!
micro11sl is offline   Reply With Quote

Old   November 12, 2014, 09:28
Default Sst udf
  #29
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Hello all,
Does anyone write an UDF for SST model? Did you get the same results that Fluent gives us?

Actually, I am writing an UDF for a new turbulence model that is very close to the SST model. Therefore, I decided that write SST model by UDF, firstly. To make sure the UDF working correctly, I want to compare the result of UDF and Fluent.
behest is offline   Reply With Quote

Old   November 12, 2014, 10:04
Default
  #30
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
Hi ,
If you use the fluent theory guide, you should get similar results...
Quote:
Originally Posted by behest View Post
Hello all,
Does anyone write an UDF for SST model? Did you get the same results that Fluent gives us?

Actually, I am writing an UDF for a new turbulence model that is very close to the SST model. Therefore, I decided that write SST model by UDF, firstly. To make sure the UDF working correctly, I want to compare the result of UDF and Fluent.
Kanarya is offline   Reply With Quote

Old   November 12, 2014, 11:06
Default
  #31
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Hello,
Thank you very much for your answer. Did you try to write an UDF for SST? Which part of Fluent theory guide is your aim?

Actually, I am writting an UDF for SST model, my problem is the boundary condition and the value of them is not the same with Fluent one.

Quote:
Originally Posted by Kanarya View Post
Hi ,
If you use the fluent theory guide, you should get similar results...
behest is offline   Reply With Quote

Old   November 12, 2014, 11:34
Default
  #32
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
Hi,
I did several turbulence models but not specifically SST and I think it does not matter that much!
I think you should describe your problem more in detail...
And then you could receive some help...
thanks!
Quote:
Originally Posted by behest View Post
Hello,
Thank you very much for your answer. Did you try to write an UDF for SST? Which part of Fluent theory guide is your aim?

Actually, I am writting an UDF for SST model, my problem is the boundary condition and the value of them is not the same with Fluent one.
Kanarya is offline   Reply With Quote

Old   November 13, 2014, 05:46
Unhappy
  #33
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Thank you very much for your answer. My goal is to write an UDF for SST model and solve it for a 2D flat plate case.
I run it but it gives me a wrong answer and the result is not the same with Fluent.

this is my code:
/**This UDF is k-w SST model without Low Reynolds correction and any other options,just SST equation is applied**/

#include "udf.h"
#include "mem.h"
#include "math.h"
#include "sg_udms.h"
#include "global.h"

/* User-defined constants */
#define SIG_TKE1 1.176
#define SIG_OMG1 2.0
#define SIG_TKE2 1.0
#define SIG_OMG2 1.168
#define ALPHA_1 0.31
#define ALPHA_infstar 1.0
#define ALPHA_star 1.0
#define ALPHA_0 1/9
#define BETA_i1 0.075
#define BETA_i2 0.0828
#define BETA_infstar 0.09 // the compressibility correction is not enabled for k
#define R_BETA 8.0
#define R_TKE 6.0
#define R_OMG 2.95
#define ZETA_star 1.5
#define M_t0 0.25
#define K_karman 0.41

#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MIN(x,y) (((x) < (y)) ? (x) : (y))

/* User-defined scalars */
enum
{
TKE,
OMG,
N_REQUIRED_UDS
};

/*==========================define dissipation term of k (Y_K)============================*/
real Y_k (cell_t c,Thread *t)
{return C_R(c,t)*BETA_infstar*C_UDSI(c,t,TKE)*C_UDSI(c,t,O MG);}

/*======================define production of k(G_Kbar) for each cell=====================*/
real G_kbar(cell_t c,Thread *t)
{
real G_k,G_bar,s1; // refers to the production of k
G_k = C_MU_T(c,t)*SQR(Strainrate_Mag(c,t)); // Bounsinesq hypothesis, production of k
s1 = 10*Y_k(c,t);

G_bar = MIN(G_k,s1);
return G_bar;
}
/**********************************Source term of TKE************************************/
DEFINE_SOURCE(k_source, c, t, dS, eqn)
{
real dGK_bar,dY_k;

dY_k = C_R(c,t)*BETA_infstar*C_UDSI(c,t,OMG);
dGK_bar = MIN((10*dY_k),0);

/* dS[eqn] = dGK_bar-dY_k; */
dS[eqn] = -C_R(c,t)*BETA_infstar*C_UDSI(c,t,OMG);
return G_kbar(c,t)-Y_k(c,t);
}
/*==========================================F1===== =====================================*/
real F1(cell_t c,Thread *t)
{
real s1,s2,s3,s4,cdkw1,arg1,cdkw,cdkw2=pow(10,-10);

s1 = sqrt(C_UDSI(c,t,TKE))/(0.09*C_WALL_DIST(c,t)*MAX(C_UDSI(c,t,OMG),1.e-10));
s2 = 500*C_MU_L(c,t)/(C_R(c,t)*SQR(C_WALL_DIST(c,t))*MAX(C_UDSI(c,t,OMG ),1.e-10));
s3 = MAX(s1,s2);

/* compute CDkw */
cdkw1 = (2*C_R(c,t)*NV_DOT(C_UDSI_G(c,t,TKE),C_UDSI_G(c,t, OMG)))/(SIG_OMG2*MAX(C_UDSI(c,t,OMG),1.e-10));
cdkw = MAX(cdkw1,cdkw2);

s4 = 4*C_R(c,t)*C_UDSI(c,t,TKE)/(SIG_OMG2*cdkw*SQR(C_WALL_DIST(c,t)));
arg1 = MIN(s4, s3);
return tanh(arg1*arg1*arg1*arg1);
}
/**********************************Source term of OMG************************************/
DEFINE_SOURCE(omg_source, c, t, dS, eqn)
{
real ALPHA_inf,ALPHA_inf1,ALPHA_inf2,BETA,dG_w,dY_w;

ALPHA_inf1 = (BETA_i1/BETA_infstar)-(SQR(K_karman)/(SIG_OMG1*sqrt(BETA_infstar)));
ALPHA_inf2 = (BETA_i2/BETA_infstar)-(SQR(K_karman)/(SIG_OMG2*sqrt(BETA_infstar)));
/* ALPHA_inf = F1(c,t)*ALPHA_inf1+(1-F1(c,t))*ALPHA_inf2; */
ALPHA_inf = 0.52;
BETA = F1(c,t)*BETA_i1+(1-F1(c,t))*BETA_i2;

dY_w = 10*C_R(c,t)*BETA_infstar*C_UDSI(c,t,TKE);
dG_w = MIN(dY_w,0);

dS[eqn]=-(fabs(2*(1-F1(c,t))*C_R(c,t)*NV_DOT(C_UDSI_G(c,t,TKE),C_UDSI_ G(c,t,OMG))/(MAX(C_UDSI(c,t,OMG),1.e-10)*SIG_OMG2))+2*C_R(c,t)*BETA*C_UDSI(c,t,OMG))/MAX(C_UDSI(c,t,OMG),1.e-10);
/* ALPHA_inf*dG_w*C_R(c,t)/C_MU_T(c,t); */

return ALPHA_inf*G_kbar(c,t)*C_R(c,t)/C_MU_T(c,t)-C_R(c,t)*BETA*SQR(C_UDSI(c,t,OMG))+2*(1-F1(c,t))*C_R(c,t)*NV_DOT(C_UDSI_G(c,t,TKE),C_UDSI_ G(c,t,OMG))/(MAX(C_UDSI(c,t,OMG),1.e-10)*SIG_OMG2);
}
/*==========================================F2===== =====================================*/
real F2(cell_t c,Thread *t)
{
real s1,s2,arg2;

s1 = 2*sqrt(C_UDSI(c,t,TKE))/(0.09*C_WALL_DIST(c,t)*MAX(C_UDSI(c,t,OMG),1.e-10));
s2 = 500*C_MU_L(c,t)/(C_R(c,t)*SQR(C_WALL_DIST(c,t))*MAX(C_UDSI(c,t,OMG ),1.e-10));
arg2 = MAX(s1,s2);

return tanh(arg2*arg2);
}
/*************************************eddy viscosity**************************************/
DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t)
{
real mu_t,s1,s2;

s1=Strainrate_Mag(c,t)*F2(c,t)/(ALPHA_1*MAX(C_UDSI(c,t,OMG),1.e-10));
s2=1/ALPHA_star;

mu_t=C_R(c,t)*C_UDSI(c,t,TKE)/(MAX(s1,s2)*MAX(C_UDSI(c,t,OMG),1.e-10));
return mu_t;
}
/*================================Prandtl number for TKE==================================*/
real SIG_TKE(cell_t c,Thread *t)
{ return 1/((F1(c,t)/SIG_TKE1)+((1-F1(c,t))/SIG_TKE2));}

/*================================Prandtl number for OMG==================================*/
real SIG_OMG(cell_t c,Thread *t)
{ return 1/((F1(c,t)/SIG_OMG1)+((1-F1(c,t))/SIG_OMG2));}

/***************************Diffusivity term of TKE and OMG********************************/
DEFINE_DIFFUSIVITY(kw_diff, c, t, eqn)
{
real diff; // define the diffusion coeffcient
switch (eqn)
{
case TKE:
diff=C_MU_T(c,t)/SIG_TKE(c,t)+C_MU_L(c,t);
break;
case OMG:
diff=C_MU_T(c,t)/SIG_OMG(c,t)+C_MU_L(c,t);
break;
default:
diff=C_MU_T(c,t)+C_MU_L(c,t);
}
return diff;
}
/*===================Wall boundary=======================*/
DEFINE_PROFILE(wall_d_bc,t,i)
{
Thread *t0;
face_t f;
cell_t c, c0;
real yplus,wshear;

begin_f_loop(f,t)
{
c0 = F_C0(f,t);
t0 = THREAD_T0(t);

yplus = C_STORAGE_R(f,t,SV_WALL_YPLUS_UTAU); /* Y+*/
wshear = C_MU_L(c0,t0)*C_U(c0,t0)/C_WALL_DIST(c0,t0); /* wall shear stress */
F_PROFILE(f,t,i) = 3.*wshear/(BETA_infstar*C_MU_L(c0,t0)*SQR(yplus));
}
end_f_loop(f,t)
}

You can use this code for other 2D problems and check that it does not give us the correct results.
Quote:
Originally Posted by Kanarya View Post
Hi,
I did several turbulence models but not specifically SST and I think it does not matter that much!
I think you should describe your problem more in detail...
And then you could receive some help...
thanks!
behest is offline   Reply With Quote

Old   November 13, 2014, 06:27
Default
  #34
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
Hi,

I can not debug your code but I can give suggestions...do you have some results which you can show here...
thanks!
Quote:
Originally Posted by behest View Post
Thank you very much for your answer. My goal is to write an UDF for SST model and solve it for a 2D flat plate case.
I run it but it gives me a wrong answer and the result is not the same with Fluent.

this is my code:
/**This UDF is k-w SST model without Low Reynolds correction and any other options,just SST equation is applied**/

#include "udf.h"
#include "mem.h"
#include "math.h"
#include "sg_udms.h"
#include "global.h"

/* User-defined constants */
#define SIG_TKE1 1.176
#define SIG_OMG1 2.0
#define SIG_TKE2 1.0
#define SIG_OMG2 1.168
#define ALPHA_1 0.31
#define ALPHA_infstar 1.0
#define ALPHA_star 1.0
#define ALPHA_0 1/9
#define BETA_i1 0.075
#define BETA_i2 0.0828
#define BETA_infstar 0.09 // the compressibility correction is not enabled for k
#define R_BETA 8.0
#define R_TKE 6.0
#define R_OMG 2.95
#define ZETA_star 1.5
#define M_t0 0.25
#define K_karman 0.41

#define MAX(x,y) (((x) > (y)) ? (x) : (y))
#define MIN(x,y) (((x) < (y)) ? (x) : (y))

/* User-defined scalars */
enum
{
TKE,
OMG,
N_REQUIRED_UDS
};

/*==========================define dissipation term of k (Y_K)============================*/
real Y_k (cell_t c,Thread *t)
{return C_R(c,t)*BETA_infstar*C_UDSI(c,t,TKE)*C_UDSI(c,t,O MG);}

/*======================define production of k(G_Kbar) for each cell=====================*/
real G_kbar(cell_t c,Thread *t)
{
real G_k,G_bar,s1; // refers to the production of k
G_k = C_MU_T(c,t)*SQR(Strainrate_Mag(c,t)); // Bounsinesq hypothesis, production of k
s1 = 10*Y_k(c,t);

G_bar = MIN(G_k,s1);
return G_bar;
}
/**********************************Source term of TKE************************************/
DEFINE_SOURCE(k_source, c, t, dS, eqn)
{
real dGK_bar,dY_k;

dY_k = C_R(c,t)*BETA_infstar*C_UDSI(c,t,OMG);
dGK_bar = MIN((10*dY_k),0);

/* dS[eqn] = dGK_bar-dY_k; */
dS[eqn] = -C_R(c,t)*BETA_infstar*C_UDSI(c,t,OMG);
return G_kbar(c,t)-Y_k(c,t);
}
/*==========================================F1===== =====================================*/
real F1(cell_t c,Thread *t)
{
real s1,s2,s3,s4,cdkw1,arg1,cdkw,cdkw2=pow(10,-10);

s1 = sqrt(C_UDSI(c,t,TKE))/(0.09*C_WALL_DIST(c,t)*MAX(C_UDSI(c,t,OMG),1.e-10));
s2 = 500*C_MU_L(c,t)/(C_R(c,t)*SQR(C_WALL_DIST(c,t))*MAX(C_UDSI(c,t,OMG ),1.e-10));
s3 = MAX(s1,s2);

/* compute CDkw */
cdkw1 = (2*C_R(c,t)*NV_DOT(C_UDSI_G(c,t,TKE),C_UDSI_G(c,t, OMG)))/(SIG_OMG2*MAX(C_UDSI(c,t,OMG),1.e-10));
cdkw = MAX(cdkw1,cdkw2);

s4 = 4*C_R(c,t)*C_UDSI(c,t,TKE)/(SIG_OMG2*cdkw*SQR(C_WALL_DIST(c,t)));
arg1 = MIN(s4, s3);
return tanh(arg1*arg1*arg1*arg1);
}
/**********************************Source term of OMG************************************/
DEFINE_SOURCE(omg_source, c, t, dS, eqn)
{
real ALPHA_inf,ALPHA_inf1,ALPHA_inf2,BETA,dG_w,dY_w;

ALPHA_inf1 = (BETA_i1/BETA_infstar)-(SQR(K_karman)/(SIG_OMG1*sqrt(BETA_infstar)));
ALPHA_inf2 = (BETA_i2/BETA_infstar)-(SQR(K_karman)/(SIG_OMG2*sqrt(BETA_infstar)));
/* ALPHA_inf = F1(c,t)*ALPHA_inf1+(1-F1(c,t))*ALPHA_inf2; */
ALPHA_inf = 0.52;
BETA = F1(c,t)*BETA_i1+(1-F1(c,t))*BETA_i2;

dY_w = 10*C_R(c,t)*BETA_infstar*C_UDSI(c,t,TKE);
dG_w = MIN(dY_w,0);

dS[eqn]=-(fabs(2*(1-F1(c,t))*C_R(c,t)*NV_DOT(C_UDSI_G(c,t,TKE),C_UDSI_ G(c,t,OMG))/(MAX(C_UDSI(c,t,OMG),1.e-10)*SIG_OMG2))+2*C_R(c,t)*BETA*C_UDSI(c,t,OMG))/MAX(C_UDSI(c,t,OMG),1.e-10);
/* ALPHA_inf*dG_w*C_R(c,t)/C_MU_T(c,t); */

return ALPHA_inf*G_kbar(c,t)*C_R(c,t)/C_MU_T(c,t)-C_R(c,t)*BETA*SQR(C_UDSI(c,t,OMG))+2*(1-F1(c,t))*C_R(c,t)*NV_DOT(C_UDSI_G(c,t,TKE),C_UDSI_ G(c,t,OMG))/(MAX(C_UDSI(c,t,OMG),1.e-10)*SIG_OMG2);
}
/*==========================================F2===== =====================================*/
real F2(cell_t c,Thread *t)
{
real s1,s2,arg2;

s1 = 2*sqrt(C_UDSI(c,t,TKE))/(0.09*C_WALL_DIST(c,t)*MAX(C_UDSI(c,t,OMG),1.e-10));
s2 = 500*C_MU_L(c,t)/(C_R(c,t)*SQR(C_WALL_DIST(c,t))*MAX(C_UDSI(c,t,OMG ),1.e-10));
arg2 = MAX(s1,s2);

return tanh(arg2*arg2);
}
/*************************************eddy viscosity**************************************/
DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t)
{
real mu_t,s1,s2;

s1=Strainrate_Mag(c,t)*F2(c,t)/(ALPHA_1*MAX(C_UDSI(c,t,OMG),1.e-10));
s2=1/ALPHA_star;

mu_t=C_R(c,t)*C_UDSI(c,t,TKE)/(MAX(s1,s2)*MAX(C_UDSI(c,t,OMG),1.e-10));
return mu_t;
}
/*================================Prandtl number for TKE==================================*/
real SIG_TKE(cell_t c,Thread *t)
{ return 1/((F1(c,t)/SIG_TKE1)+((1-F1(c,t))/SIG_TKE2));}

/*================================Prandtl number for OMG==================================*/
real SIG_OMG(cell_t c,Thread *t)
{ return 1/((F1(c,t)/SIG_OMG1)+((1-F1(c,t))/SIG_OMG2));}

/***************************Diffusivity term of TKE and OMG********************************/
DEFINE_DIFFUSIVITY(kw_diff, c, t, eqn)
{
real diff; // define the diffusion coeffcient
switch (eqn)
{
case TKE:
diff=C_MU_T(c,t)/SIG_TKE(c,t)+C_MU_L(c,t);
break;
case OMG:
diff=C_MU_T(c,t)/SIG_OMG(c,t)+C_MU_L(c,t);
break;
default:
diff=C_MU_T(c,t)+C_MU_L(c,t);
}
return diff;
}
/*===================Wall boundary=======================*/
DEFINE_PROFILE(wall_d_bc,t,i)
{
Thread *t0;
face_t f;
cell_t c, c0;
real yplus,wshear;

begin_f_loop(f,t)
{
c0 = F_C0(f,t);
t0 = THREAD_T0(t);

yplus = C_STORAGE_R(f,t,SV_WALL_YPLUS_UTAU); /* Y+*/
wshear = C_MU_L(c0,t0)*C_U(c0,t0)/C_WALL_DIST(c0,t0); /* wall shear stress */
F_PROFILE(f,t,i) = 3.*wshear/(BETA_infstar*C_MU_L(c0,t0)*SQR(yplus));
}
end_f_loop(f,t)
}

You can use this code for other 2D problems and check that it does not give us the correct results.
Kanarya is offline   Reply With Quote

Old   November 13, 2014, 09:41
Default
  #35
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Actually, I have not gotten a good results yet and must of time the simulation would be divege after some itteration. It means that some thing is wrong; therefore, boundary condition is one of them.
Did you write an UDF for any turbulence model and get a good result? or did you see any simulation with different model by UDF and reach the same result that Fluent obtains?
I read all threads and nobody said that he gets the correct answer by UDF. may be Fluent performs some extra work on the turbulence model that is not written in the theory guide. What do you think?
Yuan Bao likes this.
behest is offline   Reply With Quote

Old   November 13, 2014, 10:00
Default
  #36
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
Hi,
I thought so, did the simulations crashing immidiately or they run for a while?
yes , I got reasonable results from my code for turbulence!
the problem can be the marco like C_WALL_DIST(c0,t0), if the simulations crash immidiatly, this macro you can use only with enhanced wall function in standard k-epsilon model or so on... but I do not know whether it is ok for your case, you should check it...
Quote:
Originally Posted by behest View Post
Actually, I have not gotten a good results yet and must of time the simulation would be divege after some itteration. It means that some thing is wrong; therefore, boundary condition is one of them.
Did you write an UDF for any turbulence model and get a good result? or did you see any simulation with different model by UDF and reach the same result that Fluent obtains?
I read all threads and nobody said that he gets the correct answer by UDF. may be Fluent performs some extra work on the turbulence model that is not written in the theory guide. What do you think?
Kanarya is offline   Reply With Quote

Old   November 13, 2014, 18:18
Default
  #37
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Actually, my simulation is crash after some iteration.
I have a question about wall treatment, did you check that your code gives the same value on the wall surface?
Do you know how I hook "DEFINE_TURBULENT_VISCOSITY" in Fluent? How did you define wall function?

I have some macro like C_WALL_DIST(c0,t0), too. I check them. Thank you


Quote:
Originally Posted by Kanarya View Post
Hi,
I thought so, did the simulations crashing immidiately or they run for a while?
yes , I got reasonable results from my code for turbulence!
the problem can be the marco like C_WALL_DIST(c0,t0), if the simulations crash immidiatly, this macro you can use only with enhanced wall function in standard k-epsilon model or so on... but I do not know whether it is ok for your case, you should check it...
behest is offline   Reply With Quote

Old   November 14, 2014, 12:52
Default
  #38
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 13
Kanarya is on a distinguished road
hi,
to hook DEFINE_TURBULENT_VISCOSITY:
go to Models-->click on Viscous Model-->then you should see bottom right hand side User-Defined Function Turbulent Viscosity. you should hook there...
did you deactivate the turbulence from Equation panel...?
best!
Quote:
Originally Posted by behest View Post
Actually, my simulation is crash after some iteration.
I have a question about wall treatment, did you check that your code gives the same value on the wall surface?
Do you know how I hook "DEFINE_TURBULENT_VISCOSITY" in Fluent? How did you define wall function?

I have some macro like C_WALL_DIST(c0,t0), too. I check them. Thank you
Kanarya is offline   Reply With Quote

Old   November 14, 2014, 13:01
Default
  #39
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Thank you for your answer. I did do, deactivate the turbulence model in equation panel. Moreover, I hook turbulent viscosity correctly.

Quote:
Originally Posted by Kanarya View Post
hi,
to hook DEFINE_TURBULENT_VISCOSITY:
go to Models-->click on Viscous Model-->then you should see bottom right hand side User-Defined Function Turbulent Viscosity. you should hook there...
did you deactivate the turbulence from Equation panel...?
best!
behest is offline   Reply With Quote

Old   November 20, 2014, 07:18
Red face
  #40
Member
 
Ali.E
Join Date: Sep 2010
Location: Lisboa
Posts: 83
Rep Power: 13
behest is on a distinguished road
Hello,
May I ask you about that how you consider y+ and wall shear stress near the wall in your UDF? Did you get them from Fluent by these expressions? C_UDMI(c0,t0,0)=C_STORAGE_R(f,t,SV_WALL_YPLUS_UTAU ); /* Y+*/
C_UDMI(c0,t0,2)=C_STORAGE_R(f,t,SV_WALL_SHEAR); /* wall shear */ C_UDMI(c0,t0,3)=C_STORAGE_R(f,t,SV_WALL_YPLUS); /* Ystar */

and did you save them in C_UDMI or in F_UDMI?

thanks alot for your consideration.

Quote:
Originally Posted by Kanarya View Post
hi,
to hook DEFINE_TURBULENT_VISCOSITY:
go to Models-->click on Viscous Model-->then you should see bottom right hand side User-Defined Function Turbulent Viscosity. you should hook there...
did you deactivate the turbulence from Equation panel...?
best!
behest is offline   Reply With Quote

Reply

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
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44
how to define the symmetric boundary condition for Menter's SST turbulence model? flyingseed Main CFD Forum 8 November 24, 2012 02:53
What model of turbulence choose to study an external aerodynamics case raffale OpenFOAM 0 August 23, 2012 05:45
Reynolds Stress Model in Fluent Vs CFX Tim FLUENT 0 December 6, 2005 22:03
Sinclair Model + secondary turbulence Yi FLUENT 0 October 26, 2001 13:37


All times are GMT -4. The time now is 19:23.