# Variable mass flow rate (Step function) dependent on Coordinates UDF

 Register Blogs Members List Search Today's Posts Mark Forums Read

 September 15, 2023, 03:24 Variable mass flow rate (Step function) dependent on Coordinates UDF #1 New Member   veda Join Date: Jul 2022 Posts: 8 Rep Power: 3 Hello. I am trying to use a UDF to model a step function for mass flow rate at inlet of my simulation. It is a simple case of: If the x-coordinate of the face is less than 'certain value', mass flow rate = A, otherwise, mass flow rate = B. I am using the following UDF, but when I initialize and check my case, the entire inlet is initialized with the 94.0 Kg/s. I checked the coordinates and it seems fine. (I can initialize a velocity step function using the same coordinates without any issues, using the same code below (changing inlet_mf to inlet_z_velocity)). I know I can simply divide the face into multiple faces for a step function inlet like this, and specify the mass flow rates separately, but I am practising writing UDFs, so I was hoping if someone would kindly guide me with what I am doing wrong? Thank you. UDF: #include "udf.h" DEFINE_PROFILE(inlet_mf, thread, position) { real x[ND_ND]; real x0; face_t f; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); x0 = x[0]; if (x0 < 27.65) F_PROFILE(f, thread, position) = 212.0; else F_PROFILE(f, thread, position) = 94.0; } end_f_loop(f, thread) } Last edited by saha.vedabit; September 15, 2023 at 05:03. Reason: additional information

 September 15, 2023, 05:01 #2 Senior Member   Alexander Join Date: Apr 2013 Posts: 2,342 Rep Power: 33 code seems to be correct, by default fluent uses SI so meters for x[0] are you sure 27.65 is correct value? __________________ best regards ****************************** press LIKE if this message was helpful

September 15, 2023, 05:09
#3
New Member

veda
Join Date: Jul 2022
Posts: 8
Rep Power: 3
Quote:
 Originally Posted by AlexanderZ code seems to be correct, by default fluent uses SI so meters for x[0] are you sure 27.65 is correct value?
Thank you for your reply. Yes, I tried initializing a velocity field at inlet with the same code just by changing inlet_mf to inlet_z_velocity and speicifying the cartesian velocity at inlet using udf. It is working fine in that case.

I wonder why mass flow rate can't be initialized. Does it have a different associated macro or variable that I am supposed to use?

 Tags cfd, fluent, udf