|
[Sponsors] |
December 16, 2019, 13:08 |
UDF error_ undeclared variable
|
#1 |
New Member
greece
Join Date: Jul 2016
Posts: 8
Rep Power: 10 |
Hello,
i am using Fluent 19.2 and i am trying a very simple UDF that i found on Ansys Customer Portal just to get familiar with that before trying to make my own UDF. So i copy the text and produce a .c file located at the same location with my case and dat file. The UDF text follows below: /************************************************** ******************** UDF that models a custom law for evaporation swelling of particles ************************************************** *********************/ #include "udf.h" DEFINE_DPM_LAW(Evapor_Swelling_Law,tp,ci) { real swelling_coeff = 1.1; /* first, call standard evaporation routine to calculate the mass and heat transfer */ VaporizationLaw(tp); /* compute new particle diameter and density */ TP_DIAM(tp) = TP_INIT_DIAM(tp)*(1. + (swelling_coeff - 1.)* (TP_INIT_MASS(tp)-TP_MASS(tp))/(DPM_VOLATILE_FRACTION(tp)*TP_INIT_MASS(tp))); TP_RHO(tp) = TP_MASS(tp) / (3.14159*TP_DIAM(tp)*TP_DIAM(tp)*TP_DIAM(tp)/6); TP_RHO(tp) = MAX(0.1, MIN(1e5, TP_RHO(tp))); } After trying to compile it using Fluent GUI, i receive the following error: cpp -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/main" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/addon-wrapper" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/io" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/species" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/pbns" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/numerics" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/sphysics" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/storage" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/mphase" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/bc" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/models" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/material" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/amg" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/util" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/mesh" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/udf" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/ht" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/dx" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/turbulence" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/parallel" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/etc" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/ue" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/dpm" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/dbns" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/tgrid/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/PRIME/tgrid/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/client/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/multiport/src" -I. -DUDFCONFIG_H="<udfconfig-host.h>" "D:/OneDrive - central.ntua.gr/drive/projects/VEF_design&exper_CFD/new_runs/recent/grid dependence/paper/non_isothermal/swel.c" Error: D:/OneDrive - central.ntua.gr/drive/projects/VEF_design&exper_CFD/new_runs/recent/grid dependence/paper/non_isothermal/swel.c: line 15: TP_DIAM: undeclared variable cpp -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/main" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/addon-wrapper" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/io" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/species" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/pbns" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/numerics" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/sphysics" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/storage" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/mphase" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/bc" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/models" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/material" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/amg" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/util" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/mesh" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/udf" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/ht" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/dx" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/turbulence" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/parallel" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/etc" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/ue" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/dpm" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/dbns" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/tgrid/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/PRIME/tgrid/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/client/src" -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/multiport/src" -I. -DUDFCONFIG_H="<C:/Users/PANAGI~1/AppData/Local/Temp/udfconfig-17984-node0.h>" "C:/Users/PANAGI~1/AppData/Local/Temp/swel.c.17984.0.c" Error: C:/Users/PANAGI~1/AppData/Local/Temp/swel.c.17984.0.c: [/U]line 15: TP_DIAM: undeclared variable Note: The second paragraph appears about 7 times with different swel.c. number Can someone inform me on the followings: 1. Is it an compiling or code error? 2. Should i declare TP_DIAM at the beginning of the code? 3. Other possible sources of error? Thanks in advance. Panos |
|
December 17, 2019, 07:23 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
seems like you've changed automatically all p to tp....
change all macros names back to P TP_DIAM -> P_DIAM
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 17, 2019, 13:44 |
|
#3 | |
New Member
greece
Join Date: Jul 2016
Posts: 8
Rep Power: 10 |
Quote:
I did make the change you proposed. Please see below the code /************************************************** ******************** UDF that models a custom law for evaporation swelling of particles ************************************************** *********************/ #include "udf.h" DEFINE_DPM_LAW(Evapor_Swelling_Law,p,ci) { real swelling_coeff = 1.1; /* first, call standard evaporation routine to calculate the mass and heat transfer */ VaporizationLaw(p); /* compute new particle diameter and density */ P_DIAM(p) = P_INIT_DIAM(p)*(1. + (swelling_coeff - 1.)*(P_INIT_MASS(p)-P_MASS(p))/(DPM_VOLATILE_FRACTION(p)*P_INIT_MASS(p))); P_RHO(p) = P_MASS(p) / (3.14159*P_DIAM(p)*P_DIAM(p)*P_DIAM(p)/6); P_RHO(p) = MAX(0.1, MIN(1e5,P_RHO(p))); } The error now is the following: cpp -I"C:\PROGRA~1\ANSYSI~1\v192\fluent\fluent19.2.0/src/main" - . . . Error: C:/Users/PANAGI~1/AppData/Local/Temp/swelp.c.2364.11.c: line 15: TP_MATERIAL: undeclared variable The variable that appears in line 15 for the first time is P_INIT_MASS(p) Do you think that this might cause the error? Thank you again! |
||
December 18, 2019, 00:17 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
#include "udf.h" DEFINE_DPM_LAW(Evapor_Swelling_Law,p,ci) { real swelling_coeff = 1.1; /* first, call standard evaporation routine to calculate the mass and heat transfer */ VaporizationLaw(p); /* compute new particle diameter and density */ P_DIAM(p) = P_INIT_DIAM(p)*(1. + (swelling_coeff - 1.)*(P_INIT_MASS(p)-P_MASS(p))/(DPM_VOLATILE_FRACTION(p)*P_INIT_MASS(p))); P_RHO(p) = P_MASS(p) / (3.14159*P_DIAM(p)*P_DIAM(p)*P_DIAM(p)/6); P_RHO(p) = MAX(0.1, MIN(1e5,P_RHO(p))); }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 18, 2019, 05:13 |
|
#5 | |
New Member
greece
Join Date: Jul 2016
Posts: 8
Rep Power: 10 |
Quote:
Still same issue, message is line 11: P_MATERIAL: undeclared variable But i do intepret the UDF and not compile it since i find compliling more complicated since it involved setting of VS , open Fluent from command line etc (i have not found somewhere the PC setting steps for UDFs compiling) . IS there any other setting/ requirement that needs to be done to allow Fluent perform simple UDFs intepretation, except of (1) having code without mistakes, and (2) the code to be at the same folder with cas and dat file? Your help is appreciated! Thanks |
||
December 18, 2019, 14:04 |
Update
|
#6 |
New Member
greece
Join Date: Jul 2016
Posts: 8
Rep Power: 10 |
I try to use another simple UDF that is closer to what i want to do.
Please see the code below: /************************************************** ******************** UDF that calculates a temperature dependent swelling factor ************************************************** *********************/ #include "udf.h" DEFINE_DPM_LAW(Swelling_Factor,p,ci) { real swelling_coeff; real temp = P_T(p); swelling_coeff = temp/400.; return swelling_coeff; } After trying to interpret the UDF, Fluent returns the following error: Error: C:/Users/PANAGI~1/AppData/Local/Temp/swelcoef2.c.11368.11.c: line 12: function returning void returns double. Any suggestion would be appreciated. Thanks |
|
December 19, 2019, 01:44 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
interpretation leads to errors in my machine too, so I recommend you to compile code
regarding your last code: DEFINE_DPM_LAW has type void, it means, it doesn't return any value in example from manual (ansys fluent customization manual) they modified density according to swelling coef. they used P_RHO(p) macro
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Tags |
dpm fluent, fluent - udf, udf and programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF error for variable Cp | B.Hamada | Fluent UDF and Scheme Programming | 4 | May 18, 2015 07:27 |
udf for variable cp | B.Hamada | Fluent UDF and Scheme Programming | 2 | April 22, 2015 15:20 |
UDF extern variable - mean time moment coefficient | enry | Fluent UDF and Scheme Programming | 0 | November 14, 2009 07:51 |
name variable in UDF using Thread : syntax error before numeric constant | Laurence Wallian | FLUENT | 0 | October 8, 2009 10:18 |
UDF: exporting a variable between two DEFINE function | Carlo | FLUENT | 3 | August 19, 2009 13:21 |