

October 23, 2024 at 12:37 amMaxSubscriber
Hi Fluent experts,
I am trying to make the UDF for the Realizable kepsilon turbulent viscosity based on the paper of Shih et al. and that expressed in the Fluent theory guide.
The UDF code is for 2D simulation as follows:
#include "udf.h"
#include "math.h"DEFINE_TURBULENT_VISCOSITY(tur_vis,c,t)
{
Â real mu_tur;
Â real S11, S12, S22, W12, W12r, S;
Â real SMU, WAS, PHI, USTAR;
Â real AS;
Â real CMU, a1, a2, a3, a4, a5, a6;
Â real PHI2, F2;/***/
Â real betas=0.09;
Â real A0=4.04;
Â real rho=C_R(c,t);
Â real k=C_K(c,t);
Â real w=C_D(c,t);
Â real CMUL=C_MU_L(c,t);
Â real y=C_WALL_DIST(c,t);/***/
Â real wr=1.485446130; Â Â Â /***rotation speed unit: 1/s***//***/
Â S11=0.5*(C_DUDX(c,t)+C_DUDX(c,t));
Â S12=0.5*(C_DUDY(c,t)+C_DVDX(c,t));
Â S22=0.5*(C_DVDY(c,t)+C_DVDY(c,t));
Â
Â W12=0.5*(C_DVDX(c,t)C_DUDY(c,t));/*** Cal vorticity with angular velocity wr ***/
Â
Â W12r=W12wr;/*** Cal U* Â ***/
Â USTAR=sqrt(S11*S11+2.0*S12*S12+S22*S22+2.0*W12r*W12r);
/*** Cal Phi ***/
Â SMU=sqrt(S11*S11+2.0*S12*S12+S22*S22);
Â WAS=(pow(S11,3)+pow(S22,3)+3.0*pow(S12,2)*(S11+S22))/pow(SMU,3);
Â PHI=1.0/3.0*acos(max(1.0,min(sqrt(6.0)*WAS,1.0)));/*** Cal As ***/
Â
Â AS = sqrt(6.0)*cos(PHI);/*** Cal CMU ***/
Â
Â CMU=1.0/(A0+AS*USTAR*k/w);/*** Cal Viscosity ***/
Â mu_tur=CMU*rho*k*k/w;
Â Â
Â return mu_tur;
}The simulations were performed for both the UDF and the default viscous model. However, there is a large deviation between these simulations' averaged results. I do not know why and why this difference is because the UDF code was based on the expression in the Fluent theory guide. I also compared the simulation between the UDF code and the default turbulent viscosity of the SST komega model and got a good agreement between the results.
Could anyone please help?
Thank you very much.

October 23, 2024 at 1:44 pmRobForum Moderator
I'm assuming PHI is in radians? Otherwise the code doesn't look to have any obvious problems. I'd favour more intenting and comments for future reference and I'd tend to avoid 23 character variables where possible in case anything overlaps with a Fluent value.Â
I've not had a detailed look, and won't be doing any debugging. If you plot contours, linesÂ etc are the results off by an offset, factor or just random differences?

October 24, 2024 at 12:06 am


October 24, 2024 at 9:37 amRobForum Moderator
That looks like an offset, how constant is that value?

 You must be logged in to reply to this topic.

861

427

367

225

201
Â© 2024 Copyright ANSYS, Inc. All rights reserved.