How strain rate works in Herschel-Bulkley viscosity model?

Hello everyone,

In the latest Ansys update, we can see there is a new window -" STRAIN RATE" in the Herschel-Buckley viscosity model.

Want to know how this works and is there any manual for it?

And how can I create a UDF to define Herschel-Bulkley viscosity model?

Thank you.


  • RobRob UKForum Coordinator

    It'll be covered in the documentation, check in Materials in the User's Guide. It is also possible to write a UDF for the model (I've done it for other viscosity models), ask your supervisor to look on the Ansys Customer Portal for the Carreau-Yasuda model.

  • Dear Sir,

    Thank You for answering.

    Is it not written yet? I didn't find anything on strain rate on the user manual. I am running the 2020R2 student version for a research purpose.

    Is there any tutorial on how I can write a UDF for Herschel-Bulkley viscosity model?

    Thank You Sir.

  • DrAmineDrAmine GermanyForum Coordinator

    Viscosity to be prescribed as UDF via DEFINE_PROPERTY or as expression.

  • Dear Dr. Amine Sir,

    Sir, the fluid in my project is drilling fluid which follows the Herschel-Bulkley viscosity model. So for a proper analysis I need the UDF. I need to compare my results with another model to validate my results. The other model used Herschel-Bulkley viscosity model UDF.

    Yes Sir. But I need a whole tutorial on how to write the UDF in C++ or C language, since I also have to specify the critical stress, flow behavior index, consistency index and yield stress and I don't know how it's done. Is there any?

    I saw in Ansys 2020R2 there is a new window "Strain Rate" in Herschel-Bulkley viscosity model. Looked for it in the user manual but there is nothing there on Strain rate and how it works.

    Thank You Sir for answering.

  • RobRob UKForum Coordinator

    There's an example for DEFINE_PROPERTY in the manual, and Section Derivative Macros of the 2020R2 UDF manual will help. There is an example on the Customer Portal that your supervisor (ie registered Ansys contact) can access: we're not permitted to share it on here.

  • DrAmineDrAmine GermanyForum Coordinator

    @uditkumar007 : why do you need an UDF? Do you need another flavour of the in-built approach?

  • Dear Rob Sir,

    Thank you Sir I will look into it. Sir, sadly my supervisor isn't registered as Ansys contact. I have to solve this by myself.

  • Dear Dr Amine Sir,

    Sir, I am not sure the UDF I want to run whether the built-in approach covers it. Also there is a new window called "Strain rate" there isn't anything mentioned about "Strain Rate" and how it works in the User manual of Ansys 2020R2.

    Sir I wrote this code with the help of my supervisor, not sure how to run it though and if the build in approach covers this code or not. I am posting it here,

    #include "udf.h"

    FILE *fp;

    DEFINE_PROPERTY(hb_viscosity, c, t)


    real viscosity;

    real stress;

    real ys;

    real n, m;

    real k;

    real Max, Min;

    n = 0.94;

    ys = 4.022;

    k = 0.04;

    m = 1000;

    Max = 100000;

    Min = 0.00000000001;

    stress = C_STRAIN_RATE_MAG(c,t);

    viscosity = ys*(1-exp(-m*stress))/stress + k*pow(stress,n-1);

    return viscosity;


    Can you tell me how can I run this UDF? Every time I try to interpret the UDF and run it, I receive this error. Without the UDF the model runs fine.

    Thank You Sir for answering. I would be grateful for any kind of help.

  • The max and min values of Strain rate in the built-in Herschel-Bulkley model doesn't change. I tried to put the values of the code in the built-in window, but the values stay the same. I don't know what the issue is here.

    Thank You Sir.

  • RobRob UKForum Coordinator

    You may want to alter the min and max to more realistic values. Gases tend to be around 1e-5 and tar is about 5 (rough guess). The range you have may be responsible for the problem, especially if the initial turbulence values are nonphysical.

  • Sir, I am using drilling fluid as the fluid material. Drilling Fluid follows the Herschel-Bulkley viscosity model. The values of k, n and Yield stress are given.

    k = 0.04;

    n = 0.94;

    ys = 4.022 Pa;

    What should be the values count , max and min values in this strain rate section for Drilling fluids? The values are kind of fixed. No matter what I number I put, it changes back to the default values expect for Count. We can only change the values of Count from "10-1000" range.

  • RobRob UKForum Coordinator

    That's the plotting variable: you need to fill in the values on the left. Look at the graph x-axis.

  • Yes sir I did so. But the max and min number in strain rate doesn't change whatever I put. It stays 500 and 300 by default. Why is this happening?

  • RobRob UKForum Coordinator

    Have you added data for k, n, yield and critical shear and OK'd the input? The min and max are for the display, from what you've shown there's nothing to display

  • Yes Sir I did. I tried to change the max, min and count values according to the UDF. But the max and min value doesn't change. The default values doesn't change.

  • For the UDF, I changed the range for max and min still I am receiving the same error. Is there anything with the code?

    When I interpret the code it doesn't show any error though. Where is the problem? My mesh quality is fine too.

    Skewness: Max = 0.72

    Orthogonal quality: Min = 0.33

  • RobRob UKForum Coordinator

    What error are you seeing?

  • Sir the same error as before.

    The error message is like this:

    iter continuity x-velocity y-velocity z-velocity time/iter

    Stabilizing x-momentum to enhance linear solver robustness.

    Stabilizing x-momentum using GMRES to enhance linear solver robustness.

    Divergence detected in AMG solver: x-momentum Stabilizing y-momentum to enhance linear solver robustness.

    Stabilizing y-momentum using GMRES to enhance linear solver robustness.

    Divergence detected in AMG solver: y-momentum Stabilizing z-momentum to enhance linear solver robustness.

    Stabilizing z-momentum using GMRES to enhance linear solver robustness.

    Divergence detected in AMG solver: z-momentum Stabilizing pressure correction to enhance linear solver robustness.

    Stabilizing pressure correction using GMRES to enhance linear solver robustness.

    Divergence detected

    Error at Node 0: floating point exception

    in AMG solver: pressure correction

    Error at host: floating point exception

    ===============Message from the Cortex Process================================

    Compute processes interrupted. Processing can be resumed.


    Error: floating point exception

    Error Object: #f

    Registering Udf, ("D:\2020 R2 new\vis.c")

    Calculation complete.

  • The model runs fine without the UDF. I am receiving this error when I try to apply the UDF.

Sign In or Register to comment.