Fluids

Fluids

Error in UDF for specific heat in terms of liquid fraction

    • khalidb77
      Subscriber

      Dear FLUENT users,


      I used the below UDF for specific heat in terms of liquid fraction it compiled normally and uploaded successfully into Cp in materials panel but an error happened and the program quit with unknown reason as soon as I initial the solution? knowing that I activated the melting and solidification model and the case is running normally without using the UDF? So is there an error on it? any recommendations are appreciated please?

      #include "udf.h"
      /*
      #define cps 1800.0
      #define cpl 2400.0
      #define lat 160000.0
      */
      DEFINE_SPECIFIC_HEAT(specificheat, T, Tref, h, yi)
      {
      real cpm,dt;
      Tref=308;
      real cps = 1800.0;
      real cpl = 2400.0;
      real lat = 160000.0;
      Thread *t;
      cell_t c;

      dt=exp(-T*(T-Tref)*(T-Tref)/4.0)/sqrt(4.0*3.14);

      cpm =cps+(cpl-cps)*C_LIQF(c,t)+lat*dt;

      *h = cpm*(T-Tref);
      return cpm;

      }


       

    • DrAmine
      Ansys Employee

      That would not work: There is no way to access cell and thread data from within the DEFINE_SPECIFIC_HEAT macro.

    • khalidb77
      Subscriber

      Thanks Amine for the reply. So how I can resolve the error? is there any changes can I make within the UDF?


       


      Khalid

    • DrAmine
      Ansys Employee
      One way via udrgm (not tested).
    • khalidb77
      Subscriber

      Excuse me what did you mean with udrgm?

    • DrAmine
      Ansys Employee
      User defined real gas model.
    • khalidb77
      Subscriber

      But I do not have a gas in my case? I used PCM model hence I have just two liquids and a solid?

    • DrAmine
      Ansys Employee
      Can be used for liquid eos. Only way to make the trick. Or you use solidification and melting model or you use specie transport and code Cp with mass fraction. The problem here is that the macro to modify cp dies not support cell access or cell loop just temperature access and species access.
    • khalidb77
      Subscriber

      I am actually used the solidification and melting model? then is there a solution to the problem?

    • DrAmine
      Ansys Employee
      Just provide Cp as temperature dependent and melt heat in the material panel.
    • khalidb77
      Subscriber

      The problem Cp is function of liquid fraction too? OK I need to ask is it possible to define LIQF inside the specific heat UDF using the definition below (where f(T) is LIQF):



      Then I give the relation of Cp as written on the UDF in my first post?

    • DrAmine
      Ansys Employee
      Please look thoroughly in my answers and you will see that Cp can be defined in UDF for temperature dependency.
    • khalidb77
      Subscriber

      I thought you never notice what I mentioned in my previous post. If you see the definition at the picture I sent you will realized that LIQF is a function of temperature too. Hence can I use this definition for f(T) (liquid fraction) inside the specific heat UDF or no?


       


      Thanks


      Khalid

    • DrAmine
      Ansys Employee

      Again: You cannot access any cell variables in DEFINE_SPECIF_HEAT you need to use the passed temperature and species arguments into the macro.

Viewing 13 reply threads
  • You must be logged in to reply to this topic.