Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Error “structure reference not implemented” while compiling or interpreting UDF

    • Arun mathew
      Subscriber

      Hello Ansys Innovation Forum,

      I am encountering an error while trying to compile or interpret a User-Defined Function (UDF) in Ansys Fluent. I would like to understand the reason behind this error and find a solution to resolve it. The error message I receive is as follows:

      "Error: C:/Users/271557I/AppData/Local/Temp/evapoartion_UDF.c.24848.3.c: line 22: structure reference not implemented"

      To provide more context, I am including the full code of the UDF which obtained from (/forum/forums/topic/saturation-temperature-udf/) below:

      #include "udf.h"

      #define MOLAR_MASS_WATER 18.01534                 // g/mol
      #define MOLAR_MASS_AIR 28.97                     // g/mol
      #define RHO_WV 0.5542                             // kg/m3
      #define RHO_AIR 1.225                             // kg/m3
      DEFINE_PROPERTY(saturation_temp, c, t)             // t: mixture thread, c: cell variable, Cell volume
      {
      real vol = C_VOLUME(c, t);
      Thread *pt = THREAD_SUB_THREAD(t, 0);             // Primary phase thread
      Thread *st = THREAD_SUB_THREAD(t, 1);             // Secondary phase thread
      real vf_s = C_VOF(c, st);                         // Get the volume fraction of secondary phases
      real vf_p = 1 - vf_s;                             // Get the volume fraction of primary phases
      real p_mix = C_P(c, t);                         // Get the pressure of the mixture 
      real p_op = RP_Get_Real("operating-pressure");     // Get the operating pressure
      real rho_p = C_R(c, pt);                         // Primary phase density

      // Get mass fractions in primary phase
      real mf[2];                                     // to store mass fractions
      Material *m = THREAD_MATERIAL(pt);
      Material *sp = NULL;
      int i;                                             // Species index - 0 for water vapor and 1 for air
      mixture_species_loop(m, sp, i)
      {
      mf[i] = C_YI(c, pt, i);
      }
      real p_w;                                         // Water vapor pressure for the cell
      if (vf_s == 1)                                    // If secondary phase only
      {
      p_w = p_mix + p_op;
      }
      else                                             // If primary phase or mixture of phases
      {
      // Find the partial pressure of water vapour, partial pressure = cell pressure * water mole fraction
      real m_prim = rho_p * vol * vf_p;                // mass of primary phase in cell
      real m_wv = mf[0] * m_prim;                        // mass of water vapour in cell
      real m_air = m_prim - m_wv;                        // mass of air in cell
      real N_wv = m_wv / MOLAR_MASS_WATER;             // No of moles in water vapour
      real N_air = m_air / MOLAR_MASS_AIR;            // No of moles in  air
      real N_total = N_wv + N_air;                    // total moles
      p_w = (C_P(c, t)+ p_op)* (N_wv / N_total);        // water vapour partial pressure
      }
      real t_sat;
      t_sat = (1730.63 / (10.196 - log10(p_w))) + 39.724; // Calculate saturation temperature
      return t_sat;
      }

       

      Additionally, during the compilation process, the following error was obtained:

       

      Copyright 1987-2023 ANSYS, Inc. All Rights Reserved.
      Compiler and linker: Clang (builtin)
      Compiler path: "C:\PROGRA~1\ANSYSI~1\v231\fluent"\ntbin\clang\bin\clang-cl
      Linker   path: "C:\PROGRA~1\ANSYSI~1\v231\fluent"\ntbin\clang\bin\lld-link
      C sources: ['evapoartion_UDF.c']
      udf_names.c(6,46): error: expected ';' after top level declarator
      extern DEFINE_PROPERTY(saturation_temp, c, t) // t: mixture thread, c: cell variable, Cell volume;
                                                   ^
                                                   ;
      1 error generated.
      scons: *** [udf_names.obj] Error 1

      Done.

       

      I would appreciate any insights or suggestions regarding the reasons for these errors and how to resolve them. Thank you in advance for your valuable assistance.

       

    • Rob
      Forum Moderator

      The clue is the complaint about the DEFINE_PROPERTY line, so try getting rid of the colons. I tend to use /*   */ for comments, but my coding isn't great. Beyond that, check the original UDF works on your model (we change some macros with versions, but I'm not aware of anything that'll effect the above) and then look for differences. 

       

    • Arun mathew
      Subscriber

      Thanks for the reply. I will look into it.

      I have a basic doubt regarding evaporation and condensation in multiphase simulations. The problem is as follows:

      I have a chamber that contains a mixture of moisture (air + water vapor) and liquid water at atmospheric pressure with a relative humidity of 50%. My goal is to simulate the evaporation of the liquid water into the air. I expect the evaporation to occur well below 100°C. How should I set the conditions to induce evaporation? Additionally, I need to ensure that the evaporation stops once the air becomes fully saturated with water vapor.

      I am confused about the default saturation temperature of 100°C. Does the saturation temperature of 100°C imply that boiling will occur at those conditions?

    • Rob
      Forum Moderator

      Have a look at the evaporation/condensation model in Fluent. Don't use it with VOF (as of 2023R1, may change in the future). 

Viewing 3 reply threads
  • The topic ‘Error “structure reference not implemented” while compiling or interpreting UDF’ is closed to new replies.