How to create valid UDF for specific heat if formula depends on whether it's melting or solidifying?
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).
How 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.
A piece of example code (NOT working yet) illustrating what I would like to do:
#include "udf.h"
DEFINE_SPECIFIC_HEAT(name, T, Tref, h, yi, c, t)
{
real cp;
real Tprev = C_T_M1(c,t);
if (T => 300 && T=< 400 && Tprev < T)
cp = certain formula for melting;
if (T => 310 && T=< 390 && Tprev > T)
cp = certain formula for solidifying;
else
cp = 2000;
*h = cp*(T-Tref);
return cp;
}
Any suggestions would be amazing!
Bests,
Leona
Answers
Hello,
Yes. you will need to fetch the domain using domain *domain =Get_Domain(1).
This will provide the Mixture Domain that you can then use.
Then you will need to loop over the threads and then cells within those threads if you do not have any specific zone id.
thread_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]
Check 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.html
Inside the loop for threads, you will need to loop for cells. Check the link below for that.
Lookup_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.
I hope this helps.
Regards,
Surya