We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

    • kiran.purushothamakeshavan
      Subscriber

      I get this error when I use run simulation with this UDF:

      #include "udf.h"
      #include "dpm.h"
      #include

      #define Rho_air 1.225
      #define mu 0.5
      #define PI 3.14
      #define VISC 1.7894e-05 // dynamic viscosity of air
      #define Rho_p 1550

      FILE *fp1;

      DEFINE_DPM_DRAG(particle_drag_force, Re, p)
      {    
          real b1, b2, b3, b4, Cd, drag_force, A, radius, df;
          real shf = 1;
          real nf, ff;

          Thread* tcell = P_CELL_THREAD(p);
          cell_t c = P_CELL(p);
          real relVel[ND_3], dvtdn, fluidVel[ND_3];

          // Fluid velocity
          NV_D(fluidVel, =, C_U(c, tcell), C_V(c, tcell), C_W(c, tcell));  // Assign fluid velocity components to vector
          // Relative velocity
          NV_VV(relVel, =, fluidVel, -, P_VEL(p));                         // Calculate relative velocity of flow on particle by subtracting absolute particle velocity from fluid velocity
          dvtdn = NV_MAG(relVel);                                          // Calculate relative velocity magnitude

          radius = P_DIAM(p) / 2.0;
          A = PI * radius * radius;

          b1 = exp(2.3288 - 6.4581 * shf + 2.4456 * pow(shf, 2));
          b2 = 0.0964 + 0.5565 * shf;
          b3 = exp(4.905 - 13.8944 * shf + 18.4222 * pow(shf, 2) - 10.2599 * pow(shf, 3));
          b4 = exp(1.4681 + 12.2584 * shf - 20.7322 * pow(shf, 2) + 15.8855 * pow(shf, 3));
          Cd = (24 * (1 + b1 * pow(Re, b2)) / Re) + (b3 * Re / (b4 + Re));

          // Store drag force and other quantities in UDMs
          df = (1 / 2) * Rho_p * A * Cd * (dvtdn * dvtdn);

          // Store quantities in UDMs
          C_UDMI(c, tcell, 0) = df;           // Store drag force
          C_UDMI(c, tcell, 1) = dvtdn;        // Store relative velocity
          nf = C_P(c, tcell) * A;       // Calculate some quantity 'nf'
          C_UDMI(c, tcell, 2) = nf;           // Store 'nf'
          ff = mu * nf;                 // Calculate some quantity 'ff'
          C_UDMI(c, tcell, 3) = ff;           // Store 'ff'
          C_UDMI(c, tcell, 4) = C_P(c, tcell); // Store cell pressure

          P_USER_REAL(p, 0) = df;
          P_USER_REAL(p, 1) = dvtdn;
          P_USER_REAL(p, 2) = nf;
          P_USER_REAL(p, 3) = ff;
          P_USER_REAL(p, 4) = C_P(c, tcell);


          fp1=fopen ("Impact1.txt" , "a") ;
          fprintf( fp1 , "%f %f %f %f %f\n", P_USER_REAL(p, 0), P_USER_REAL(p, 1), P_USER_REAL(p, 2), P_USER_REAL(p, 3), P_USER_REAL(p, 4));
          fclose(fp1);


          // Calculate drag force
          drag_force = (18 * Cd * Re) / 24;                // is this taking the reynolds number of the particle or the flow?

          return drag_force;
      }
       
      Can you please tell me what this error is??
       
      Thanks,
      Kiran
    • Rob
      Forum Moderator

      Were there any compilation warnings? I'm not going to debug code. 

Viewing 1 reply thread
  • You must be logged in to reply to this topic.