CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   UDF Adjust to redefine UDS Diffusivity (

David harvey February 26, 2004 02:53

UDF Adjust to redefine UDS Diffusivity
I am attempting to use the Define_Adjust function to enforce a value of 0 for the scalar transport diffusivity for a specific thread, but my adjust function does not appear to modify the value of the diffusivity. If I try to actually implement 0, I return an error so I have tried to force the value to as close to zero as possible. I am working with full multicomponent flow and my UDS is an attempt to model electrical potentials across two locations, but the third physically has a very small value for conduction. The zone id from the fluent panel is 4. Here is the UDF code:

/************************************************** *************** * UDF FOR ADJUSTING THE SCALAR DIFFUSIVITY * * ************************************************** *************/

#include "udf.h"

DEFINE_ADJUST(channel_diff, d) {

int ID;

ID = 4;

Thread *channel = Lookup_Thread(d,ID);

cell_t c;

begin_c_loop(c, channel)


C_UDSI_DIFF(c,channel,0) =1e-20;


end_c_loop(c, channel) }



Andrew Garrard February 26, 2004 06:15

Re: UDF Adjust to redefine UDS Diffusivity
OK, I have been dealing with a similar problem, so I will try and be as helpful as I can. I really have had very little luck with define adjust functions and UDS's. I think this is because when you start a single interation, the define adjust sets conditions, then the act of performing the iteration then trys to solve the UDS, which can alter the parameters set in the adjust, if that makes any sense. Try a DEFINE_DIFFUSIVITY (4.3.2) I have had luck with these.

The other point that I want to raise is that you cannot set the diffusivity to zero if you have certain boundary conditions, e.g. a fixed value boundary and a flux. This is because if the diffusivity/conductivity goes to zero, then the flux will tend to infinity and you will get a nan error.

David harvey February 26, 2004 14:41

Re: UDF Adjust to redefine UDS Diffusivity
I did look at the Define Diffusivity function that you say. However I thought there might be a problem there because I am able to return only one value for diffusivity. More or less what I have is a zone that is a catalyst region, another zone which is a gas diffusion layer, and lastly a zone which is my flow channel (Bipolar plate to be added later). So my desire is to allow this electronic conductivity (the diffusivity) to be a specific value in my catalyst and my gas diffusion layer, but enforce the physical condition of zero conductivity in the flow channel. Do you think it might be possible to do this through an if else statement, ie if the zone id is the flow channel return near zero, but otherwise return the conductivity of the other two zones?

(btw to another post we talked on, fluent appears to have added a possible fix for modelling the scalar transport for a solid medium, although it still does require the work around of defining it as a porous media).

Thanks for you help


Andrew Garrard February 27, 2004 06:38

Re: UDF Adjust to redefine UDS Diffusivity
You definalty can use an if else statement to make the diffusivity different in different zones, I have done it and I know that it works. There is a problem though, as the code will not allow a two neighbouring cells to have different diffusivities with a step change. There is a gradient change between the two zones. There are a couple of way around this. Firstly create a *very* set of cells to allow the gradient change to exist. Secondly, use two UDS's with differenct diffusivitys and allow interaction between them I know the problems you are experiencing, as I am working on fuel cells as well, albeit, not hydrogen fuel cells. However, I work for a company, and they are not too thrilled at the prospect of me revealing too much information.

I still don't think that you will be able to solve a UDS with 0 diffusivity.

David Harvey February 27, 2004 08:47

Re: UDF Adjust to redefine UDS Diffusivity
I have done this with modifying through an if else statement. It does seem to help and yes you are correct that it doesn't not allow for a zero and that their exists a step interpolation between the face diffusivities. I have also coded in using a define adjust a loop to set the neighboring cells equal removing the gradient and I see some small gradient effect from the interpolation still within the flow channel, but now fairly minimal. Now I just need to implement a finer grid so that the interpolation scheme doesn't skew my plots. I am thinking more about coupling the UDS equations as I am going to need to do this anyway to get my potentials in the conducting plate. But this does need some thought on my part prior to doing. Thanks for the help it was much appreciated. (btw if you can say...are you working with SOFC?)



All times are GMT -4. The time now is 13:20.