|
[Sponsors] |
Defining UDF function for Time-dependent mass flow |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 27, 2022, 04:09 |
Defining UDF function for Time-dependent mass flow
|
#1 |
New Member
cfdstudent12
Join Date: Jun 2022
Posts: 1
Rep Power: 0 |
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) } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mass flow dependent pressure profile. | Pinxty | FLUENT | 0 | October 9, 2020 21:26 |
Mass flow rate history over solution step- rhoSimpleFoam | gian93 | OpenFOAM Post-Processing | 0 | December 8, 2019 11:20 |
Pressure Outlet Targeted Mass Flow Rate | LuckyTran | FLUENT | 1 | November 23, 2016 11:40 |
Mass Flow Rate Custom Field Function | AJoubert | FLUENT | 2 | March 23, 2013 09:50 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 10:56 |