-
-
October 23, 2024 at 12:37 am
Max
SubscriberHi Fluent experts,
I am trying to make the UDF for the Realizable k-epsilon 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=W12-wr;/*** 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 k-omega model and got a good agreement between the results.
Could anyone please help?
Thank you very much.
-
October 23, 2024 at 1:44 pm
Rob
Forum ModeratorI'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 2-3 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 am
Rob
Forum ModeratorThat looks like an offset, how constant is that value?
-
- You must be logged in to reply to this topic.
-
2938
-
970
-
852
-
599
-
591
© 2025 Copyright ANSYS, Inc. All rights reserved.