CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Specifying equation of motion in Fluent (UDF) (https://www.cfd-online.com/Forums/fluent-udf/219707-specifying-equation-motion-fluent-udf.html)

Shuvadeep August 6, 2019 03:00

Specifying equation of motion in Fluent (UDF)
 
I have a 2-d plate hinged at (0,0). It is free to rotate about the z-axis, due to the fluid forces. The motion is purely rotational about z-axis following the equation of motion as below. M is the moment of the previous time step about the z-axis due to fluid forces. the theta is the rotation angle about z-axis.

Please help me in writing the UDF.

θ(t)=M(e^(-0.823t)) {(0.0001709(e^0.823t))-(0.000017177 sin⁡(8.19t))-(0.0001709 cos⁡(8.19t)) }

AlexanderZ August 6, 2019 03:13

ansys fluent customization manual
chapter -> DEFINE_GRID_MOTION

best regards

Shuvadeep August 6, 2019 05:38

I am unable to write the udf. Could you help me in writing the code?

AlexanderZ August 6, 2019 05:39

why you are unable?

best regards

Shuvadeep August 6, 2019 08:39

I have been trying for a long time. But I am not sure that I fully understand the functioning and the variables in the macros. Can you please help?

AlexanderZ August 7, 2019 01:37

show you code

best regards

Shuvadeep August 7, 2019 03:31

@AlexanderZ

The equation of motion is:
θ(t)=M(e^(-0.823t)) {(0.0001709(e^0.823t))-(0.000017177 sin⁡(8.19t))-(0.0001709 cos⁡(8.19t)) }

M is the moment about the z-axis. All other dof are arrested. The domains are created similar to the link below (the airfoil replaced by flat plate):
https://www.youtube.com/watch?v=G0zAHv0rEa8

The fluid flow over the flat plate generates moment about z-axis of the plate (origin). this moment should rotate the inner domain with fine mesh , as rigid body, according to the equation of motion above. On rotation, the effective angle of attack of plate changes, and hence the fluid forces and moments. This changes the moment about the z-axis which further rotates the domain (hence the plate AOA).

The moment is fed into the equation of motion at the beginning of every time-step. The time step iteration should end with the rotation of the inner domain as rigid body. This process continues, until the end of time.

In dynamic mesh options, I would specify the inner domain as passive 6dof udf rigid motion (i.e., no deformation in the inner domain mesh) and the plate as sdof udf rigid motion and the outer boundary as deforming zone

#include "udf.h"

DEFINE_CG_MOTION (rotational_motion, dt, cg_vel, cg omega, time, dtime)
{
Domain *d =Get Domain(1);
Thread *t_object = Lookup_Thread(d, 2);
real moment [ND_ND], cg[ND_ND], force [ND_ND];

Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE)
real moment_z= moment [3]; \* To compute the moment at the beginning of the time step and feed into the equation of motion */

real i1 = exp(-0.823*time);
real i2 = cos (8.19*time);
real i3 = 48870 sin(8.19*time);
real i4 = 2.893 pow(10,-8);
real omega = -i4 * moment_z * i1 * (i2-i3);

cg_vel[0]=0.0;
cg_vel [1]=0.0;
cg_ve1[2]=0.0;

cg omega [0]-0.0 ;
cg omega (1)-0.0;
cg omega [2]=real omega;
}

AlexanderZ August 8, 2019 02:27

Code:

moment [ND_ND]
means that it is array, which has 2 elements in case of 2D solver and 3 elements in case of 3D solver
In case of 3D it has indexes 0,1,2 -> so if you want moment in z direction you should use moment[2], but not moment[3]

try this code, explain your results:
Code:

#include "udf.h"

DEFINE_CG_MOTION (rotational_motion, dt, cg_vel, cg omega, time, dtime)
{
Domain *d =Get Domain(1);
Thread *t_object = Lookup_Thread(d, 2);
real moment [ND_ND], cg[ND_ND], force [ND_ND];
real i1, i2, i3,i4,omega,moment_z;

Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE)
moment_z= moment [2]; \* To compute the moment at the beginning of the time step and feed into the equation of motion */


i1 = exp(-0.823*time);
i2 = cos (8.19*time);
i3 = 48870 sin(8.19*time);
i4 = 2.893 pow(10,-8);
omega = -i4 * moment_z * i1 * (i2-i3);

cg_vel[0]=0.0;
cg_vel [1]=0.0;
cg_ve1[2]=0.0;

cg omega [0]-0.0 ;
cg omega (1)-0.0;
cg omega [2]=real omega;
}

best regards

Shuvadeep August 8, 2019 03:17

Thanks for your reply!

Do you have any idea why such error pops up when I try to compile the above udf

The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64).
The system cannot find the file specified.

Please help!

AlexanderZ August 8, 2019 08:43

Quote:

The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64).
The system cannot find the file specified.
first of all, you've started fluent in @d mode, buy your UDF uses z-axis, which is not exists in 2D

second isseu -> you are not compiling UDF, but try to load it. Click button build instead of load (make it in 3D, or change UDF)

best regards

Shuvadeep August 10, 2019 11:49

Hello,
There is no error in compilation now. Thanks to you.
Now the problem is the moment about the z-axis doesn't load after each time step iteration.

If I omit the moment part in the previous udf, then I can see my udf running properly in the zone motion in dynamic mesh tab. But with the moment part in the udf, the motion is not updated. Can you help?

#include "udf.h"

DEFINE_CG_MOTION (rotational_motion, dt, cg_vel, cg omega, time, dtime)
{
real i1, i2, i3,i4,omega;

i1 = exp(-0.823*time);
i2 = cos (8.19*time);
i3 = 48870 sin(8.19*time);
i4 = 2.893 pow(10,-8);
omega = -i4 * i1 * (i2-i3);

cg_vel[0]=0.0;
cg_vel [1]=0.0;
cg_ve1[2]=0.0;

cg omega [0]-0.0 ;
cg omega (1)-0.0;
cg omega [2]=real omega;
}

AlexanderZ August 11, 2019 20:16

it seem that this part of code computes momentum
Code:

Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE)
moment_z= moment [2]; \* To compute the moment at the beginning of the time step and feed into the equation of motion */

if nothing works when these lines are in your code, then it means, that moment [2] is zero
so you got zero in Compute_Force_And_Moment function (this function was made by you)
check it

best regards


All times are GMT -4. The time now is 09:45.