CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF to adjust pressure outlet (

a.lynchy February 24, 2010 14:14

UDF to adjust pressure outlet
I am trying to write a UDF and have no experience doing this:confused:.

What i require the UDF to do, is to determine the mass flow rate at the outlet and compare it to a set value for mass flow rate. If the set point mass flux and actual mass flux are not equall i want to adjust the outlet pressure in an iterative approach to make them equal.
I want to apply the UDF to a straight pipe initially, with a pressure inlet and pressure outlet as the boundary conditions.

I have atttempted to write the UDF and have got it to interprete but when i initialize the model the Fluent software crashes.

I have attached my attempt at a UDF below:(.

Any help or direction you could give in relation to this would be greatly appreciated.

#include "udf.h"
#define SET_POINT 0.005
DEFINE_PROFILE(outlet_pressure, thread, nv)
Thread *t;
face_t f;
cell_t c;

real actual_mass_flow;
real pressure = C_P(c,t);

actual_mass_flow = F_FLUX(f,t);

if (actual_mass_flow > SET_POINT)
begin_f_loop (f,t)
F_PROFILE(f,thread,nv) = pressure + 1;
end_f_loop (f,t)

else if (actual_mass_flow < SET_POINT)
begin_f_loop (f,t)
F_PROFILE(f,thread,nv) = pressure - 1;
end_f_loop (f,t)

begin_f_loop (f,t)
F_PROFILE(f,thread,nv) = pressure;
end_f_loop (f,t)

aounallah February 24, 2010 18:51

hi lynchy

well, I think that you simulates flow in pipe, solving fluid mechanics equations make equal the flow mass rate in entrance to the exit (continuty eqt.)
you can improve accuracy by reduicing the tolerance of equation and verfing the net imbalance between inlet and outlet

I think it is not necessary to use UDF just to equalize the flow rate

what you are thinking ? ?? :)

a.lynchy February 25, 2010 07:07

Thanks aounallah,
i agree for a straight pipe the mass flow in and out must balance. I suppose i should have outline the actually final geometry i will be applying it to.

The geometry i have is an artery system with 3 inlets and 6 outlets, with communication arteries that connect all inlets ad outlets. I know the pressure and mass flow rate at the inlet and i know what ratio the mass flow rate is divided between the outlets. What i want to get is the pressure at the outlets. I want these pressure outlet values because in later models i will have to set a pressure in and pressure out as the BC's.

Fluent does not allow a pressure inlet and outflow BC :mad: unfortunately, so i was trying to set a pressure inlet and pressure outlet. However i only have an idea of what p out should be, so i was trying to use an iterative process in the form of a UDF to determine the pressure out i requires to the mass flow rates out each outlet then i want.

niravtm007 February 13, 2012 05:03

pressure udf
Hii friends
My problem is flow through river channel, I have taken a orbitary region so at exit of my geometry flow exits into river itself. so i need to know how to apply UDf at exit, as pressure must vary with P=row*g*h. my exit cross section is not uniform so what should i do please help. is it possible to apply custom field function ???? pressure should vary with outlet depth of water which changes with depth of liquid at outlet. so how can i apply udf ?????

All times are GMT -4. The time now is 14:57.