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

property UDF compiles but runs with error

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By obscureed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 23, 2018, 10:18
Default property UDF compiles but runs with error
  #1
New Member
 
Sathish
Join Date: Apr 2018
Location: germany
Posts: 5
Rep Power: 8
Sam_1913 is on a distinguished road
hi guys,

i used a couple of UDFs to define viscosity, thermal conductivity, heat capacity and density of water as function of temperature...compilation wasnt a problem with visual studio express 15 (Fluent 17.2) yet after running the simulation, getting the error '' temperature limited to 1 on 12000 cells on zone 7 in domain 1'' for example...

when these functions are implemented directly in Fluent material database as piecewise polynomial, no such messages appear in TUI..

these are relatively simply polynomial fucntion UDFs...can anyone please point out what should i change regarding the setup ...thanks in advance
Attached Files
File Type: c Cp_35.c (2.0 KB, 4 views)
Sam_1913 is offline   Reply With Quote

Old   April 23, 2018, 10:21
Default
  #2
New Member
 
Sathish
Join Date: Apr 2018
Location: germany
Posts: 5
Rep Power: 8
Sam_1913 is on a distinguished road
these are the udfs....


#include "udf.h"

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

if (T > 700.)
{
cp = 14000;
*h = cp * (T - Tref);
}

else if (T > 678.2)
{
cp = (-12066.64 + 35. * T - 0.0253 * pow(T,2.)) * 1000;
*h = (-12066.64 * (T - Tref) + 17.5 * (T * T - Tref * Tref) - 0.00843 * (pow(T,3.) - pow(Tref,3.))) * 1000;
}

else if (T > 614.8)
{
cp = (-10342.5 + 49.32 * T - 0.0784 * pow(T,2.) + 4.16e-5 * pow(T,3.)) * 1000;
*h = (-10342.5 * (T - Tref) + 24.66 * (T * T - Tref * Tref) - 0.02613 * (pow(T,3.) - pow(Tref,3.)) + 1.04e-5 * (pow(T,4.) - pow(Tref,4.))) * 1000;
}

else if (T > 273.)
{
cp = (-0.5112 + 0.0371 * T - 9.935e-5 * pow(T,2.) + 9.0e-8 * pow(T,3.)) * 1000;
*h = (-0.5112 * (T - Tref) + 0.0189 * (T * T - Tref * Tref) - 3.312e-5 * (pow(T,3.) - pow(Tref,3.)) + 2.25e-8 * (pow(T,4.) - pow(Tref,4.))) * 1000;
}

else
{
cp = 4000;
*h = cp * (T - Tref);
}

return cp;
}


DEFINE_PROPERTY(therm_cond,c,t)
{
real ktc;
real T = C_T(c,t);

if (T > 700.)
ktc = 240.1e-3;

else if (T > 601.1)
ktc = (59597. - 282. * T + 0.45 * pow(T,2.) - 2.43e-4 * pow(T,3.)) * 1.e-3;

else if (T > 273.)
ktc = (-617.55 + 7.37 * T - 0.0123 * pow(T,2.) + 5.7e-6 * pow(T,3.)) * 1.e-3;

else
ktc = 560.1e-3;

return ktc;
}

DEFINE_PROPERTY(density,c,t)
{
real rho;
real T = C_T(c,t);

if (T > 700.)
rho = 270.;

else if (T > 585.9)
rho = 62651. - 303.4 * T + 0.5 * pow(T,2.) - 2.75e-4 * pow(T,3.);

else if (T > 273.)
rho = 967.6 + 0.61 * T - 0.0014 * pow(T,2.) - 5.82e-7 * pow(T,3.);

else
rho = 1020.;

return rho;
}

DEFINE_PROPERTY(viscosity,c,t)
{
real mu;
real T = C_T(c,t);


if (T > 700.)
mu = 37.1e-6;

else if (T > 355.6)
mu = (3436.2 - 16.8 * T + 0.029 * pow(T,2.) - 1.65e-5 * pow(T,3.)) * 1.e-6;

else if (T > 273.)
mu = (122974. - 1074.9 * T + 3.16 * pow(T,2.) - 0.003 * pow(T,3.)) * 1.e-6;

else
mu = 1750.1e-6;

return mu;
}
Sam_1913 is offline   Reply With Quote

Old   April 23, 2018, 11:08
Default
  #3
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi Sam_1913,

One important issue is that you have not integrated the piecewise polynomial in order to reach h -- for each temperature interval, you have integrated that interval's polynomial. To get from Tref to 690K, for example, you should not integrate "cp = (-12066.64 + ...) * 1000;" all the way -- first you integrate "cp = (-0.5112 +...) * 1000;" from Tref to 614.8, etc. Since your polynomials go to absurd values outside their chosen ranges (because that's what polynomials always do), I would expect that this is quite a big problem. Maybe try it in a spreadsheet. You can rely on Tref being 298.15K unless you change it, and I would not advise changing it.

While you're trying a spreadsheet, see whether you are happy with the discontinuities in Cp (and maybe others) across your intervals. When I tried your polynomials, I got a jump from 5.66e3 to 1.30e4 at T=614.8K, for example. I might have made a mistake, or these might be intentional, but big jumps won't help stability. This is a much smaller problem than integrating h. Possibly you have created beautifully matching polynomials, but you are quoting the coefficients with low precision -- this is a common mistake.

Good luck!
Ed
Sam_1913 likes this.
obscureed is offline   Reply With Quote

Old   April 24, 2018, 09:52
Default
  #4
New Member
 
Sathish
Join Date: Apr 2018
Location: germany
Posts: 5
Rep Power: 8
Sam_1913 is on a distinguished road
Quote:
Originally Posted by obscureed View Post
Hi Sam_1913,

One important issue is that you have not integrated the piecewise polynomial in order to reach h -- for each temperature interval, you have integrated that interval's polynomial. To get from Tref to 690K, for example, you should not integrate "cp = (-12066.64 + ...) * 1000;" all the way -- first you integrate "cp = (-0.5112 +...) * 1000;" from Tref to 614.8, etc. Since your polynomials go to absurd values outside their chosen ranges (because that's what polynomials always do), I would expect that this is quite a big problem. Maybe try it in a spreadsheet. You can rely on Tref being 298.15K unless you change it, and I would not advise changing it.

While you're trying a spreadsheet, see whether you are happy with the discontinuities in Cp (and maybe others) across your intervals. When I tried your polynomials, I got a jump from 5.66e3 to 1.30e4 at T=614.8K, for example. I might have made a mistake, or these might be intentional, but big jumps won't help stability. This is a much smaller problem than integrating h. Possibly you have created beautifully matching polynomials, but you are quoting the coefficients with low precision -- this is a common mistake.

Good luck!
Ed
Hi Ed, thanks a lot for your input...i tried integrating the cp as you said and the problem is now seemed to be solved and you were also absolutely right about me quoting the coefficients with low precision..

Thanks once again

Regards
Sam
Sam_1913 is offline   Reply With Quote

Reply

Tags
property udf, temperature limited


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
Compile calcMassFlowC aurore OpenFOAM Programming & Development 13 March 23, 2018 07:43
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM Community Contributions 300 October 29, 2014 18:00
Undeclared Identifier Errof UDF SteveGoat Fluent UDF and Scheme Programming 7 October 15, 2014 07:11
Ansys Fluent 13.0 UDF compilation problem in Window XP (32 bit) Yogini Fluent UDF and Scheme Programming 7 October 3, 2012 07:24
UDF: DEFINE_CG_MOTION for vertical jump motion of an electrode! alban Fluent UDF and Scheme Programming 2 June 8, 2010 18:54


All times are GMT -4. The time now is 09:42.