CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   problematic source term in UDS (http://www.cfd-online.com/Forums/fluent-udf/65780-problematic-source-term-uds.html)

 ak6g08 June 25, 2009 11:42

problematic source term in UDS

Hello everyone,

I have posted a similar question as this previously, but no one has gotten back, so Ill be more detailed, could somebody please provide some assistance...

I have 2 PDEs which I am trying to solve using UDSs

PDE of scalar 1 (V) : 0=electric_diff*d/dx_i(dV/dx_i)+(density*Q)/e

PDE of scalar 2 (Q) : 0=spcharge_diff*d/dx_i(dQ/dx_i)+(density^2*Q^2*K)/e+density*k*(dV/Dx_i)*(dQ/DX_i)

I am having a very big problem with the term in bold, which I have implemented as a source term..defined in my UDF shown below as

DEFINE_SOURCE(spcharge_lin,c,t,dS,eqn):

The problem is that when I turn this term on, the solution diverges in very few iterations, it doesnt seem possible to get convergence even with tiny relaxation factors (.0001)...does someone have an idea as to why this may be happening?

The UDF is shown below:

#include "udf.h"
#include "sg.h"

static real kappa = .00000003;
static real epsilon = .00000000000855;

/*source of scalar 1 (V)*/
DEFINE_SOURCE(electric_source,c,t,dS,eqn)
{
dS[eqn] = 0;
return (C_R(c,t)*C_UDSI(c,t,1)/epsilon);
}

/*diffusivity of scalar 1*/
DEFINE_DIFFUSIVITY(electric_diff, c, t, i)
{
return 3.54;
}

/*problematic source of scalar 2 (Q)*/
DEFINE_SOURCE(spcharge_lin,c,t,dS,eqn)
{

real source,source_a,source_b;

source_a = C_R(c,t)*kappa*C_UDSI_G(c,t,0)[0]*C_UDSI_G(c,t,1)[0];

source_b = C_R(c,t)*kappa*C_UDSI_G(c,t,0)[1]*C_UDSI_G(c,t,1)[1];

source=source_a+source_b;

dS[eqn] = 0;

return source;

}

/*OK source of scalar 2*/
{
real source;
source = -(pow(C_R(c,t),2)*pow(C_UDSI(c,t,1),2)*kappa)/epsilon;
dS[eqn] = -(2*pow(C_R(c,t),2)*C_UDSI(c,t,1)*kappa)/epsilon;
return source;
}

/*diffusivity of scalar 2*/
DEFINE_DIFFUSIVITY(spcharge_diff, c, t, i)
{
return kappa / 40;
}

 _Greg_ July 10, 2009 11:38

Hi,

dS[eqn] = 0 means that FLUENT treats your source term explicitly and it could cause divergence problems.

If you specify the derivative of your source term, FLUENT may treat your source term with an explicit and implicit part and this could help convergence.

good luck,

 ak6g08 July 12, 2009 15:57

hi,

thanks for your reply greg...however I am solving for scalar Q, and my source term has a dQ/dX term so i dont think I can specify the derivative of that (with respect to Q)...so I am not sure what the problem is...

 louiza July 15, 2009 09:30

UDF with C_H_G "access violation"

Hello,

I am solving the energy equation with the enthalpy formulation. I would like to add a source term via UDF that includes the gradient of enthalpy but I get an Access Violation error when I try to use the C_H_G(c,t) macro. "access violation"

I was able to work around the problem by storing enthalpy in a UDS and then calculating the gradient using a C_UDSI_G macro. but a have also message error in compilation.
physics formule is: (dh/dx+dh/dr); deriverd enthalpy axial+ derived enthalpy radial.

Thank you!

 ustbdynamic December 25, 2013 00:36

Dear ak6g08,
I have read the similar simulation published in Fuel Processing Technology titled Particulate removal via electrostatic precipitators-CFD simulation.
And write a letter to find some consulatings, but no reply.
I wonder wether they have treat the gradients very well in their simulation...

Quote:
 Originally Posted by ak6g08 (Post 220495) Hello everyone, I have posted a similar question as this previously, but no one has gotten back, so Ill be more detailed, could somebody please provide some assistance... I have 2 PDEs which I am trying to solve using UDSs PDE of scalar 1 (V) : 0=electric_diff*d/dx_i(dV/dx_i)+(density*Q)/e PDE of scalar 2 (Q) : 0=spcharge_diff*d/dx_i(dQ/dx_i)+(density^2*Q^2*K)/e+density*k*(dV/Dx_i)*(dQ/DX_i) I am having a very big problem with the term in bold, which I have implemented as a source term..defined in my UDF shown below as DEFINE_SOURCE(spcharge_lin,c,t,dS,eqn): The problem is that when I turn this term on, the solution diverges in very few iterations, it doesnt seem possible to get convergence even with tiny relaxation factors (.0001)...does someone have an idea as to why this may be happening? The UDF is shown below: #include "udf.h" #include "sg.h" static real kappa = .00000003; static real epsilon = .00000000000855; /*source of scalar 1 (V)*/ DEFINE_SOURCE(electric_source,c,t,dS,eqn) { dS[eqn] = 0; return (C_R(c,t)*C_UDSI(c,t,1)/epsilon); } /*diffusivity of scalar 1*/ DEFINE_DIFFUSIVITY(electric_diff, c, t, i) { return 3.54; } /*problematic source of scalar 2 (Q)*/ DEFINE_SOURCE(spcharge_lin,c,t,dS,eqn) { real source,source_a,source_b; source_a = C_R(c,t)*kappa*C_UDSI_G(c,t,0)[0]*C_UDSI_G(c,t,1)[0]; source_b = C_R(c,t)*kappa*C_UDSI_G(c,t,0)[1]*C_UDSI_G(c,t,1)[1]; source=source_a+source_b; dS[eqn] = 0; return source; } /*OK source of scalar 2*/ DEFINE_SOURCE(spcharge_quad,c,t,dS,eqn) { real source; source = -(pow(C_R(c,t),2)*pow(C_UDSI(c,t,1),2)*kappa)/epsilon; dS[eqn] = -(2*pow(C_R(c,t),2)*C_UDSI(c,t,1)*kappa)/epsilon; return source; } /*diffusivity of scalar 2*/ DEFINE_DIFFUSIVITY(spcharge_diff, c, t, i) { return kappa / 40; }

 shuai_manlou January 4, 2014 22:38

Quote:
 Originally Posted by _Greg_ (Post 222289) Hi, dS[eqn] = 0 means that FLUENT treats your source term explicitly and it could cause divergence problems. If you specify the derivative of your source term, FLUENT may treat your source term with an explicit and implicit part and this could help convergence. good luck,

The gradients should be treated well to help the convergence, I think it is better to be a negetive expression.

 mvee February 10, 2015 01:19

Hi Shuai

I am also facing same problem.
I am not solving UDS but using it to store the value which is solution variable depedent. This is done to have gradient of UDS (C_UDSI_G) in source term. I felt this is not the correct way to achieve it. And in this case linearization is not requried because gradient itselt suggest to be linearlized the function.

Can you suggest better way to calculate gradient of UDS which I am not solving?

ak6g08, you can also share your experience.

Thank you

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