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

UDF compilation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 19, 2013, 00:45
Default UDF compilation
  #1
New Member
 
Andhra Pradesh
Join Date: Jan 2013
Posts: 13
Rep Power: 13
vismayie is on a distinguished road
Hello,

I am trying to compile a UDF when i compile it ,
the following appears in console window,
(system "copy C:\Fluent.Inc\fluent6.3.26\src\makefile_nt.udf libudf\win64\2ddp\makefile")
1 file(s) copied.
(chdir "libudf")()
(chdir "win64\2ddp")()
wgs_4.c
c:\fluent.inc\fluent6.3.26\src\machine.h(114) : warning C4005: 'stdout' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(161) : see previous definition of 'stdout'
c:\fluent.inc\fluent6.3.26\src\machine.h(115) : warning C4005: 'stderr' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(162) : see previous definition of 'stderr'
c:\fluent.inc\fluent6.3.26\src\machine.h(116) : warning C4005: 'stdin' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(160) : see previous definition of 'stdin'
# Generating udf_names.c because of makefile wgs_4.obj
udf_names.c
c:\fluent.inc\fluent6.3.26\src\machine.h(114) : warning C4005: 'stdout' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(161) : see previous definition of 'stdout'
c:\fluent.inc\fluent6.3.26\src\machine.h(115) : warning C4005: 'stderr' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(162) : see previous definition of 'stderr'
c:\fluent.inc\fluent6.3.26\src\machine.h(116) : warning C4005: 'stdin' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(160) : see previous definition of 'stdin'
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj wgs_4.obj
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

I didnt understand what the problem is . Could someone please help me out ?

Another problem is that i loaded the UDF even when it sent this warning and then i carried out the simulations. When i carried out the simulations the outlet concentration is same as inlet, essentially the reaction wasnt happening. This is because when i asked it to calculate the weighted average of the the used defined memory at the wall, it shows zero.

The steps i followed are as follows,
1) created a 2D mesh in Gambit
2) write the UDF with.c extension
3) open fluent using SDK command prompt
4) defined the models for solver enabled species transport
5) compiled and loaded the UDF
6) define boundary conditions and operating conditions
7) initialize
8) iterate
9) checked the contours for species

the outlet and the inlet mole fractions are same

Someone please please help me out since this is my BTech project and only a weeks time is left
vismayie is offline   Reply With Quote

Old   March 19, 2013, 02:42
Default
  #2
Senior Member
 
Stuart Buckingham
Join Date: May 2010
Location: United Kingdom
Posts: 267
Rep Power: 25
stuart23 will become famous soon enoughstuart23 will become famous soon enough
This:
Quote:
c:\fluent.inc\fluent6.3.26\src\machine.h(114) : warning C4005: 'stdout' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(161) : see previous definition of 'stdout'
c:\fluent.inc\fluent6.3.26\src\machine.h(115) : warning C4005: 'stderr' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(162) : see previous definition of 'stderr'
c:\fluent.inc\fluent6.3.26\src\machine.h(116) : warning C4005: 'stdin' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(160) : see previous definition of 'stdin'
# Generating udf_names.c because of makefile wgs_4.obj
udf_names.c
c:\fluent.inc\fluent6.3.26\src\machine.h(114) : warning C4005: 'stdout' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(161) : see previous definition of 'stdout'
c:\fluent.inc\fluent6.3.26\src\machine.h(115) : warning C4005: 'stderr' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(162) : see previous definition of 'stderr'
c:\fluent.inc\fluent6.3.26\src\machine.h(116) : warning C4005: 'stdin' : macro redefinition
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Include\stdio.h(160) : see previous definition of 'stdin'
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj wgs_4.obj
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
is fine. It is your compiler working normally.


You haven't given enough information to diagnose the rest of your problem. There must be a problem in your UDF or the way you are hooking it to the solver. Maybe dumb down the equation a bit (ie constant rate of reaction) and see if you get something happening, then try introducing more and more complexity at a time.

Stu
stuart23 is offline   Reply With Quote

Old   March 19, 2013, 06:58
Default
  #3
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 22
vasava will become famous soon enough
Can you please show your UDF?
vasava is offline   Reply With Quote

Old   March 19, 2013, 10:17
Default
  #4
New Member
 
Andhra Pradesh
Join Date: Jan 2013
Posts: 13
Rep Power: 13
vismayie is on a distinguished road
The following is my udf:

#include "udf.h"
#define R 8.314
#define p 101325
#define pi 3.14159


DEFINE_SR_RATE(my_rate,f,t,r,mw,yi,rr)
{
Thread *t0 = t -> t0;

cell_t c0=F_C0(f,t);


real co = yi[0]; /* MASS FRACTION AT THE WALL*/
real h2o = yi[1];
real co2 = yi[2];
real h2 = yi[3];
real n2 = yi[4];
real ar = yi[5];

real rho_w = 1.0, T_w = 300, sd=2.49045e-5 , Tr=100;
real xco = 1.0, xh2o = 1.0, xco2 = 1.0, xh2 = 1.0, xn2 = 1.0;

real pco, ph2o, pco2, ph2, pn2, theta=1.0;
real k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15 ,k16,k17,k18,K1eq,K2eq,K3eq,K4eq,K5eq,K6eq,K7eq,K8 eq;
real rate;


T_w = F_T(f,t);
rho_w = C_R(c0,t0)*C_T(c0,t0)/T_w;

h2o *= rho_w/mw[1]; /*CONVERTING MASS FRACTIONS AT THE WALL TO MOLAR CONCENTRATIONS */
co2 *= rho_w/mw[2];
co *= rho_w/mw[0];
h2 *= rho_w/mw[3];
n2 *= rho_w/mw[4];
ar *= rho_w/mw[5];



xn2 = n2/(n2+h2+co2+co+h2o); /* MOLE FRACTIONS*/
xh2 = h2/(n2+h2+co2+co+h2o);
xco2 = co2/(n2+h2+co2+co+h2o);
xco = co/(n2+h2+co2+co+h2o);
xh2o = h2o/(n2+h2+co2+co+h2o);


pn2 = xn2*p; /*PARTIAL PRESSURES*/
ph2 = xh2*p;
ph2o = xh2o*p;
pco = xco*p;
pco2 = xco2*p;

Tr = (T_w/300);


k1 = (0.129/(R*T_w))*(sqrt((1000*R*T_w)/(2*pi*mw[3])))*pow(Tr,0.858);
k2 = (7.95*1e12*sd)*(pow(Tr,-0.001))*exp(((-21.78 + (2.56*Tr))*4185.8)/(R*T_w));
k3 = (9.36*1e12*sd)*(pow(Tr,-0.118))*exp(((-17.404 - (0.38*Tr))*4185.8)/(R*T_w));
k4 = (9.99*1e12*sd)*(pow(Tr,-1.049))*exp(((-13.836 + (0.92*Tr))*4185.8)/(R*T_w));
k5 = (0.108/(R*T_w))*(sqrt((1000*R*T_w)/(2*pi*mw[1])))*(pow(Tr,1.162));
k6 = (2.03*1e12*sd)*(pow(Tr,1.372))*exp(((-11.5225 + (5*T_w))*4185.8)/(R*T_w));
k7 = (1.0/(R*T_w))*(sqrt((1000*R*T_w)/(2*pi*mw[0])))*(pow(Tr,0.000));
k8 = (5.66*1e15*sd)*(pow(Tr,-0.5))*exp(((-28.6 + (4*T_w))*4185.8)/(R*T_w));
k9 = (0.195/(R*T_w))*(sqrt((1000*R*T_w)/(2*pi*mw[2])))*(pow(Tr,0.250));
k10 = (2.63*1e12*sd)*(pow(Tr,-0.250))*exp(((4.8- (0.004*T_w))*4185.8)/(R*T_w));
k11 = (8.03*1e08*sd)*(pow(Tr,-0.531))*exp(((-9.36 + (0.28*Tr))*4185.8)/(R*T_w));
k12 = (1.25*1e09*sd)*(pow(Tr,0.531))*exp(((-10.021 + (0.38*Tr))*4185.8)/(R*T_w));
k13 = (8.43*1e08*sd)*(pow(Tr,0.024))*exp(((-9.01 - (0.00782*Tr))*4185.8)/(R*T_w));
k14 = (1.19*1e09*sd)*(pow(Tr,-0.024))*exp(((-10.46 + (0.67*Tr))*4185.8)/(R*T_w));
k15 = (1.06*1e11*sd)*(pow(Tr,0.549))*exp(((-1.1 + (0.036*Tr))*4185.8)/(R*T_w));
k16 = (9.45*1e10*sd)*(pow(Tr,-0.549))*exp(((-2.22 + (0.62*Tr))*4185.8)/(R*T_w));
k17 = (1.1*1e11*sd)*(pow(Tr,0.492))*exp(((-17.394 - (0.00136*Tr))*4185.8)/(R*T_w));
k18 = (9.07*1e10*sd)*(pow(Tr,-0.492))*exp(((-12.43 + (0.62*Tr))*4185.8)/(R*T_w));


K1eq = k1/k2;
K2eq = k3/k4;
K3eq = k5/k6;
K4eq = k7/k8;
K5eq = k10/k9;
K6eq = k11/k12;
K7eq = k14/k13;
K8eq = k15/k16;


theta=1/(1+(K3eq*ph2o)+sqrt((ph2/K1eq))+(pco2/K5eq)+(K2eq*K3eq*ph2o*(sqrt((K1eq/ph2))))+(K4eq*pco2)+(((K5eq*K2eq*K3eq*ph2o*pco2)/K8eq)*(sqrt((ph2/K1eq)))));

rate = pow(theta,2)*(k17*K4eq*K3eq*pco*ph2o);


if (STREQ(r->name, "reaction-1"))
{
*rr = rate;
C_UDMI(c0,t0,0) = *rr;
}

}

Please let me know if you find any mistakes.
Thanking you,
V.Vismayie
Student
IIT Madras
vismayie is offline   Reply With Quote

Old   March 19, 2013, 11:24
Default
  #5
New Member
 
Andhra Pradesh
Join Date: Jan 2013
Posts: 13
Rep Power: 13
vismayie is on a distinguished road
hey hello Stuart,

So i believe my compiler is working properly and there are no issues with the compilation . When i run the simulation, the User defined memory returns a value of 0. This is my problem.
Please find the UDF in the previous reply i posted on this thread.

Thanking you,
V.Vismayie
Student
vismayie is offline   Reply With Quote

Old   March 20, 2013, 02:54
Default
  #6
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 22
vasava will become famous soon enough
I didnt get what you meant by 'User defined memory returns a value of 0'. Could you please elaborate??
vasava is offline   Reply With Quote

Reply


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
UDF compilation problem on Linux System Nitin Pathak Fluent UDF and Scheme Programming 6 September 29, 2018 20:26
UDF compilation error Szabolcs Varga Fluent UDF and Scheme Programming 4 September 14, 2015 05:27
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 compilation problem -- "undeclared variable" Henrik Ström FLUENT 1 September 21, 2005 05:25
Compiled UDF / Compilation problem mikhail FLUENT 1 October 13, 2000 06:12


All times are GMT -4. The time now is 18:57.