|
[Sponsors] |
July 15, 2016, 13:32 |
UDF for DPM property
|
#1 |
New Member
Sagar
Join Date: Apr 2016
Posts: 23
Rep Power: 10 |
Hello all!
I am new to UDF coding and I'm trying to define a DPM properties for a new material. I have a ASCII tabulated (temperature wise) file for material properties namely: density, Cp, latent heat. I'm able to compile the code successfully. But when I assign these UDF's in the material dialog box, I get a segmentation fault. I'm now wondering whether my UDF is proper and is FLUENT able to actually read it. Here is the code: #include "udf.h" #include "stdio.h" #include "stdlib.h" #include "math.h" DEFINE_DPM_PROPERTY(particle_spheat,c,t,p,T) { double tgiven = C_T(c,t); //solver returned Temperature value int i, j; FILE * fp; static const int maxno = 726; //(1-726) number of values present in the .txt file double temparr[726][1],rhoarr[726],cpliqarr[726],pvaparr[726],hevaparr[726]; //arrays to store the values read from the file double intpart_temp,frac; double cpliqcalc,tempup,templow, tcrit=725.9; fp = fopen("liq_prop.txt", "r"); //data file containing temperature and density values (726 rows) for(i=0;i<maxno;i++) { if(feof(fp)) break; fscanf(fp,"%lf %lf %lf %lf %lf",&(temparr[i][0]),&(rhoarr[i]),&(cpliqarr[i]),&(pvaparr[i]),&(hevaparr[i])); } // fclose(fp); frac = modf(tgiven, &intpart_temp); // modf gives the fractional and integer part of the real temperature // for(i=0;i<maxno;i++) { if(tgiven>tcrit) { cpliqcalc = cpliqarr[725]; break; } else if(temparr[i] == intpart_temp) /*linear interpolation to get Cp value between two temperatures*/ { j = i; templow = temparr[i]; tempup = templow + 1; cpliqcalc = cpliqarr[j] + ((cpliqarr[j+1]-cpliqarr[j]* (tgiven - templow)/(tempup-templow)); } } p->enthalpy = cpliqcalc*(tgiven-T_REF); //FLUENT requires this line to set the particle enthalpy according to the calculated Cp return cpliqcalc; } I am not sure whether Fluent can understand the fopen and fclose commands. To be precise, I can read the density UDF. But when I try to hook Cp UDF, I get a segmentation fault. Last edited by ksgr; July 15, 2016 at 15:45. |
|
August 16, 2016, 05:16 |
|
#2 |
New Member
Sagar
Join Date: Apr 2016
Posts: 23
Rep Power: 10 |
After much deliberation, I found that it was my mistake and a silly one. In taking the temperature from solver I was reading the gas phase temperature for liquid properties
When I read the particle temperature all the problems were solved. |
|
July 12, 2017, 04:51 |
DPM property
|
#3 |
New Member
Join Date: Jan 2017
Posts: 25
Rep Power: 9 |
dear friend,
i want to change the property od my DPM injection property. can we discuss about it. |
|
Tags |
dpm fluent, udf code |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with unsteady calculation with source/sink UDF | RobV | Fluent UDF and Scheme Programming | 3 | March 10, 2016 04:45 |
udf eror + Define property + density | rezvan | Fluent UDF and Scheme Programming | 10 | July 10, 2015 05:30 |
access to a property in a boundary condition using UDF | Negin_Salehi | Fluent UDF and Scheme Programming | 3 | November 16, 2012 17:11 |
UDF programming | fullmonty | FLUENT | 5 | June 30, 2011 03:40 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |