CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Problem with using UDF to modify viscosity (http://www.cfd-online.com/Forums/fluent-udf/112705-problem-using-udf-modify-viscosity.html)

teethfish February 3, 2013 11:15

Problem with using UDF to modify viscosity
 
Hi, I want to modify the viscosity in K-W SST model in Fluent 13.0. But I met a problem that my UDF cannot initiate and it shows that:
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

I have tried initialise without using "compute from" ....but the error was still there, I pasted my UDF here, if anone can help me with that?

#include "udf.h"

DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t)
{
real mu_t;
real a;
real rho;
real k;
real d;

a=(C_R(c,t)-0.5542)/997.6458;
rho = 0.5542+a*a*997.6458;

k = C_K(c,t);
d = C_D(c,t);
mu_t = M_keCmu*rho*k*k/d;
return mu_t;
}

akm February 4, 2013 09:03

Specific dissipation rate C_O(c,t)
 
If you are working with k-w turbulence model, the dissipation rate C_D(c,t) will not be available in the UDFs as it is not calculated by the solver. Instead, specific dissipation rate is calculated C_O(c,t).

For the purpose of your udf calculation, you can covert \omega to \epsilon as under:
http://www.cfd-online.com/Wiki/Speci...ssipation_rate

teethfish February 4, 2013 10:47

Wow, thank you for your help, you really helped me a lot!
And I have one more question, when i use this UDF:

DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t)
{
real mu_t;
real a;
real rho;
real k;
real d;

a=(C_R(c,t)-0.5542)/997.6458;
rho = 0.5542+a*a*997.6458;

k = C_K(c,t);
d = C_D(c,t);
mu_t = M_keCmu*rho*k*k/d;
return mu_t;
}

with realizable k-epsilon model, the results diverged, but it worked well with the RNG-kepsilon model, are they actually different?


Quote:

Originally Posted by akm (Post 405904)
If you are working with k-w turbulence model, the dissipation rate C_D(c,t) will not be available in the UDFs as it is not calculated by the solver. Instead, specific dissipation rate is calculated C_O(c,t).

For the purpose of your udf calculation, you can covert \omega to \epsilon as under:
http://www.cfd-online.com/Wiki/Speci...ssipation_rate


micro11sl May 1, 2013 09:20

Hi teethfish,
Did you get your problem sorted?
I have some problems using the modified turbulent viscosity problem as well. I guess, although you hook a same udf to different turbulence models, there're something different more than the udf. The boundary condition, wall treatment, may be different. So a possible circumstance is the solution behavior is different between two distinct turbulence model with an identical udf.

I am still investigating this.

Sheng

Babs May 17, 2013 07:33

Error occurs in UDF for DPM viscosity
 
Hello to you all,

I hope I post this in the right place, I did not found a more appropriate one...for an atomizer jet I have to write an UDF to express non- newtonian behaviour for the liquid phase. It is not possible to choose any non- newtonian models like cross or carreau or power- law for the DPM- material so I have to write this UDF. I want to realize the model of CROSS with this UDF.

I compiled this UDF and everything works fine but after exactly 9 iteration steps the same error as descriped above ocurrs:

Error:
Ansys received fatal signal (ACCESS VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your contributor.
Error: Object f#

The code I use for realizing the UDF (and that causes this error) is:
------------------------------------------------------------------

#include "udf.h"
#include "dpm.h"


DEFINE_DPM_PROPERTY(cell_viscosity_CROSS_m2, c, t, p)
{
real mu_INF,mu_0,k,mu_CROSS,m;
double aux,SR;

SR=C_STRAIN_RATE_MAG(c,t);


k=0.01372;
m=0.7857;
mu_0=1.885;
mu_INF=0.05320;
mu_CROSS=DPM_MU(p);


aux=pow(SR,m);

mu_CROSS=mu_INF+(mu_0-mu_INF)/(1+k*aux);

return mu_CROSS;
}


I treid it out in steady, in transient, I changed the URF, I just interpreted it I compiled it, but nothing helps...I guess there is some error in the code that I do not see....actually my programming skills are quite bad and I do not have any experience at all with UDF.

I would really appreciate if someone could help me or has some advice for me. Greetings and thank you, have a nice weekend!

blackmask May 17, 2013 08:07

Check one of the pointers before actually access them. Try add the highlighted line to see whether it helps.


Quote:

Originally Posted by Babs (Post 428234)


DEFINE_DPM_PROPERTY(cell_viscosity_CROSS_m2, c, t, p)
{
real mu_INF,mu_0,k,mu_CROSS,m;
double aux,SR;

if ( NULLP(T_STORAGE_R_NV(t, SV_U_G)) ) return;


SR=C_STRAIN_RATE_MAG(c,t);


k=0.01372;
m=0.7857;
mu_0=1.885;
mu_INF=0.05320;
mu_CROSS=DPM_MU(p);


aux=pow(SR,m);

mu_CROSS=mu_INF+(mu_0-mu_INF)/(1+k*aux);

return mu_CROSS;
}



Babs May 17, 2013 08:29

Hello Blackmask,

Thank you for your quick response and your advice. I tried it out but it did not work, the same error occurs at the same iteration step.

Maybe there is something wrong with the usage of the macro DPM_MU(p)? I tried to vary the posibilietes to include this (still I am not sure if I need it) but nothing changes...:-(

blackmask May 17, 2013 09:31

I did not see that your error occurs after several iterations. Did the calculation tends to diverge before the error occurred?

Babs May 17, 2013 13:28

No, not at all...it neither brings any messages of divergences. The residuals are normal and tend to fall than to rise.

Babs May 20, 2013 04:16

Quote:

Originally Posted by blackmask (Post 428270)
I did not see that your error occurs after several iterations. Did the calculation tends to diverge before the error occurred?

But as I found out, before this error occurs, there is brought a message "Advancing DPM injection..." and then the error occurs. So I guess it has directly to do with the particle model and with the code. When I set the viscosity to a constant value it works.

Has anyone any ideas?


All times are GMT -4. The time now is 01:29.