Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

How to fix parse error in the following UDF code for my Fluent simulation

    • Ulfah
      Subscriber

      When I tried to interpret the following code, i got a message error 'line 6: parse error.'

      #include "udf.h"
      
      #define Cd 0.2 /* usually between 0.1 - 0.3 ; lambda = Cd * LAD */ 
      #define LAD 2.0
      
      real A1t = 1.0; /* Betap */
      real A2t = 5.1; /* Betad */
      real A3t = 0.9; /* closure constant cepsilon4 */ 
      real A4t = 0.9; /* closure constant cepsilon5 */
      
      DEFINE_SOURCE(xmom_source,c,t,dS,eqn)
      {
      real x[ND_ND]; 
      real source;
      real U = C_U(c,t);
      real V = C_V(c,t);
      real W = C_W(c,t);
      real VEL = sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t)+C_W(c,t)*C_W(c,t)); 
      real k = C_K(c,t);
      real e = C_D(c,t);
      real rho = C_R(c,t);
      C_CENTROID(x,c,t);
      
      source = -Cd*LAD*rho*VEL*U;
      dS[eqn] = -Cd*LAD*rho*(U*U/VEL + VEL);
      return sour
      


    • aitor.amatriain
      Subscriber
      At a glance, you have not closed the square bracket
    • Rob
      Forum Moderator
      There's also a ? symbol in line 1: check for white space characters too.
    • aitor.amatriain
      Subscriber
      And "sour" should be "source" in the last line
    • Ulfah
      Subscriber
      Sorry this is the real code
      #include "udf.h"┬Ø




      #define Cd 0.2 /* usually between 0.1 - 0.3 ; lambda = Cd * LAD */

      #define LAD 2.0




      real A1t = 1.0; /* Betap */

      real A2t = 5.1; /* Betad */

      real A3t = 0.9; /* closure constant cepsilon4 */

      real A4t = 0.9; /* closure constant cepsilon5 */




      DEFINE_SOURCE(xmom_source,c,t,dS,eqn)

      {

      real x[ND_ND];

      real source;

      real U = C_U(c,t);

      real V = C_V(c,t);

      real W = C_W(c,t);

      real VEL = sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t)+C_W(c,t)*C_W(c,t));

      real k = C_K(c,t);

      real e = C_D(c,t);

      real rho = C_R(c,t);

      C_CENTROID(x,c,t);




      source = -Cd*LAD*rho*VEL*U;

      dS[eqn] = -Cd*LAD*rho*(U*U/VEL + VEL);

      return source;

      }


    • Rob
      Forum Moderator
      Assuming the white space character isn't present, check if Cd is used elsewhere in the code: avoid 1-2 letter variables as we may use them elsewhere. A parse error warning is typically triggered on the line after the mistake, or rather the next line with text as the code found a fault but didn't know it was a fault until the next bit of code comes along.
    • Ulfah
      Subscriber
      Thank you for your help. I rewrote the code and I believe there was a white space character. I tried to interpret the new code and there seems to be no error occurred. However, I am confused with the message on the console which can be seen in the picture I attached below. What does this message indicate?

    • Rob
      Forum Moderator
      It's the result of the interpreter running through all of your commands. If it doesn't give an error or lots of warnings you can generally ignore it: it may mean something but no one I know has ever bothered trying to figure it out.
Viewing 7 reply threads
  • The topic ‘How to fix parse error in the following UDF code for my Fluent simulation’ is closed to new replies.