April 16, 2024 at 9:06 am
Nahian Masud
Subscriber
Hi, thanks for replying. this is the latest UDF I am using,
#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.