Fluids

Fluids

UDF for mass transfer VOF

    • Cathleen
      Subscriber

      Hello, I am working on a UDF for a problem with mass transfer at the interface between a liquid and a vapor layer. I use the DEFINE_MASS_TRANSFER macro to sweep, finding the interface by checking the volume of fluid using:  (C_VOF(cell, liq) > 0.05) && (C_VOF(cell, liq) <= 0.95)) and then applying the mass transfer to just those cells that are at the interface. 

      However, when I run this, I am not getting into the if-statement to check the VOF. My understanding is that the DEFINE macros will sweep and I do not need a loop to go through the faces (ie. begin_f_loop(f, thread), etc) but I've tried it with that as well with the same result. 

      Also, I know that there is an interface because this is essentially a two-zone problem and I patch the zones at the beginning to have a liquid zone and a vapor zone. Plotting the VOF shows an area where the if statement is satisfied. Any ideas what I am missing here?

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

      // UDF to define a simple mass transfer based on VOF.The "TO" phase is the gas and the "FROM" phase is the liquid phase

      #include "udf.h"
      #include "sg_mphase.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* liq = THREAD_SUB_THREAD(thread, from_index);
          Thread* gas = THREAD_SUB_THREAD(thread, to_index);
          Message("\n \n UDF IS DOING SOMETHING");
          m_lg = 0.;
          face_t f;

              if ((C_VOF(cell, liq) > 0.05) && (C_VOF(cell, liq) <= 0.95))
              {
                  Message("\n \n I found the interface!");
                  
                  if (C_T(cell, liq) > T_SAT)
                  {                                               /* Evaporating */
                      m_lg = -0.1 * C_VOF(cell, liq) * C_R(cell, liq) *
                          (C_T(cell, liq) - T_SAT) / T_SAT;
                  }
                  else if (C_T(cell, gas) < T_SAT)
                  {                                               /* Condensing */
                      m_lg = 0.1 * C_VOF(cell, gas) * C_R(cell, gas) *
                          (T_SAT - C_T(cell, gas)) / T_SAT;
                  }


              }
          return (m_lg);
      }

       

    • Rob
      Ansys Employee

      If you put  DEFINE_MASS_TRANSFER into the search tool and then limit to the "fluids" channel you'll find one or two threads on the topic.

      Re the IF statement,  0.05 < Liquid < 0.95 will pick up a huge region, 0.45 < liquid < 0.55 may be a little more precise. You may also want to check on the VOF model energy equation: there's only one temperature field so C_T is for the mixture, not the phase thread. 

      • Cathleen
        Subscriber

        For your second point on the IF statement. I have a message printing "   Message("\n \n I found the interface!");" if the if-statement executes but it is not displaying so I am never getting to the energy equation. Any idea why it would not be picking up the in-between region since I have defined it in the initialization?

    • Rob
      Ansys Employee

      I assume you do have an interface? Just checking the obvious omission! 

      • Cathleen
        Subscriber

        Hi Robert, yes! I definitely have an interface. The primary phase is vapor (to_species) and I patch the liquid zone at the initialization step. I can plot the contour of the phases and I have liquid in the liquid zone and vapor everywhere else. The interface itself shows a gradient so it should be satisfying the if-statement condition. I initially thought that patching it would create a step change at the interface so the if-statement would not work but it seems to apply a gradient to those cells. 

    • Rob
      Ansys Employee

      Check Thread* liq very carefully relative to https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v221/en/flu_udf/flu_udf_sec_define_mass_transfer.html?q=define_mass_transfer

    • Cathleen
      Subscriber

      I'm sorry, can you clarify what you mean by checking Thread*liq? The UDF in the link is the one I based mine off of, I just changed the from and to and added the if-statement. 

      In that link they have the Thread *mixture_thread but they say that if the phase does not have a mixture associated then it will be with the bulk phase which is what I want. 

      Is it a constraint of the DEFINE_MASS_TRANSFER to fix the from and to indices? 

    • Rob
      Ansys Employee

      You've got Thread*  liq and not Thread  *liq  not sure what that'll do: I don't do much UDF stuff. 

      • Cathleen
        Subscriber

        I've tried that, I literally just copied the sample UDF from the link and made the only change be the if-statement and it still doesn't do anything. 

        Is it possible this is happening due to the patching? When you patch the zones are they "fixed" there? Is it possible that by patching the zones, I'm telling ANSYS that the liquid zone will always be liquid and its essentially overiding everything else? 

    • Rob
      Ansys Employee

      No, patch is the initial condition. As soon as the solver updates (typically a time step with multiphase) the boundary conditions will take over. 

Viewing 6 reply threads
  • You must be logged in to reply to this topic.