UDF for Specific Heat  Problem
Hi all! :)
Im doing simulations with High temperature and pressure differences for argon and have specified UFD's for the density, Cp, Therm. cond. and viscosity using Multiple Regression in Excel (with respect to both Temp. and pressure). Loading the UFD's works great. No error messages. But when i try to choose "user  defined" in the drop down menu for Cp (Specific heat) in the Materials setup i get the error message: "No user defiend functions have been loaded". :( For all the other material properties: density, therm cond etc. the loaded UDF's pops up and and i can choose anyone of them with no problem. Im using Fluent v. 14.5. The code im using looks something like this: #include "udf.h" #include "math.h" DEFINE_PROPERTY(cp_ar, c,t) { real p_operating_Pa; real p_pressure_Pa; real abs_pressure_Pa; real Temp_K; Temp_K = C_T(c,t)+273; p_pressure_Pa = C_P(c,t); p_operating_Pa = RP_Get_Real("operatingpressure"); abs_pressure_Pa = p_operating_Pa + p_pressure_Pa; cp_ar = 0.25 + 0.00060 * abs_pressure_Pa  0.0099 * Temp_K; return cp_ar; } Any help would be great. thx.:) 
Quote:
For specific heat you cannot use define_property but you must use define_specific_heat; however, I think it is not possibile to define specific heat in terms of pressure. You can define cp function of temperature, see the following example: Code:
#include "udf.h" Code:
real T: Temperature for the calculation of the specific heat and enthalpy why this? Code:
Temp_K = C_T(c,t)+273 Daniele 
Thx for ze answer! i think i found a way round the problem. Im currently using the DEFINE_SPECIFIC_HEAT marco but with the same code(ish). But since i cant use the C_P(c,t) in my calculations im only using the operating pressure. I think it still might work since the pressure difference in the domain wont change much form the operating pressuer. (around 1700 bars)
Dont know why i hace set the Temp_K=C_T(c,t) + 273.. 
ok, this is right since you can define through fluent udf only specific heat at constant pressure.
Remember to add to your code *h enthalpy calculation. Daniele 
hello dear friends, recently i got that for defining the specific heat, we need to use DEFINE_SPECIFIC_HEAT macro and so i did it but im not sure if my udf code is right?
can u give me the honor to have a look at it? the code is below and the formula is attached, and just to mention first of all i'd used this code: real temp=C_T(cell,thread) just like other parts and then i deleted it and used the T variable cause i need it in rho_w line, is it the right way? best regards /************************************************** ******************* Fluent UDF Author: Milan all calculations for al2o3 nanoparticles ************************************************** ********************/ #include "udf.h" #define FI 0.01 #define RHO_np 3600 #define SI_1 0.9830 #define SI_2 12.959 #define KTC_np 36 #define TI 5.E4 #define BETA_1 8.4407 #define BETA_2 1.07304 #define CP_w 4200 #define KA 1.383E23 #define SIi_1 2.8217E2 #define SIi_2 3.917E3 #define SIi_3 3.0669E2 #define SIi_4 3.91123E3 #define T_0 298.15 #define D_np 59.E9 #define CP_np 765 DEFINE_PROPERTY(cell_conductivity,cell,thread) { real ktc,ktc_w,temp,f,beta,rho_w; temp = C_T(cell,thread); f = ((SIi_1*FI+SIi_2*temp)/T_0)+(SIi_3*FI+SIi_4); beta = BETA_1*(pow(100*FI,BETA_2)); rho_w = (3.570*(pow(10,3))*(pow(temp,2))+(1.88*temp+753.2)); ktc_w = (8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)0.5981); ktc = ((KTC_np+(2*ktc_w)2*(ktc_wKTC_np)*FI)/(KTC_np+(2*ktc_w)+(ktc_wKTC_np)*FI))+(TI*beta*FI*rho_w*CP_w*(pow(((KA*temp )/(RHO_np*D_np)),0.5))*f); return ktc; } DEFINE_PROPERTY(cell_density,cell,thread) { real temp,rho_w,rho; temp = C_T(cell,thread); rho_w = (3.570*(pow(10,3))*(pow(temp,2))+(1.88*temp+753.2)); rho = (FI*RHO_np)+((1FI)*rho_w); return rho; } DEFINE_PROPERTY(cell_viscosity,cell,thread) { real mu,mu_w,temp; temp = C_T(cell,thread); mu_w = (2.591*(pow(10,5))*(pow(10,(238.3/(temp143.2))))); mu = (SI_1*exp(SI_2*FI)*mu_w); return mu; } DEFINE_SPECIFIC_HEAT(specificheat, T, Tref, h, yi) { real cp,rho_w,rho; rho_w = (3.570*(pow(10,3))*(pow(T,2))+(1.88*T+753.2)); rho = (FI*RHO_np)+((1FI)*rho_w); cp = (FI*RHO_np*CP_np)+(((1FI)*rho_w*CP_w)/rho); return cp; } http://upload7.ir/imgs/201404/51072664768343189552.jpg 
Hi, I think it's ok, test it.
From the cp formula I think there is a mistake: cp = (FI*RHO_np*CP_np)+(((1FI)*rho_w*CP_w)/rho); should be changed to: cp = ((FI*RHO_np*CP_np)+((1FI)*rho_w*CP_w))/rho; Are you sure you don't need to add enthalpy calculation in the Cp part of code? 
Quote:
yessss that was the point,small but really important.i modified it and now i can run the calcs without any error or problem, but is there any necessity to add enthalpy equation in this code, since my goal is to calculate cp? 
1 Attachment(s)
Hi,
it depends on the model you use; in anyway I would define it in udf; all you have to do is to integrate the cp to have enthalpy. Look at the attached picture for the integrals (you have to sum the blue terms) and implement them in your udf. You can define an arbitrary Tref (reference temperature) in fluent. Daniele 
Try this and remember to define a reference temperature in fluent, under reference values:
Code:
/********************************************************************* 
A problem
hello dear daniele thank u for ur help that is really kind of u.
but i have some problems: 1 first of all i used my last code(post #7) that needed a correction about parenthesis, without the enthalpy line( u wrote for me), but after running the calcs for a simple tube, and extracted the h diagram in excel, there was an odd diagram about h, it had to be like pic1((attached) for water) but it was very unusual like pic2(attached). 2.when i used the code with ur enthalpy line and interpret it, an error occured about : math.h: No such file or directory any help would be appreciated PIC1WATER http://upload7.ir/imgs/201404/59626825848091859990.jpg PIC2NANOFLUID http://upload7.ir/imgs/201404/31798431275535786671.jpg 
math.h is header necessary for atan (arctan); macro DEFINE_SPECIFIC_HEAT has to be compiled, not interpreted.
Daniele 
pordon
Quote:

Yes,
in fluent you can interpret or compile a udf. To compile a udf you need visual studio installed. Read here for more information: http://www.cfdonline.com/Forums/flu...iledudfs.html From the wiki, for win 7 64 bit: Code:
How can I manage to compile my UDF with Windows 7 64bit? Code:

ok
Ok dear daniele I'll do that. tnx so much

Hi,
I have Windows 8.1 64 bit and Fluent 14.5.7 64 bit. I installed Microsoft Visual Studio 10 Ultimate and it worked like a charm, didn't even need to modify the environment variable, I just had to start Fluent from one of the 64 bit Visual Studio 10 command prompt and it compiled/loaded (I almost cried). 
UDF for specific heat of water
Dear friends, I have to write udf for specific heat of water as function of temperature. I have written according to DEFINE_PROPERTY macro, but it is not working. Specific heat of water as a function of temperature (in deg Celsius) is as follows:
cp = 4.2174356  0.0056181625*temp + 0.0012992528*pow(temp,1.5)  0.00011535353*pow(temp,2.0) + 4.14964*pow(10.0,6.0)*pow(temp,2.5) I have seen in UDF manual DEFINE_SPECIFIC_HEAT, but don't understand how can I write for above defined function. Please help me. Thanks in advance:) 
Hi Daniele,
Dear All, I have just compiled the above UDF for the specific heat of Al2O3 nanofluids in FLUENT. The UDF was compiled and the CASE file was initialised with no errors. However, as soon as I initiated the calculations, I was prompted with a solver error due to a diverging temperature. This was not the case with a constant Cp and with the UDFs for density, conductivity and viscosity. Hence, my suspicion is that the cause of this error is Tref. Hence do we need to specify a reference temperature? Thanks in advance! 
All times are GMT 4. The time now is 19:53. 