Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

UDF for mass transfer parse error

    • Ibrahim Allam
      Subscriber

      Hallo,
       I'm trying to write a udf to model the mass transfer equation indicated in the image below for condensation model 
      the porblem is when i press interpret in fluent it gives me an error 
      "line 13 parse error
      line 14: parse error
      line.15: parse error.
      line 18: liq: undeclared variable"

      here is my UDF code 

      /* UDF to define a simple mass transfer based on Saturation
         Temperature. The "from" phase is the gas and the "to" phase is the
         liquid phase  */

      #include "udf.h"


      DEFINE_MASS_TRANSFER(Th_conds, cell, thread, from_index,from_species_index, to_index, to_species_index)
      {
         real m_lg;
         real time_step;
         time_step=5e-5;
         real T_SAT = 309.15;
         Thread *gas = THREAD_SUB_THREAD(thread, from_index);
         Thread *liq = THREAD_SUB_THREAD(thread, to_index);

         m_lg = 0;
         if (C_T(cell, liq) >= T_SAT)
           {
             m_lg = - (C_R(cell,liq)*C_CP(cell,liq)*(C_T(cell,liq)-T_SAT))/(time_step*C_H(cell,liq));    
           }          
         if ((m_lg == 0 ) && (C_T(cell, gas) <= T_SAT))
           {
             m_lg =  (C_R(cell,gas)*C_CP(cell,gas)*(C_T(cell,liq)-T_SAT))/(time_step*C_H(cell,gas));  
           }

         return (m_lg);
      }

      here is the mass transfer equation

    • Rob
      Forum Moderator

      Did you copy (using CTRL+C and CTRL+P) the example from the manual and then adjust that? 

      • Ibrahim Allam
        Subscriber

        Yes i did that 

    • Rob
      Forum Moderator

      Open the file in an editor that can show white space characters, and then delete those. 

      • Ibrahim Allam
        Subscriber

         

        Hey Rob,
        i removed all the whitespaces but it didnt work, and it gave me the same error.
        But i came up with a solution ,i make the declarations of the variables in separeated lines and the assignement below them and it worked. I have no idea why ansys interpreter didn't accept the declaration  and assignment of the variable in the same line!!
        but here is my code in the image below and it has been interpreted sucessfully !

         

      • Ibrahim Allam
        Subscriber

         

        If you could give me an explanation about what happened exaclty and how interpreter works i would be very grateful

         

    • Rob
      Forum Moderator

      Interpreter or Compiler? Don't use the former. 

      • Ibrahim Allam
        Subscriber


        what is the difference between use built in compiler and build without checking it please 

    • Rob
      Forum Moderator

      Built in compiler uses a bundled CLANG compiler (do NOT use it on Linux) that's in with the Fluent install. Otherwise you're relying on having found & installed all of the correct bits of Microsoft Visual Studio and that's got much harder over the years as the bundles and licence agreements have changed. 

Viewing 4 reply threads
  • The topic ‘UDF for mass transfer parse error’ is closed to new replies.