|
[Sponsors] |
Divergence using UDF for specific Heat(Fluent) |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
John Antony Misquith
Join Date: Feb 2020
Posts: 4
Rep Power: 5 ![]() |
Hello Everyone!
Background: Running water in co-axial channels into a 2-D domain with temperatures varying from sub- to super-critical using Fluent Since water has a Cp spike for Super critical water ( as attached in the file). Cp_NIST_data.JPG I was looking at trying to model the spike using a UDF with temperature range from 300K to 1000K .I Took data points from the NIST website and generated piece-wise functions for multiple temperature ranges ( as depicted in the code). Cp_temp_contour.JPG While I believe the UDF gets loaded properly into fluent( using interpreted , it loads without showing any error), the residuals of continuity tend to blow up ( --> 1e+10 etc) while the energy residual (1e+0) and i get all sorts of temperature spots in the domain(As depicted in the picture). CODE: #include "udf.h" DEFINE_SPECIFIC_HEAT(john_cp, T, Tref, h, yi) { real cp; if (T >= 523 && T <=600) cp = 6.84697E+04 + -2.41062E+02*T + 2.28273E-01*T*T; else if (T>600 && T <= 630) cp = 6.05982E+05 -2.00334E+03*T +1.67297E+00*T*T; else if (T>630 && T<= 650) cp =8.91902E+06 -2.81935E+04*T+ 2.23004E+01*T*T; else if (T>650 && T <= 658) cp = 3.34752E+08 -1.02965E+06*T+ 7.91808E+02*T*T; else if (T>658 && T <= 660) cp = -1.01330E+08+ 3.22934E+05*T-2.56559E+02*T*T; else if (T>660 && T <= 668) cp =2.60837E+08 + -7.81911E+05*T+ 5.86025E+02*T*T; else if (T>668 && T <= 700) cp = 4.94026E+06 -1.41350E+04*T+ 1.01250E+01*T*T; else if (T>700 && T <= 850) cp = 1.18004E+06 -4.36540E+03*T+ 5.40459E+00*T*T -2.23261E-03*T*T*T; else cp = 3000; *h = cp*(T-Tref); return cp; } I was wondering if anyone has faced such an issue. p.s: I tried to recreate the Cp plot using the functions in MATLab and it seems to recreate them pretty well. I have also tried with coarse and fine mesh and it still gives me such plots. Any help or suggestion would be greatly appreciated. John Misquith |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
|
You don't need a UDF for this. This is just piecewise polynomial, which can be entered directly in GUI.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
John Antony Misquith
Join Date: Feb 2020
Posts: 4
Rep Power: 5 ![]() |
Thank you for your reply.
I am currently using piecewise polynomials to capture the curve but since ansys fluent does not allow more than 3 temperature ranges and puts a restriction on the number of significant digits after the decimal point (for the coefficients entered), I cant seem to accurately capture the peak without deviating a lot from the curve. Hence I decided to move to UDFs. Would love any other suggestions. Thank you |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
|
If you want to use UDF, you have to compile it. Specific Heat UDF or any UDF that uses references or structures need to be compiled. Interpreter cannot handle this.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#5 |
New Member
John Antony Misquith
Join Date: Feb 2020
Posts: 4
Rep Power: 5 ![]() |
Thanks for your reply again!
Yeah so i tried compiling the code and running it instead of the interpreter. It gave me an 'nmake' error , which i rectified by running fluent through the VS prompt (version 2019). Even after i was able to compile the code correctly , Im still facing this issue of random temperature spots all over the domain. Regards John |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
|
That''s because you have got the Thermodynamics wrong in the UDF. Enthalpy is equal to
![]() ![]()
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#7 |
New Member
John Antony Misquith
Join Date: Feb 2020
Posts: 4
Rep Power: 5 ![]() |
Thank you for your reply!
You are absolutely right! Thanks for pointing that out. I made the changes to the code to calculate the enthalpy(h) using the integral from Tref to T and it worked! Thanks for your help again! John M |
|
![]() |
![]() |
![]() |
![]() |
#8 |
New Member
Join Date: Jul 2020
Posts: 1
Rep Power: 0 ![]() |
Hi Johnam,
I meet a problem similar to yours. However, I'm not quite familiar with C language. Could you please specify how to write a code for the integral to calculate enthalpy? Regards, Danwei |
|
![]() |
![]() |
![]() |
Tags |
fluent - udf - parallel, specific heat, supercritical water |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PEMFC model with FLUENT | brahimchoice | FLUENT | 22 | April 19, 2020 15:44 |
Two Phase Flow In Vertical Pipe | stonepreston | FLUENT | 2 | October 31, 2017 08:35 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 07:00 |
UDF for heat convection coefficient with fixed surface temperature | Boo85 | Fluent UDF and Scheme Programming | 2 | July 10, 2012 18:43 |
heat flow UDF on coupled surface (wall-shadow wall) | Friedmann | Fluent UDF and Scheme Programming | 0 | August 5, 2010 10:25 |