Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Problem in compiling specific heat UDF

    • waqas12345
      Subscriber

      Hello everyone. Please find below the specific heat UDF which I intend to compile in 2021R1 academic version of fluent. I receive the following error message shown in the image. 

      ji.c

      ....srcji.c(81) : error C2143: syntax error : missing ')' before 'constant'

      ....srcji.c(81) : error C2143: syntax error : missing '{' before 'constant'

      ....srcji.c(81) : error C2059: syntax error : 'constant'

      ....srcji.c(81) : error C2059: syntax error : ')'

      NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio 12.0VCBINx86_amd64cl.EXE"' : return code '0x2'

      Stop.

      Done.


      Line 81 is the very first line of my UDF. DEFINE_SPECIFIC_HEAT(my_udf_sp,T,Tref,h,yi), also mentioned in bold letter.


      DEFINE_SPECIFIC_HEAT(my_udf_sp,T,Tref,h,yi)

      {

       real Cp;

      real gamma;

      if (T >= 298.0 && T <= 855.0)

      {

      gamma = 0;

      }

      else if (T > 855.0 && T < 925.0)

      {

      gamma = (T - 855.0) / (925.0 - 855.0);

      }

      else if (T >= 925.0 && T<=2790)

      {

      gamma = 1.0;

      }

      else

      {

      gamma = 0;

      }

      if (T >= 298.0 && T <= 855.0)

      {

      Cp = 900.0 + 0.3*(T - 298.0);

      }

      else if (T > 855.0 && T < 925.0)

      {

      Cp = (1 - gamma)*(900.0 + 0.3*(T - 298.0)) + gamma*1170.0;

      }

      else if (T >=925.0)

      {

      Cp = 1170.0;

      }

      *h = Cp*(T - Tref);

      return Cp;

      }


      Can someone please help me in identifying the problem.?

      Thank you for your time and support.

    • Rob
      Forum Moderator
      Check lines 75-80 too, it may be you've missed a bracket terminating the previous block of text. If you save the file as .c in Notepad++ (for example) the editor is good for working out which bracket pairs are closed.
    • DrAmine
      Ansys Employee
      Use good Editors with Syntax Highlighting to avoid missing brackets. I won't use any UDF here you can just rely on NASA Polynomials for Cp or piecewise linear profile.
    • waqas12345
      Subscriber
      Thanx Rob and Dr Amine.
      I tried to change the location specific heat UDF. I even tried to compile it alone but the console always pointed towards the line containing the DEFINE_SPECIFIC_HEAT
      I will also try with NASA polynomial but I am not understanding why this error occurs. My fluent version is 2021R1 academic and I am using VS 2013. Up till now, all my UDFs are working fine. Only this is creating problem in compiling.


    • waqas12345
      Subscriber

    • Rob
      Forum Moderator
      Did you copy the line from the manual using CTRL+C or did you type it in? Check for white space characters if it's the former.
    • DrAmine
      Ansys Employee
      In Editor display Tabs and White Spaces and remove unnecessary.
    • waqas12345
      Subscriber
      Problem solved as advised by both of you. Thank you
Viewing 7 reply threads
  • The topic ‘Problem in compiling specific heat UDF’ is closed to new replies.
[bingo_chatbox]