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:
DEFINE_SPECIFIC_HEAT(name, T, Tref, h, yi, c, t)
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;
cp = 2000;
*h = cp*(T-Tref);
Any suggestions would be amazing!