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

UDF for defining specific heat ratio,gas constant,molecular weight

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Bruno Machado

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 16, 2016, 07:54
Default UDF for defining specific heat ratio,gas constant,molecular weight
  #1
New Member
 
soumya nanda
Join Date: Aug 2015
Posts: 9
Rep Power: 11
n.soumya is on a distinguished road
Actually i am doing fluent simulation in which i have to initialize one half of the model with different initial conditions and properties of helium where as the other half has to be initialized with different initial conditions and properties of air. With the help of UDF i am able to intialize both the half with their corresponding initial conditions but i am unable to provide different gas properties to both the halves. I am able to assign gas properties like thermal conductivity, viscosity but basically i want to provide different values of coefficient of specific heat, gas constant, Specific heat ratio and molecular weight to both the halves. Is there any such UDF for defining the above mentioned properties or by any method we can assign the properties. I get an UDF for defining the coefficient of specific heat but it does not consider the cell location as the input argument, So also i want to know how to define different value of Cp to different location.

Thanks in advance.
n.soumya is offline   Reply With Quote

Old   February 16, 2016, 09:21
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
Originally Posted by n.soumya View Post
Actually i am doing fluent simulation in which i have to initialize one half of the model with different initial conditions and properties of helium where as the other half has to be initialized with different initial conditions and properties of air. With the help of UDF i am able to intialize both the half with their corresponding initial conditions but i am unable to provide different gas properties to both the halves. I am able to assign gas properties like thermal conductivity, viscosity but basically i want to provide different values of coefficient of specific heat, gas constant, Specific heat ratio and molecular weight to both the halves. Is there any such UDF for defining the above mentioned properties or by any method we can assign the properties. I get an UDF for defining the coefficient of specific heat but it does not consider the cell location as the input argument, So also i want to know how to define different value of Cp to different location.

Thanks in advance.
I am pretty sure that you can not specific heat based on cell location. It can has a dependence on temperature but not on cell/position.

Regarding different properties for the gas, you can add extra species for your mixture (species A2 and B2, for example), define the different properties for this new species accordingly and in the initial conditions (and inlet, if so) you can define the mass fraction as 0. so in this case you can have

HALF
Y_A1 = 0.2;
Y_B1 = 0.8;
Y_A2 = 0.0;
Y_B2 = 0.0;

OTHER HALF
Y_A1 = 0.0;
Y_B1 = 0.0;
Y_A2 = 0.4;
Y_B2 = 0.6;
Bruno Machado is offline   Reply With Quote

Old   February 17, 2016, 00:32
Default
  #3
New Member
 
soumya nanda
Join Date: Aug 2015
Posts: 9
Rep Power: 11
n.soumya is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
I am pretty sure that you can not specific heat based on cell location. It can has a dependence on temperature but not on cell/position.

Regarding different properties for the gas, you can add extra species for your mixture (species A2 and B2, for example), define the different properties for this new species accordingly and in the initial conditions (and inlet, if so) you can define the mass fraction as 0. so in this case you can have

HALF
Y_A1 = 0.2;
Y_B1 = 0.8;
Y_A2 = 0.0;
Y_B2 = 0.0;

OTHER HALF
Y_A1 = 0.0;
Y_B1 = 0.0;
Y_A2 = 0.4;
Y_B2 = 0.6;
Thanks for ur replay .
I am still a bit confused. let me explain the problem elaborately. I am simulating a tube of length 720 mm which comprises of first section as 120 mm and rest is the second section.All the boundary of the tube is considered as wall. I am initializing pressure properly. To ensure that i am attaching the pressure contour which has different pressure as provided during initialization. I am also initializing the temperature correctly. It has same temperature on both the section as provided during the initialization. Further i am providing density as material property using udf which is also ensured from the density contour. Now the 1st section should contain helium gas and the second section should contain air. As both the gases have different cp and both the section has same temperature, so how to define cp. I have attached the udf of intialization for pressure and temperature. Also i have attached the material define udf for density. So please help me in writing the udf for R,Cp,Gamma and Molecular weight.

DEFINE_INIT(soumya_init,d)
{
cell_t c;
Thread *t;
real xc[ND_ND];


thread_loop_c(t,d)
{


begin_c_loop_all(c,t)
{

C_CENTROID(xc,c,t);

if (xc[0] < 0.12 )

{

C_U(c,t) = 0.;
C_V(c,t) = 0.;
C_P(c,t) = 1965000.;
C_T(c,t) = 298.;
}

else

{

C_U(c,t) = 0.;
C_V(c,t) = 0.;
C_P(c,t) = 80000.;
C_T(c,t) = 298.;

}

}
end_c_loop_all(c,t)
}
}


DEFINE_PROPERTY(my_density, c, t)

{

real rho;

real cr[ND_ND];

C_CENTROID(cr,c,t);

if ( cr[0]<0.12)

{

rho =3.170173;

}

else

{

rho=0.9357141;

}
return rho;
}

press.PNGtemp.PNG
n.soumya is offline   Reply With Quote

Old   February 17, 2016, 06:59
Default
  #4
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
then Ill try to explain better. Create a mixture in which you have helium + air (species 0 and 1). You can use the same loop for initial condition.

PHP Code:
DEFINE_INIT(soumya_init,d)
{
cell_t c;
Thread *t;
real xc[ND_ND];


thread_loop_c(t,d)
{


begin_c_loop_all(c,t)
{

C_CENTROID(xc,c,t);

if (
xc[0] < 0.12 )

{

C_U(c,t) = 0.;
C_V(c,t) = 0.;
C_P(c,t) = 1965000.;
C_T(c,t) = 298.;
C_YI(c,t,0)= 1.0/*This will fulfill the first part with helium*/
C_YI(c,t,1)= 0.0/*This will ensure there is no air in the first part*/
}

else

{

C_U(c,t) = 0.;
C_V(c,t) = 0.;
C_P(c,t) = 80000.;
C_T(c,t) = 298.;
C_YI(c,t,0)= 0.0/*This will ensure there is no helium in the second part*/
C_YI(c,t,1)= 1.0/*This will fulfill the second part with air*/

}

}
end_c_loop_all(c,t)
}

This properties R, Cp, Gamma and Molecular weight can be defined for each species (helium and air) in the Material Panel or if it is the case, you can create a DEFINE_PROPERTY.
n.soumya likes this.
Bruno Machado is offline   Reply With Quote

Old   February 17, 2016, 07:11
Default
  #5
New Member
 
soumya nanda
Join Date: Aug 2015
Posts: 9
Rep Power: 11
n.soumya is on a distinguished road
Hi
thank u for ur help.
But i dont any find any define property command for defining R,Cp,Gamma and Molecular weight. Can u tell me the command for same. Actually i am a learner, so less knowledge. Sorry for bothering you
n.soumya is offline   Reply With Quote

Old   February 17, 2016, 07:22
Default
  #6
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13
Bruno Machado is on a distinguished road
Quote:
Originally Posted by n.soumya View Post
Hi
thank u for ur help.
But i dont any find any define property command for defining R,Cp,Gamma and Molecular weight. Can u tell me the command for same. Actually i am a learner, so less knowledge. Sorry for bothering you
you can define it here (check images) as a constant or using a DEFINE_PROFILE (generic bellow) (Cp cant be specified using DEFINE_PROPERTY, it has a specific macro, but it has dependence only on the temperature)

DEFINE_PROPERTY(property, c, t)
{
int i;
real property;
if (i == 0)
{
property = 1.0; /*insert the value here*/
}
else if (i == 1)
{
property = 0.9; /*insert the value here*/
}
return property;
}


***** EDIT: made a small change in the code ******
Attached Images
File Type: jpg 1.jpg (129.2 KB, 40 views)
File Type: jpg 2.jpg (75.0 KB, 35 views)
Bruno Machado is offline   Reply With Quote

Old   February 17, 2016, 09:37
Default
  #7
New Member
 
soumya nanda
Join Date: Aug 2015
Posts: 9
Rep Power: 11
n.soumya is on a distinguished road
Thanks a lot.
My problem get solved.
n.soumya 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
UDF for specific heat - error tarui23 Fluent UDF and Scheme Programming 0 October 13, 2013 07:30
error message cuteapathy CFX 14 March 20, 2012 07:45
How to write udf for specific heat nanoraja ANSYS Meshing & Geometry 1 September 14, 2011 12:34
Concentric tube heat exchanger (Air-Water) Young CFX 5 October 7, 2008 00:17
Two-Phase Buoyant Flow Issue Miguel Baritto CFX 4 August 31, 2006 13:02


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