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/)
-   -   Why this udf is not working???? (https://www.cfd-online.com/Forums/fluent-udf/95642-why-udf-not-working.html)

dkb_bg December 27, 2011 00:38

Why this udf is not working????
 
Hi all,
Plz help me
I have written this udf for density a function of pressure.i am woking on narrow diameter pipe and woking fluid is r134a single phase. since pressure is changing across the pipe so i want to change density with press. but fluent is showing follwing error:confused:
I am taking press inlet and press outlet



*UDF for liquid density*/
#include"udf.h"

DEFINE_PROPERTY(fluid_density,cell,thread)
{
real density;
real pressure = C_P(cell,thread);
density =1e-10*pressure*pressure-0.000*pressure+1385;
return density;
}



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.

duri December 27, 2011 09:52

The is no error in you UDF I checked it with fluent 6.3 as interpreted UDF in 64bit machine. Something else is causing the trouble.
why are you using 0.0*pressure it makes nosense, it could add some machine error (values like 1e-45) and this could cause problem in 32bit machine.

ComputerGuy December 29, 2011 18:28

Deepak,

While you can define whatever density you want, C_P(cell,thread) won't return the absolute pressure, which I think you're looking for. Consequently, I think you're getting a density approaching zero, which is probably throwing the error. Additionally, the second term in your formula (0.000*pressure+1385) will *never* be anything but zero, given that you're multiplying by zero.

Verify that you're using the proper calculation for density (more specifically, for pressure), and then let us know.

Best,
ComputerGuy


All times are GMT -4. The time now is 04:50.