Ansys Learning Forum Forums Discuss Simulation Fluids Initialization Error – Droplet Evaporation Reply To: Initialization Error – Droplet Evaporation

Sidharth_Raut
Subscriber

Hello Rob,

I'm having UDM in my UDF but it doesn't give me any value since the case is not even getting initialized. Can you have a good look at my UDF and let me know where I'm wrong? Also, I'm trying to run this in parallel with 4 processors. I'm sharing my actual code here.

Also, is there a way that my udf is causing a cell or value or something similar that doesn't exist is getting written to and Fluent then crashes??  

/********************************************************
 DEFINITION OF MASS SOURCE TERM FOR LIQUID PHASE
 *******************************************************/

DEFINE_SOURCE(liq_src, c, t, ds, eqn)
{
   #if !RP_Host
   
   real m_dot_l, T_sat;
   real vol = C_VOLUME(c, t);                                                                           //SIGNIFIES THE CELL VOLUME FOR A CELL AND THREAD
   Thread *pt = THREAD_SUB_THREAD(t, 0);                                                                //PRIMARY PHASE THREAD
   Thread *st = THREAD_SUB_THREAD(t, 1);                                                                //SECONDARY PHASE THREAD

   if (C_VOF(c, t) < 0.99 && C_VOF(c, t) > 0.01)
   {
    if (C_T(c,pt) >= T_sat)
    {
        m_dot_l = -0.1 * C_VOF(c,t) * C_R(c,t) * fabs(C_T(c,t) - T_sat) / T_sat;                      //LEE EVAPORATION MODEL
        ds[eqn] = -0.1 * C_R(c,t) * fabs(C_T(c,t) - T_sat) / T_sat;
    }
    else
    {
        m_dot_l = 0.1 * C_VOF(c,st) * C_R(c,st) * fabs(T_sat - C_T(c,pt)) / T_sat;                    //LEE CONDENSATION MODEL
        ds[eqn] = 0;
    }
   }
   else
   {
    m_dot_l = 0;
    ds[eqn] = 0;
   }

   C_UDMI(c, t, 9) = m_dot_l;
   return m_dot_l;
   
    #endif
}

/********************************************************
 DEFINITION OF MASS SOURCE TERM FOR VAPOR PHASE
 *******************************************************/

DEFINE_SOURCE(vap_src, c, t, ds,eqn)
{
    #if !RP_Host
       
   real m_dot_v, T_sat;
   real vol = C_VOLUME(c, t);                                                                           //SIGNIFIES THE CELL VOLUME FOR A CELL AND THREAD
   Thread *pt = THREAD_SUB_THREAD(t, 0);                                                                //PRIMARY PHASE THREAD
   Thread *st = THREAD_SUB_THREAD(t, 1);                                                                //SECONDARY PHASE THREAD

   if (C_VOF(c,t) < 0.99 && C_VOF(c,t) > 0.01)
   {
    if (C_T(c,pt) >= T_sat)
    {
        m_dot_v = 0.1 * C_VOF(c,t) * C_R(c,t) * fabs(T_sat - C_T(c,pt)) / T_sat;                       //LEE CONDENSATION MODEL
        ds[eqn] = 0;
    }
    else
    {
        m_dot_v = -0.1 * C_VOF(c,t) * C_R(c,t) * fabs(T_sat - C_T(c,pt)) / T_sat;                      //LEE CONDENSATION MODEL
        ds[eqn] = -0.1 * C_R(c,t) * fabs(T_sat - C_T(c,t)) / T_sat;
    }
   }
   else
   {
    m_dot_v = 0;
    ds[eqn] = 0;
   }

   C_UDMI(c, t, 10) = m_dot_v;
   return m_dot_v;
   
    #endif
}

/********************************************************
 DEFINITION OF ENERGY SOURCE TERM FOR BOTH PHASES
 *******************************************************/

DEFINE_SOURCE(enrg_src, c, mix_th, ds, eqn)
{
    #if !RP_Host
   
    real m_dot, T_sat, hfg;
    Thread *pt, *st;
    pt = THREAD_SUB_THREAD(mix_th, 0);
    st = THREAD_SUB_THREAD(mix_th, 1);

    if (C_VOF(c, pt) < 0.99 && C_VOF(c, pt) > 0.01)
    {
        if (C_T(c, mix_th) >= T_sat)
        {
            m_dot = -0.1 * C_VOF(c,pt) * C_R(c,pt) * fabs(C_T(c,pt) - T_sat) / T_sat;                      //LEE EVAPORATION MODEL
            ds[eqn] = -0.1 * C_VOF(c,pt) * C_R(c,pt) / T_sat;
        }
    }
    else
    {
        m_dot = 0.1 * C_VOF(c,st) * C_R(c,st) * fabs(T_sat - C_T(c,mix_th)) / T_sat;                      //LEE CONDENSATION MODEL
        ds[eqn] = -0.1 * C_VOF(c,st) * C_R(c,st) / T_sat;
    }
    else
    {
        m_dot = 0;
        ds[eqn] = 0;
    }
   
    C_UDMI(c, t, 11) = m_dot;
    return hfg * m_dot;
   
    #endif
}