UDF for specific heat
Hi,
Does anybody know why user defined functions dont work with defining specific heat (Cp) in fluent? I need to siulate critcal flows in which specific heat dramatically varies, and there is no way but to use UDFs. piecewise linear method is not that accurate and is very timeconsuming as well. I welcome any suggestion. 
UDFs for specific heat have been implemented in Fluent 12. If you're using Fluent < 12, use a piecewise polynomial, and curve fit your data in Excel or some other similar tool. A good one is www.zunzun.com. How significantly do your pressures and temperatures change?
ComputerGuy 
Thnx for reply. I have Ansys 12.1 but I still can not use define_property macro for Cp. There is also another macro named define_specific_heat which I could not use it, since this macro do not get information for every cell (unlike define_property macro); rather it gets a Temperature from solver which is always constant and equal to zero. In fact the arguments of the 2 functions are totally different. I do not know if I could used the latter for finding Cp at each cell and iteration as a function of cell's temoerature, and could not find a good guid.
Specific heat varies by near 10 times in a 2030 degree temperature range so I can not neglect it. Pieacewise polinomial also does not work since in my version it only accepts 3 pieces, which is not enough for an accurate approximation in my proble. 
What information are you trying to get about the cell other than the temperature, and why is the cell temperature 0? 0 Kelvin?
Send me a private message with that data you're trying to fit, and I'll see if I can find a 3piece polynomial that will do it. 
The specific heat is only function of temperature. My udf is as follows:
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi) { real cp; real TT=T273.16; if (T < 33.) cp = 1000/(.41710.0000008225*pow(TT,3.)); else if (T <37.) cp = 5730.+23590./(1+pow((TT35.33)/(0.9414),2.)); else cp = 1000/(0.9288190.14/pow(TT,1.5)); *h = cp*(TTTref); return cp; } I wrote it according to Ansys 12.0 UDF manual. (of course the way for calculating h must be modified in the udf, but that is not the source of problem.) According to the manual, the macro gets T (temperature), T_ref (some reference temperature) and yi, from the solver and returns specific heat. h is enthalpy. But when I run software with this udf interpreted, the resulted C_p is constant for all cells and equals the value corresponding to 0 (Kelvin), and enthalpy is also some constant negative value. It seems that the solver only gives a constant temperature of zero to the macro. It should be added that the syntax of define_specific_heat macro is different with define_property macro; the latter gets cell and tread as input arguments while the former only get a temperature. 
p_agoodboy,
A couple things: 1) I'd suggest ensuring that all of your values are written floats/doubles. There are 3 values (1000, 1, 1000) that don't have this. It just helps debugging later. 2) Most importantly (I think) is this statement: Code:
*h = cp*(TTTref); Code:
real TT=T273.16; If your code compiles as expected, try and add: Code:
TT=TT+273.16; Code:
*h = cp*(TTTref); For clarity, here's the code as I would write it: Code:
DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi) Best, ComputerGuy Quote:

why don't you use complying instead of interpreting. the complied UDF is recommended for DEFINE_SPECIFIC_HEAT.

Did you guys figure it out?
@ Computer Guy & p_agoodboy
Did you guys figure the UDF for Cp out? I have created the following UDF for Cp of water at 24MPa and Temp varying from 350C to 450C Here is the UDF, I am getting Temperature limited to 1K in many cells (>19,000 cells). Can you guys help me out? #include "udf.h" /* Date: 11/15/2012 Specific heat of supercritcal water at pressure line of 24MPa*/ DEFINE_SPECIFIC_HEAT(specific_heat, T, Tref, h, yi) { real cp; int i; int N1 = 8; real aa[8]={9.731592783661666e+015, 1.074681034976496e+014, 5.086001403165526e+011, 1.337146166142533e+009, 2.109165058548607e+006, 1.996050543970421e+003, 1.049392685740774, 2.364317464886547e004}; int N2 = 5; real bb[5]={1.362812606162869e+016, 8.330882640185808e+013, 1.909751859195201e+011, 1.945719052198394e+008, 7.433859903690445e+004}; int N3 = 8; real cc[8]={7.705464178099725e+012, 7.521528195313355e+010, 3.145122808193584e+008, 7.302941362683474e+005, 1.016975967814141e+003, 0.849330125970483, 3.938872500273441e004, 7.825155875904535e008}; /* Inorder to prevent the solution to collapse in case the temperature of the system goes below the ranges provided the following steps were taken to limit the values to a constant quantity*/ if (T < 618.0) { cp = 6730.0; *h = cp*(TTref); } else if (T > 773.0) { cp = 3634.0; *h = cp*(TTref); } /* Finally the curve fits are implemented in the following way for the three temperature ranges*/ if (T >= 618 && T <= 653.86) { cp = aa[7]; for (i=N12; i>=0; i) cp = cp*T + aa[i]; *h = 0.000029553968311081836302205150257549*(pow(T,8)pow(Tref,8))  0.14991324082011057784922871048496*(pow(T,7)(Tref,7)) + 332.67509066173681731015676632524*(pow(T,6)pow(Tref,6))  421833.01170972138643264770507813*(pow(T,5)pow(Tref,5)) + 334286541.53563326597213745117188*(pow(T,4) pow(Tref,4))  169533380105.51753743489583333333*(pow(T,3)pow(Tref,3)) + 53734051748824.796875*(pow(T,2)pow(Tref,2))  9731592783661666.0*(TTref); } else if (T > 653.86 && T <= 654.96) { cp = bb[4]; for (i= N22; i>=0; i) cp = cp*T + bb[i]; *h = 14867.719807380888960324227809906*(pow(T,5)pow(Tref,5))  48642976.304959848523139953613281*(pow(T,4)pow(Tref,4)) + 63658395306.506703694661458333333*(pow(T,3)pow(Tref,3))  41654413200929.0390625*(pow(T,2)pow(Tref,2)) + 13628126061628690.0*(TTref); } else if (T > 654.96 && T <= 773) { cp = cc[7]; for (i= N32; i>=0; i) cp = cp*T + cc[i]; *h = 0.0000000097814448448806689168386557060517*(pow(T, 8)pow(Tref,8)) + 0.000056269607146763441313043672766168*(pow(T,7)pow(Tref,7))  0.14155502099508049385079289095302*(pow(T,6)pow(Tref,6))+ 203.39519356282819444459164515138*(pow(T,5)pow(Tref,5))  182573.53406708684633485972881317*(pow(T,4)pow(Tref,4)) + 104837426.93978613615036010742188*(pow(T,3)pow(Tref,3))  37607640976.5667724609375*(pow(T,2)pow(Tref,2)) + 7705464178099.724609375*(TTref); } /* Return the value of specific heat calculated by the curve fits*/ return cp; } There is no issue with compiling.. It hooked successfully. Thank you Abhijeet 
udf function
Quote:
can you tell me from where this formula for Cp is taken. Actually i want to know it for my simulation. Do we need to input this Cp in the Cp property of material menu in fluent as UDF. 
Hello!
I need to introduce in FLUENT 6.3.26 a UDF of Cp. There is not the possibility in this version. I tried to introduce a piecewise polynomial, but I need to introduce 4 ranges, and the maximum number is 3! Is there a way to introduce more ranges?? 
All times are GMT 4. The time now is 13:04. 