CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   pressure udf (https://www.cfd-online.com/Forums/fluent/242924-pressure-udf.html)

le-ceko May 19, 2022 05:19

pressure udf
 
Hi all,

I work on a project and i'm pretty new in UDF.

I have to set an udf depending on the mass flow rate at the outlet.
i try to write an udf code but it doesn,t work :
#include "udf.h"

DEFINE_PROFILE(pressure_outlet,t,i)
{
real inlet_mass_flow_rate = 0.025 ; /* liquid inlet mass flow rate */
real current_mass_flow_rate; /* declare variable for the current mass flow rate */
real error;
real kp = 50; /* proportional constant */
face_t f;
begin_f_loop(f,t)
{
current_mass_flow_rate = F_FLUX(f,t); /* F_FLUX is the mass flow rate through a face */
error = inlet_mass_flow_rate - current_mass_flow_rate; /* difference between each mass flow rate */
F_PROFILE(f,t,i) = F_P(f,t) + kp * error; /* pressure definition */
}
end_f_loop(f,t)
}

I think i have forgotten something. I found an article about that so they said that :

the set point of the exit mass flow rates ( sp
mexit ) was determined as the inlet mass flow rate. The error (Ei)
between the set point and the actual mass flow rate ( ie
m xit ) at the ith time level was calculated as follows:
Ei = msp -mexit
The exit pressure ( i+1 Pexit ) at the next time level was obtained from the current exit pressure (P i exit ) and a correction value proportional to the error
Pexit(i+1) = P(i) - K Ei


All times are GMT -4. The time now is 18:13.