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/)
-   -   Problem with UDF's output (https://www.cfd-online.com/Forums/fluent-udf/206059-problem-udfs-output.html)

Biji.Goli August 29, 2018 04:22

Problem with UDF's output
 
Hi
I wrote a simple UDF code for practicing.
The code Interpreted with no errors.
But the output is not what I expected.

#include "udf.h"
DEFINE_PROPERTY(cell_heat_capacity, cell, thread)
{
real cp_n;
real ro_n;

real cp_f = 4179;
real ro_f = 997.1;
real phi = 0.02;
real cp_p = 765;
real ro_p = 3970;

ro_n = ro_f * (1 - phi) + phi * ro_p;
cp_n = (phi * ro_p * cp_p + (1 - phi) * ro_f * cp_f) / ro_n;

return cp_n;
}

Output of the code in fluent is 997.1 but with simple calculation one can get cp_n = 1056.46.
What is wrong with it?

pakk August 29, 2018 15:22

I think Fluent should output 3922.44, unless I do something wrong.

Anyway, in your "simple calculation" to calculate cp_n, I think you you calculated ro_n by accident...

Biji.Goli August 29, 2018 15:40

1 Attachment(s)
Quote:

Originally Posted by pakk (Post 704543)
I think Fluent should output 3922.44, unless I do something wrong.

Anyway, in your "simple calculation" to calculate cp_n, I think you you calculated ro_n by accident...

OH! Sorry about my mistake and thank you for your time calculating it.
You are absolutely right about my simple calculation ;) (It was a little bit messy on the paper and I "accidentally" wrote wrong number here), But not about the output. Still get 997.1!

pakk August 30, 2018 02:54

If I add the following line to your code:

Quote:

Message("%f\n",cp_n);
Then Fluent outputs:
Quote:

3922.438965

But the real culprit here is that you used the wrong macro...


Look in the manual for DEFINE_SPECIFIC_HEAT.

Biji.Goli August 30, 2018 03:32

Thank you for replying to my silly question.

Is this a real code line "Message("%f\n",cp_n);" because it doesn't work.

About DEFINE_SPECIFIC_HEAT (name,T,Tref,h,yi) from manual: "The DEFINE_SPECIFIC_HEAT macro can be used to define temperature-dependent functions for specific heat and sensible enthalpy for fluid, solid and mixture materials (this does not include DPM particles)." But in my case It's not temperature dependent just a constant number.

I know I can simply set specific heat to 3922 in materials. But it's not a good start to learn UDFs.

Can you please enlighten me on where does 997.1 come from?

pakk August 30, 2018 03:36

The line with Message works if you compile. General tip: always compile, never interpret.


And the only 997.1 that I see is the ro_f in your code, but I don't know how that ends up as the answer...




But you need DEFINE_SPECIFIC_HEAT to change the specific heat. DEFINE_PROFILE will not work. And the equation CAN depend on temperature, it does not have to...

Biji.Goli August 30, 2018 11:23

1 Attachment(s)
Dear pakk.
I used the macro you suggested and it is working fine for the heat capacity value. But the energy equation doesn't converge (Look at the picture I attached). Also the results aren't correct comparing with when constant value is used. Does it have something to do with compiling the code?
Are there more material properties that need specific macro to define?

gouravjee October 12, 2018 08:28

similar results
 
Quote:

Originally Posted by pakk (Post 704543)
I think Fluent should output 3922.44, unless I do something wrong.

Anyway, in your "simple calculation" to calculate cp_n, I think you you calculated ro_n by accident...

hi,
i have been simulating a solidification melting problem in a cylinder using fluent udf for different fin configurations (meridional plane)such as for 30,45,60 degrees.
i am using 1mm mesh for all configurations
But getting the same results(Temperature range) for melting in all the configurations of fins
can suggest some way to rectify this problem?


All times are GMT -4. The time now is 02:45.