CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

I need UDF help.

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 15, 2007, 11:29
Default I need UDF help.
  #1
S.Whitney
Guest
 
Posts: n/a
I have a situation where I need to have a source/sink of a chemical within a mixture on a boundary. The size of the source/sink depends on the average mass fraction of that chemical across that entire boundary.

Thus, I need to do this: 1) Calculate the average mass fraction of a chemical in a mixture on a boundary. 2) Perform mathematical calculations on that average mass fraction. 3) Have a source/sink over that entire boundary that depends on the results of those calculations.

Initially I thought I could create a profile UDF to do all of the above. On the boundary wall, I set the species mass fraction to the UDF. But that failed miserably. It failed because Fluent would force the mass fraction to be whatever level I set it to, and wouldn't let any of that chemical flow into/out of the cell during the iteration. Thus from one iteration to the next, there would be no diffusion into/out of the cell and when I calculated the next iteration's average mass fraction it was simply just what I set it to during the last iteration.

For example, suppose in iteration #1, I set the mass fraction to 0.5. Some of that mass should diffuse away, and the mass fraction may drop to ~0.4. However, while the surrounding cells properly get the mass diffusion, for iteration #2 when I calculated the average mass fraction on the boundary, it was still 0.5 and not the lowered value after some diffused away. Fluent wouldn't adjust the mass fraction during it's iteration.

So, then I thought I could have a source UDF and a profile UDF. I wanted the profile UDF to average the mass fraction and store it into a global variable. Then the source UDF would adjust the mass fraction as needed. I created a face which is one node thick around the boundary in which to run the source UDF. Again, I have a problem. The source UDF reads the global variable just fine and sources/sinks perfectly. But the profile UDF cannot calculate the average mass fraction, it is always zero even if displaying the mass fraction contours in Fluent shows non-zero values. The face loop that properly calculated the average before, now gives zero each and every time.

Can anybody provide some help? Thanks.

Here is what I have so far:

#include "udf.h"

real average_conc;

DEFINE_PROFILE(wall_concentration, t, i) { face_t f; real j;

average_conc=0.0; j=0; begin_f_loop(f,t)

{

average_conc=average_conc+F_PROFILE(f,t,i);

j=j+1;

} end_f_loop(f,t) average_conc=average_conc/j;

printf("Profile: %f\n",average_conc); }

DEFINE_SOURCE(wall_source,c,t,dS,eqn) { real source;

source = 1.0; dS[eqn] = 0.0;

printf("Source: %f\n",average_conc); return source; }

Forget the source and dS[] numbers for now, I edited out all the complicated math.
  Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
Dynamic Mesh UDF Qureshi FLUENT 1 December 2, 2009 01:27
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 19:14.