CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   udf for source term (https://www.cfd-online.com/Forums/fluent-udf/163956-udf-source-term.html)

fersim December 9, 2015 00:05

udf for source term
 
Good morning,
Please help me to write a UDF program for calculate the source term
This source code calculation value of the source term to account for the phase change phenomenon of a material. As the temperature increases (T (t) > T (t-delta t) the material absorbs heat, so the source term is negative. And decreasing temperature (T (t) <T (t-delta t) the material releases heat, so the source term is positive and finally if the temperature remains constant (T (t) = T (t-delta t) the source term equal to the previous value (source at t - delta t).
This code takes into account the hysteresis of a no pure phase change material. That is to say, the source term is different during the heat absorption and release of heat. This source term is written as a polynomial equation (Source = A * T + B).
I inform you that I code is compiled during simulation but there is the following error:
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()

This error is caused that this problem does not recognize the temperature at time t delta-t.


#include "udf.h"
DEFINE_SOURCE(terme_source, c, t, dS, eqn)
{
real source;
real sourrce_previous; /*sourrce_previous= source at t-delta t */
if (C_T(c,t)>C_T_M1(c,t))
source = -5*C_T(c,t)-25;
else if (C_T(c,t)<C_T_M1(c,t))
source = 8*C_T(c,t)+15;
else
source = sourrce_previous;
dS[eqn]=0;
return source;
}

Sun December 10, 2015 07:20

I think the reason you are getting ACCESS VIOLATION error is that you haven't initialized the source_previous variable.

maziyarghani September 15, 2017 03:50

Hello
I want to write a negative source term or heat flux UDF which has a linear relation with temperature
I am very beginner in UDF could you help me?


All times are GMT -4. The time now is 11:08.