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/)
-   -   UDF for modified Herschel-Bulkley rheology model (https://www.cfd-online.com/Forums/fluent-udf/218820-udf-modified-herschel-bulkley-rheology-model.html)

aashna@iitp July 5, 2019 01:07

UDF for modified Herschel-Bulkley rheology model
 
1 Attachment(s)
I am trying to write C-code for specifying rheology model of grease. For this, I am using the Herschel-Bulkley model. But my UDF has three compilation errors. I have attached my codes here.
If anyone has any idea about it, please let me know.

AlexanderZ July 5, 2019 01:24

put here your code, NOT PICTURE

you need math.h library,
make all variable types the same (double or float)
2 and 3 lines are confusing

where is information about error you've gotten?

best regards

aashna@iitp July 5, 2019 01:47

UDF for Herschel-Bulkley rheology model
 
#include ''udf.h''
double pow(double, double);
double exp(double);
float yst = 189;
float m = 1;
float k = 4.1;
float n = 0.797;
define VISCOSITY(cell_viscosity,c,t)
{
float visco;
float rate;
rate= (C_STRAIN_RATE_MAG(c,t));
visco =(((yst/rate)*(1-exp((-1)*m*rate)))+(k*pow(rate,(n-1))));
return visco;
}

The errors displaying are:
1. unable to open include file 'UDF.H'
2. For line8, Declaration syntax error

In the Ansys user guide manual, it was given to use udf.h for defining all udfs.

AlexanderZ July 5, 2019 04:31

you should set appropriate environment variables (windows environment variables)
https://www.cfd-online.com/Wiki/Fluent_FAQ
read User-Defined Function (UDF) Related carefully

best regards

aashna@iitp July 19, 2019 09:40

UDF for Herschel-Bulkley rheology model
 
As suggested, I set up the environment variables and then compiled the UDF. It is getting compiled and I am able to successfully hook it to fluent and use it to set the viscosity variation as per the modified Herschel-Bulkley rheology model.

But when the software solves it, an error message pops up. It reads: ''floating-point exception. Divergence detected.''

This is after the first iteration itself. Can anyone suggest me where am I wrong? Are my codes incorrect or there is any problem with the way it is being hooked?

AlexanderZ July 22, 2019 04:12

when you a telling, that there were no errors during compilation, what did you mean?

I've told you, you must put here your code and console output each time!

use code
Code:

#include "udf.h"
#include "math.h"

float yst = 189;
float m = 1;
float k = 4.1;
float n = 0.797;
DEFINE_PROPERTY(cell_viscosity,c,t)
{
float visco;
float rate;
rate= (C_STRAIN_RATE_MAG(c,t));
visco =(((yst/rate)*(1-exp((-1)*m*rate)))+(k*pow(rate,(n-1))));
return visco;
}

best regards

bloodflow August 19, 2019 08:00

It likely diverges becauses the equation or coefficients are wrong, from what I have looked up on the Herschel-Bulkley model I cant understand your equation, can you post a link to the paper you get these values and equations from?


All times are GMT -4. The time now is 02:35.