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.

How To write a Correct UDF (FLUENT) for Specific heat as Function of Temperature for Polynomials ?

    • atulsbhat
      Subscriber

      This UDF didnt Get Any Error message but its not running, Can someone correct the UDF BELOW? {Suggest Changes Required}


      Should I add anything Related To Enthalpy or Some UDM MACRO like C_UDMI(c,t,0) = cp


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


      {  


      real T = C_T(c, t);


      real cp;


      if (500< T <550)


      {


      cp = (0.63464529*pow(T,2))-(356.13993666*T)+(61767.53243895);


      }


      else if (550< T <600.10)


      {


      cp = (0.23484528*pow(T,2))-(250.13953470*T)+(71466.09249852);


      }


      else if (600.10< T < 625.15)


      {


      cp = (1.58260392*pow(T,2))-(1873.17493506*T)+(560143.47661247);


      }


      else if (625.15< T <640)


      {


      cp = (16.13751699*pow(T,2))-(20137.03882161*T)+(6289718.12316515);


      }


      else


      {


      cp = 13000;


      }


      return cp;


      }


       

    • Amine Ben Hadj Ali
      Ansys Employee
      Just likewise polynomial function in Fluent. Moreover the UDF is wrong. Check the specific macro in the docu.
    • atulsbhat
      Subscriber

      Can you be a Little more Specific?, Where The exact Changes are Required , That will be More appropriate and helpful.


      GENERAL FORMAT:



      Kindly Correct My UDF..


      Regards

    • Amine Ben Hadj Ali
      Ansys Employee
      I was specific that is why I referred to the manual. You forgot the most important line telling Fluent how to deal with enthalpy pointer. I still see no requirement for UDF as same functionality already in Fluent.
    • atulsbhat
      Subscriber

      Is the UDF okay now ? Where to Add Tref ? 


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


      {  


      real T = C_T(c, t);


      real cp;


      if (500< T <550)


      {


      cp = (0.63464529*pow(T,2))-(356.13993666*T)+(61767.53243895);


      *h = cp*(T-Tref);


      }


      else if (550< T <600.10)


      {


      cp = (0.23484528*pow(T,2))-(250.13953470*T)+(71466.09249852);


      *h = cp*(T-Tref);


      }


      else if (600.10< T < 625.15)


      {


      cp = (1.58260392*pow(T,2))-(1873.17493506*T)+(560143.47661247);


      *h = cp*(T-Tref);


      }


      else if (625.15< T <640)


      {


      cp = (16.13751699*pow(T,2))-(20137.03882161*T)+(6289718.12316515);


      *h = cp*(T-Tref);


      }


      else


      {


      cp = 13000;


      *h = cp*(T-Tref);


      }


      return cp;


      }


       


      OR


       


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


      {  


      real T = C_T(c, t);


      real cp;


      if (500< T <550)


      {


      cp = (0.63464529*pow(T,2))-(356.13993666*T)+(61767.53243895);


      }


      else if (550< T <600.10)


      {


      cp = (0.23484528*pow(T,2))-(250.13953470*T)+(71466.09249852);


      }


      else if (600.10< T < 625.15)


      {


      cp = (1.58260392*pow(T,2))-(1873.17493506*T)+(560143.47661247);


      }


      else if (625.15< T <640)


      {


      cp = (16.13751699*pow(T,2))-(20137.03882161*T)+(6289718.12316515);


      }


      else


      {


      cp = 13000;


      }


      *h = cp*(T-Tref);


      return cp;


       


      }


       


      I have Rational Polynomials too, So to add them i need UDF.

    • Amine Ben Hadj Ali
      Ansys Employee
      Try the second one seems fine. If it is not working start debugging.
    • atulsbhat
      Subscriber

      Thank You Sir,


      I have a few Questions More,


      1. When should we Set UDM Macros (UDM MACRO like C_UDMI(c,t,0) = cp)?


      2. Where to Set Tref , Should We Give any Any Value to It?


      3. Is The UDF independent of the Number of Cells (Total Number of Elements/nodes) ?


      4. Will Units of Returned by UDF are Same As Default Units ?


      Thank You Very Much In Advance


      These Questions answer all my doubts..

    • Rob
      Forum Moderator

      1) When you need it. Why do you need to save the value?


      2) What does the manual say about Tref?


      3) Pretty much, the UDF is attached to the whole domain (In most cases) and set via the material properties.


      4) UDFs use the default SI units: if you've not changed anything they'll be the same.

    • pratheeba.chandanagarajan
      Subscriber

       

      Hi,

      I am trying to get UDF for solid (cordierite) specific heat as a function of temperature.

      I made the following UDF:

      DEFINE_SPECIFIC_HEAT(cell_specific_heat, T, Tref, h, yi)
      {

        real T = C_T(c,t);

      /* Units of Cp_Porous is in J/kg/K */

          real Cp_porous = 1.071 + 1.56e-4*T – 3.435e4/(T*T);
      *h = Cp_porous*(T-Tref);
        return Cp_porous ;
      }

      ReactionKineticsImplicitV2.c(268,8): error: redefinition of ‘T'

      real T = C_T(c,t);

      ^

      ReactionKineticsImplicitV2.c(265,42): note: previous definition is here

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

      ^

      ReactionKineticsImplicitV2.c(268,18): error: use of undeclared identifier ‘t'

      real T = C_T(c,t);

      ^

      ReactionKineticsImplicitV2.c(268,16): error: use of undeclared identifier ‘c'

      real T = C_T(c,t);

       

      Can you help me to resolve these errors?

      2. The Polynomial is Cp = a + BT + C/(T^2). Can the built-in polynomial handle this equation?

       

      Thank you so much.

      Pratheeba

       

       

Viewing 8 reply threads
  • The topic ‘How To write a Correct UDF (FLUENT) for Specific heat as Function of Temperature for Polynomials ?’ is closed to new replies.