CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   Divergence detected in AMG solver:species-0 (

arulmurugan February 15, 2011 05:22

Divergence detected in AMG solver:species-0
Hi all,

I am using fluent 12, I am simualting flow in duct which is separated by a membrane and need to findout the mass transfer(concentration gradiant) through the membrane. I am also using compiled UDFs which contains the macros DEFINE_ADJUST, DEFINE_SOURCE. While compling UDF i dont get any error. The UDF is below.
#include "udf.h"
#include "sg.h"
int memb_id = 10;
cell_t c0;
cell_t c1;
Thread *t0;
Thread *t1;
real A[ND_ND];
real At;
real C0_COORD[ND_ND];
real C1_COORD[ND_ND];
real del_xi;
DEFINE_ADJUST(filter_adjust, domain)
face_t f, f_shadow;
real x_GAS_outer;
real x_AIR_outer;
real x_GAS_inner;
real x_AIR_inner;
real P_outer = 1;
real P_inner = 1;
Thread *memb_thread;
Thread *memb_thread_shadow;
real flux_GAS , flux_AIR, tot_flux;
real MW_GAS=32, MW_AIR=29;
real Q_GAS = 0.2206, Q_AIR =0.2258;
/* find membrane thread by ID in BC panel*/
memb_thread = Lookup_Thread(domain,memb_id);
/* looping over cells faces of membrane*/
begin_f_loop (f, memb_thread)
/* get cell pointer for side of membrane on high pressure*/
c0 = F_C0(f,memb_thread);
/* get face thread pointer for shadow membrane surface*/
memb_thread_shadow = THREAD_SHADOW(memb_thread);
/* get face pointer for shadow membrane surface*/
f_shadow = F_SHADOW(f,memb_thread);
/* get cell pointer from shadow side of membrane*/
c1 = F_C0(f_shadow,memb_thread_shadow);
/* get cell thread pointer for side of membrane*/
t0 = F_C0_THREAD(f,memb_thread);
/* get cell thread pointer for shadow side of membrane*/
t1 =memb_thread_shadow->t0;
/* calculate molar concentration for side of membrane*/
x_GAS_outer = molefrac(C_YI(c0, t0, 0), MW_GAS, MW_AIR);
x_AIR_outer = 1.- x_GAS_outer;
/* calculate molar concentration for shadow side of membrane*/
x_GAS_inner = molefrac(C_YI(c1, t1, 0), MW_GAS, MW_AIR);
x_AIR_inner = 1.- x_GAS_inner;
/* calculate membrane face area*/
F_AREA(A, f, memb_thread);
At = NV_MAG(A);
/* calculate species mass fluxes across the membrane, Pi=P*Xi*/
flux_GAS = Q_GAS * ((x_GAS_outer*P_outer) - (x_GAS_inner*P_inner));
flux_AIR = Q_AIR * ((x_AIR_outer*P_outer) - (x_AIR_inner*P_inner));
tot_flux = tot_flux + MW_GAS*flux_GAS*At + MW_AIR*flux_AIR*At;
C_UDMI(c0, t0, 0) = - (MW_GAS*flux_GAS)*At/C_VOLUME(c0,t0);
C_UDMI(c1, t1, 0) = (MW_GAS*flux_GAS)*At/C_VOLUME(c1,t1);=0.0;
C_UDMI(c0, t0, 1) = -(MW_AIR*flux_AIR)*At/C_VOLUME(c0,t0);
C_UDMI(c1, t1, 1) = (MW_AIR*flux_AIR)*At/C_VOLUME(c1,t1);
end_f_loop (f, memb_thread)
DEFINE_SOURCE(mass_source, c, t, dS, eqn)
real source;
source = C_UDMI(c, t, 0) + C_UDMI(c, t, 1);
dS[eqn] = 0.0;
return source;
real molefrac(real sp_mass, real mol_wt_comp_1, real mol_wt_comp_2)
real mfract = 0;
mfract = sp_mass * (mol_wt_comp_1 + mol_wt_comp_2) / mol_wt_comp_1;
return mfract;
After initialization, when the run started i got " Divergence detected in AMG solver:species-0". I used F-cycle in the solver-->control.
If I removed that coloured line in that UDF means, there is no divergence. But in the outlet I get Zero mass flux. This shows there is no mass transfer through the membrane. I need some mass flux in the outlet.
Can anyone help me to rectify this problem?


All times are GMT -4. The time now is 07:27.