CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF Galindo y Rosales

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 6, 2018, 10:58
Default UDF Galindo y Rosales
  #1
New Member
 
Víctor Rueda García
Join Date: May 2018
Posts: 6
Rep Power: 8
victorueda7 is on a distinguished road
Hi everybody, I'm trying to programme a viscosity model using Galindo y Rosales model in fluent 16.1, but when I run the simulation, it crashes and I get the next message:

"Divergence detected in AMG Solver: X momentum"

I write here my code:

#include "udf.h"
#include "mem.h"

DEFINE_PROPERTY(cell_viscosity,c,t)
{
real visco=1;
real mu_0=3.5191;
real mu_c=3.05642;
real gamma_c=7.94343;
real lambda_I=1.161901047;
real n_I=1.28837007;
real mu_max=60.6729;
real gamma_max=79.4275;
real lambda_II=0.0594804;
real n_II=1.83716288;
real lambda_III=0.00206575;
real n_III=0.62014834;
real gamma=C_STRAIN_RATE_MAG(c,t);
real den;
if (gamma==0)
visco=1;
if (gamma<=gamma_c){
den=lambda_I*((pow(gamma,2))/(gamma-gamma_c));
visco=mu_c+((mu_0-mu_c)/(1+pow(den,1.28837007)));
}
if ((gamma>gamma_c)&&(gamma<=gamma_max)){
den=lambda_II*((gamma-gamma_c)/(gamma-gamma_max))*gamma;
visco=mu_max+((mu_c-mu_max)/(1+pow(den,1.83716288)));
}
if (gamma>gamma_max){
den=lambda_III*(gamma-gamma_max);
visco=mu_max/(1+pow(den,0.62014834));
}
return visco;
}

I hope you could help me, thank u in advance.
victorueda7 is offline   Reply With Quote

Old   June 7, 2018, 00:09
Default
  #2
New Member
 
Ngo Bao Chung
Join Date: Sep 2012
Posts: 14
Rep Power: 14
chienfm is on a distinguished road
Hello Víctor Rueda García,

I don't think the error comes from your udf. First try your simulation with constant viscosity, if there is no error, then test your udf. Also, your If-condition in your UDF is not strict, you can simply test your code by print your value in C program.
chienfm is offline   Reply With Quote

Old   June 7, 2018, 01:53
Default
  #3
New Member
 
Víctor Rueda García
Join Date: May 2018
Posts: 6
Rep Power: 8
victorueda7 is on a distinguished road
Quote:
Originally Posted by chienfm View Post
Hello Víctor Rueda García,

I don't think the error comes from your udf. First try your simulation with constant viscosity, if there is no error, then test your udf. Also, your If-condition in your UDF is not strict, you can simply test your code by print your value in C program.
Yes, thank u very much. Indeed, yesterday after post It, I tried what you just have proposed and apparently, the problem is that the value I get in the first denominator is a complex number, but I don't know how to solve this, because I have checked the paper where the equations un my udf come from, and they are well implemented. Do u have any solution?

Thank u very much for your help 😊
victorueda7 is offline   Reply With Quote

Old   June 7, 2018, 03:15
Default
  #4
New Member
 
Ngo Bao Chung
Join Date: Sep 2012
Posts: 14
Rep Power: 14
chienfm is on a distinguished road
As I said, your if-condition is not strict, such as the case gamma == 0, it actually returns the value in second if-condition since gamma = 0 also satisfies gamma < gamma_c. Hence, you should use else-if in this case.

For example
Code:
#include "udf.h"
#include "mem.h"

DEFINE_PROPERTY(cell_viscosity,c,t)
{
	real visco=1;
	real mu_0=3.5191;
	real mu_c=3.05642;
	real gamma_c=7.94343;
	real lambda_I=1.161901047;
	real n_I=1.28837007;
	real mu_max=60.6729;
	real gamma_max=79.4275;
	real lambda_II=0.0594804;
	real n_II=1.83716288;
	real lambda_III=0.00206575;
	real n_III=0.62014834;
	real gamma=C_STRAIN_RATE_MAG(c,t);
	real den;
	if (gamma==0) 
	{
		visco=1;
	}
	else if (gamma<=gamma_c)
	{
		den=lambda_I*((pow(gamma,2))/(gamma-gamma_c));
		visco=mu_c+((mu_0-mu_c)/(1+pow(den,1.28837007)));
	}
	else if ((gamma>gamma_c)&&(gamma<=gamma_max))
	{
		den=lambda_II*((gamma-gamma_c)/(gamma-gamma_max))*gamma;
		visco=mu_max+((mu_c-mu_max)/(1+pow(den,1.83716288)));
	}
	else
	{
		den=lambda_III*(gamma-gamma_max);
		visco=mu_max/(1+pow(den,0.62014834));
	}
	return visco;
}
chienfm is offline   Reply With Quote

Old   June 8, 2018, 06:37
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Code:
else if (gamma<=gamma_c)
    {
        den=lambda_I*((pow(gamma,2))/(gamma-gamma_c));
        visco=mu_c+((mu_0-mu_c)/(1+pow(den,1.28837007)));
    }

Double-check if you copied this correctly from the article.


If gamma<=gamma_c, then "den" becomes negative, so "visco" becomes imaginary. Maybe you missed a minus sign, or should have typed "gamma_c-gamma"?
pakk is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
udf for one dimensional linear motion based on force maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 03:18
Save output of udf in another udf! JuanJoMex FLUENT 0 February 8, 2018 13:43
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 01:53
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 16:43.