TAGGED: define-diffusivity, udf, uds-udm
-
-
August 13, 2021 at 4:20 am
HenanCui
SubscriberHello everyone!
I'm trying to compile my UDF code to define the electric conductivity of air by using the DEFINE_DIFFUSIVITY macro.
There is a series of electric conductivity data in various temperatures and I try to use linear interpolation to get the electric conductivity at a certain temperature.
When I built the source file of the UDF in Fluent, something goes wrong. I get some errors from the console, it told me that the "j" and "k" are "undeclared identifier(C2065)".
I am not sure if there is any conflict between the "i" in DEFINE_DIFFUSIVITY(AirCOND,c,ct,i) and the "i" I defined in the code.
Will this conflict may be the core of the problem? How can I solve it?
I have changed the "i" I defined into "a" "x" or something but it didn't work.
The code is displayed as follow:
DEFINE_DIFFUSIVITY(AirCOND,c,ct,i) { real Aircond[78]={ 2.6866E-01,1.4648E-02,7.4981E-05,7.0752E-05,1.0492E-03,8.0531E-03,3.9720E-02,1.4376E-01, 4.1687E-01,1.0311E+00,2.2830E+00,4.6939E+00,9.1551E+00,1.6955E+01,2.9510E+01,4.7930E+01, 7.2697E+01,1.0352E+02,1.3934E+02,1.7851E+02,2.1909E+02,2.5951E+02,2.9949E+02,3.4105E+02}; /*electric conductivity data*/ real tem = C_T(c,ct); real condair; if (tem <= 800) { condair= Aircond[0];Â Â C_UDMI(c,ct,CONDMIX_UDM)=condair; } else if (tem >= 20050) { condair = Aircond[77];Â C_UDMI(c,ct,CONDMIX_UDM)=condair; } else { int i=0; int j=77; int k; while(j-i!=1) { k=(i+j)/2;Â k=(int)k; if (tem<(800+150*k))Â Â j=k; else i=k; } condair = (Aircond[j]-Aircond[i])*(tem/150-8-i)+Aircond[i]; C_UDMI(c,ct,CONDMIX_UDM)=condair; } return condair; }
August 17, 2021 at 9:38 pmSurya Deb
Ansys EmployeeHello,
Don't define the i,j,k inside the Else loop. Just define them at the very start.
Also don't use "i" if it is already passed as an argument to the UDF. Use "ii" or any other variable.
I hope this helps.
Regards SD
Viewing 1 reply thread- The topic ‘UDF compile Error in DEFINE_DIFFUSIVITY’ is closed to new replies.
Ansys Innovation SpaceTrending discussionsTop Contributors-
3622
-
1303
-
1122
-
1068
-
1008
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.
-