Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

UDF source term

    • douniaextra1
      Subscriber

      I wrote a UDF of a source term and temperature in function of time, but I'm not sure if it's right or no, can you please tell me if there is something wrong with it;


      #include "udf.h"


      #include


       


      DEFINE_SOURCE(Energy_source, c, ct)


      {


      real source;


      real flow_time;


      real t = CURRENT_TIME;


       {


      if ((t>21600)&&(t<72000)) 


       


      {


      source =(965.0*sin(3.14*(((t/3600)-6.0)/14)))*(0.81/0.002);


      }


      else


      {


       source=0;


      }     


              }


      return source;


      }


      DEFINE_PROFILE(temperature, thread, T)


      {


      face_t f;


      real t = CURRENT_TIME;


              begin_f_loop(f, thread)


              {


       


      F_PROFILE(f, thread, T)=298+6.0*cos(3.14*(((t/3600)-14.0)/12.0));


              }


      end_f_loop(f, thread)


      }        


       

    • Amine Ben Hadj Ali
      Ansys Employee
      I would rather work on that without UDFs easy to do with Expressions. Look ok. By the way we do not debug UDFs.
    • douniaextra1
      Subscriber

      Thank you for replying me,


      I tried the expression option in source term but I have a probleme with units 



      the numbers that I used in the equations have a unity. they are not just a constantes, wich means that the equations has a correct unity but fluent doesnot know that. he only see the time variable (t)


      do you have any idea about that ? 


      by the way I really appreciate any comment from you, they are so helpfull.


      Best regards,


      Dounia

    • Amine Ben Hadj Ali
      Ansys Employee
      Apart from time other quantities in you expression do not have any dimensions if input into Fluent. You need to make the expression in the sinus function dimensionsless: time can be only added to time and you divide by time. So (t-7)/(12).. the whole expressioneds to be multiplied by 1[W m^-3].

      All hints above are in the documentation.
    • douniaextra1
      Subscriber

      Thank you I got it know. can you please send me the documentation link that talks about this option so I can learn more.


      but in my equation I have a condition of time 


      if ((t>21600)&&(t<72000)) 


       


      {


      source =(965.0*sin(3.14*(((t/3600)-6.0)/14)))*(0.81/0.002);


      }


      else


      {


       source=0;


      }     


       


      there is a condition option in Fluent "IF" but I don't know how to use it to you have any idea about that?


      Thank you for keeping answering me ...


      Best regards,


      Dounia

    • Amine Ben Hadj Ali
      Ansys Employee
      Check FLUENT User's Guide.

      IF(CONDITION, IF TRUE, IF FALSE).
    • douniaextra1
      Subscriber

       thank you I got it know


      Best regards,


      Dounia

Viewing 6 reply threads
  • The topic ‘UDF source term’ is closed to new replies.