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

User Defined Property-Density

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 11, 2011, 23:13
Default User Defined Property-Density
  #1
New Member
 
Join Date: Jun 2011
Posts: 3
Rep Power: 14
bmatsuo is on a distinguished road
Hello,

I am trying to create a user defined density, which is temperature dependent. Basically, I have the values for the density at different temperatures and am using the UDF to interpolate the temperature in the cell to give the value for what the density should be. Below is the UDF that I have written. FLUENT will compile the UDF, but when I try to set the reference values or initialize the solution I get the following error:

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

Here is what I have for the UDF:

#include "udf.h"

int ctr; /*loop counter*/

double temp_data[201] = {280.00, 280.25, 280.50, 280.75, 281.00, 281.25,
281.50, 281.75, 282.00, 282.25, 282.50,282.75,
...(I'll omit the middle values), 330.00};
double dens_data[201] = {971.0105, 969.3090, 967.6075, 965.8965, 964.1615,
962.4265, 960.6770, 958.9135, 957.1450, 955.3620,
...(Omitting middle values), 197.7790};
DEFINE_PROPERTY(cell_density, cell, thread)
{
double rho; /* kg/m^3 */
double rho_1; /* kg/m^3 */
double rho_2; /* kg/m^3 */
double temp_1; /* Kelvin */
double temp_2; /* Kelvin */
double temp = C_T(cell, thread);
for (ctr=0; ctr < 210; ctr++)
{
if (temp >= temp_data[ctr] && temp <= temp_data[ctr+1])
{
temp_1 = temp_data[ctr];
temp_2 = temp_data[ctr+1];
rho_1 = dens_data[ctr];
rho_1 = dens_data[ctr+1];
rho = rho_1+(temp-temp_1)*(rho_2-rho_1)/(temp_2-temp_1);
}
else if (temp < temp_data[1])
{
rho = 971.011;
}
else if (temp > temp_data[210])
{
rho = 197.779;
}
else
break;
}
return rho;
}

Thank you in advance for your help!
bmatsuo is offline   Reply With Quote

Old   July 11, 2011, 23:17
Default
  #2
New Member
 
Join Date: Jun 2011
Posts: 3
Rep Power: 14
bmatsuo is on a distinguished road
Also, the flow is at a constant pressure throughout the whole system.
bmatsuo is offline   Reply With Quote

Reply


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
Set_material_property: null user defined function Albert Franco FLUENT 1 April 4, 2016 08:12
[General] Paraview User defined view prapanj ParaView 3 January 3, 2014 20:54
Creating new user defined material Vidya FLUENT 4 August 26, 2013 09:26
user defined turbulence model manuutin STAR-CD 5 October 14, 2009 05:29
User defined functions Tuomas Koiranen FLUENT 2 December 29, 1999 07:41


All times are GMT -4. The time now is 15:06.