# Fluent - Shear stress divergence UDF

**18**

Hi,

I'm trying to create a UDF which analyses the shear stress gradients (and hence contribution to the X and Y momentum) for steady, compressible turbulent (SA) flow.

This can be done easily by rearranging the navier stokes such that the X term would look like

Grad(P)[0]+ rho(q . nabla)q [0]

where q is velocity. We have all these properties which can be easy to implement in a UDF and visualised using a user defined scalar.

However, I want to do this using the shear stress alone where we have tau xx[0] + tau xy[1] for the X momentum term which should then be equal or close to equal to the other method. However, I have been unsuccessful in doing so, my stress components are given as follows (note some over expansion etc for data analysis purposes). Instead of this longwinded way is there a shear stress variable available or do I need to calculate this. Is there a clear problem with my implementation process?

/*tau_xx*/

C_UDSI(c,t,0) = (-2/3)*(C_MU_L(c,t))*(C_DUDX(c,t) + C_DVDY(c,t)) + 2*(C_MU_L(c,t) + C_MU_T(c,t))*C_DUDX(c,t);

/*tau_xy*/

C_UDSI(c,t,1) = (C_MU_L(c,t) + C_MU_T(c,t))*(C_DVDX(c,t) + C_DUDY(c,t));

/*tau_yy*/

C_UDSI(c,t,2) = (-2/3)*(C_MU_L(c,t))*(C_DUDX(c,t) + C_DVDY(c,t)) + 2*(C_MU_L(c,t) + C_MU_T(c,t))*C_DVDY(c,t);

Thanks.

## Comments

12,186Forum CoordinatorWe have the shear rate, with some explanation here https://forum.ansys.com/discussion/comment/111686#Comment_111686 C_STRAIN_RATE_MAG(c,pt) which is used when we need to code up nonNewtonian viscosity models. Check the Custom Field Functions too, if you're just plotting they can be quicker and don't require coding.