CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Calculate net species/ UDS flux (http://www.cfd-online.com/Forums/fluent/34189-calculate-net-species-uds-flux.html)

PK57 July 13, 2004 15:18

Calculate net species/ UDS flux
 
I am new to Fluent. I am using the software to model electrochemical analyses with advective effects. I have found in Fluent the capability to solve for the net flux of energy through a surface which has a specified temperature. Is there an easily available analogous capability for calculating the net flux of an electroactive species to a solid surface? Or the surface integral of normal gradient of the species concentration at a surface? Thanks!

Peter Kottke July 21, 2004 09:58

Re: Calculate net species/ UDS flux
 
Figured it out - a UDF to do this is based on Fluent 6.1 UDF Guide section 5.2.2 Connectivity Variables. Here's the UDF for UDS-0 : note that because Execute_at_end does not have threads available to be passed, the zone ID and index must be hard coded. Also, prior to linking to a case file, type "solve/set/expert" and then answer "yes" to the question "keep temporary solver memory from being freed? Finally, use as a compliled not interpreted UDF.

------------------------------------------------------

#include "udf.h"

#include "sg.h"

DEFINE_EXECUTE_AT_END(uds_flux)

{

Domain *dom= Get_Domain(1);

int ID=5;

int index=0;

Thread *f_thread = Lookup_Thread(dom,ID);

Thread *tc0;

face_t f;

cell_t c0;

real grad[ND_ND];

real A[ND_ND];

real es[ND_ND];

real dr0[ND_ND];

real A_by_es;

real ds;

real flux;

real scalar_c;

real scalar_f;

real grad_p;

real grad_x;

real D;/* scalar diffusion coefficient*/

real rho;/* mixture density*/

flux = 0.0;

begin_f_loop(f, f_thread);

{

c0 = F_C0(f,f_thread);

tc0 = THREAD_T0(f_thread); BOUNDARY_FACE_GEOMETRY(f,f_thread,A,ds,es,A_by_es, dr0)

grad[0]=C_UDSI_G(c0,tc0,index)[0];

grad[1]=C_UDSI_G(c0,tc0,index)[1];

scalar_c=C_UDSI(c0,tc0,index);

scalar_f=F_UDSI(f,f_thread,index);

rho = C_R(c0,tc0);

D=C_UDSI_DIFF(c0,tc0,index)/rho; /* for my applications expect D to be constant therefore OK, also, my D is FLUENTs gamma/rho*/

grad_p=(scalar_f-scalar_c)/ds*A_by_es;

grad_x=NV_DOT(grad,A)-NV_DOT(grad,es)*A_by_es;

flux+=D*(grad_p+grad_x);

}

end_f_loop(f, f_thread);

flux=flux*2.*M_PI; /* for 2-D axisymetric calculation */

Message("Surface integral of boundary flux of normal gradient of scalar: %g\n", flux);

Petere Kottke August 2, 2004 08:16

Re: Calculate net species/ UDS flux
 
Slight correction to the above - for general 2 or 3 - D problem replace lines such as "grad[0]=C_UDSI_G(c0,tc0,index)[0];" with ND_SET commands

Sandeep August 4, 2004 09:59

Re: VOF
 
How can I calculate the Flux of Vof species at the cell face. Please let me know


All times are GMT -4. The time now is 06:11.