We’re updating our badges platform. Badge issuance is temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Interface tracking between 2 phases in VOF

    • Dubey92
      Subscriber

      I am modeling laser melting in FLUENT using solidification/melting and VOF. There are a number of particles over a solid substrate and there is an inert gas atmosphere above them. Now, the laser energy is a surface heat source. I need to convert it into volumetric heat source and then apply it into the interfacial cells between the metal particles and the gas. I need 2 things for this:

      1. Gradient of volume fraction of a phase in a cell(C_VOF_G) to convert the surface source to volumetric source. I understand that FLUENT does not have a macro for gradient of volume fraction. How to get the gradient of volume fraction?
      2. When the laser will melt the particle, volume fraction in the cells will change and hence the interface. How to track this interface using a UDF so that laser is applied on the interfacial cells?

      Till now I have been using the following code and it compiles without any error, When I give an inlet velocity for the gas domain and an outlet, the simulation runs although the results are not correct. When I make the gas domain stationary , the simulation completes without anything happening. Any help is much appreciated.

      Thank you

      DEFINE_ADJUST(adjust_gradient_heat, domain)

      {

      Thread *t;

      Thread **pt;

      cell_t c;

      int phase_domain_index = 1.0;

      Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);

      {

      Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);

      Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);

      Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate);

      }


      mp_thread_loop_c(t,domain,pt)

      if (FLUID_THREAD_P(t))

      {

      Thread *ppt = pt[phase_domain_index];


      begin_c_loop (c,t)

      {

      C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];

      C_UDMI(c,t,1) = C_VOF_G(c,ppt)[1];

      C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];

      C_UDMI(c,t,3) = sqrt(C_UDMI(c,t,0)*C_UDMI(c,t,0) + C_UDMI(c,t,1)*C_UDMI(c,t,1) + C_UDMI(c,t,2)*C_UDMI(c,t,2));    // magnitude of gradient of volume fraction                                 

      C_UDMI(c,t,4) = C_UDMI(c,t,0)/C_UDMI(c,t,3);        // nx -> x gradient of volume fraction divided by magnitude of gradient of volume fraction

      C_UDMI(c,t,5) = C_UDMI(c,t,1)/C_UDMI(c,t,3);        // ny -> y gradient of volume fraction divided by magnitude of gradient of volume fraction 

      C_UDMI(c,t,6) = C_UDMI(c,t,2)/C_UDMI(c,t,3);       // nz -> z gradient of volume fraction divided by magnitude of gradient of volume fraction                                             

      }

      end_c_loop (c,t)

      }

      Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);

      }

      DEFINE_SOURCE(heat_source, c, t, dS, eqn)       // The name of the UDF is heat_source

      {

      Thread *pri_th;

      Thread *sec_th;

      real source;

      real x[ND_ND], time;                // Define face centroid vector, time

      time = RP_Get_Real("flow-time");             // Acquire time from Fluent solver

      C_CENTROID(x, c, t);                // Acquire the cell centroid location

      real T = C_T(c,t);

      pri_th = THREAD_SUB_THREAD(t, 0);

      sec_th = THREAD_SUB_THREAD(t, 1);

      real alpha = C_VOF(c,sec_th);                    // cell volume fraction

      real gamma;

      if (T>293.0 && T<1658.0)

      {

      gamma = 0;

      }

      else if (T>=1658.0 && T<=1723.0)

      {

      gamma = (T-Ts)/(Tl-Ts);

      }

      else if (T>1723.0)

      {

      gamma = 1;

      }

      real Pv = 0.54*Pa*exp((Lv*M*(T-Tv))/(Rg*T*Tv));

      real mv = (0.82*M*Pv)/(sqrt(2*Pi*M*Rg*T));

      real rhos = 7900;                     // density of solid SS316

      real rhol = 7433 + 0.0393*T - 0.00018*pow(T,2);      // density of liquid SS316

      real rhom = rhol*gamma + rhos*(1-gamma);          // density of SS316

      real rho = alpha*rhom + rhog*(1-alpha);          // density of cell containing metal and gas

      real Cps = 462 + 0.134*T;                 // specific heat of solid SS316

      real Cpl = 775;                      // specific heat of liquid SS316

      real Cpm = Cpl*gamma + Cps*(1-gamma);           // specific heat of SS316

      real Cp = alpha*Cpm + Cpg*(1-alpha);            // specific heat of cell containing metal and gas

      real factor = (2*rho*Cp)/(rhom*Cpm + rhog*Cpg);

      real r = sqrt(pow(x[0]-x0-v*time,2.0) + pow(x[1]-y0,2.0));


      if(C_VOF(c,sec_th)>0.05 && C_VOF(c,sec_th)<1)

      {

      if(C_T(c,t) < 3090)

      {

      source = (((2*A*P)/(Pi*R*R))*exp((-2*(r*r))/(R*R)) - h*(T-Ta) - s*e*(pow(T,4) - pow(Ta,4)))*C_UDMI(c,t,3)*factor;

      dS[eqn] = 0.0;

      }

      else if(C_T(c,t) >= 3090)

      {

      source = (((2*A*P)/(Pi*R*R))*exp((-2*(r*r))/(R*R)) - h*(T-Ta) - s*e*(pow(T,4) - pow(Ta,4)) - Lv*mv)*C_UDMI(c,t,3)*factor;

      dS[eqn] = 0.0;

      }

      }

      else

      {

      source = 0.0;

      dS[eqn] = 0.0;

      }

      return source;

      }

    • Amine Ben Hadj Ali
      Ansys Employee
      Fluent calculates the gradients and once they are not required anymore they are reset and so on. You can keep memory from being freed : that is the official way to access gradients.
      Laser Energy Source should be applied at the interface so in partial filled cells (Simple IF Condition).
    • Dubey92
      Subscriber
      Thanks for your suggestion. Till now, I have been using the following condition for applying the laser source in the interfacial cells:
      Thread *pri_th;
      Thread *sec_th;
      pri_th = THREAD_SUB_THREAD(t, 0);
      sec_th = THREAD_SUB_THREAD(t, 1);
      if(C_VOF(c,sec_th)>0.05 && C_VOF(c,sec_th)<1)
      But I am not sure if it is right. Then I read in a paper that the way to track the interfacial cells is to compare the coordinates of centroid of cells. If a cell has all the secondary phase and the above cell has volume fraction in between then I can use that z coordinate to apply laser source. Can you please tell which approach is correct? And should I use the above condition inside DEFINE_SOURCE or DEFINE_ADJUST?
    • Dubey92
      Subscriber
      As for the volume fraction gradients, which macro can I use to access gradient of volume fraction in my UDF as I understand that FLUENT does not have any macro C_VOF_G for accessing volume fraction gradient directly?
Viewing 3 reply threads
  • The topic ‘Interface tracking between 2 phases in VOF’ is closed to new replies.