CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Whats is wrong with my UDF (https://www.cfd-online.com/Forums/fluent-udf/194759-whats-wrong-my-udf.html)

gelogghe October 23, 2017 12:55

Whats is wrong with my UDF
 
Hi,

I'm trying to model blood flow on a backward facing step (2D) using a shear-dependent viscosity (non-newtonian). When I use a UDF-defined carreau viscosity, I get normal convergence and results. However, when I'm using a UDF-defined viscosity for both the power-law viscosity and Walburn-Schneck model, I getting following messege (before any iterations took place).

"Error: Divergence detected in AMG solver: x-momentum
Error Object: #f"

code for carreau-viscosity:

#include "udf.h"
#define LAMBDA 3.313
#define N 0.3568
#define MU_ZERO 0.056
#define MU_INF 0.0035

DEFINE_PROPERTY(carr_viscosity,c,t)
{

real mu; /*I created a variable mu*/
real strain_rate;

strain_rate = C_STRAIN_RATE_MAG(c,t);

mu = MU_INF+(MU_ZERO-MU_INF)*pow((1+pow((LAMBDA*strain_rate),2)),(N-1)/2);
return mu;
}


Code for power-law:

#include "udf.h"
#define N 0.6
#define MU_ZERO 0.035

DEFINE_PROPERTY(cell_viscosity,c,t)
{
real mu;
real strain_rate;
strain_rate = C_STRAIN_RATE_MAG(c,t);
mu = MU_ZERO*pow(strain_rate,N-1);
return mu;
}

code for Walburn-Schneck:

#include "udf.h"
#define C_1 0.00797
#define C_2 0.0608
#define C_3 0.00499
#define C_4 14.585
#define H 0.40
#define TPMA 25.9
#define E 2.71828182846

DEFINE_PROPERTY(cell_viscosity,c,t)
{
real mu;
real strain_rate;

strain_rate = C_STRAIN_RATE_MAG(c,t);

mu = C_1*pow(E,C_2*H)*pow(E,C_4*TPMA/pow(H,2))*pow(strain_rate,-C_3*H);

return mu;
}

Could someone tell me what I'm doing wrong?

Thanks!

liliana September 3, 2018 19:43

Hi,

try to set the relaxation factor to a lower value on your initialization. It worked for me.

pakk September 5, 2018 16:58

Not the problem, but really ugly:
Code:

pow(E,C_2*H)
Please replace this (and other places where you take the exponent of E) by:
Code:

exp(C_2*H)
To solve your real problem: I think you just made a mistake in your equations, and have a viscosity that is much too large/small.

- Initialize your case with the carreau-viscosity that worked.
- Change the viscosity to the power law. Don't run the simulation!
- Plot the viscosity, and look which values you get. Are they reasonable?


All times are GMT -4. The time now is 19:57.