TAGGED: specific-heat, udf-fluent
-
-
March 3, 2021 at 9:24 am
ashch
SubscriberI am trying to execute a UDF to adapt specific heat in one of my materials, however it is not getting compiled. nHere's the code -nDEFINE_SPECIFIC_HEAT(SpecificHeat, T, Tref, h, yi)n{nreal cp;n{n if (T > 1458. && T < 2000.)n cp = 850.0e-0;n else if (T >= 1418. && T <= 1457.)n cp = 1803.0e-0;n else if (T >= 1373. && T <= 1417.)n cp = 5190.0e-0n elsen cp = 850.0;n}nreturn cp;n}nnAny comments/suggestions to rectify this ?nThanks,nAshishn -
March 3, 2021 at 10:44 am
Keyur Kanade
Ansys EmployeeAre you getting any error? Which version you are using? Do you have any compiler installed? nWe may not help you to debug udfs. Please check help at nnYou may search this forum which has many posts about udf. nRegards,nKeyurnHow to access Ansys Online Help DocumentnHow to show full resolution imagenGuidelines on the Student CommunitynHow to use Google to search within Ansys Student Communityn -
March 3, 2021 at 10:46 am
Keyur Kanade
Ansys EmployeeIf you are using 2021R1, please check nRegards,nKeyurnHow to access Ansys Online Help DocumentnHow to show full resolution imagenGuidelines on the Student CommunitynHow to use Google to search within Ansys Student Communityn -
March 3, 2021 at 10:47 am
ashch
SubscriberVersion - 2020R1nCompiler- Visual Studio (Other UDF's are getting compiled)nError messages - ..\..\src\Cp.c(7): error C2065: 'real:undeclared identifiern..\..\src\Cp.c(7): error C2146: syntax error: missing ';' before identifier 'cp'n..\..\src\Cp.c(7): error C2065: 'cp:undeclared identifiern..\..\src\Cp.c(14): error C2065: 'cp:undeclared identifiern..\..\src\Cp.c(19): error C2065: 'cp:undeclared identifiern..\..\src\Cp.c(22): error C2065: 'cp:undeclared identifiern..\..\src\Cp.c(25): error C2065: 'cp:undeclared identifiern..\..\src\Cp.c(31): error C2065: 'cp:undeclared identifiern -
March 3, 2021 at 11:06 am
YasserSelima
Subscriberyou must have this at the topn#include udf.hnnnand this before return cp;n*h = cp*(T-Tref);n -
March 3, 2021 at 11:08 am
YasserSelima
Subscriber#include udf.hnDEFINE_SPECIFIC_HEAT(SpecificHeat, T, Tref, h, yi)n{nreal cp;nn if (T > 1458. && T < 2000.)n   cp = 850.0e-0;n else if (T >= 1418. && T <= 1457.)n   cp = 1803.0e-0;n else if (T >= 1373. && T <= 1417.)n   cp = 5190.0e-0;n elsen   cp = 850.0;nn*h = cp*(T-Tref);nreturn cp;n}n -
March 4, 2021 at 9:05 am
ashch
SubscriberHi Array nThanks for your reply. nYes, it works now. However, for it says it shows a warning message invalid cp at certain temperatures. Do you have any comments on this?WARNING: Invalid cp (0.000000e+00 J/kgK) for melt at temperature 1371.553061 KnnThanks,nAshishn -
March 4, 2021 at 9:44 am
Rob
Forum ModeratorTry without the e-0 for the two cp values, my C coding is rusty so it's an educated guess. I'd also check the logic, what is cp at 1457.5K? Easy oversight, and remember the Ansys staff have either seen or made most errors you'll see on here: there are lots of us and collectively we have centuries of experience. n -
March 4, 2021 at 1:20 pm
YasserSelima
SubscribernAs pointed out, you have gabs in the if statements ... This would cause discontinuity in the Cp values ... like at 1457.5K nHowever, this gab won't cause this problem. You should get Cp = 850 at 1371.55nnDid you get this warning at the first iteration or after some iterations? n -
March 4, 2021 at 1:40 pm
ashch
SubscriberHi Array and ArraynThank you for the comments. nYes I have checked the logic for the if statements. There are no gaps in temperature, and as Array pointed out even if there is gap it should execute the else statementnof Cp 850 J/kgK. It is strange for me. nI get a warning in all the iterations (total 500 iterations) and the warning is also at different temperatures. Since I was testing this UDF, my mesh is very coarse and hence very low residuals. I hope this is not an issue.Let me know n
Thanks,nAshishn
-
March 4, 2021 at 1:53 pm
YasserSelima
SubscriberDid you hookup the function to your materials? make sure you didnIf you are still using the curly brackets after real cp; and before return cp; , remove themnif the error still there after doing the above, add this line before return cp;n#if RP_HOSTnif (cp != 0) {nMessage(Temperature = %f , Cp = %f, T, cp);n}n#endifnThese lines will print lots of lines ... so probably the computer will get slower and the solver will print lots of messages ... but this is to know if the function works for some cells or it is not read at alln -
March 4, 2021 at 2:22 pm
ashch
SubscriberHi ArraynThank you for the comments.nYes, I did hook it up. Checked twice nIt seems to me the UDF is NOT getting read-only. It's because after having included the code lines, still the same warning messages are being displayed and the message Message(Temperature = %f , Cp = %f, T, cp);is not being displayed even once.  nNOTE - It shows NO ERROR while getting compiled nWARNING: Invalid cp (0.000000e+00 J/kgK) for melt at temperature 1370.089680 KnnHere's the UDF again- n #include udf.hn DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi)n {n  real cp;n/* Specific Heat of Liquid Melt above T-liquidus(above 1185 deg C)*/n if (T > 1458. && T < 2000.)n   cp = 850.0e-0;n/* Specific Heat of Liquid Melt in between T-liquidus and T-eutectic-start (>1185 & <1145 deg C) (0.0170239*T*T) - (35.0263*T) + 18651.1 + 850.0*/n else if (T <= 1458. && T > 1418.)n   cp = 1890.0;n/* Specific Heat of Liquid Melt in between T-eutectic-start and T-solidus(>1100 & <1145 deg C) (1.264730168e-7*T*T) + (42.6196*T) - 43600 + 850.0;*/n else if (T >1373. && T <= 1418.)n   cp = 4262.0;n/* Specific Heat of Liquid Melt in below T-solidus(<1100 deg C) */n elsen   850.0e-0;n #if RP_HOSTntif (cp != 0) tnt{tMessage(Temperature = %f , Cp = %f, T, cp); }n#endiftn  *h = cp*(T-Tref);n  return cp;n }nnThanks,nAshishn -
March 4, 2021 at 2:31 pm
YasserSelima
SubscriberRemove the #if RP_HOST and #endif and try againn -
March 4, 2021 at 2:39 pm
YasserSelima
Subscriberbecause you removed cp
from last linenelse n cp = 850;nn
-
March 4, 2021 at 3:36 pm
ashch
SubscriberHi ArraynThank you for the comments. It works nicely nAshishn -
March 4, 2021 at 3:55 pm
YasserSelima
SubscriberMy pleasure!n
-
Viewing 15 reply threads
- The topic ‘UDF not getting compiled’ is closed to new replies.
Innovation Space
Trending discussions
Top Contributors
-
4673
-
1565
-
1386
-
1231
-
1021
Top Rated Tags
© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.