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/)
-   -   regarding UDF (https://www.cfd-online.com/Forums/fluent-udf/212915-regarding-udf.html)

shivanb December 11, 2018 09:22

regarding UDF
 
Can anyone help me writing the UDF for the density varying with temperature
as follows
rho(T)=1000*(1-((T+288.9414)/(508929.2*T+34673158.1))-(T-3.9863)^2)
Thanks

AlexanderZ December 12, 2018 01:33

Ansys FLuent Customization manual
look for DEFINE_PROPERTY macro
example
Code:

/*********************************************************************
UDF that simulates solidification by specifying a temperaturedependent
viscosity property
**********************************************************************/
#include "udf.h"
DEFINE_PROPERTY(cell_viscosity,c,t)
{
real mu_lam;
real temp = C_T(c,t);
if (temp > 288.)
mu_lam = 5.5e-3;
else if (temp > 286.)
mu_lam = 143.2135 - 0.49725 * temp;
else
mu_lam = 1.;
return mu_lam;
}

modify this code to your needs

best regards

shivanb December 12, 2018 02:23

Regardin UDF
 
I have written the following UDF but I don't whether its correct or not. I tried it in fluent but its not working. Any idea for any correction please tell me

#include "udf.h"
DEFINE_PROPERTY(cell_density,c,t)
{
real rho;
real T= C_T(c,t);
rho= 1000*(1-((T-273.15+288.9414)/(508929.2*(T-273)+34673158.1))-(T-273-3.9863)*(T-273-3.9863));

return rho;
}

AlexanderZ December 12, 2018 04:18

why do you think it doesn't work?
udf seems to be correct
did you apply this udf as material property?

best regards

shivanb December 12, 2018 04:22

Yes I applied it as material property but solution is not getting converged now. for constant density it was converging but now it is showing floating point error. I don't know how to proceed further.
Please help what to do now

AlexanderZ December 12, 2018 21:23

check your equation, put simple equation first to clarify, that everything works well, most likely problem comes from your equation
make more strict convergence criteria, make more iterations
put smaller relaxation value

best regards

pavankonchada December 13, 2018 04:16

Getting different answer when intializing through udf
 
The below is a part of density udf for PCM
r1=(9*(pow(temp,3)))
the value I am getting when initializing is 239613872.000000
but the actual value is 239613851.304
please help me due to this I am getting divergence

AlexanderZ December 14, 2018 02:47

Check your equation: rho= 1000*(1-((T-273.15+288.9414)/(508929.2*(T-273)+34673158.1))-(T-273-3.9863)*(T-273-3.9863));
It gives negative values
Code:

temperature(K)  value
300        -528630.3942
310        -1088904.394
320        -1849178.393
330        -2809452.393
340        -3969726.393
350        -5330000.393
360        -6890274.392
370        -8650548.392
380        -10610822.39
390        -12771096.39
400        -15131370.39
410        -17691644.39
420        -20451918.39
430        -23412192.39
440        -26572466.39
450        -29932740.39


best regards


All times are GMT -4. The time now is 03:58.