Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

How to create valid UDF for specific heat if formula depends on whether it’s melting or solidifying?

    • Leona
      Subscriber
      I would like to use the technique of assigning a certain function for the specific heat, dependent on whether the fluid is melting, T(t-1) < T(t), or solidifying, T(t-1) > T(t). This is known as hysteresis. I try to obtain T(t-1) via C_T_M1(c,t). However, the function DEFINE_SPECIFIC_HEAT(name, T, Tref, h, yi) only takes these five limited inputs, which does not include (c,t).nHow to solve this? Somewhere I saw a suggestion to a similar type of problem using 'domain *domain = Get_Domain(1); Thread *t; cell_t c;', but it is not sure if this works.nA piece of example code (NOT working yet) illustrating what I would like to do:n#include udf.hnnDEFINE_SPECIFIC_HEAT(name, T, Tref, h, yi, c, t)n{n real cp;n real Tprev = C_T_M1(c,t);n if (T => 300 && T=< 400 && Tprev < T)n cp = certain formula for melting;n if (T => 310 && T=< 390 && Tprev > T)n cp = certain formula for solidifying;n elsen cp = 2000;n *h = cp*(T-Tref);n return cp;nnAny suggestions would be amazing!nBests,nLeona
    • Surya Deb
      Ansys Employee
      Hello, nYes. you will need to fetch the domain using domain *domain =Get_Domain(1). nThis will provide the Mixture Domain that you can then use.nThen you will need to loop over the threads and then cells within those threads if you do not have any specific zone id.nthread_loop_c is the macro that can be used to loop over all existing threads . [you can also use a check to make sure it is a fluid thread]nCheck this link for further information on this. https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v195/flu_udf/flu_udf_sec_thread_loop_c.htmlnInside the loop for threads, you will need to loop for cells. Check the link below for that.nLookup_Thread(domain, zone id) can be used if you know your specific zone id which might not be the case for you as you want to implement this throughout the domain I believe.nI hope this helps.nRegards,nSuryann
Viewing 1 reply thread
  • You must be logged in to reply to this topic.