We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

oscillating cylinder UDF

    • marco.pedata
      Subscriber

      Hello Ansys community,

      I have a problem similar to a flow around a cylinder in 2D. I expect the cylinder to oscillate due to vortex shedding.
      I try to perform a FSI via UDF using DEFINE_CG_MOTION. To solve my desired DGL of motion I need the vertical force on the cylinder. In FLUENT I already created a report file for the lift coefficient. How can I access solution parameters on the cylinder wall inside my UDF file? I already did sth. similar using the DEFINE_SDOF_PROPERTIES function. What are the benefits of solving the DGL inside DEFINE_CG_MOTION myself? Is it also possible using DEFINE_CG_MOTION to specify sourounding cells as Passive inside the Dynamic Mesh tab in FLUENT GUI as it is with DEFINE_SDOF_PROPERTIES?

      I am looking forward to your ideas and recommendations!

    • ashkan.ghafari92
      Subscriber

      Hello.

       

      For these types of movements SDOF is the best way since it is designed for it. However, to access the forces you can use Compute_Force_And_Moment command.

    • marco.pedata
      Subscriber

      Hello,

      thank you for your reply!

      I decided on trying both approaches. The SDOF works. As for the DEFINE_CG_MOTION I get the following error when loading the compiled file: 

      ERROR: chip-exec: function "stage::libudf" not found.

      Here is a snippet of the udf.c I use:


      #include "udf.h"
      #include "dynamesh_tools.h"
      #include

      /* global variables*/

      static real delta_y_prev = 0.0;    // starting position
      static real delta_v_prev = 0.0;    // starting velocity
      static real Fy_prev = 0.0;         // starting vertical force
      FILE* fout;

      /* functions for RK4*/

      DEFINE_CG_MOTION(fahrdraht_bewegung, dt, vel, omega, time, dtime)               
      {
          Domain* d = Get_Domain(1);
          //Thread * t = Lookup_Thread(d,8);     // gets thread of object with ID (ID from boundary condition in FLUENT GUI)
          Thread * t = DT_THREAD(dt);                  // get the thread pointer for which this motion is defined 

          real force[ND_ND];
          real moment[ND_ND];
          //real cg[ND_ND];

          Compute_Force_And_Moment(d, t, NULL, force, moment, FALSE); // Compute_Force_And_Moment(d, t, cg, force, moment, TRUE)

          real Fy = force[1];


          /* System Parameters */
          real rho = 8890.0;        
          real area = 1e-4;          
          real mass = rho * area;          
          real diameter = 12.3e-3;           
          real f = 0.8;                      
          real omega_n = 2 * M_PI * f;        
          real z = 0.001;                     
          real k = mass * omega_n * omega_n; 
          real c = 2 * mass * omega_n * z;  
          real rhoFluid = 1.225;         

          /* External force increment*/
          real deltaP = Fy-Fy_prev;  

          /* RK4 coefficients */

          /* Calculate change in velocity and position using RK4*/
          real delta_v = delta_v_prev + dtime / 6.0 * (Q1 + 2.0 * Q2 + 2.0 * Q3 + Q4);
          real delta_y = delta_y_prev + delta_v_prev * dtime +
              dtime * dtime / 6.0 * (Q1 + Q2 + Q3);

          /* Set Velocitys and Rot */
          vel[0] = 0.0;      
          vel[1] += delta_v;    

          omega[0] = 0.0;  
          omega[1] = 0.0;    

          /* Save new values */
          delta_y_prev = delta_y;
          delta_v_prev = delta_v;
          Fy_prev = Fy;
      }

    • Rajat Chaudhari
      Ansys Employee

      Hi Marco,

      es, using a Six Degree of Freedom (SDOF) model, you can simulate such scenarios and utilize the Compute_Force_And_Moment macro to calculate the forces acting on the body.

      If you want to move a cell zone such as inflation layers near a wall—while using a CG_MOTION UDF, you must apply the same UDF to the cell zone. Alternatively, you can enable the relative motion option and assign zero relative motion to the cell zone with respect to the wall.

      The error you're encountering may be due to a UDF named "stage" that was previously hooked but is no longer available. To resolve this, either unhook the missing UDF or attach a new one in its place.

    • marco.pedata
      Subscriber

      Hi, thank you for your reply.
      The error was indeed due to a previous UDF.
      I followed your advise on using relative motion with zeros assigned to the cell zone for the inflation layers. The CG_MOTION approach works now :)

      SDOF approach: Can you recommend any sources on how the solver works. As for CG_MOTION i can specify the integration method (e.g. explicit Euler or RK4) for my DGL myself. But how is the DGL solved using SDOF?

Viewing 4 reply threads
  • You must be logged in to reply to this topic.