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

UDF error for variable Cp

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 16, 2015, 20:16
Red face UDF error for variable Cp
  #1
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Hi all, I have written a UDF to a variable Cp, but when I interpreted it, an error appears on line 12:

line 12: exp: too many arguments supplied (argument 2)

My UDF:
HTML Code:
#include "udf.h" 
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi) 
{ 
real cp; 
real delta=6; 
real Tmelt=299.5; 
real cps=1413; 
real cpl=1797.6; 
real lf=232; 

if (T <= Tmelt) 
{ 
cp = cps+lf*exp(-0,5*(T-Tmelt)*(T-Tmelt)); 
} 
else if (T > Tmelt)
{ 
cp = cpl+lf*exp(-0,5*(T-Tmelt)*(T-Tmelt)); 
} 
*h = cp*(T-Tref); 
return cp; 
}
So, please help me to rewrite it correctly!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:c onfused::c onfused:

Last edited by B.Hamada; May 17, 2015 at 07:22.
B.Hamada is offline   Reply With Quote

Old   May 17, 2015, 16:27
Default
  #2
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
PLeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaase help meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
B.Hamada is offline   Reply With Quote

Old   May 18, 2015, 05:43
Default
  #3
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
#include "udf.h"
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi)
{
real cp;
real delta=6;
real Tmelt=299.5;
real cps=1413;
real cpl=1797.6;
real lf=232;

if (T <= Tmelt)
{
cp = cps+lf*exp(-0.5*(T-Tmelt)*(T-Tmelt));
}
else if (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;
}

Last edited by upeksa; May 18, 2015 at 05:47. Reason: In case it was not clear
upeksa is offline   Reply With Quote

Old   May 18, 2015, 06:14
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Upkesa gives the right answer, I can give some more explanation.

You used:
Code:
exp(-0,5*(T-Tmelt)*(T-Tmelt))
In the c programming language, the symbol used for decimal notation is the dot (.) and not the comma (,). The comma is used to separate inputs. So your code was read as if the function "exp" was called with two arguments, one equal to "-0", and one equal to "5*(T-Tmelt)*(T-Tmelt)". But the function "exp" should only have one argument, so that is why the compiler gave the error message "too many arguments supplied".
pakk is offline   Reply With Quote

Old   May 18, 2015, 07:27
Red face
  #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
#include "udf.h"
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi)
{
real cp;
real delta=6;
real Tmelt=299.5;
real cps=1413;
real cpl=1797.6;
real lf=232;

if (T <= Tmelt)
{
cp = cps+lf*exp(-0.5*(T-Tmelt)*(T-Tmelt));
}
else if (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;
}
Quote:
Originally Posted by pakk View Post
Upkesa gives the right answer, I can give some more explanation.

You used:
Code:
exp(-0,5*(T-Tmelt)*(T-Tmelt))
In the c programming language, the symbol used for decimal notation is the dot (.) and not the comma (,). The comma is used to separate inputs. So your code was read as if the function "exp" was called with two arguments, one equal to "-0", and one equal to "5*(T-Tmelt)*(T-Tmelt)". But the function "exp" should only have one argument, so that is why the compiler gave the error message "too many arguments supplied".
Thank you very much for your help, it's really nice to give a hand to someone who needs a help. salam
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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 08:37
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 08:26
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 07:12
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


All times are GMT -4. The time now is 04:41.