|
[Sponsors] |
August 29, 2018, 05:22 |
Problem with UDF's output
|
#1 |
New Member
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12 |
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? |
|
August 29, 2018, 16:22 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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... |
|
August 29, 2018, 16:40 |
|
#3 | |
New Member
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12 |
Quote:
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! |
||
August 30, 2018, 03:54 |
|
#4 | ||
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
If I add the following line to your code:
Quote:
Quote:
But the real culprit here is that you used the wrong macro... Look in the manual for DEFINE_SPECIFIC_HEAT. |
|||
August 30, 2018, 04:32 |
|
#5 |
New Member
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12 |
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? |
|
August 30, 2018, 04:36 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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... |
|
August 30, 2018, 12:23 |
|
#7 |
New Member
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12 |
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? |
|
October 12, 2018, 09:28 |
similar results
|
#8 | |
Member
Join Date: Oct 2017
Posts: 52
Rep Power: 9 |
Quote:
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? |
||
Tags |
properties, specific heat, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] outputTime in Swak function | immortality | OpenFOAM Community Contributions | 20 | October 6, 2022 13:08 |
problem using property udfs in parallel mode | EllenW | FLUENT | 0 | June 23, 2009 18:18 |
CFX-5.7 MPICH Parallel Problem (Output of Results) | James Date | CFX | 7 | February 15, 2005 17:03 |
ICEM5 Hexa output problem | Pete | CFX | 9 | September 16, 2004 19:33 |
Problem concerning the use of UDF's | Mukund | FLUENT | 2 | May 12, 2004 12:41 |