2.4.5.  DEFINE_LINEARIZED_MASS_TRANSFER

2.4.5.1. Description

You can use DEFINE_LINEARIZED_MASS_TRANSFER when you want to model mass transfer in a multiphase problem. This macro allows you to linearize the mass transfer source terms as well as couple the interfacial mass transfer with flows. This is the recommend UDF method for modeling mass transfer in multiphase flows.

You can linearize the mass transfer term for the calculation of the volume fraction equation in ANSYS Fluent, such that

(2–15)

where

 
 

= mass transfer rate

 

= volume fraction of the phase from which mass is transferred

 

= volume fraction of the phase to which mass is transferred

 

= mass transfer source which cannot be linearized to and

 

linearization coefficient related to

 

linearization coefficient related to

To couple the mass transfer terms with flow transport equations, the derivative of the mass transfer rate to pressure is required to be computed and stored in a macro:

(2–16)

Where and are the reference densities of the phases. Typically, they are the cell phase densities.

2.4.5.2. Usage

DEFINE_LINEARIZED_MASS_TRANSFER (name, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index, lin_from, lin_to)


Important:  Note that all of the arguments to a DEFINE macro need to be placed on the same line in your source code. Splitting the DEFINE statement onto several lines will result in a compilation error.


Argument Type

Description

symbol name

UDF name.

cell_t c

Index of cell on the thread pointed to by mixture_thread.

Thread *mixture_thread

Pointer to mixture-level thread.

int from_phase_index

Index of phase from which mass is transferred.

int from_species_index

ID of species from which mass is transferred (ID= -1 if phase does not have mixture material).

int to_phase_index

Index of phase to which mass is transferred.

int to_species_index

ID of species to which mass is transferred (ID= -1 if phase does not have mixture material).

real *lin_from

Linearization term for the origin phase ()

real *lin_to

Linearization term for the destination phase ()

Function returns

real

There are nine arguments to DEFINE_LINEARIZED_MASS_TRANSFER: name, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index, lin_from, lin_to. You supply name, the name of the UDF. The variables c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index, lin_from, and lin_to are passed by the ANSYS Fluent solver to your UDF. Your UDF will need to return the real value of the mass transfer rate to the solver and the two linearized terms lin_from and lin_to.


Important:  The linearization terms *lin_from and *lin_to are calculated based on the linearization coefficients and in Equation 2–15:

(2–17)

(2–18)

The derivative of mass transfer rate to pressure is stored in the above-mentioned macro in Equation 2–16.

The arguments from_species_index and to_species_index are relevant for multiphase species transport problems only, and only if the respective phase has a mixture material associated with it.


2.4.5.3. Example

The following UDF, named cav_source, specifies mass transfer source terms as a function of liquid vaporization pressure and flow pressure.


Important:  Note that in the example that follows, the DEFINE_LINEARIZED_MASS_TRANSFER statement is broken up into three lines for the sake of readability. In your source file, you must make sure that the DEFINE statement is on one line only.


 #include "udf.h"
DEFINE_LINEARIZED_MASS_TRANSFER (cav_source,cell,thread,from_index,
                  from_species  _index, to_index, to_species_index, d_mdot_d_vof_from, 
                 d_mdot_d_vof_to)
{
   real  vof_nuc =  RP_Get_Real("mp/cvt/cfx/vof-nuc");     
   real  r_b     =  RP_Get_Real("mp/cvt/cfx/r-bubbles");   
   real  F_evap  =  RP_Get_Real("mp/cvt/cfx/f-evap");       
   real  F_cond  =  RP_Get_Real("mp/cvt/cfx/f-cond");       
   real  c_evap = 3.0*F_evap*vof_nuc/r_b;                   
   real  c_cond = 3.0*F_cond/r_b;                           
   real  P_SAT = RP_Get_Real("mp/cvt/vapor-p");

   Thread *liq = THREAD_SUB_THREAD(thread, from_index);
   Thread *vap = THREAD_SUB_THREAD(thread, to_index);


   real m_dot, dp, m_source;
   real p_op = RP_Get_Real ("operating-pressure");
   real press = C_P(cell, thread) + p_op;
   real rho_l = C_R(cell,liq);
   real rho_v = C_R(cell,vap);
   real vof_l = C_VOF(cell,liq);
   real vof_v = C_VOF(cell,vap);
   real r_rho_lv = 1./rho_v - 1./rho_l;
m_dot = 0.;
   m_source = 0.0;

   if (press <=  P_SAT)
     {
        dp = P_SAT - press;
        dp = MAX(dp, 1e-4);

        m_dot = c_evap*rho_v*sqrt(2/3.0*dp/rho_l);
        m_source = m_dot*vof_l;

        *d_mdot_d_vof_from  = m_dot;
        *d_mdot_d_vof_to    = -m_dot;
     }
   else
     {
       dp = press - P_SAT;
       dp = MAX(dp, 1e-4);

       m_dot = -c_cond*rho_v*sqrt(2/3.0*dp/rho_l);
       m_source = m_dot*vof_v;

       *d_mdot_d_vof_from  = m_dot;
       *d_mdot_d_vof_to    = -m_dot;
     }

   /*  ++++++++++ ds/dp term ++++++++++++++   */
     if(NNULLP(THREAD_STORAGE(thread, SV_MT_DS_DP)))
        C_STORAGE_R(cell,thread,SV_MT_DS_DP) = ABS(r_rho_lv*m_source/dp);

   return m_source;
}

2.4.5.4. Hooking a Linearized Mass Transfer UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_LINEARIZED_MASS_TRANSFER is interpreted (Interpreting UDFs) or compiled (Compiling UDFs), the name of the argument that you supplied as the first DEFINE macro argument will become visible and selectable under Mass Transfer when you select the Mass tab option in the Phase Interaction dialog box and specify the Number of Mass Transfer Functions. See Hooking DEFINE_LINEARIZED_MASS_TRANSFER UDFs for details.


Release 18.2 - © ANSYS, Inc. All rights reserved.