CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Force in UDF (http://www.cfd-online.com/Forums/fluent-udf/109325-force-udf.html)

J14 November 15, 2012 03:56

Force in UDF
 
Hey,

does anybody know who to include a force in an udf. I would like to write an iteration where the mass flow rate is raised if the force is to low and reduced if it is to high as a define force. By force i mean a force which takes place on a special part of my figure because of the fluid flow.

Another question is how can i write down an iteration in an udf.

I hope somebody can help me i tried to do this a long time and it does not work.

Thank you!

Dorit November 20, 2012 02:43

Hi,

For monitoring the force over a given surface you could use the function Compute_Force_and_Moment inside your UDF. It gives you the forces in the x, y and z direction and moments around the x, y and z axis. The function should be applied to a surface that is already defined in the mesh that you import into Fluent, it shouldn't be a surface that you only create in Fluent.

Based on the resultant force/pressure/moment you could then calculate the new mass flow rate that you want. From there you can calculate the new inlet velocity that satisfies your updated mass flow rate. You can then change the inlet velocity using a DEFINE_PROFILE macro.

Not sure what you mean by writing down an iteration in a UDF.

Hope it helps,
Dorit

J14 November 20, 2012 08:08

Alright thank you very much now i got an idea how i can solve my problem. Do you know exactly how to write/ inlcude a Compute_Force_And_Moment function into an udf, because i did not find any information about that. If you have an example which shows how to use the Compute_Force_And_Moment function that would be very helpful. Or do you know where i can find some information about using the Compute_Force_And_Moment function. As you see i am not very good in writing udfs.

Thank you very much for your help!

J14

Dorit November 20, 2012 08:48

Yeah there's very little information on Compute_Force_And_Moment.

You could try something like this:
The UDF will need to be compiled & hooked to the velocity inlet (if that's what you're using).


#include "udf.h"

DEFINE_PROFILE(update_velocity,t_inlet,i)
{
/* get moment or force */
Domain *d = Get_Domain(1); /* for single phase flow*/
Thread *t_object = Lookup_Thread(d, Boundary_ID); /* you get Boundary_ID from the boundary condition panel in Fluent*/
real force[ND_ND], moment[ND_ND], cg[ND_ND]; /*initialise*/

Compute_Force_And_Moment (d,t_object,cg,force,moment,TRUE)

real force_x = force[0]; /* force components of surface "Boundary_ID" */
real force_y = force[1];
real force_z = force[2];
real moment_x = moment[0]; /* moment components */
real moment_y = moment[1];
real moment_z = moment[3];

/* use some equation to calculate new inlet velocity */
real v_new = ..........;

/* update inlet velocity */
face_t f;
begin_f_loop(f,t_inlet) /* loop over all faces at velocity inelt */
{
F_PROFILE(f,t_inlet,i) = v_new;
}
end_f_loop(f,t_inlet)

}

Dorit November 20, 2012 08:55

Actually you'll need to find a different macro I think, cause you're running an unsteady simulation right? If so, then you'll need something that's called at the start of every time step. Don't think DEFINE_PROFILE is continuously updated. But the moment stuff should still work.


All times are GMT -4. The time now is 10:42.