CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Problem with UDF's output

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 29, 2018, 05:22
Default Problem with UDF's output
  #1
New Member
 
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12
Biji.Goli is on a distinguished road
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?
Biji.Goli is offline   Reply With Quote

Old   August 29, 2018, 16:22
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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...
pakk is offline   Reply With Quote

Old   August 29, 2018, 16:40
Default
  #3
New Member
 
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12
Biji.Goli is on a distinguished road
Quote:
Originally Posted by pakk View Post
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!
Attached Images
File Type: jpg 1.jpg (75.5 KB, 12 views)
Biji.Goli is offline   Reply With Quote

Old   August 30, 2018, 03:54
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   August 30, 2018, 04:32
Default
  #5
New Member
 
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12
Biji.Goli is on a distinguished road
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?
Biji.Goli is offline   Reply With Quote

Old   August 30, 2018, 04:36
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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...
pakk is offline   Reply With Quote

Old   August 30, 2018, 12:23
Default
  #7
New Member
 
Bijan
Join Date: Jul 2014
Posts: 9
Rep Power: 12
Biji.Goli is on a distinguished road
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?
Attached Images
File Type: jpg 1.jpg (95.0 KB, 7 views)
Biji.Goli is offline   Reply With Quote

Old   October 12, 2018, 09:28
Default similar results
  #8
Member
 
Join Date: Oct 2017
Posts: 52
Rep Power: 9
gouravjee is on a distinguished road
Quote:
Originally Posted by pakk View Post
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?
gouravjee is offline   Reply With Quote

Reply

Tags
properties, specific heat, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 22:36.