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

power law code

Register Blogs Community New Posts Updated Threads Search

Like Tree11Likes
  • 1 Post By majid reza mahjoob
  • 1 Post By Antoine
  • 1 Post By majid reza mahjoob
  • 1 Post By Antoine
  • 1 Post By majid reza mahjoob
  • 5 Post By Antoine
  • 1 Post By alven299

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 7, 2007, 13:19
Default power law code
  #1
majid reza mahjoob
Guest
 
Posts: n/a
hi,how can take the fluent code for power law?(i know that fluent simulate the power law fluids)
presidentmamun likes this.
  Reply With Quote

Old   February 7, 2007, 15:21
Default Re: power law code
  #2
Antoine
Guest
 
Posts: n/a
yes, you can configure it in the Define-->Materials panel. You can select "non-newtonian power-law" instead of "constant" for viscosity properties. When you select Edit, you can enter the consistency, the power-law index, the maximum and minimum value for viscosity. Note that Fluent enables the energy equation. If you are not interested in the solution of the energy equation, you can deselect "Energy" in the Solve-->Controls-->Solution panel and Fluent won't solve this equation. I hope I answered to your question.

Antoine
presidentmamun likes this.
  Reply With Quote

Old   February 8, 2007, 11:08
Default Re: power law code
  #3
majid reza mahjoob
Guest
 
Posts: n/a
thanks Antoine, power law in fluent defined as : k exp(T0/T),but i need to change the power law define to : k exp(T0/(T-T1)),then i need the know how to change the source code of power law fluid in fluent,if can you help me PLEASE help me.

majid reza
presidentmamun likes this.
  Reply With Quote

Old   February 12, 2007, 20:04
Default Re: power law code
  #4
Antoine
Guest
 
Posts: n/a
Sorry to give an answer so late; I'm interested in customizing laws for viscosity too, and I tried with your case without succeeding very well.

So, you can modify the law for viscosity in Fluent using an UDF DEFINE_PROFILE. This UDF is called in the "Material panel" in Fluent selecting "user-defined" for viscosity. In this UDF, you will define your variable for viscosity (ex: mu_app) and define a law for this variable. Then with the line "return mu_app", Fluent will consider the calculated value in the UDF as a value for the viscosity. When you define the law for viscosity, you have to access the shear rate variable and the temperature variable calculated by Fluent. This can be done using C_STRAIN_RATE_MAG(c,t) and C_T(c,t).

Now I will give you the UDF I've done. It works but the problem is that the user-defined viscosity is not initialized correctly: when you select in Fluent the classic non newtonian power law, apparent viscosity is set to the value of k at initialisation. But when you initialize Fluent with your UDF (defining mu_app=k), apparent viscosity is set to the max value (because shear_rate=0), even if you hook a DEFINE_INIT macro. So results calculated with this method are not correct.

I'm sorry to have written so much but if you find the way to initialize correctly this function, please tell me. Here is the UDF:

#include "udf.h"

real mu_app;

real k;

DEFINE_INIT(init_mu_app,d)

{

cell_t c;

Thread *t;

thread_loop_c(t,d)

{

begin_c_loop_all(c,t)

{

k=1;

mu_app=k;

}

end_c_loop_all(c,t)

}

}

DEFINE_PROPERTY(user_power_law,c,t)

{

real visc_dyn_min=0.0001;

real visc_dyn_max=10000;

real index_n=0.9;

real T0=0;

real T1=0;

real temp=C_T(c,t);

real shear_rate=C_STRAIN_RATE_MAG(c,t);

real mu_temp;

mu_temp=(-k)*pow(shear_rate,index_n-1)*exp(T0/(temp-T1));

/*!!1/pow(--)is correct only if index_n < 1; this is written like this only to set mu_app to visc_dyn_max when shear_rate is equal to 0*/

if ((mu_temp>=visc_dyn_min)&&(mu_temp<=visc_dyn_max))

{

mu_app=mu_temp;

}

else if (mu_temp>=visc_dyn_max)

{

mu_app=visc_dyn_max;

}

else if (mu_temp<=visc_dyn_min)

{

mu_app=visc_dyn_min;

}

return mu_app;

}

presidentmamun likes this.
  Reply With Quote

Old   February 13, 2007, 17:28
Default Re: power law code
  #5
majid reza mahjoob
Guest
 
Posts: n/a
Hi Antonie, Thank you very very much, i try to find it and then tell you again,thank you

mahjoob
presidentmamun likes this.
  Reply With Quote

Old   February 17, 2007, 19:42
Default Re: power law code
  #6
Antoine
Guest
 
Posts: n/a
I've finally found the causes of the problem. To initialize correctly the apparent viscosity, I used the current iteration number macro N_ITER, so when it is < 1 (computation is not launched) apparent viscosity is set to a fixed value. Also, in my previous udf, I defined -k because I'm used to see a minus sign before k in the definition of the shear stress. But the apparent viscosity is positive so the minus sign is a source of error because mu_app always took a negative value < visc_dyn_min... I've also modified some lines of the last version of the udf because they finally weren't necessary. Now the udf works fine, I tested the case of a simple power-law and I obtained errors below 0.5% compared to the fluent integrated power-law. Here is the tested last version of the user defined power-law. Even if I don't find problems anymore, you should test it before launching important computations.

#include "udf.h"

DEFINE_PROPERTY(user_power_law,c,t)

{

real visc_dyn_min=0.0001; /*Define the minimum limit for the value of viscosity*/

real visc_dyn_max=10000; /*Define the maximum limit for the value of viscosity*/

real index_n=0.9; /*Define the power law index*/

real k=1; /*Define the consistency index*/

real T0=0; /*Define the reference temperature T0*/

real T1=0; /*Define the fixed temperature T1*/

real temp=C_T(c,t); /*Define the access to the temperature calculated by Fluent through the temp variable*/

real mu_app; /*Define the variable for the apparent viscosity which will be returned to the solver*/

real mu_temp; /*Define a temporary variable to stock the user defined apparent viscosity*/

mu_temp=k*pow(C_STRAIN_RATE_MAG(c,t),index_n-1)*exp(T0/(temp-T1));

if (N_ITER<1)

{

mu_app=k; /*Initialize mu_app to the value of k*/

}

else if

((N_ITER>=1)&&

(mu_temp>visc_dyn_min)&&

(mu_temp<

visc_dyn_max))

}

mu_app=mu_temp; /*Replace the value of mu_app by the calculated user-defined temporary viscosity when the computation has been launched*/

}

else if ((N_ITER>=1)&&(mu_temp>=visc_dyn_max))

{

mu_app=visc_dyn_max;

}

else if ((N_ITER>=1)&&(mu_temp<=visc_dyn_min))

{

mu_app=visc_dyn_min;

}

return mu_app; /*Set the value of the user-defined viscosity in Fluent*/

}

Best regards

Antoine
  Reply With Quote

Old   June 12, 2012, 01:25
Default
  #7
New Member
 
alven
Join Date: Mar 2009
Location: Malaysia
Posts: 25
Blog Entries: 1
Rep Power: 17
alven299 is on a distinguished road
Thanks...this is very helpful
presidentmamun likes this.
alven299 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
DPM-Source Code for Standard Vaporization Law Woo Meng Wai FLUENT 13 April 22, 2020 05:37
power law inlet condition asharma OpenFOAM Running, Solving & CFD 12 May 25, 2018 14:45
How to implement power law or hybrid schemes?? kamkari OpenFOAM Programming & Development 13 January 13, 2018 07:35
Non-Newtonian Power Law for Viscosity John FLUENT 16 September 12, 2015 07:18
new parameter for non newtonian power law model! Antoine FLUENT 0 July 21, 2008 05:30


All times are GMT -4. The time now is 12:54.