Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Density UDF for a mixture

TAGGED: ,

    • sjohn
      Subscriber

      I wrote a UDF to specify density as a function of  temperature for a multi-species, multiphase model. This is the error I get.

        step  flow-time     p-inlet
           0  0.0000e+00 -1.0553e-14
       
      Updating solution at time level N...
       done.
       
        iter  continuity  x-velocity  y-velocity  z-velocity      energy  ch44-p  ch3oh-pha  n2-phase-a  co2-phase-  vf-phase-a     time/iter
              Stabilizing pressure coupled to enhance linear solver robustness.
              Stabilizing pressure coupled using GMRES to enhance linear solver robustness.
       
      Experiencing convergence difficulties - temporarily relaxing and trying again...
       
      Experiencing convergence difficulties - temporarily relaxing and trying again...
       
      Experiencing convergence difficulties - temporarily relaxing and trying again...
       
      Experiencing convergence difficulties - temporarily relaxing and trying again...
              Stabilizing pressure coupled to enhance linear solver robustness.
              Stabilizing pressure coupled using GMRES to enhance linear solver robustness.
       
      Experiencing convergence difficulties - temporarily relaxing and trying again...
       
      Divergence detected in AMG solver: pressure coupled temperature limited to 3.273150e+03 in 387997 cells on zone 1231 in domain 1
               Stabilizing vof-1 to enhance linear solver robustness.
              Stabilizing vof-1 using GMRES to enhance linear solver robustness.
       
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Divergence detected in AMG solver: pressure coupled
      Divergence detected in AMG solver: vof-1
      Error at host: floating point exception
       
      Error: floating point exception
      Error Object: ()
       
      Error at Node 5: floating point exception
       
      Error at Node 4: floating point exception
       
      Error at Node 6: floating point exception
       
      Error at Node 3: floating point exception
       
      Error at Node 10: floating point exception
       
      Error at Node 7: floating point exception
       
      Error at Node 0: floating point exception
       
      Error at Node 9: floating point exception
       
      Error at Node 8: floating point exception
       
      Error at Node 1: floating point exception
       
      Error at Node 11: floating point exception
       
      Error at Node 2: floating point exception
       
      Error: floating point exception

      Would someone be able to review my UDF (below) and tell me if there is an obvious mistake.

      #include "udf.h"
      /* Define the UDF to specify temperature-dependent density */
      DEFINE_PROPERTY(temperature_dependent_density, cell, thread)
      {
          real T;  /* Temperature */
          real density;  /* Density */
          real vol_frac;  /* Volume fraction of phase A */
       
          /* Loop over all cells in the thread */
          begin_c_loop(cell, thread)
          {
              /* Get the volume fraction of phase A in the cell */
              vol_frac = C_VOF(cell, thread);
       
              /* Check if the volume fraction of phase A is greater than 50% */
              if (vol_frac > 0.5)
              {
                  /* Get the temperature of the cell */
                  T = C_T(cell, thread);
       
                  /* Calculate the density based on the given relationship */
                  density = 1.4811 - 0.0007 * T;
       
                  /* Set the density for the cell */
                  C_R(cell, thread) = density;
              }
          }
          end_c_loop(cell, thread)
       
          return density;
      }
    • Rob
      Forum Moderator

      It's diverging, so the code is grammatically correct. But.... Is your intent to set a material density based on the species or phase fraction in a cell? Have a think about the physics, why would that be the case? 

    • sjohn
      Subscriber

      I would like to set the density based on phase fraction because the temperature-dependent density equation is for the phase. Instead of 50%, I could use 100% as the condition to change density as per temperature.

    • Rob
      Forum Moderator

      You're setting the phase density based on the phase fraction. You're not setting the mixture density. 

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