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

UDF for DPM property

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 15, 2016, 12:32
Default UDF for DPM property
  #1
New Member
 
Sagar
Join Date: Apr 2016
Posts: 23
Rep Power: 10
ksgr is on a distinguished road
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 14:45.
ksgr is offline   Reply With Quote

Old   August 16, 2016, 04:16
Default
  #2
New Member
 
Sagar
Join Date: Apr 2016
Posts: 23
Rep Power: 10
ksgr is on a distinguished road
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.
ksgr is offline   Reply With Quote

Old   July 12, 2017, 03:51
Default DPM property
  #3
New Member
 
Join Date: Jan 2017
Posts: 25
Rep Power: 9
sewgolam is on a distinguished road
dear friend,

i want to change the property od my DPM injection property. can we discuss about it.
sewgolam is offline   Reply With Quote

Reply

Tags
dpm fluent, udf code


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
Help with unsteady calculation with source/sink UDF RobV Fluent UDF and Scheme Programming 3 March 10, 2016 03:45
udf eror + Define property + density rezvan Fluent UDF and Scheme Programming 10 July 10, 2015 04:30
access to a property in a boundary condition using UDF Negin_Salehi Fluent UDF and Scheme Programming 3 November 16, 2012 16:11
UDF programming fullmonty FLUENT 5 June 30, 2011 02:40
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03


All times are GMT -4. The time now is 12:26.