CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF problem (

cp_jef July 21, 2011 13:40

UDF problem
Hi FLUENT Gurus,

I am trying to create a UDF that changes the velocity magnitude at the inlet only after certain conditions are satisfied. Basically, once the pressure at the inlet has stabilized (during interations; this is a steady-state analysis), the velocity at the inlet needs to be changed so as to deliver a certain value of pumping power, P_predefined = deltaP*A_inlet*V_avg_inlet. So, once the pressure at the inlet seems to have stabilized, the inlet velocity is to be adjusted to V_avg_inlet = P_predefined/(deltaP*A_inlet). The UDF has to continue to adjust the inlet velocity until the predefined value of pumping power is achieved within a certain accuracy. Any suggestions as to how to go about doing this?




johnwinter August 12, 2011 03:28

i think you can do it by using DEFINE_ADJUST UDF
may be you can also use DEFINE_PROFILE.
good luck

cp_jef August 12, 2011 14:05

Hi John,

Thanks for the reply. I'm currently using "DEFINE_PROFILE" to adjust the inlet velocity and "DEFINE_ADJUST" or "DEFINE_EXECUTE_AT_END" to calculate the area-weighted average of pressure at the inlet. (One of) The later functions feed into DEFINE_PROFILE as input (P_avg) to calculate the new velocity magnitude (average). However, once I have hooked the UDFs to Fluent, I continue to get "Error: divergence detected in AMG solver: x-momentum" even when I drop the momentum URF to 0.01 and change solvers. Any suggestions of how to tackle this issue?



johnwinter August 13, 2011 02:01

It is difficult to say what may be the exact problem. But i have few suggestions
1. Check units consistency
2. Print Pressure or velcoity values at the inlet face, check if there are any abnormal values.

Good luck

cp_jef August 13, 2011 13:21

Thanks again!
Hi John,

Thanks for the input. Now that I think about it, I don't recall having scaled my model to m from mm. Since the UDF manual specifies that all operations are carried out in SI units, I guess that might be my mistake. Anyway, I'll take a crack at it and hope for the best.
With regard to your second point, the solution doesn't even get through the first iteration, so I do not have the option of checking values. If you can think of something else that might be causing issues, kindly bring it to my attention.

As always, thanks for your input.


John EF

niravtm007 August 29, 2011 02:31

velocity inlet udf
hiii friends i am entirely new to using udf's in fluent. I have a cubical geometry, with two inlets on perpendicular adjacent faces. i have to implement udf to only one of the conditions.
i have two cases
1) parabolic velocity inlet ( space varient)
2) sinusodial velocity velocity inlet ( time variant)
can any one pls send me the udf ( code

johnwinter August 29, 2011 07:02

Hi Nirav,

Fluent manual have velcoity profile example. Please their velcoity function with yours.
you can find example here

Good luck

niravtm007 August 30, 2011 00:04

thanks john i will try that

niravtm007 August 30, 2011 07:27

Hii john i tried that link but didnt really have my kind of problem. i have worked out with 2d udf for parabolic velocity inlet.
please help me how this code will change with 3d. i wanna know how will be the equation considering 3rd dimmension.
as in 2d we have V(x)=Vmax- y^2/(disatnce from centre in y direction )^2 * Vmax.
please help me.
also give suggestion how to work out on sinusoidal inlet udf.
thanks in advance

All times are GMT -4. The time now is 05:51.