Fluids

Fluids

Unexpected values with a strain rate depending viscosity UDF

    • Antonin HIPPOLYTE
      Subscriber

      Hi everyone,
      I am new to UDF function and I am trying to implement a new viscosity in a lid driven simulation. The required viscosity is proportional to the inverse of the strain rate magnitude and is computed in the following script:


      #include "udf.h"

      DEFINE_PROPERTY(muinverse, c, t)
      {
      real strain_rate_mag;
      real mu;
      real mumin = 0.01;
      real mumax = 1.0;

      strain_rate_mag = pow(C_STRAIN_RATE_MAG(c, t),1);

      mu = 0.01 + 1.0/(1 + strain_rate_mag);
      if (mu < mumin)
      {
      mu = mumin;
      }

      if (mu > mumax)
      {
      mu = mumax;
      }

      return mu;
      }

      However, when I run the simulation and export the viscosity results, I have some parts of the plot that are not in agreement with the analytical solution. Does anyone experienced the same error and do you have any suggestion or explication for this case?

       

      This plot corresponds to the results obtained from the UDF simulation versus the theoretical curve. The red points in the figure corresponds to the unexpected viscosity in the lid driven cavity.

    • Rob
      Ansys Employee

      The code looks OK, although I'm not sure why you included strain_rate_mag = pow(C_STRAIN_RATE_MAG(c, t),1);  rather than just using the macro. Is the result from the UDF maths or the solution? 

       

      • Antonin HIPPOLYTE
        Subscriber

        I previously used the square of the velocity. Actually this step is useless now but I don't think that's the cause of my problem. 

    • Rob
      Ansys Employee

      Agreed. 

Viewing 2 reply threads
  • You must be logged in to reply to this topic.