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

UDF for mass transfer through a boundary (mt-sofc case)

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 7, 2009, 17:42
Default UDF for mass transfer through a boundary (mt-sofc case)
  #1
New Member
 
vlawlor
Join Date: Sep 2009
Posts: 2
Rep Power: 0
vlawlor is on a distinguished road
Dear Community,

Outline of the Problem:

In a simple model that just has a source term (oxygen sink kg/(m^3).(s) applied to a "cathode" volume wrapped around a cylinder in cross flow (like a microtubular solid oxide fuel cell)

I am trying to mimick the consumption of oxygen for a single cell in cross flow and see the effects on mass transfer in the wake of the cell. I can get values for species concentration etc. in fluent but I would like to get a reading for the rate at which oxygen passes through the cathode wall. Something like kg/(m^2) .(s)

I would like to compare mass comsumption rates in simple models without the fuel cell module, with it and also hand caluclations.

Possible solution:

I know very little about C programming and less about how all this works in fluent but I have found the following code on the net that says it should do what I would like to do. the problem is that when I try to compile it in fluent I ger the following error.



File path: line 12: THREAD_STORE: undeclared variable

/************************************************** ********************/
/* UDF that implements a simplified advective term in the */
/* scalar transport equation */
/************************************************** ********************/

#include "udf.h"

DEFINE_UDS_FLUX(my_uds_flux, f, t, i)
{
Thread *t0, *t1 = NULL;
cell_t c0, c1 = -1;

real NV_VEC(psi_vec), NV_VEC(A);

/* neighboring cells of face f, and their (corresponding) threads */

t0 = F_C0_THREAD(f,t);
c0 = F_C0(f,t);

if (NULL != F_C1_THREAD(f,t))
/* Alternative: if (! BOUNDARY_FACE_THREAD_P(t)) */
{
t1 = F_C1_THREAD(f,t);
c1 = F_C1(f,t);
}
else
{
t1 = NULL;
c1 = -1;
}

/* If Face lies at domain boundary, use face values; */
/* If Face lies IN the domain, use average of adjacent cells. */

if (NULL == t1)
/* Alternative: if (BOUNDARY_FACE_THREAD_P(t)) */
{
NV_D(psi_vec, =, F_U(f,t), F_V(f,t), F_W(f,t));
NV_S(psi_vec, *=, F_R(f,t));
}
else
{
NV_D(psi_vec, =, C_U(c0,t0), C_V(c0,t0), C_W(c0,t0));
NV_D(psi_vec, +=, C_U(c1,t1), C_V(c1,t1), C_W(c1,t1));
NV_S(psi_vec, /=, 2.); /* averaging. */
NV_S(psi_vec, *=, (((C_R(c0,t0) + C_R(c1,t1)) / 2.)));
}

/* Now psi_vec contains our "psi" from above. */
/* Next, get the face normal vector: */

F_AREA(A, f, t);

/* Finally, return the dot product of both. */
/* Fluent will multiply the returned value */
/* by phi_f (the scalar's value at the face) */
/* to get the "complete" advective term... */

return NV_DOT(psi_vec, A);
}




Many thanks for any help in advance
vlawlor is offline   Reply With Quote

Old   November 9, 2009, 02:24
Default The code seems to be correct
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Are you sure this is what you're compiling?
First of all, there is nothing on line 12, and second, I compiled the code you posted on my fluent 6.3, and no erros appeared.
dmoroian is offline   Reply With Quote

Old   November 9, 2009, 05:48
Default
  #3
New Member
 
vlawlor
Join Date: Sep 2009
Posts: 2
Rep Power: 0
vlawlor is on a distinguished road
Many thanks for checking this,

So I will list the steps I am taking to compile it.

1. I copy the code as it is into the text editor in windows and call it udfmasstransfer.c

2. I copy the file to the working directory.

3. define--> user defined-->functions-->interpreted

4. I then browse to the file and leave the CPP command name to CPP and stack size to 10000

5. Then i hit interpret

And the error line 17 THREAD_STORE: undeclared variable appears (it has changed from 12 to 17 now.

I know very little about this but can the error be with the CPP command?

MAny thanks once agian
vlawlor is offline   Reply With Quote

Old   November 9, 2009, 06:09
Default
  #4
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Instead of interpreted, try compiled.
dmoroian is offline   Reply With Quote

Old   November 9, 2009, 08:31
Default UDF for mass transfer through a boundary (mt-sofc case)
  #5
Member
 
Shane
Join Date: Oct 2009
Posts: 52
Rep Power: 7
sircorp is on a distinguished road
One tiny thing

t1 is assigned to NULL and later compared to NULL. Best in such sitation is try to check the t1 condition. If it is within place then it should be true else not.

Try one of the two option

eitther
(1) (t1==NULL) change this.

or Change the code this way

if ( F_C1_THREAD(f,t) == NULL)
/* Alternative: if (! BOUNDARY_FACE_THREAD_P(t)) */
{
t1 = NULL;
c1 = -1;
}
else
{
t1 = F_C1_THREAD(f,t);
c1 = F_C1(f,t);
}
sircorp is offline   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
Wind turbine simulation Saturn CFX 34 October 16, 2014 05:27
inlet velocity boundary condition murali CFX 5 August 3, 2012 08:56
Concentric tube heat exchanger (Air-Water) Young CFX 5 October 6, 2008 23:17
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15
heat transfer coefficient udf nam su FLUENT 0 March 25, 2005 03:28


All times are GMT -4. The time now is 04:29.