CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How to use UDS solve this problem (https://www.cfd-online.com/Forums/fluent/112214-how-use-uds-solve-problem.html)

risklotus January 23, 2013 20:22

How to use UDS solve this problem
 
Hi Guys, I have a set of eqs and want to use UDS to solve them. I solved this problem before with my own code and Matlab. I just want to see whether I can get the same results and learn how to use UDS. The following is the set of the eqs. I also attach the UDF I wrote for your information. I still have problem to get the right answer as I got before. I cannot find out the errors.

d^2 C1/dx^2 = PHI^2 * {C1*exp[(1-ALPHA)(C2-C3)] - C0*exp[-ALPHA(C2-C3)]}
d^2 C2/dx^2 = PHI1^2 * {C1*exp[(1-ALPHA)(C2-C3)] - C0*exp[-ALPHA(C2-C3)]}
d^2 C3/dx^2 = -PHI2^2 * {C1*exp[(1-ALPHA)(C2-C3)] - C0*exp[-ALPHA(C2-C3)]}

The dependent variables are C1, C2, and C3. The others are constant

/************************************************** ****************
UDF that adds momentum source term and derivative to duct flow
************************************************** *****************/
#include "udf.h"
#define PHI2 0.1406
#define PHI12 0.8277
#define PHI22 0.8277
#define C0 0.5714
#define ALPHA 0.5
enum
{
C1,
C2,
C3
};
 
DEFINE_SOURCE(C1_source, cell, thread, dS, eqn)
{
real source;
dS[eqn] = -PHI2 * exp((1-ALPHA)*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3)));
source = -PHI2 * (C_UDSI(cell,thread,C1) * exp((1-ALPHA)*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))) - C0 * exp(-ALPHA*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))));
return source;
}
DEFINE_SOURCE(C2_source, cell, thread, dS, eqn)
{
real source;
dS[eqn] = -PHI12 * ((1-ALPHA)*C_UDSI(cell,thread,C1) * exp((1-ALPHA)*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))) + ALPHA* C0 * exp(-ALPHA*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))));
source = -PHI12 * (C_UDSI(cell,thread,C1) * exp((1-ALPHA)*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))) - C0 * exp(-ALPHA*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))));
return source;
}
DEFINE_SOURCE(C3_source, cell, thread, dS, eqn)
{
real source;
dS[eqn] = PHI22 * ((ALPHA-1)*C_UDSI(cell,thread,C1) * exp((1-ALPHA)*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))) - ALPHA*C0 * exp(-ALPHA*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))));
source = PHI22 * (C_UDSI(cell,thread,C1) * exp((1-ALPHA)*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))) - C0 * exp(-ALPHA*(C_UDSI(cell,thread,C2)-C_UDSI(cell,thread,C3))));
return source;
}

Thanks

Sixkillers January 24, 2013 01:54

I am quite sure that you can't use UDS for this particular case. Because is Fluent is solving partial differential equation (scalar transport equation), however you would like to solve set of ordinary differential equations. In other words your left side of equations is completely different from Fluent ones.

msaeedsadeghi January 24, 2013 06:54

Quote:

Originally Posted by Sixkillers (Post 403696)
I am quite sure that you can't use UDS for this particular case. Because is Fluent is solving partial differential equation (scalar transport equation), however you would like to solve set of ordinary differential equations. In other words your left side of equations is completely different from Fluent ones.

No, he can model it. Left hand side is the flux term and the right hand side is sources. Correct.

msaeedsadeghi January 24, 2013 06:55

I have done like that before. It has so many complicated points that should be cared.

risklotus January 24, 2013 12:55

Saeed,

Can you recall any particular tips? Anyone is helpful to me.

msaeedsadeghi January 25, 2013 00:21

It seems you want to add three new scalar equations. So add three UDS. These equations only have source and diffusion terms. So disable unsteady and convection terms in UDS menu. Now you need to write UDF for defining source and diffusion terms.


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