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

how to express the exponential function in a UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 31, 2015, 17:29
Talking how to express the exponential function in a UDF
  #1
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Hi all.

how to express the exponential function in a UDF on FLUENT 15.0, I used the epression exp (value) as UDF following shows:
but it does not work.
HTML Code:
#include "udf.h" 
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi) 
{ 
real cp;  
real Tmelt=299.6; 
real cps=1413; 
real cpl=1797; 
real lf=232000; 

if (T <= Tmelt) 
{ 
cp = cps+lf*exp(-0.5*(T-Tmelt)*(T-Tmelt)); 
} 
else /*(T > Tmelt)no need if statement, "else" is enough*/
{ 
cp = cpl+lf*exp(-0.5*(T-Tmelt)*(T-Tmelt)); 
} 
*h = cp*(T-Tref); 
return cp; 
}
but it does not work, so how I express it please
THank you.
B.Hamada is offline   Reply With Quote

Old   June 1, 2015, 09:20
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
"it does not work." is not very useful. To help you, more information would be better.

Does it compile?
Do you get errors?
Do you get warnings?
Do you get results at all?
What do you get for results, what do you expect?
pakk is offline   Reply With Quote

Old   June 1, 2015, 12:17
Default
  #3
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Quote:
Originally Posted by pakk View Post
"it does not work." is not very useful. To help you, more information would be better.

Does it compile?
Do you get errors?
Do you get warnings?
Do you get results at all?
What do you get for results, what do you expect?
Thank you for you help.

So.
I compiled the UDF.
No errors?
no warnings?
I have not achieved the desired results by that UDF
For the results, it did not work for variable specific heat.
B.Hamada is offline   Reply With Quote

Old   June 1, 2015, 13:20
Default
  #4
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
Quote:
Originally Posted by B.Hamada View Post
Thank you for you help.

So.
I compiled the UDF.
No errors?
no warnings?
I have not achieved the desired results by that UDF
For the results, it did not work for variable specific heat.
I knew you had no errors at compilation since I did that code and I checked it some weeks ago

You are not the first one to give this approach to simulate multiphase flow, check this post (also answered by me, by the way)

http://www.cfd-online.com/Forums/flu...em-cp-udf.html

I bet you have a similar problem as related in that post.

Cp variable is quite odd in Fluent: it has its particular UDF instead a "classic" DEFINE_PROPERTY macro. That because the solver integrates Cp and get enthalpy, although it is no that trivial indeed.

I think that your (only) solution is to use the multiphase models of Fluent (VOF, Euler, etc), and if you eventually need an UDF, you should use a DEFINE_SOURCE and DEFINE_MASS_TRANSFER. You will have many posts in this forum dealing with this

If you want to give a last try to your approach, you could drop the energy relaxation factor. It is set as 1 as default, try 0.8 or lower.

Cheers.
upeksa is offline   Reply With Quote

Old   June 1, 2015, 16:08
Default
  #5
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Quote:
Originally Posted by upeksa View Post
I knew you had no errors at compilation since I did that code and I checked it some weeks ago

You are not the first one to give this approach to simulate multiphase flow, check this post (also answered by me, by the way)

http://www.cfd-online.com/Forums/flu...em-cp-udf.html

I bet you have a similar problem as related in that post.

Cp variable is quite odd in Fluent: it has its particular UDF instead a "classic" DEFINE_PROPERTY macro. That because the solver integrates Cp and get enthalpy, although it is no that trivial indeed.

I think that your (only) solution is to use the multiphase models of Fluent (VOF, Euler, etc), and if you eventually need an UDF, you should use a DEFINE_SOURCE and DEFINE_MASS_TRANSFER. You will have many posts in this forum dealing with this

If you want to give a last try to your approach, you could drop the energy relaxation factor. It is set as 1 as default, try 0.8 or lower.

Cheers.
Why are no errors in the UDI, and Fluent does not use it in calculations,
B.Hamada 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 specific heat as function of pressure ghobold Fluent UDF and Scheme Programming 20 August 22, 2019 09:19
using METIS functions in fortran dokeun Main CFD Forum 7 January 29, 2013 05:06
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 10:56
UDF: exporting a variable between two DEFINE function Carlo FLUENT 3 August 19, 2009 13:21
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51


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