CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF Define_Source problem (http://www.cfd-online.com/Forums/fluent/93191-udf-define_source-problem.html)

lholsen08 October 7, 2011 10:43

UDF Define_Source problem
 
I have a Souce term which should be generating a constant value. However it appears that the value is only generating the value at one side of the cell zone. This is the first UDF and C++ code I have written so I probably missed something simple.

#include "udf.h"
/************************************************** ****************************************
This UDF calculates Source Terms for the Lumen, Endothelium, Vascular Wall, and Tissue Layer
************************************************** ******************************************/
/*** Species numbers ***/
#define Oxygen 0
#define NO 1
/************************************************** ****************************************
Endothelium
Source Terms: NO Generation and O2 Consumption
************************************************** ******************************************/
/*** Define Variables for Calculation ***/
#define RNOmax 0.000054 /*Maximum eNOS Production Rate (54 uM/s )->(M/s)*/
#define KmeNOS 4.7 /*Michaelis-Menten reaction kinetics term (4.7 Torr)*/
#define AlphaT .00000134 /*Solubility Coefficient (M/Torr)*/

DEFINE_SOURCE( Endothelium_NOGen, c, t, dS, eqn)
{
real con, concNO;
concNO=(((RNOmax) *C_UDSI(c,t,Oxygen))/(C_UDSI(c,t,Oxygen)+(KmeNOS)));
return concNO;
}

DEFINE_SOURCE( Endothelium_Oxygencons, c, t, dS, eqn)
{
real con, concOxy;
concOxy=((-1)*((RNOmax)*C_UDSI(c,t,Oxygen))/(C_UDSI(c,t,Oxygen)+(KmeNOS)))/AlphaT;
return concOxy;
}


Any help would be great. Thanks!

Amir October 7, 2011 12:45

Dear Luke,

Probably, you've hooked this UDF to one of your zones. You have to hook it to any fluid/solid zone which you want to be included in equations there. Otherwise check validity of your UDSs, maybe there aren't defined for some zones or aren't solved there.

Bests,

lholsen08 October 7, 2011 12:50

I guess it is linked to the Cell zone but thats the only zone I want it to run in. So when I opened the Cell zone conditions that is where I applied the source term. It should be using the Concentration of the UDS defined as C_UDSI(c,t,Oxygen). Isthat not what I was supposed to do?

It appears it does not continue to run throught the cell zone just the left side.

Amir October 7, 2011 13:08

Quote:

Originally Posted by lholsen08 (Post 327083)
I guess it is linked to the Cell zone but thats the only zone I want it to run in. So when I opened the Cell zone conditions that is where I applied the source term. It should be using the Concentration of the UDS defined as C_UDSI(c,t,Oxygen). Isthat not what I was supposed to do?

It appears it does not continue to run throught the cell zone just the left side.

If you hooked it just for a specific zone, it will be added to that specific cells when solving an equation. I don't know want do you want to do exactly, but you can solve an equation in a whole domain but set some source terms in specific zones.

lholsen08 October 7, 2011 13:15

Ok, I want that equation to be solved for every cell in that specific cell zone. I am looking at thevariable macros and maybe instead of C_UDSI for cell field it should be F_UDSI for face field?

Amir October 7, 2011 13:20

Quote:

Originally Posted by lholsen08 (Post 327087)
Ok, I want that equation to be solved for every cell in that specific cell zone. I am looking at thevariable macros and maybe instead of C_UDSI for cell field it should be F_UDSI for face field?

Ok, you want to solve that equation in a specific zone so you need source term for that specific zone and you have to be aware of boundary values of your variable near that zone which you can use fixed values in fluent or a UDF to set that in other zone.

lholsen08 October 7, 2011 13:27

Right. I set this UDF as the Source term in the Cell Zone. I set a constant value for the C_UDSI(c,t,Oxygen). Even when I used the constant value it was giving me a declining value across the zone. the color contour plot of the UDS looks like the source term is only working on one side of the cell zone.

Amir October 7, 2011 13:31

Quote:

Originally Posted by lholsen08 (Post 327089)
Right. I set this UDF as the Source term in the Cell Zone. I set a constant value for the C_UDSI(c,t,Oxygen). Even when I used the constant value it was giving me a declining value across the zone. the color contour plot of the UDS looks like the source term is only working on one side of the cell zone.

Dear Luke,

It seems that I couldn't clear my idea. You've hooked it just for one side where you want to solve your UDS, so why do you anticipate both side source?


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