CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Where is the problem in UDF (FLUENT) for cp as a function of Temperature?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 31, 2022, 05:17
Default Where is the problem in UDF (FLUENT) for cp as a function of Temperature?
  #1
New Member
 
ANTALYA
Join Date: Sep 2017
Posts: 20
Rep Power: 9
erginbayrak is on a distinguished road
Hi, I take a compiled error from my code as follows;

supercritical_cp.c
..\..\src\supercritical_cp.c(3): error C2065: 'real': undeclared identifier
..\..\src\supercritical_cp.c(3): error C2146: syntax error: missing ';' before identifier 'cp'
..\..\src\supercritical_cp.c(3): error C2065: 'cp': undeclared identifier
..\..\src\supercritical_cp.c(7): error C2065: 'cp': undeclared identifier
..\..\src\supercritical_cp.c(11): error C2065: 'cp': undeclared identifier
..\..\src\supercritical_cp.c(15): error C2065: 'cp': undeclared identifier
..\..\src\supercritical_cp.c(19): error C2065: 'cp': undeclared identifier
..\..\src\supercritical_cp.c(21): error C2100: illegal indirection
..\..\src\supercritical_cp.c(21): error C2065: 'cp': undeclared identifier
..\..\src\supercritical_cp.c(22): error C2065: 'cp': undeclared identifier

Done.

My code is;

DEFINE_SPECIFIC_HEAT(supercritical_cp, T, Tref, h, yi)
{
real cp;

if (306. >= T >= 285.)
{
cp = 0.0029 * pow(T, 6.) - 5.0805 * pow(T, 5.) + 3733.1 * pow(T, 4.) - 1e+6 * pow(T, 3.) + 3e+8 * pow(T, 2.) - 4e+10 * T + 2e+12;
}
if (307.8 >= T > 306.)
{
cp = 2342.3 * pow(T, 6.) - 4e+6 * pow(T, 5.) + 3e+9 * pow(T, 4.) - 1e+12 * pow(T, 3.) + 3e+14 * pow(T, 2.) - 4e+16 * T + 2e+18;
}
if (310. >= T > 307.8)
{
cp = -4663.3 * pow(T, 6.) + 9e+6 * pow(T, 5.) - 7e+9 * pow(T, 4.) + 3e+12 * pow(T, 3.) - 6e+14 * pow(T, 2.) + 8e+16 * T - 4e+18;
}
if (350. >= T > 310.)
{
cp = 8e-5 * pow(T, 6.) - 0.1631 * pow(T, 5.) + 135.66 * pow(T, 4.) - 60154 * pow(T, 3.) + 1e+7 * pow(T, 2.) - 2e+9 * T + 1e+11;
}
*h = cp*(T-Tref);
return cp;
}

I would like to be grateful if you could say your recommendations.
Regards,
erginbayrak is offline   Reply With Quote

Old   August 31, 2022, 06:13
Default
  #2
Senior Member
 
Join Date: Oct 2011
Posts: 242
Rep Power: 17
naffrancois is on a distinguished road
Hello,

Could it be that you forgot to include udf.h or that it can't be located ?

edit: probably unrelated to your error but what happens to cp if T does not lie in [306,350] ? You should consider default values when using if statements.
naffrancois is offline   Reply With Quote

Old   September 6, 2022, 06:49
Default
  #3
New Member
 
ANTALYA
Join Date: Sep 2017
Posts: 20
Rep Power: 9
erginbayrak is on a distinguished road
Quote:
Originally Posted by naffrancois View Post
Hello,

Could it be that you forgot to include udf.h or that it can't be located ?

edit: probably unrelated to your error but what happens to cp if T does not lie in [306,350] ? You should consider default values when using if statements.
Hello, thank you for your reply. I forgot udf.h. I am trying to catch a sharp increase of specific heat in the vicinity of the near-critical region of CO2. My revised code is working (there is no problem with compiling) but after the user defining of thermophysical properties for CO2, I have taken another error as follows:

My Code
#include "udf.h"

DEFINE_SPECIFIC_HEAT(supercritical_cp2, T, Tref, h, yi)
{
real cp;

if (285. > T)
{
cp = 2540.85;
}
if (306. >= T >= 285.)
{
cp = 0.0029 * pow(T, 6.) - 5.0805 * pow(T, 5.) + 3733.1 * pow(T, 4.) - 1e+6 * pow(T, 3.) + 3e+8 * pow(T, 2.) - 4e+10 * T + 2e+12;
}
if (307.8 >= T > 306.)
{
cp = 2342.3 * pow(T, 6) - 4e+6 * pow(T, 5) + 3e+9 * pow(T, 4) - 1e+12 * pow(T, 3) + 3e+14 * pow(T, 2) - 4e+16 * T + 2e+18;
}
if (310. >= T > 307.8)
{
cp = -4663.3 * pow(T, 6) + 9e+6 * pow(T, 5) - 7e+9 * pow(T, 4) + 3e+12 * pow(T, 3) - 6e+14 * pow(T, 2) + 8e+16 * T - 4e+18;
}
if (350. >= T > 310.)
{
cp = 8e-5 * pow(T, 6) - 0.1631 * pow(T, 5) + 135.66 * pow(T, 4) - 60154. * pow(T, 3) + 1e+7 * pow(T, 2) - 2e+9 * T + 1e+11;
}

if (T > 350.)
{
cp = 1546.34;
}
*h = cp*(T-Tref);
return cp;
}

Error:

WARNING: Invalid cp (0.000000e+00 J/kgK) for carbon-dioxide at temperature 289.692000 K
iter continuity x-velocity y-velocity energy k omega intermit retheta time/iter
Stabilizing pressure coupled to enhance linear solver robustness.
Stabilizing pressure coupled using GMRES to enhance linear solver robustness.

Experiencing convergence difficulties - temporarily relaxing and trying aga

ivergence detected in AMG solver: pressure coupled Stabilizing k to enhance linear solver robustness.
Stabilizing k using GMRES to enhance linear solver robustness.
Divergence detected in AMG solver: pressure coupled
Divergence detected in AMG solver: k
Divergence detected in AMG solver: omega
Divergence detected in AMG solver: intermit
Divergence detected in AMG solver: retheta
Divergence detected in AMG solver: temperature

WARNING: Invalid cp (0.0000Error at Node 0: floating point exception
Error at Node 1: floating point exception
Error at Node 2: floating point exception
Error at Node 3: floating point exception
00e+00 J/kgK) for carbon-dioxide at temperature 289.692000 K

Error at Node 4: floating point exception
Error at Node 5: floating point exception
Error at Node 6: floating point exception
Error at Node 7: floating point exception
Error at Node 8: floating point exception

Error at host: floating point exception
Error at Node 9: floating point exception
Error at Node 10: floating point exception
Error at Node 11: floating point exception

Error: floating point exception
Error Object: #f
erginbayrak is offline   Reply With Quote

Old   September 6, 2022, 07:01
Default
  #4
Senior Member
 
Join Date: Oct 2011
Posts: 242
Rep Power: 17
naffrancois is on a distinguished road
Hello,

I don't have experience with fluent so I can just provide very general help here.

If I were you I would double check first the correlations you are using by plotting them for each temperature range. Hand computing your correlation at T=289.692K gives an unrealistic value for cp ~ 10^12
naffrancois is offline   Reply With Quote

Reply


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
Getting density, temperature, and other cell flow variables via macros in Fluent UDF ingabobjoe Fluent UDF and Scheme Programming 2 August 15, 2020 22:08
How To write a Correct UDF (FLUENT) for Specific heat as Function of Temperature for atulsbhat FLUENT 4 December 10, 2019 11:57
Problem in compiling fluent UDF lunched from MATLAB cfdman10 Fluent UDF and Scheme Programming 16 December 5, 2019 06:32
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 10:31


All times are GMT -4. The time now is 23:46.