Fluids

Fluids

UDF for undulating Fish

    • kfouladi
      Subscriber

      Hello,


      We are trying to model a fish swimming with undulating motion. Does anyone has a UDF example that we can start with? Thanks.


      Kamran

    • Karthik R
      Administrator

      Hello Kamran,


      Please elaborate on how you are attempting to model this problem. What is the purpose of this UDF? Perhaps, we may be able to point you to some resources which can help you get started?


      Thank you.


      Best Regards,


      Karthik

    • jmccasli
      Ansys Employee

      Hi Kamran,


       


      I do not have a UDF to share, but there are some useful examples in the literature for similar studies involving Fluent. See this one for example, in which the use a DEFINE_GRID_MOTION macro to account for the undulation of the fish:


      https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5375146/


       


      That may be a good place to start.


       


      Regards,


      Jeremy

    • kfouladi
      Subscriber

      Hi Kremella and Jeremy,


      Thank you for your quick replies. What I need to do is put the fish in wavy motion. Therefore, I need a UDF so I can put the fish through some lateral or vertical displacement as a function of time. I am not sure what the UDF should look like or more specifically, what parameters it should pass to Fluent. I will provide a picture for more clarity.


      Kamran


      (I posted this earlier but somehow that post is gone now).

    • kfouladi
      Subscriber

      Here is a picture

    • Rob
      Ansys Employee

      Thanks. As Jeremy says you'll need the DEFINE_GRID_MOTION macro to define change in shape of the object. There's an example in the UDF manual, and as an ASC you should be able to access the Customer Portal for additional resources: I'd suggest looking at the UDF and Moving Mesh materials. 

    • kfouladi
      Subscriber

      Thank you all. I will look into DEFINE_GRID_MOTION macro and see if I can make any progress. 


      Kamran


       

    • CatherineIl
      Subscriber

      Hello, 

      I would like to ask you if you can post the code here because I am doing something similar for my dissertation but using an airfoil and a wing. I would really appreciate that as I have already wasted a lot of time trying to find a solution and I have never used udf before. 

      Thank you in advance. 

    • kfouladi
      Subscriber

      I modified a UDF file so I can put a flat plate in flapping motion. Here is the file. I wonder if this helps you.


       


      /**********************************************/


      /* WingDM.c                                  */


      /* UDF for specifying a time-varying omega    */


      /*                                            */


      /* Simulates +/- angFlip deg flapping with a  */


      /* cycle of FN Hz.                            */


      /*                                            */


      /**********************************************/


       


      #include "udf.h"


      #define FN 34.4


      #define angFlip 30


      #define omegpi 2.0*M_PI*FN


      #define omegMx angFlip*M_PI*omegpi/180.0


       


      DEFINE_CG_MOTION(dm, dt, cg_vel, cg_omega, time, dtime)


      {


        real omega, tm;


       


        tm = time - 0.5*dtime; 


       


        omega = omegMx*cos(omegpi*tm); /* rotational speed about axis*/ 


        


        cg_vel[0] = 0.0;


        cg_vel[1] = 0.0;


        cg_vel[2] = 0.0;


       


        cg_omega[0] = 0.0;


        cg_omega[1] = 0.0;


        cg_omega[2] = omega;


      }


       

    • sanjida
      Subscriber

      Hi,


      I had used a UDF similar to your UDF, to give a flapping motion to a foil. The UDF worked well. But the problem is that, If I want to know the exact position of the foil at a particular time step and put the values in the equation, It does not give the right value. Here is my UDF,


      #include "udf.h"
      #define Freq 0.5
      #define angular_freq 2.0*M_PI*Freq
      #define tetmax 15.0*M_PI/180

      DEFINE_CG_MOTION(shm, dt, cg_vel, cg_omega, time, dtime)
      {
         real omega;

       omega = tetmax*angular_freq*cos(angular_freq*time);

         cg_vel[0] = 0.0;
         cg_vel[1] = 0.0;
         cg_vel[2] = 0.0;
        
         cg_omega[0] = 0.0;
         cg_omega[1] = omega;
         cg_omega[2] = 0.0;
      }


      Can anyone please help me with this? Thanks in advance.

    • Rob
      Ansys Employee

      How far off are you? Have you converged all of the time steps?

    • sanjida
      Subscriber

      Hi,


      Yes, it converged in all of the time steps. Even, if I plot all the data I can see the foil had flapping motion with correct frequency and amplitude in the simulation. The total duration of the simulation is 12 s with time step 0.01. I want to know the position of the foil at the 8th time step (at 0.08 s). If I put the values of all the parameters in the equation, omega = tetmax*angular_freq*cos(angular_freq*time), which I used in the UDF, it gives 0.822 radian, which is not the actual position in the simulation result. If I give a higher value for the time then the value of Omega barely changes. However, the value of omega is 15 degrees (0.2618 radian) at maximum position. How can I know the angular position of the foil manually from that equation? My confusion is mainly how this equation is operating in Fluent w.r.t time.


      Thanks.

    • koshurkoor
      Subscriber
      I am trying to emulate the fish like motion as well. I am using UDF DEFINE_GRID_MOTION similar to cantilever beam example in the UDF manual. It does not work on 2D hydrofoil. So, i created a 3D case with symmetry to replicate 2D motion. The UDF works but unfortunately, the dynamic mesh moves outside the domain despite having tried everything by the book. Any insights to solve this will be appreciated. n
    • Mawen
      Subscriber
      As far as I know you must use triangular mesh for dynamic meshing.
Viewing 13 reply threads
  • You must be logged in to reply to this topic.