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

Defining UDF function for Time-dependent mass flow

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 27, 2022, 03:09
Default Defining UDF function for Time-dependent mass flow
  #1
New Member
 
cfdstudent12
Join Date: Jun 2022
Posts: 1
Rep Power: 0
cfdstudent12 is on a distinguished road
Hello,

I am new to UDF functions in Flunet and would like to set mass inlet.

Definition of the problem: An insulated cylinder containing helium at 200 bar is kept at the constant temperature of 50 °C. When the valve is opened, gas enters the volume with initial temperature of 380 °C and pressure of 0.1 bar. In our simulation cylinder will be replaced with mass inlet.

When I compile the code, the error appear in line 39 undeclared variable (T = C_T(c,t); )


Any help would be greatly appreciated.


Mass flow is changing according to the pressure difference between the cylinder and the volume.

Flow in to the volume is supersonic so mass flow will be calculated with the following equation:

mfr = (A*P/sqrt(T))*sqrt(kappa/(R/M*1000))*Ma*(1+(kappa-1)/2*Ma^2)^(-(kappa+1)/(2*kappa-1));

A = nozzle area
P = pressure in volume
T = temperature in volume
kappa = specific heat ratio
R = gas constant
M = molar mas of helium gas
Ma = Mach number


Mach number is calculated with the following equation:
Ma = sqrt(2*(p_cyl_new/P)^(kappa-1)/kappa)-1)/(kappa-1));

p_cyl_new = new pressure in cylinder


CODE:

#include "udf.h"

#define A 0.000706858; /* [m^2] Nozzle area */
#define p_cyl 20000000; /* [Pa] Pressure in gas cylinder */
#define T_V 653.15; /* [K] Temperature in volume */
#define T_cyl 323.15; /* [K] Temperature in cylinder */
#define kappa 1.667; /* [/] Heat Capacity ratio */
#define R 8.3144; /* [J / (K mol) ] Gas constant */
#define M 4.0026; /* [g/mol] Molar mas of helium gas */
#define V_cyl 3.75; /* [m^3] Volume of gas in cylinder */






DEFINE_PROFILE(mass_flow, t, i)
{

face_t f;

real c_t_step; /* current time step */
float Ma; /* Mach number */
float mfr; /* Mass flow */
float p_cyl_new; /* pressure in cylinder */
float dm; /* Change of mass in time step */
float T; /* Current temperature in volume */
float P; /* Current pressure in volume */

c_t_step = CURRENT_TIMESTEP; /* current timestep */



dm = 2.7625; /* mass of gas in volume at the beginning */

begin_f_loop(f, t)
{

T = C_T(c,t); */ Current temperature in volume */
P = C_P(c,t); */ Current pressure in the volume */

p_cyl_new = p_cyl-dm*R*T_cyl/(V_cyl * M); /* new pressure in cylinder */
Ma = sqrt((2*pow(((p_cyl_new/P),(kappa-1)/kappa))-1)/(kappa-1))); /* Mach number */
mfr = (A*P/sqrt(T))*sqrt(kappa/(R/M*1000))*Ma*pow(1+(kappa-1)/2*pow(Ma,2),(-((kappa+1)/(2*kappa-1)))); /* mass flow */
dm += mfr*c_t_step; /* change in mass inside of the volume */


F_PROFILE(f,t,i) = mfr;
p_cyl = p_cyl_new;
}
end_f_loop(f,t)
}
Attached Images
File Type: jpg Mass_flow_nozzle.jpg (43.8 KB, 2 views)
cfdstudent12 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
Mass flow dependent pressure profile. Pinxty FLUENT 0 October 9, 2020 20:26
Mass flow rate history over solution step- rhoSimpleFoam gian93 OpenFOAM Post-Processing 0 December 8, 2019 10:20
Pressure Outlet Targeted Mass Flow Rate LuckyTran FLUENT 1 November 23, 2016 10:40
Mass Flow Rate Custom Field Function AJoubert FLUENT 2 March 23, 2013 08:50
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 09:56


All times are GMT -4. The time now is 01:20.