# Ansys Fluent UDF small coding to define forces over a body 6DOF

• Posted:
• Proposals: 1
• Remote
• #664087
• Expired
• 1

### Description

Experience Level: Intermediate
Estimated project duration: 1 day or less
Fluent, transient analysis of a body that travels through a fluid (deforming mesh + 6DOF). There is some forces applied over this body, and need to be defined through UDF code. It should be very simple if you are familiar with this type of problems and UDF coding. It´s a box with some thickness and some material. It´s CG its at 0,0,0 and I use symmetry respect the xy plane. The properties then are described in the following UDF

#include "udf.h"

DEFINE_SDOF_PROPERTIES(test_box, prop, dt, time, dtime)
{
prop[SDOF_MASS] = 471;
prop[SDOF_IXX] = 130.83;
prop[SDOF_IYY] = 130.83;
prop[SDOF_IZZ] = 130.83;
prop[SDOF_SYMMETRY_X] = 0;
prop[SDOF_SYMMETRY_Y] = 0;
prop[SDOF_SYMMETRY_Z] = 1;

printf ("\n2d_test_box: Updated 6 DOF properties");
}

I just need to include a moment and force with some magnitude, that of course will change due to the rotation of the body due to the external pressure from the flow. You can use for example a 1.5 Newtons in the x direction. Since this box is 1x1x1 m and I apply this force over one point , lets say at x=0.5, y=-0.5 and z=0, then over the cg, there will be a force and a moment. the force will be 1.5 N and the moment will be Mz=-1.5x0.5=-0.75 Mm .

here there is an example of what I believe should be something very similar, but I don't know anything about udf so I´m not sure how this guy included the values and where. So I can´t trak the variables and I don't know where to include them in this example

Example 1
The following UDF, named stage, is a simple example of setting mass and moments of
inertia properties for a moving object. This UDF is typical for applications in which a
body is dropped and the SDOF solver computes the body’s motion in the flow field.
/************************************************** **********
Simple example of a SDOF property UDF for a moving body
************************************************** ************/
#include "udf.h"
DEFINE_SDOF_PROPERTIES(stage, prop, dt, time, dtime)
{
prop[SDOF_MASS] = 800.0;
prop[SDOF_IXX] = 200.0;
prop[SDOF_IYY] = 100.0;
prop[SDOF_IZZ] = 100.0;
printf ("\nstage: updated 6DOF properties");
}
Example 2
The following UDF named delta missile specifies case injector forces and moments
that are time-dependent. Specifically, the external forces and moments depend on the
current angular orientation of the moving object. Note that this UDF must be executed
as a compiled UDF.
/************************************************** *****
SDOF property compiled UDF with external forces/moments
************************************************** *****/
#include "udf.h"
DEFINE_SDOF_PROPERTIES(delta_missile, prop, dt, time, dtime)
{
prop[SDOF_MASS] = 907.185;
prop[SDOF_IXX] = 27.116;
prop[SDOF_IYY] = 488.094;
prop[SDOF_IZZ] = 488.094;
/* add injector forces, moments */
{
register real dfront = fabs (DT_CG (dt) -
(0.179832*DT_THETA (dt)));
register real dback = fabs (DT_CG (dt) +
(0.329184*DT_THETA (dt)));
if (dfront <= 0.100584)
{
}
if (dback <= 0.100584)
{
}
}
printf ("\ndelta_missile: updated 6DOF properties");
}

Example 2
The following UDF named delta missile specifies case injector forces and moments
that are time-dependent. Specifically, the external forces and moments depend on the
current angular orientation of the moving object. Note that this UDF must be executed
as a compiled UDF.
/*******************************************************
SDOF property compiled UDF with external forces/moments
*******************************************************/
#include "udf.h"
DEFINE_SDOF_PROPERTIES(delta_missile, prop, dt, time, dtime)
{
prop[SDOF_MASS] = 907.185;
prop[SDOF_IXX] = 27.116;
prop[SDOF_IYY] = 488.094;
prop[SDOF_IZZ] = 488.094;
/* add injector forces, moments */
{
register real dfront = fabs (DT_CG (dt) -
(0.179832*DT_THETA (dt)));
register real dback = fabs (DT_CG (dt) +
(0.329184*DT_THETA (dt)));
if (dfront <= 0.100584)
{
}
if (dback <= 0.100584)
{