UDF for partial pressure in heat pipe simulation – divergence after one time step

    • fjulio


      I am working on the simulation of a heat pipe with non-condensable gases. For that I am using the VOF model with the Lee model for evaporation/condensation, as well as the species transport model to account for gas diffusion of vapor into the NCG-vapor mixture.

      I am using a UDF to calculate the partial pressure of vapor in the gas mixture and then find the saturation temperature at each cell, everything goes well, it compiles, hooks, etc. My problem is the simulation runs for one time step, then in the next one when the residuals shoot up, it diverges. The fluids are water (phase-changing) and air (NCG). My gas mixture has water-vapor as the first component.

      I am not sure if this is needed, but this is the UDF I am using (adapted from this post: https://forum.ansys.com/discussion/29866/saturation-temperature-udf)

      #include "udf.h"

      #define MOLAR_MASS_WATER 18.01534 //g/mol

      #define MOLAR_MASS_AIR 28.97 // g/mol

      DEFINE_PROPERTY(saturation_temp, c, t)


      // t: mixture thread

      // c: cell variable

      // Cell volume

      real vol = C_VOLUME(c, t);

      Thread *pt = THREAD_SUB_THREAD(t, 0); // Primary phase thread

      Thread *st = THREAD_SUB_THREAD(t, 1); // Secondary phase thread

      // Get the volume fraction of both phases

      real vf_s = C_VOF(c, st);

      real vf_p = 1 - vf_s;

      // Get the pressure of the mixture 

      real p_mix = C_P(c, t);

      // Get the operating pressure

      real p_op = RP_Get_Real("operating-pressure");

      // Primary phase density

      real rho_p = C_R(c, pt);

      // Get mass fractions in primary phase

      real mf[2]; // to store mass fractions

      Material *m = THREAD_MATERIAL(pt);

      Material *sp = NULL;

      int i; // Species index - 0 for water vapor and 1 for air

      mixture_species_loop(m, sp, i)


      mf[i] = C_YI(c, pt, i);


      real p_w; // h20 pressure for cell

      // If secondary phase only

      if (vf_s == 1)


      p_w = p_mix + p_op;


      // If primary phase or mixture of phases



      // Find the partial pressure of water vapour

      // partial pressure = cell pressure * water mole fraction

      // mass of primary phase in cell

      real m_prim = rho_p * vol * vf_p;

      // mass of water vapour and air in cell

      real m_wv = mf[0] * m_prim;

      real m_air = m_prim - m_wv;

      // No of moles in water vapour and air

      real N_wv = m_wv / MOLAR_MASS_WATER;

      real N_air = m_air / MOLAR_MASS_AIR;

      real N_total = N_wv + N_air;

      // water vapour partial pressure

      p_w = (C_P(c, t)+ p_op)* (N_wv / N_total);


      // Calculate saturation temperature

      real t_sat;

      t_sat = (1730.63 / (10.196 - log10(p_w))) + 39.724;

      return t_sat;


    • Karthik R
      It is very difficult to say why your model is diverging as there may be several reasons for it. How did you set up your model? How are you handling your mass transfer? Can you share some details about your model set up?
    • fjulio
      Hi Kremella Thanks for your response, I agree this was a lot to take in.
      In the meantime I tried rolling the complexity back a little bit and removed the species diffusion to treat it as a simple heat pipe with no NCG (non-condensable gas) and a UDF for saturation temperature as a function of absolute pressure. In this simplified problem I still encountered the same issue, this time I was able to track it to a sudden shift in the absolute pressure, causing it to be negative, I go into detail in this other thread: https://forum.ansys.com/discussion/comment/148781#Comment_148781.
      But answering your questions:
      this is a heat pipe with water as the phase-changing fluid with air as NCG.
      I am using axisymmetric coordinates with evaporator, adiabatic section and condenser.
      My boundary conditions are constant temperature in the evaporator wall and convection in the condenser wall.
      For the diffusion I am using species diffusion with a mixture-template with species Air and Water-Vapor.
      I am using explicit VOF model for multiphase with the air and water-vapor mixture as the primary phase and water-liquid as secondary phase.
      For evaporation/condensation I am using the Lee model (from water-liquid to air-vapor mixture H2O component) with constants 0.1 and 181. I am using the UDF mentioned in the original post to track the saturation temperature with respect to partial pressure.
      Thanks again
Viewing 2 reply threads
  • You must be logged in to reply to this topic.