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

Problem in Interpretation of UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 8, 2011, 08:15
Default Problem in Interpretation of UDF
  #1
New Member
 
Kirti Deo Mishra
Join Date: Jun 2011
Posts: 2
Rep Power: 0
coolkdm is on a distinguished road
hi...
this is my first post in this forum so please help me guys..
I m doing a project in gasification and I have to write a UDF for adding a source term in the fluid zone...I have written the program but the thing is that I suck at C programming and also I m writing the UDF of this form for the first time....

When I try to interpret the following program I get the following error...

"line 18:float (arrow) pointer to char"

Where "arrow" appears as a symbol in the warning.

Code:

#include "udf.h"
#define n 0.38
#define k 1.7
#define vi 0.426369
#define A 36.16
#define E 77390.00
#define R 8.314


DEFINE_SOURCE(CO_source,c,t,dS,eqn)
{
real x[ND_ND];
real source,ti,t,k1;
int i;
Material *m;
C_CENTROID(x,c,t);


k1= A*exp(-E/(R*C_T(c,t)));

ti = -(ln((vi-k*x[1])/vi))/k;



t = CURRENT_TIME;
source = 2*pow((1-(1-(2*k1*(t-ti)*(-n+1)))),1/(-n+1));

if((1==strcmp(MIXTURE_SPECIES_NAME(m,i),"CO2"))||( 1==strcmp(MIXTURE_SPECIES_NAME(m,i),"co2")))

{
ds[eqn] = k1*pow((C_YI(c,t,i)-(Source/2)),n);




}






return source;
}



I am stuck here and don't see a way out......please help me guys......


Email: mail2kirtideomishra@gmail.com
coolkdm is offline   Reply With Quote

Old   June 10, 2011, 04:21
Default
  #2
New Member
 
Kristian Etienne Einarsrud
Join Date: Oct 2010
Location: Trondheim
Posts: 29
Rep Power: 15
KristianEtienne is on a distinguished road
Hi,

I can see several issues with your code;

1) Your integer (int i) and pointer to the material thread (Material *m) are declared but not initialized! That is, the name of the variable exists, but it does not have a value! These variables are appropriately initialized with a "mixture_species_loop(m,sp,i)". See section 2.5.13.3 in the UDF guide for an example.
2) As far as I can see from the documentation of ANSYS 13, the correct macro to get the specie name is "MIXTURE_SPECIE_NAME(m,i)", not "MIXTURE_SPECIES_NAME(m,i)" as it is in your code. This could however be different in different versions of FLUENT, but it is worthwhile cheking.
3) I think that your definition "t = CURRENT_TIME" overwrites thethread t pointer which is passed through the DEFINE_SOURCE macro. Hence, it should be renamed, if not, you will not be able to access C_YI(c,t,i) later.
4) Your definition of the implicit part of the source appears to be faulty. First; you have written "ds[eqn]", while the pointer passed from the macro is "dS[eqn]".
Second; ds[eqn] = k1*pow((C_YI(c,t,i)-(Source/2)),n); refers to the variable "Source", which does not exist! The variable "source" is however defined. Note that C is case sensitive.
Third; I cannot see how your implicit part is related to the source term. The meaning of the implicit part is the source term derivated with respect to the variable to which the source is applied (see section 2.7.1.4 in the UDF guide).

As you are new to UDF programming, I would recommend that you begin with something slightly simpler, just to get a feeling of what that is going on. For my part I got a lot of help and understanding from example 2.3.22.3 in the UDF user guide, or, if you prefer a more "step by step" approach, see the tutorial on "Position Dependent Porous Media", available from fluentusers.com.

Good luck and happy computing!

-KE
KristianEtienne is offline   Reply With Quote

Old   June 11, 2011, 04:42
Default Thanks......
  #3
New Member
 
Kirti Deo Mishra
Join Date: Jun 2011
Posts: 2
Rep Power: 0
coolkdm is on a distinguished road
hii....
thnx KristianEtienne for ur assistance...rite now i m busy with something else....but i look at all the mistakes u pointed out in my program ASAP...and may be get back to u if rectifying them doesn't serve the purpose....


Quote:
Originally Posted by KristianEtienne View Post
Hi,

I can see several issues with your code;

1) Your integer (int i) and pointer to the material thread (Material *m) are declared but not initialized! That is, the name of the variable exists, but it does not have a value! These variables are appropriately initialized with a "mixture_species_loop(m,sp,i)". See section 2.5.13.3 in the UDF guide for an example.
2) As far as I can see from the documentation of ANSYS 13, the correct macro to get the specie name is "MIXTURE_SPECIE_NAME(m,i)", not "MIXTURE_SPECIES_NAME(m,i)" as it is in your code. This could however be different in different versions of FLUENT, but it is worthwhile cheking.
3) I think that your definition "t = CURRENT_TIME" overwrites thethread t pointer which is passed through the DEFINE_SOURCE macro. Hence, it should be renamed, if not, you will not be able to access C_YI(c,t,i) later.
4) Your definition of the implicit part of the source appears to be faulty. First; you have written "ds[eqn]", while the pointer passed from the macro is "dS[eqn]".
Second; ds[eqn] = k1*pow((C_YI(c,t,i)-(Source/2)),n); refers to the variable "Source", which does not exist! The variable "source" is however defined. Note that C is case sensitive.
Third; I cannot see how your implicit part is related to the source term. The meaning of the implicit part is the source term derivated with respect to the variable to which the source is applied (see section 2.7.1.4 in the UDF guide).

As you are new to UDF programming, I would recommend that you begin with something slightly simpler, just to get a feeling of what that is going on. For my part I got a lot of help and understanding from example 2.3.22.3 in the UDF user guide, or, if you prefer a more "step by step" approach, see the tutorial on "Position Dependent Porous Media", available from fluentusers.com.

Good luck and happy computing!

-KE
coolkdm is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 07:05
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 07:56
UDF compiling problem in Flient 6.3 jeevan kumar FLUENT 2 February 25, 2009 01:43
I have problem of UDF with turbulent premx source. Z FLUENT 0 February 16, 2005 04:34
UDF problem chiseung FLUENT 4 January 10, 2002 10:58


All times are GMT -4. The time now is 05:46.