Hi, CFD experts. I am trying to get the mass flow rate at numerous outlets and then use them to calculate the compliance pressure (related to the total mass that has passed the outlets) and resistance pressure (related to the volume flow rate through outlets), then to apply the summation of those two pressures to every outlets as a pressure boundary condition. Apparently, those two pressures are mutually related. I have made several versions of UFD, all of them could give me the correct value of compliance pressure, but not the resistance pressure:
Version 1:
#include "udf.h"
real density2 = 1.225;
real comp_2 = 8.99e-8; /* define necessary compliances at outlets */
real mass_flow_rate_outlet2;
real total_flow_mass_outlet2;
DEFINE_EXECUTE_AT_END(get_flow_rate2) /* seems it's totally neglected by interpreter, nothing was printed on console after implementation */
{
Thread *t;
real flow2;
face_t f;
begin_f_loop(f, t)
{
flow2 +=F_FLUX(f, t);
}
end_f_loop(f, t)
printf("mass flow rate at outlet2: %g\n", flow2);
mass_flow_rate_outlet2 = flow2;
flow2=0;
}
DEFINE_PROFILE(pressure_BC2, thread, position)
{
face_t f;
real time = CURRENT_TIME;
real dtime = CURRENT_TIMESTEP;
begin_f_loop(f, thread)
{
total_flow_mass_outlet2 += mass_flow_rate_outlet2*dtime;
F_PROFILE(f, thread, position) = total_flow_mass_outlet2/density2/comp_2 + 133056.6*14*mass_flow_rate_outlet2/density2; /* compliance pressure + resistance pressure */
}
end_f_loop(f, thread)
}
Version 2:
#include "udf.h"
real density2 = 1.225;
real comp_2 = 8.99e-8; /* define necessary compliances at outlets */
real mass_flow_rate_outlet2;
real total_flow_mass_outlet2;
int i;
DEFINE_PROFILE(pressure_BC2, thread, position)
{
face_t f;
real time = CURRENT_TIME;
real dtime = CURRENT_TIMESTEP;
begin_f_loop(f, thread)
{
mass_flow_rate_outlet2 = F_FLUX(f, thread);
total_flow_mass_outlet2 += mass_flow_rate_outlet2*dtime;
F_PROFILE(f, thread, position) = total_flow_mass_outlet2/density2/comp_2 + 133056.6*14*mass_flow_rate_outlet2/density2;
}
end_f_loop(f, thread)
}
As foresaid, they both gave me the correct value of total mass (or compliance pressure), but not mass flow rate (or resistance pressure). Ridiculously, the total mass depends on the mass flow rate. Anyone can give me an explanation on this? Any thoughts is appreciated!