Fluids

Fluids

Issues Creating a UDF to act as a force on particles

    • rmoss06
      Subscriber
      Hi, nI 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 = 19nI'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.nnThanksn/* UDF for computing the electric force on a charged particle */nn#include udf.hnn#define Q 7.0     /* particle electric charge   */n#define E 3.0    /* electric field magnitude */n#define TSTART 0  /* field applied at t = tstart  */ nn/* Calculate electric force on charged particle.  */n/* velocity with electric field: Fx= q*bz*Vy, Fy= -q*bz*Vx */nnDEFINE_DPM_BODY_FORCE(electric_force, p, i)n{ntreal bforce[ND_ND] = 0;ntif (P_TIME(p) >= TSTART)nt{nttif (i == 0) bforce[i] = Q * E*P_VEL(p)[0];nnttelse if (i == 1) bforce[i] = -Q * E*P_VEL(p)[1];nnt}ntelsenttbforce[i] = 0.0;nt/* an acceleration should be returned */ntreturn (bforce[i] / P_MASS(p));n}
    • YasserSelima
      Subscriber
      try this .. n#include udf.h#define Q 7.0     /* particle electric charge   */nn#define E 3.0    /* electric field magnitude */nn#define TSTART 0  /* field applied at t = tstart  */ nDEFINE_DPM_BODY_FORCE(electric_force, p, i)n{n real bforce = 0;n if (P_TIME(p) >= TSTART)n {n if (i == 0) {n bforce = Q * E*P_VEL(p)[0];n } else if (i == 1) {n bforce = -Q * E*P_VEL(p)[1];n } else {n bforce = 0.0;n }n }n/* an acceleration should be returned */n return (bforce / P_MASS(p));nnnLet me know if you are still getting the same errorn
    • 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!n
    • Rob
      Ansys Employee
      Continues here to work out why the particles aren't doing anything! nhttps://forum.ansys.com/discussion/26079/body-force-not-affecting-particle-motion#latestnn
Viewing 3 reply threads
  • The topic ‘Issues Creating a UDF to act as a force on particles’ is closed to new replies.