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/)
-   -   conductivity, viscosity, and density udf (https://www.cfd-online.com/Forums/fluent-udf/133386-conductivity-viscosity-density-udf.html)

mdakbari April 14, 2014 09:37

conductivity, viscosity, and density udf
 
3 Attachment(s)
hello friends, i have 3 .c files that need to be checked cause i am not sure which they work or not.
i really appreciate u to check it for me,
i'm waiting for ur comments dudes
best wishes for u

Attachment 30141

Attachment 30142

Attachment 30143

Galileo April 14, 2014 12:33

Re: My UDF Code
 
Quote:

Originally Posted by mdakbari (Post 486023)
hello friends, i have 3 .c files that need to be checked cause i am not sure which they work or not.
i really appreciate u to check it for me,
i'm waiting for ur comments dudes
best wishes for u

Attachment 30141

Attachment 30142

Attachment 30143


Hi,
Can you explain what problem you are facing with the code? You don't have to have 3 different files for your code. You can place them all in one file (since they are not that lengthy).
Since I don't know what you are trying to do. I will suggest you try and debug the code using a simple way as follows.
1) Do the calculations in an Excel sheet with different inputs
2) Place some lines to print the output to the console in Fluent.
2a) Note that I have put a limit to the number of times your code will print to the console so that it does not hang up your system.
I hope that will help in what you are trying to do. I did not run the code but I think it looks OK, the red parts are my addition to your code to help you in debugging, I have not changed anything, you can remove them after the debugging.

Regards


APPENDIX
/************************************************** *******************
UDF that simulates solidification by specifying a temperaturedependent
thermal conductivity property
************************************************** ********************/
#include "udf.h"

int printStopper=0; /*This is a dummy counter */
DEFINE_PROPERTY(cell_density,cell,thread)
{
real rho;
real temp = C_T(cell,thread);
rho=(-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));

if(printStopper<=100)
{printStopper++;
CX_Message("*****Cell Temp: %3.2f Kelvin, Rho= %E kg/m3 \n",temp,rho);
}

return rho;
}
DEFINE_PROPERTY(cell_conductivity,cell,thread)
{
real ktc;
real temp = C_T(cell,thread);
ktc=(-8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)-0.5981);

if(printStopper<=100)
{printStopper++;
CX_Message("*****Cell Temp: %3.2f Kelvin, KTC= %E W/m.K \n",temp,ktc);
}

return ktc;
}

DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
real mu;
real temp = C_T(cell,thread);
mu=2.591*(pow(10,-5))*(pow(10,(238.3/(temp-143.2))));

if(printStopper<=100)
{printStopper++;
CX_Message("*****Cell Temp: %3.2f Kelvin, Viscosity= %E Pa.s \n",temp,mu);
}

return mu;
}

mdakbari April 15, 2014 03:15

hello my friend galileo, ur reply was so helpful and i really appreciate it.
it did work finally for me but i used just that part of ur recommendation: You don't have to have 3 different files for your code. You can place them all in one file (since they are not that lengthy)
it was a very nice and on time reply.
thank u very veryyyyyyyyy much

shivanb December 12, 2018 12:08

@Mdakbari I miss also using udf for density, viscosity, and conductivity. But when I am using the same in fluent my solution is not converging. How to solve this problem


All times are GMT -4. The time now is 19:00.