# can i use named expression for specific heat?

Member Posts: 9

I am not able to find the Named expression in the specific heat column.

• Posts: 944Member

This is what I was wondering when you asked the other topic ... Use UDF , there is an example in the manual ... you need to plug your IF statements and formulas.

• Posts: 39Member

I have already written the UDF and compiled the code, but the results are not coming good.

• Posts: 944Member

• Posts: 39Member

DEFINE_SPECIFIC_HEAT(CP, T, Tref, h, yi)

{

real CP, Time;

/*Setting up the magnetic field*/

Time = CURRENT_TIME;

for(;;)

{

if(Time<=4.2)

break;

Time=Time-4.2;

}

CP=0;

if(Time<=0.1)

CP=a+b*T+c*T*T+d*T*T*T+e*T*T*T*T;

if(Time<=2.1 && Time>0.1)

CP=f+g*T+h*T*T+i*T*T*T+j*T*T*T*T;

if(Time>2.1 && Time<=2.2)

CP=a+b*T+c*T*T+d*T*T*T+e*T*T*T*T;

if(Time>2.2)

CP=k+l*T+h*T*T+m*T*T*T+n*T*T*T*T;

*h = CP*(T-Tref);

return CP;

}

Note: I mentioned here a general polynomial function.

• Posts: 39Member

• Posts: 944Member
```DEFINE_SPECIFIC_HEAT(CP, T, Tref, h, yi)
{
real  Time;
/* enter the constants */
real a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0; j = 0, k = 0, l = 0, m = 0, n = 0;
Time = CURRENT_TIME;
if(Time> 4.2) {
Time=Time-4.2;
}
if(Time<=0.1) {
CP=a+b*T+c*T*T+d*T*T*T+e*T*T*T*T;
} else if (Time<=2.1 && Time>0.1) {
CP=f+g*T+h*T*T+i*T*T*T+j*T*T*T*T;
} else  if(Time>2.1 && Time<=2.2) {
CP=a+b*T+c*T*T+d*T*T*T+e*T*T*T*T;
} else {
CP=k+l*T+h*T*T+m*T*T*T+n*T*T*T*T;
}
*h = CP*(T-Tref);
return CP;
}
```

enter the values of a, b, c ...

• Posts: 39Member

Thank you. I'll do that.

Actually, I didn't mention the values of constant here, I just took a general case.