# Model Forced Diffusion in binary gas or liquid mixtures (single phase only).

 PROBLEM:Model forced diffusion in binary mixtures (single phase) mixtures.ANALYSISJ = J_ordinary + J_forcedJ1_ordinary = -rho D12 Grad yiJ1_forced = -rho^2 * w1 * w2 * y1 * y2 * D12 * (F1 - F2) / (P * W * W)wherew1 = mol wt 1w2 = mol wt 2y1 = mass fract 1y2 = 1-y1W = mol wt mixtureF1 = Force Vector on species 1 (N/kg)F2 = Force Vector on species 2 (N/kg)P = pressureThis is solved by UDFspecies equation source is equal toS = - DIV (J1_forced)Problem is solved using UDS:UDS(0) = y1UDS(1) = xcomp of J1_forcedUDS(2) = y-comp of J1_forcedUDS(3) = z-comp of J1_forcedIn Define Adjust function, we* compute J_forced.* compute grad of components of J_forced (nine terms stored in memory)(* add appropriate components to get divergence: div J = d(J1x)/dx + D(J1y)/dy + d(J1z)/dzSource term = Div J is stored in UDM(0)For boundary condition, at a wall: J.n = 0J = J_ord + J_forced,thusFlux(1) = J1_ord . n = - J_forced . nWhere J1_forced is evaluated at the wallSo far only wall boundary conditions are in the UDF. Others can be added as necessary.UDF follows:/********************************************************************UDF to compute forced diffusion in FLUENT 6.1byWilliam Wangard, Ph.D.Fluent, Inc.All rights reserved, 2003.Fluent, Inc. does not guarantee the rigor of this User defined functionBINARY mixtures only.UDSs are used to store species:UDS(0) = species 0 mass fractionspecies 1 mass fraction = 1 - UDS(0)UDS(1) = x component of forced diffusion flux of species 1UDS(2) = y component ....UDS(3) = z component ....UDM(0) = DIV (forced diffusion flux)NOTE the variable FAC is a control to underrelax the body force, since it may be large. Adjust it as necessary to converge the solverRecommended settings,* Body-force weighted pressure scheme* Body force underrelax factor = 0.1* Mom underrleax factor = 0.1* Species 0 underrelax factor = 0.9Convergence criteria for UDS 0 should be < 1E-6.This UDF should work in PARALLEL, but it has not been tested.Address other questions toww@fluent.comThank you.**********************************************************************************/#include "udf.h"#include "sg.h"#define NSPECIES 2/* D12 of Oxygen in air is 2E-5 m2/s *//* In gui, define Diffusivity as D12 * rho_air */#define D12 2E-5/* Underrelaxation factor for body forces */#define FAC 0.01real wt[NSPECIES] = {32.0, 28.0134};real b0 = {10000., 10000., 0.};real b1 = {0., 0., 0.};enum { M = NSPECIES - 1, N_UDS_REQ = M + ND_ND };enum { N_UDM_REQ = ND_ND };DEFINE_PROFILE(flux_1,tf,i){ Thread* tc; cell_t c; face_t f; real NV_VEC(normal), NV_VEC(area), Amag; real p,w,x,flux; real NV_VEC(d1), NV_VEC(d2); begin_f_loop(f,tf) { F_AREA(area,f,tf); Amag = NV_MAG(area); NV_VS(normal,=,area,/,Amag); c = F_C0(f,tf); tc = F_C0_THREAD(f,tf); p = ABS_P(C_P(c,tc),op_pres); w = 1.0 / ( F_UDSI(f,tf,0) / wt + (1.- F_UDSI(f,tf,0)) / wt); x = C_R(c,tc) * C_R(c,tc) * wt * wt * F_UDSI(f,tf,0) * (1.0 - F_UDSI(f,tf,0)) * D12 / (p * w * w); NV_VV(d1,=,b0,-,b1); NV_VS(d2,=,d1,*,x); flux = NV_DOT(d2,normal); /* Message("normal = %10.3e, %10.3e flux = %10.3e n", normal, normal, flux);*/ F_PROFILE(f,tf,i) = flux; } end_f_loop(f,tf);}DEFINE_ADJUST(compute_forced_diffusion,d){ real w; int n, id, ns = 0; Thread* tc; face_t f; cell_t c; Thread* tf; real p; real x; if (n_uds < N_UDS_REQ) Internal_Error("You have defined not enough UDSsn"); if (sg_udm < N_UDM_REQ) Internal_Error("Not enough UDMs defined.n"); /* Put */ thread_loop_c(tc,d) { begin_c_loop(c,tc) { p = ABS_P(C_P(c,tc),op_pres); w = 1.0 / ( C_UDSI(c,tc,0) / wt + (1.-C_UDSI(c,tc,0)) / wt); x = (C_R(c,tc) * C_R(c,tc) * wt * wt * C_UDSI(c,tc,0) * (1.-C_UDSI(c,tc,0)) * D12 ) / ( p * w * w ); for(n=0; n

 No comments yet. Be the first to add a comment!