|
[Sponsors] |
June 6, 2018, 10:58 |
UDF Galindo y Rosales
|
#1 |
New Member
Víctor Rueda García
Join Date: May 2018
Posts: 6
Rep Power: 8 |
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. |
|
June 7, 2018, 00:09 |
|
#2 |
New Member
Ngo Bao Chung
Join Date: Sep 2012
Posts: 14
Rep Power: 14 |
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. |
|
June 7, 2018, 01:53 |
|
#3 | |
New Member
Víctor Rueda García
Join Date: May 2018
Posts: 6
Rep Power: 8 |
Quote:
Thank u very much for your help 😊 |
||
June 7, 2018, 03:15 |
|
#4 |
New Member
Ngo Bao Chung
Join Date: Sep 2012
Posts: 14
Rep Power: 14 |
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; } |
|
June 8, 2018, 06:37 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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"? |
|
|
|
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 |