Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Species transport equation source term udf

    • anshs
      Subscriber

      I am modeling a species mass transfer model, in which I want to transfer a species from one phase to another phase. I am trying to express this process with the last term of the equation given below. [ m_dot(p_j,q_i) = mass transfer of 'species j from p phase' to 'species i of q phase' ]




      Can anyone please help me with a very basic example of which UDF macro to use and how may I assign the phases and the species?

    • Amine Ben Hadj Ali
      Ansys Employee

      I cannot share an example but the Ansys help should be useful here. Have a look into the DEFINE_LINEARIZED_MASS_TRANSFER or even the non linear one.

    • anshs
      Subscriber

      Can you just tell me how to start? Is define_linearized_mass_transfer the same as adding source term to the species equation?

      In the past I have written a code for heterogeneous reaction:


      DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)

      {
      Thread **pt = THREAD_SUB_THREADS(t);
      Thread *tp = pt[0];
      Thread *ts = pt[1];
      int i;

      //Message("nn Area3 = %fn", C_UDMI(c,t,1));

      double D = 1.;
      double delCo2 = 1.;

      *rr_t = ((D*delCo2*C_UDMI(c,t,1) )/ C_VOLUME(c,t)); // *(C_YI_G(c,ts,i)[2]+C_YI_G(c,ts,i)[0])

      Message("n 2n");
      }

    • Amine Ben Hadj Ali
      Ansys Employee

      I am sorry but I cannot help here: we do not debug UDF's. In this case the mass transfer is described via the Heterogeneous Reaction Rate macro so you need to prepare that in GUI too. 


      Is your mass transfer a simple degassing or evaporation or require a complicated formulation like the case for reaction: one can still model evaporation as chemical heterogeneous reaction but same can be done via the macro I mentioned in the first post.

    • anshs
      Subscriber

      Okay but can you just help me, in including a rate expression in my udf , the rate expression is as giwen below:



      I know the terms of this expression as: C_D(c,t) (turb. kinetic energy dissipation rate) , C_MU_T(c,t) (turbulent viscosity) , DEFINE_DIFFUSIVITY ( D, c, t, i)

      but how to include these in the reaction rate? 


       


      *rr_t = (0.4*(sqrt(D))*(C_D(c,t) / C_MU_T(c,t)).^0.25 )*((D*delCo2*C_UDMI(c,t,1) )/ C_VOLUME(c,t)); 

      Am I right? or do I need to do anything else as well?


       

    • anshs
      Subscriber

      Any help with this? 

      Thanks

    • anshs
      Subscriber

      This is the udf which is present there in the example case of mass transfer:



      #include "udf.h"


       


      DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index,


      from_species_index, to_index, to_species_index)


      {


         real m_lg;


         real T_SAT = 373.15;


         Thread *gas = THREAD_SUB_THREAD(thread, from_index);      // gas phase


         Thread *liq = THREAD_SUB_THREAD(thread, to_index);            // liquid phase


       


         m_lg = 0.;           // initialisation 


         


       


         if (C_T(cell, liq) >= T_SAT).          // liq: pointer thread of liquid phase


          {


             m_lg = -0.1*C_VOF(cell,liq)*C_R(cell,liq)*


                     fabs(C_T(cell,liq)-T_SAT)/T_SAT;


           }


         if ((m_lg == 0. ) && (C_T(cell, gas) <= T_SAT))


           {


             m_lg = 0.1*C_VOF(cell,gas)*C_R(cell,gas)*


               fabs(T_SAT-C_T(cell,gas))/T_SAT;


           }


       


         return (m_lg);



       
      But it does not have any species inclusion, like: 'from_species_index' and 'to_species_index'. How to include this in the above example case, is it like this?

      Thread *gas_i = THREAD_SUB_THREAD(thread, from_species_index);  
      Thread *liq_j   = THREAD_SUB_THREAD(thread, to_species_index); 



      if ((m_lg == 0. ) && (C_T(cell, gas) <= T_SAT))


           {
             m_lg = 0.1* C_VOF(cell,gas) * C_R(cell,gas) * C_YI(c , gas , gas_i)  // 0.1*(Volume of gas cell)*(Density gas of cell)*(Species fraction of i in gas phase)
           }


         return (m_lg);


       

    • Amine Ben Hadj Ali
      Ansys Employee

      We do not provide UDF support. 


      The phase threads are just as in the example in the documentation. The species index are only placeholder so that Fluent knows from which component to which component mass transfer is initiated. 


      To access the diffusivity you should look into the documentation and you will see the right macro which is C_DIFF_EFF.

    • anshs
      Subscriber

      So I need not include these lines,

      Thread *gas_i = THREAD_SUB_THREAD(thread, from_species_index);  
      Thread *liq_j   = THREAD_SUB_THREAD(thread, to_species_index);

      and just write 

      from_species_index = 0. (let's say the first species)
      to_species_index = 2. (let's say the third species)

          ->  m_lg = 0.1* C_VOF(cell,gas) * C_R(cell,gas) * C_YI(c , gas , 0)  ;

      here C_YI(c, gas, 0 ), denotes species mass fraction of 1st species in the mixture denoted by phase 'gas'.

      Is the above correct?

Viewing 8 reply threads
  • The topic ‘Species transport equation source term udf’ is closed to new replies.