Multiphase non-Newtonian flow UDF Parse Error

Hello everyone!

I am trying to interpret two UDFs to describe the non-Newtonian behaviour of blood in a multiphase simulation. I have written two DEFINE_PROPERTY functions, included in the text below. However, if I want to interpret them, FLUENT keeps giving me the 'parse error' after starting at the 'Domain *plasma_domain' line.

I have tried numerous things, and also tried to delete the Get_Domain and Lookup_Thread sections in my code. But if I did that, the initialization gave me a mtp_9999 error and the whole simulation immediately quit.

I have no idea what to do next, so maybe someone here has an idea? I know that my mesh is correct, since I used it for a range of other simulations as well. I am using ANSYS version 19.1 and have to run simulations via an external hpc cluster (using max 16 nodes). Maybe that has an influence as well, but I cannot even get the simulation working on my own computer (because I keep getting the parse error / mtp_9999 error).

Thanks in advance!

#include "udf.h"

DEFINE_PROPERTY(granular_viscosity_rbc, cell, thread)


int phase_domain_index, ID = 2;

Domain *mixture_domain;

mixture_domain = Get_Domain(1);

Domain *plasma_domain;

plasma_domain = Get_Domain(2);

Domain *rbc_domain;

rbc_domain = Get_Domain(3);

Thread* mixture_thread;

mixture_thread = Lookup_Thread(mixture_domain,ID);

real muplasma = 0.006;

real murbc = 0.01;

real mumix = 0.0037;

real eps_rbc = 0.45;

real lambda = 0.110;

real m = 9.106;

real n = 0.749;

real sr = 500;

Thread* mixture_thread;

Thread* subthread;

sub_thread_loop(subthread, mixture_thread, phase_domain_index)


if(subthread == Lookup_Thread(plasma_domain,ID))




else if(subthread == Lookup_Thread(rbc_domain,ID))


sr = C_STRAIN_RATE_MAG(cell,subthread);

eps_rbc = C_VOF(cell,subthread);



n = 0.8092*pow(eps_rbc ,3.) - 0.8246*pow(eps_rbc ,2.) - 0.3503*eps_rbc + 1.;

m = 122.28*pow(eps_rbc ,3.) - 51.213*pow(eps_rbc ,2.) + 16.305*eps_rbc + 1.;

mumix = m* pow( (1.+ pow((lambda*sr) ,2.) ),((n-1.)/2.) );

murbc = (mumix*muplasma -(1.-eps_rbc)*muplasma)/eps_rbc;

return murbc;


#include "udf.h"



int phase_domain_index;

int ID=2;

Domain *mixture_domain;

Domain *plasma_domain;

Domain *rbc_domain;

Thread *mixture_thread;

Thread *subthread;

real rhoplasma = 10;

real rhorbc = 10;

real vof = 0.45;

real rhomix = 1080;

sub_thread_loop(subthread, mixture_thread, phase_domain_index)


if(subthread == plasma_domain)


rhoplasma = C_R(cell,subthread);


else if(subthread == rbc_domain)


vof = C_VOF(cell,subthread);


rhorbc = (rhomix - (rhoplasma*(1-vof)))/(vof+1e-4);


return rhorbc;



  • DrAmineDrAmine GermanyForum Coordinator

    I recommend compiling the UDFs: with 20R2 on Windows you have an in.built compiler.

    I guess you can just the properties right away you do not require to get any domains here as it is hooked for the right phase domain,

    Please share the equations you want to get in and not only the code..

  • Dear DrAmine,

    Thanks for your quick reply! I indeed am trying to compile the functions (running from the cluster). If I do this, I do not get the syntax error, however, if the simulation starts I get the 'floating point exception' error:

    Error at Node 0: floating point exception

    Error at Node 3: floating point exception

    Error at Node 1: floating point exception

    Error at Node 5: floating point exception

    Error at Node 6: floating point exception

    Error at Node 4: floating point exception

    Error at Node 7: floating point exception

    Error at Node 2: floating point exception

    So what I would like to achieve is the following:

    • Describe the blood-flow in a bended tube using a two-phase model: red blood cells (rbc's) suspended in plasma.
    • To get a proper description of the non-Newtonian behaviour, use a UDF that implies an adjusted version of the Carreau-Yasuda model. This model returns the granular viscosity and density of the red blood cells according to the following relationships:

    Thus, the red blood cell volume fraction (epsilon_rbc) should be extracted from the cell in order to calculate n and m. These parameters can then in their turn compute the viscosity of the mixture using the shear rate. This shear rate should, on its turn, also be extracted from the cell.

    I hope that you understand what I am trying to achieve haha! thanks for your effort.

    Kind regards,


  • DrAmineDrAmine GermanyForum Coordinator

    First of all do you require to model blood as multiphase flow? If yes: okay...

    Regarding the viscosity model: which multiphase model you want to use? is the first mu_mix rather a mu_rbc?

    For the density you do not require an UDF. Only for the viscosity to prescribe that non-newtonian behavior of (I think) rbc.

  • Dear Dr. Amine,

    Yes it is my thesis subject to investigate the influence of the multiphase model :) I am using the Eulerian-Eulerian approach!

    The first mu_mix is the viscosity of the mixture according to the carreau-yasuda model. However, since you cannot enter a mixture viscosity in the two-phase model, I compute the viscosity of the rbc's in order to implement it in fluent.

    Do you mean you do not require an UDF for rbc density since it is not taken into account in the model? I wanted to include it for completeness and since the previous researcher also did so.



  • DrAmineDrAmine GermanyForum Coordinator

    It does not make a sense to enter a mixture viscosity for Eulerian Multiphase. Here better to enter the same viscosity for both phases which will do the trick. Or you enter for mu_rbc the expression required so that the mixture viscosity is the same as you wrote for your formula something like


    Imagine you want to enter the expression for RBC via DEFINE_PROPERTY you do not need to access any other threads: everything is provided to you right away. Be aware here that variables like strain rate are phase specific. The return value will be used laminar viscosity.

    In Eulerian the momentum equations are solved for each phase: so mixture properties are not used for solving!

  • Thank you your input has been very useful already so far! I am busy editing and updating and will let you know the progress! Thanks a lot already :)

  • RobRob UKForum Coordinator

    Some bedtime reading too -

    Gijsen F.J.H., van de Vosse F.N., Janssen J.D.; 1999; The Influence of the non-Newtonian properties of blood on the flow in large arteries: steady flow in a carotid bifurcation model; Jou of Biomechanics, Vol 32, pp601

Sign In or Register to comment.