CFD Online URL
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

UDF-Specific heat as a function of Temperature

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes
  • 1 Post By ahvz
  • 1 Post By blackmask
  • 2 Post By ghost82

Reply
 
LinkBack Thread Tools Display Modes
Old   May 2, 2013, 22:35
Default UDF-Specific heat as a function of Temperature
  #1
Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 96
Rep Power: 3
ahvz is on a distinguished road
Hi,

I am trying to write a UDF for the Specific heat (Cp) as a function of Temperature.
I used "curve fitting" technique to obtain the formula.

my First question, am I not sure if I put the below formula correctly (the original one is attached) ?

Cp=4.3568+27.57838*exp(-0.5*((K-19.08514)/2.00369)^2)

Second question, why the code is not interrupting ("float" error)? please guide me if through the code is right or not.

As its for a transient analysis so, I expected to call the temperature from current temperature.


#include "udf.h"
DEFINE_SPECIFIC_HEAT(my_user_cp,c,K,thread, position)
{
real cp; /*specific heat as a function of temperature*/
real K; /* Temperature*/


face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(K,f,thread);
Cp = CURRENT_TEMPERATURE;

Cp=4.3568+27.57838*exp(-0.5*((K-19.08514)/2.00369)^2)

F_PROFILE(C, K, position) =Cp;
}
end_f_loop(C,K)
}


regards,
Attached Images
File Type: jpg Capture.JPG (15.7 KB, 13 views)
iriswang likes this.
ahvz is offline   Reply With Quote

Old   May 2, 2013, 23:28
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
As far as I can recall, the binary operator "^" in C means BIT-AND and it expects both operand to be integer, so you should replace
(...)^2
to
pow( (...), 2.0 )
when you need to calculate the power of a float number.

Correct me if I am wrong
blackmask is offline   Reply With Quote

Old   May 3, 2013, 06:27
Default
  #3
Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 96
Rep Power: 3
ahvz is on a distinguished road
Thank you for reply,

Actually, I recived this error for the formula :

pow: too few arguments supplied (argument 2)

which its :

cp=4.3568+27.57838*exp(-0.5*(pow((T-19.08514)/2.00369),2.0)
ahvz is offline   Reply With Quote

Old   May 3, 2013, 07:07
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
Your ")" does not match "("

cp=4.3568+27.57838*exp(-0.5*( pow( (T-19.08514)/2.00369,2.0) ) );
blackmask is offline   Reply With Quote

Old   May 3, 2013, 07:13
Default
  #5
Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 96
Rep Power: 3
ahvz is on a distinguished road
thank you! the formula's error now solved.

but still have error "invalid type for binary expression: int + pointer to float" it belongs to the line after formula I guess.


#include "udf.h"
DEFINE_SPECIFIC_HEAT(my_user_cp,c,T,thread, position)
{
real cp; /*specific heat as a function of temperature*/
real T; /* Temperature*/


face_t f;
begin_f_loop(f,thread)
{


cp=4.3568+27.57838*exp(-0.5*( pow( (T-19.08514)/2.00369,2.0) ) );


F_CENTROID(T,f,thread);
y = CURRENT_TEMPERATURE;
F_PROFILE(f, thread, position) =cp;
}
end_f_loop(C,T)
}


regards,
ahvz is offline   Reply With Quote

Old   May 3, 2013, 08:23
Default
  #6
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
Try this one, adapted from the fluent udf manual.

#include "udf.h"
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi)
{
real cp=4.3568+27.57838*exp(-0.5*( pow( (T-19.08514)/2.00369,2.0) ) );
*h = cp*(T-Tref);
return cp;
}
blackmask is offline   Reply With Quote

Old   May 3, 2013, 08:32
Default
  #7
Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 96
Rep Power: 3
ahvz is on a distinguished road
thank you very much,

It was hooked to the Fluent.

As I have two UDF file, Is it possible to hook two UDF for analysis at same time ?

it seems impossible as I tryied to do!

what I should to do ?


regards,
ahvz is offline   Reply With Quote

Old   May 3, 2013, 08:50
Default
  #8
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
I think at least you can concatenate the two files into a single file.
blackmask is offline   Reply With Quote

Old   May 3, 2013, 10:25
Default
  #9
Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 96
Rep Power: 3
ahvz is on a distinguished road
I did and its work very well. I just paste the second code at the end of first code. let see the results...

many thanks,
ahvz is offline   Reply With Quote

Old   May 4, 2013, 09:14
Default
  #10
Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 96
Rep Power: 3
ahvz is on a distinguished road
would you please tell me how to change inital temperature value in Fluent ? and in C program code as UDF file ?

as I can see the initial temperature (at step 0) for the model, its 26 C by default by Fluent. how can I change it ? where is the option menu in Fluent ? or in this such a case that in transient analysis I must define at UDF file which its already interrupted to the Fluent ?

Note: when I am using hybrid initialization!
regards,

Last edited by ahvz; May 4, 2013 at 09:30.
ahvz is offline   Reply With Quote

Old   May 4, 2013, 09:47
Default
  #11
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
You can use DEFINE_INIT to specify the initial values.
ahvz likes this.
blackmask is offline   Reply With Quote

Old   May 4, 2013, 10:11
Default
  #12
Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 96
Rep Power: 3
ahvz is on a distinguished road
Done!

it works very well, thank you very much,

best regards,
ahvz is offline   Reply With Quote

Old   October 19, 2014, 10:48
Default
  #13
Senior Member
 
ghost82's Avatar
 
Daniele
Join Date: Oct 2010
Location: Italy
Posts: 761
Rep Power: 14
ghost82 will become famous soon enough
Quote:
Originally Posted by blackmask View Post
Try this one, adapted from the fluent udf manual.

#include "udf.h"
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi)
{
real cp=4.3568+27.57838*exp(-0.5*( pow( (T-19.08514)/2.00369,2.0) ) );
*h = cp*(T-Tref);
return cp;
}
It's an old post, but take care that the equation for enthalpy is wrong, since it's valid for constant cp(f(T)).
Correct equation is integral of cp.
mvee and ahvz like this.
ghost82 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 10:31
How to write udf for specific heat nanoraja ANSYS Meshing & Geometry 1 September 14, 2011 12:34
Simulation of a single bubble with a VOF-method Suzzn CFX 18 October 2, 2009 05:18
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 01:35
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 07:27


All times are GMT -4. The time now is 10:34.