Is there any way to find the lift force in CG motion udf? I need to to use in the vertical velocity. Here is the code I have written so far. The 2D airfoil is flapping, so I described a flapping motion. The airfoil has boundary ID of 7. now I use Compute_Force_and_Moment macro to find lift force and use it in the vertical velocity. The problem is, it says floating point error after 2 or 3 time steps ( residuals goes super high and simulation stops), but if i dont use the compute force and moment macro, the flapping only works well. I need to find the lift force anyhow to get the transational velocity. can anyone help me please?
#include "udf.h"
#define MASS 0.0143
/* Declare a global variable to store the lift force */
static real lift = 0.0;
/* Function to compute the CG motion, including flapping motion */
DEFINE_CG_MOTION(paperfreq, dt, vel, omega, time, dtime)
{
Domain *d = Get_Domain(1); // Assuming single phase flow
Thread *t_object = Lookup_Thread(d, 7); // Airfoil's thread ID
real force[2], moment[2], cg[2]; // Initialize arrays
real x=0;
NV_S(vel, =, 0.0);
/* Compute force and moment at the boundary */
Compute_Force_And_Moment(d, t_object, cg, force, moment, FALSE);
/* Update global variable for lift force */
lift = force[1];
real w, a, pi;
pi = 3.14159265;
a = (pi * 15) / 180; // Pitch amplitude in radians
w = 0.62832; // Angular velocity in rad/s
/* Define the flapping motion */
omega[2] = -a * 2 * pi * 2.97 * cos(2 * pi * 2.97 * time); // Pitching motion
vel[1]=lift*dtime/MASS;
x=vel[1];
Message("lift:%f x:%f\n",lift,x);
}
The problem is, if i use the vel[1], the lift force goes very high, so does the velocity. This makes the airfoil go outside domain and it creates floating point exception error. If I dont use the vel[1], and I print the lift force using Message, it shows correct lift value. What I need is, change the location of the airfoil based on the lift force. If there is any other way to give it a y-displacement it is also ok. I am giving it a flapping motion, which generates various lift force based on time and I need the latest lift force to update the airfoil location before going to next time step.