-
-
August 23, 2021 at 5:30 am
Ulfah
SubscriberWhen I tried to interpret the following code, i got a message error 'line 6: parse error.'
#include "udf.h" #define Cd 0.2 /* usually between 0.1 - 0.3 ; lambda = Cd * LAD */ #define LAD 2.0 real A1t = 1.0; /* Betap */ real A2t = 5.1; /* Betad */ real A3t = 0.9; /* closure constant cepsilon4 */ real A4t = 0.9; /* closure constant cepsilon5 */ DEFINE_SOURCE(xmom_source,c,t,dS,eqn) { real x[ND_ND]; real source; real U = C_U(c,t); real V = C_V(c,t); real W = C_W(c,t); real VEL = sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t)+C_W(c,t)*C_W(c,t)); real k = C_K(c,t); real e = C_D(c,t); real rho = C_R(c,t); C_CENTROID(x,c,t); source = -Cd*LAD*rho*VEL*U; dS[eqn] = -Cd*LAD*rho*(U*U/VEL + VEL); return sourAugust 23, 2021 at 8:27 amaitor.amatriain
SubscriberAt a glance, you have not closed the square bracket
August 23, 2021 at 9:43 amRob
Forum ModeratorThere's also a ? symbol in line 1: check for white space characters too.
August 23, 2021 at 10:03 amaitor.amatriain
SubscriberAnd "sour" should be "source" in the last line
August 24, 2021 at 12:15 amUlfah
SubscriberSorry this is the real code
#include "udf.h"┬Ø
#define Cd 0.2 /* usually between 0.1 - 0.3 ; lambda = Cd * LAD */
#define LAD 2.0
real A1t = 1.0; /* Betap */
real A2t = 5.1; /* Betad */
real A3t = 0.9; /* closure constant cepsilon4 */
real A4t = 0.9; /* closure constant cepsilon5 */
DEFINE_SOURCE(xmom_source,c,t,dS,eqn)
{
real x[ND_ND];
real source;
real U = C_U(c,t);
real V = C_V(c,t);
real W = C_W(c,t);
real VEL = sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t)+C_W(c,t)*C_W(c,t));
real k = C_K(c,t);
real e = C_D(c,t);
real rho = C_R(c,t);
C_CENTROID(x,c,t);
source = -Cd*LAD*rho*VEL*U;
dS[eqn] = -Cd*LAD*rho*(U*U/VEL + VEL);
return source;
}
August 24, 2021 at 9:54 amRob
Forum ModeratorAssuming the white space character isn't present, check if Cd is used elsewhere in the code: avoid 1-2 letter variables as we may use them elsewhere. A parse error warning is typically triggered on the line after the mistake, or rather the next line with text as the code found a fault but didn't know it was a fault until the next bit of code comes along.
August 24, 2021 at 10:38 amUlfah
SubscriberThank you for your help. I rewrote the code and I believe there was a white space character. I tried to interpret the new code and there seems to be no error occurred. However, I am confused with the message on the console which can be seen in the picture I attached below. What does this message indicate?

August 24, 2021 at 3:27 pmRob
Forum ModeratorIt's the result of the interpreter running through all of your commands. If it doesn't give an error or lots of warnings you can generally ignore it: it may mean something but no one I know has ever bothered trying to figure it out.
Viewing 7 reply threads- The topic ‘How to fix parse error in the following UDF code for my Fluent simulation’ is closed to new replies.
Innovation SpaceTrending discussionsTop 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.
-
Ansys Assistant
Welcome to Ansys Assistant!
An AI-based virtual assistant for active Ansys Academic Customers. Please login using your university issued email address.
Hey there, you are quite inquisitive! You have hit your hourly question limit. Please retry after '10' minutes. For questions, please reach out to ansyslearn@ansys.com.
RETRY