Showing posts with label ANSYS. Show all posts
Showing posts with label ANSYS. Show all posts

Thursday, 9 October 2025

Saithe Fish Simulation: ANSYS Fluent Dynamic Mesh Setup

     One of the most famous post on the blog can be read here. Worryingly😁, many fellow researchers and readers are interested in the aerodynamics of flexible robots πŸ€“. In this post, the dynamic mesh πŸ•Έ settings used are shared πŸ₯°. These settings are used to reproduce πŸ–¨️ the results from [1], all those years ago. All in a hope that this post helps the readers in their scholarly work! 🎩

     Once the UDF πŸ’» has been acquired, the next step is to apply the UDF to the airfoil 🐠 geometry correctly ✔️. The airfoil geometry at the first time-step πŸ•° i.e. at t = 0 for UDF 02 obtained from [1] is made available here. Once on the dynamic πŸŽ️ mesh page, select the options shown in Fig. 1. The options selected in Fig. 1 show the default parameters. Within Fig. 1, "wing" refers to the named selection that includes the only the airfoil geometry. Named selections can be created during the meshing process. The "wing" named selection is shown in Fig. 3.


Fig. 1, The dynamic mesh settings

     Before following the settings in Fig. 1, do remember to compile the UDF. To compile the UDF, please use the settings shown in Fig. 2. After selecting the UDF, select the options as shown in the Fig. 2 and then select Build and Load.


Fig. 2, Compile UDF

Fig. 3, Named selection for the dynamic mesh

     The maximum Lift ⬆️ force coefficient from the simulations performed using the method explained here is at 1.77 as compared to 1.68 [1]. The average Drag ⬅️ coefficient is at 0.097 as compared to 0.103 [1]. The obtained flow-field πŸŸ️ is shown in Fig. 4. Within Fig. 4, top row has v and u components of velocity while the bottom row shows pressure field❗


Fig. 4, The flow-field


     If you are still having trouble, switch to immersed boundary method. The immersed boundary method code your truly wrote, is available here. The validation of this code is available here, here, here and more generally here.

     If you want to hire me as your next shining post-doc or collaborate in research, please reach out! Thank you for reading!

References

[1] Shi, Fulong, Xin, Jianjian and Ou, Chuanzhong, Li, Zhiwei, Chang, Xing, Wan, Ling, "Effects of the Reynolds number and attack angle on wake dynamics of fish swimming in oblique flows", Physics of Fluids, 37(2), 025205, 2025 https://doi.org/10.1063/5.0252506 

Thursday, 12 October 2023

Saithe Fish UDF (ANSYS Fluent)

     This post is about Fish Simulation in ANSYS Fluent using a User Defined Function (UDF). The UDF is mentioned below. The flow conditions are taken from [1]. This goes with the videos shown in Fig. 1-2. The CAD files for t=0 are available here (for UDF 01). A tutorial is available here.

Fig. 1, Animation of motion achieved through the UDF 01.

 
 Fig. 2, Animation of motion achieved through the UDF 02 (Validated).

     The results of present simulations are compared with [1]. The results are in excellent agreement as the Cl, max from [1] is at 1.57 while the maximum Cl, max from present simulation is at 1.6. The drag coefficient [1], Cd, max in [1] is at 0.164; while from the present simulations I got, 0.151. The Cd, avg comes out to be 0.072 [1] form the present simulations. I got a value of 0.064 from he present simulation. These would gradually become more accurate with mesh refinement, which I will certainly do if I send some ideas I have for peer review.

UDF 01:

#include "udf.h"
#include "unsteady.h"
#include "dynamesh_tools.h"
#include "math.h"


DEFINE_GRID_MOTION(dynamic,domain,dt,time,dtime)
{
 Thread *tf = DT_THREAD(dt);
 face_t f;
 Node *v;
 int n;
 double x, y, y_ref_previous, y_ref;
 SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));  
 begin_f_loop(f,tf) {
  f_node_loop(f,tf,n) {
   v = F_NODE(f,tf,n);
   if (NODE_POS_NEED_UPDATE(v)) {
    NODE_POS_UPDATED(v);
    x = NODE_X(v);
    real amplitude = 0.02 + 0.01*x + 0.1*x*x;
    y_ref_previous = amplitude * cos(2*M_PI*x + 2*M_PI*0.8*(PREVIOUS_TIME));
    y_ref = amplitude * cos(2*M_PI*x + 2*M_PI*0.8*(CURRENT_TIME));
     
if (NODE_Y(v) > y_ref_previous){
     NODE_Y(v) = y_ref+fabs(NODE_Y(v)-y_ref_previous);
    }
    else 
     if (NODE_Y(v) < y_ref_previous){
      NODE_Y(v) = y_ref-fabs(NODE_Y(v)-y_ref_previous);
     }
     else {
      NODE_Y(v) = y_ref;
     }
    }
   }
  }
 }
 end_f_loop(f,tf);

UDF 02 (Validated):

#include "udf.h"

DEFINE_GRID_MOTION(dynamic,domain,dt,time,dtime)
{
 Thread *tf = DT_THREAD(dt);
 face_t f;
 Node *v;
 int n;
 double x, y_ref_previous, y_ref, amplitude, fr;
 SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));  
 begin_f_loop(f,tf) {
  f_node_loop(f,tf,n) {
   v = F_NODE(f,tf,n);
   if (NODE_POS_NEED_UPDATE(v)) {
    NODE_POS_UPDATED(v);
    x = fabs(NODE_X(v));
    amplitude = 0.02 - 0.0825 * x + 0.1625 * x * x;
    fr = 2;
    y_ref_previous = amplitude * cos(2 * M_PI * x - 2 * M_PI * fr * (PREVIOUS_TIME));
    y_ref = amplitude * cos(2 * M_PI * x - 2 * M_PI * fr * (CURRENT_TIME));
     
if (NODE_Y(v) > y_ref_previous){
     NODE_Y(v) = y_ref + fabs(NODE_Y(v) - y_ref_previous);
    }
    else 
     if (NODE_Y(v) < y_ref_previous){
      NODE_Y(v) = y_ref - fabs(NODE_Y(v) - y_ref_previous);
     }
     else {
      NODE_Y(v) = y_ref;
     }
    }
   }
  }
 }
 end_f_loop(f,tf);

If you want to hire me as you next shining PhD/Master student or collaborate in research, please reach out! Thank you for reading!

References

[1] Gen-Jin Dong, Xi-Yun Lu; Characteristics of flow over traveling wavy foils in a side-by-side arrangement. Physics of Fluids 1 May 2007; 19 (5): 057107. https://doi.org/10.1063/1.2736083

Wednesday, 18 August 2021

Computational Fluid Dynamics Simulation of a Swimming Fish (Includes UDF)

      This post is about the simulation of a swimming fish. The fish body is made of NACA 0020 and 0015 aero-foils (air-foils). The fluke is made of NACA 0025 aero-foil (air-foil), as shown in Fig. 1. the CAD files with computational domain modelled around the fish is available here.



Fig. 1, The generic fish CAD model

      The motion of the fish's body is achieved using a combination of two user-defined functions (UDF). The UDFs use DEFINE_GRID_MOTION script mentioned below, for the head/front portion. This is taken from the ANSYS Fluent software manual, available in its original form here. The original UDF is modified for present use as required. To move the mesh, dynamic mesh option within ANSYS Fluent is enabled; with smoothing and re-meshing options. The period of oscillation is kept at 2.0 s. The Reynolds number of flow is kept at 100,000; which is typical for a swimming fish.

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

 node motion based on simple beam deflection equation
 compiled UDF
 **********************************************************/
#include "udf.h"

DEFINE_GRID_MOTION(undulating_head,domain,dt,time,dtime)
{
  Thread *tf = DT_THREAD(dt);
  face_t f;
  Node *v;
  real NV_VEC(omega), NV_VEC(axis), NV_VEC(dx);
  real NV_VEC(origin), NV_VEC(rvec);
  real sign;
  int n;
  
  /* set deforming flag on adjacent cell zone */
  SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));

  sign = 0.15707963267948966192313216916398 * cos (3.1415926535897932384626433832795 * time);
  
  Message ("time = %f, omega = %f\n", time, sign);
  
  NV_S(omega, =, 0.0);
  NV_D(axis, =, 0.0, 1.0, 0.0);
  NV_D(origin, =, 0.7, 0.0, 0.0);
  
  begin_f_loop(f,tf)
    {
      f_node_loop(f,tf,n)
        {
          v = F_NODE(f,tf,n);

          /* update node if x position is greater than 0.02
             and that the current node has not been previously
             visited when looping through previous faces */
          if (NODE_X(v) > 0.05 && NODE_X(v) < 0.7 && NODE_POS_NEED_UPDATE (v))
            {
              /* indicate that node position has been update
                 so that it's not updated more than once */
              NODE_POS_UPDATED(v);

              omega[1] = sign * pow (NODE_X(v), 0.5);
              NV_VV(rvec, =, NODE_COORD(v), -, origin);
              NV_CROSS(dx, omega, rvec);
              NV_S(dx, *=, dtime);
              NV_V(NODE_COORD(v), +=, dx);
            }
        }
    }

  end_f_loop(f,tf);
}

      The computational mesh, as shown in Fig. 2, uses cut-cell method with inflation layers. The mesh has 2,633,133 cells. The near wall y+ is kept at 5. The Spalart-Allmaras turbulence model is used to model the turbulence. The second order upwind scheme is used to discretize the momentum and modified turbulent viscosity equations. The time-step for this study is kept at 100th/period of oscillation.


Fig. 2, The mesh and zoom in view of the trailing edge.

      The animation showing fish motion is shown in Fig. 3. Within Fig. 3, the left side showcases the velocity iso-surfaces coloured by pressure and the vorticity iso-surfaces coloured by velocity magnitude is shown on the right.


Fig. 3, The animation.

      Another animation showing the fish motion is shown in Fig.4. Within Fig. 4, the left side shows surface pressure while the right side shows pressure iso-surfaces coloured by vorticity.


Fig. 4, The animation.

      If you want to collaborate on the research projects related to turbo-machinery, aerodynamics, renewable energy, please reach out. Thank you very much for reading.

Tuesday, 17 September 2013

SolidWorks Curtain Wall Railing with FEA

Curtain Wall
 
This is a CAD model of a curtain wall rail made in SolidWorks Premium 2013. It is a part and with steel as a material it weighs ~1,200 Kg. it is very useful in architecture projects. Stress analysis indicates that it can take UDL of 36,831 N vertical, with FOS of 4.88. This model is for sale.
 

Dimensions

Overall 15.167 ft. x 7.583 ft. x 10.167 ft.
Rail length 4 ft.
Rail height and width 2 in.
 

Pricing

SolidWorks 2013 Part File              $35 (PKR 3,500)
SolidWorks 2013 Part File              $85 (PKR 8,500) (with FEA data)
IGES/STEP File                             $90 (PKR 9,000)
STL File                                        $15 (PKR 1,500)
DWG File AutoCAD 2007                $25 (PKR 2,500)
DWG File AutoCAD 2013                $15 (PKR 1,500)
 

Renderings

With White Back Ground, 1366 x 626, 64 Ray Bounces, Maximum Shadow Quality, Ground Illumination, Global Illumination, Self Shadows, Ground Shadows and Ground Reflections.
 
$2.5 (PKR 250) Each (167 PPI at 9 in Diagonal) with at least 1 part file.
$10 (PKR 1,000) Each (167 PPI at 9 in Diagonal) only renders.
 
Custom Back Ground add $5 per render.

Special discount for students enrolled in degree programs!


Render 01

Render 02

Render 03

Render 04
 
 

Sunday, 15 September 2013

SolidWorks RC Aircraft Model (Profile)

RC Aircraft Model (Profile)

 

This is another of my CAD models for sale, it is a profile of RC aircraft.

Special thing about it is that everything is designed to produce lift. The fuselage is also an airfoil. This can be great buy for you if you want to learn flow simulation over static flight surfaces using any software of your choice like SolidWorks Flow Simulation Premium 2011 and onwards, SIM 360, ANSYS etc. and then preform a stress analysis on them using the data from flow simulation at various AOA and velocities.

*Full scale structural model will be available for sale as soon as i finish it. :)

Pricing

SolidWorks 2011 Assembly Files      $100 (PKR 10,000)
SolidWorks 2013 Assembly Files      $85 (PKR 8,500)
IGES/STEP Files                             $200 (PKR 20,000)
STL File                                        $80 (PKR 8,000)
DWG File AutoCAD 2007                $50 (PKR 5,000)
DWG File AutoCAD 2013                $40 (PKR 4,000)
 

Renderings

With White Back Ground, 1366 x 626, 64 Ray Bounces, Maximum Shadow Quality, Ground Illumination, Global Illumination, Self Shadows, Ground Shadows and Ground Reflections.
 
$2.5 (PKR 250) Each (167 PPI at 9 in Diagonal) with at least 1 part file.
$10 (PKR 1,000) Each (167 PPI at 9 in Diagonal) only renders.
 
Custom Back Ground add $5 per render.

Special discount for students enrolled in degree programs!
 
Render 01

Render 02

Render 03

Render 04

Render 05