Fluids

Fluids

Issues Creating a UDF to act as a force on particles

    • rmoss06
      Subscriber

      Hi,

      I am trying to simulate a Electrostatic Precipitator in Fluent. I have my PM10 injection flowing through my mesh, and my last step is to create a UDF which simulates an electric force acting on the particles. I modified the magnetic force code from the Ansys UDF manual as follows, below, then I place the c file in the folder with my project files, interpret the UDF, select it from the dropdown under UDF in my PM injection, initialize and calculate. During the iteration, I get the following error: chip-exec: electric_force: wrong return type: void udf function expectednumber tracked = 19, escaped = 19

      I'm very new to using UDFs so I was wondering if anyone my be able to point me in the right direction as to where I went wrong.


      Thanks

      /* UDF for computing the electric force on a charged particle */


      #include "udf.h"


      #define Q 7.0     /* particle electric charge   */

      #define E 3.0    /* electric field magnitude */

      #define TSTART 0  /* field applied at t = tstart  */ 


      /* Calculate electric force on charged particle.  */

      /* velocity with electric field: Fx= q*bz*Vy, Fy= -q*bz*Vx */


      DEFINE_DPM_BODY_FORCE(electric_force, p, i)

      {

      real bforce[ND_ND] = 0;

      if (P_TIME(p) >= TSTART)

      {

      if (i == 0) bforce[i] = Q * E*P_VEL(p)[0];


      else if (i == 1) bforce[i] = -Q * E*P_VEL(p)[1];


      }

      else

      bforce[i] = 0.0;

      /* an acceleration should be returned */

      return (bforce[i] / P_MASS(p));

      }

    • YasserSelima
      Subscriber
      try this ..
      #include "udf.h"




      #define Q 7.0/* particle electric charge*/

      #define E 3.0/* electric field magnitude */

      #define TSTART 0/* field applied at t = tstart*/
      DEFINE_DPM_BODY_FORCE(electric_force, p, i)
      {
      real bforce = 0;
      if (P_TIME(p) >= TSTART)
      {
      if (i == 0) {
      bforce = Q * E*P_VEL(p)[0];
      } else if (i == 1) {
      bforce = -Q * E*P_VEL(p)[1];
      } else {
      bforce = 0.0;
      }
      }
      /* an acceleration should be returned */
      return (bforce / P_MASS(p));
      }

      Let me know if you are still getting the same error
    • rmoss06
      Subscriber
      Thanks Yasser, thatÔÇÖs seemed to work. I can compile it now and apply it as a body force, the body force doesnÔÇÖt seem to be affecting my particle motion at all, but at least this is a big step forwards, appreciate it!
    • Rob
      Ansys Employee
      Continues here to work out why the particles aren't doing anything!
      https://forum.ansys.com/discussion/26079/body-force-not-affecting-particle-motion#latest

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