We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Source term UDF

TAGGED: , ,

    • sjohn
      Subscriber

      I am using a DEFINE_SOURCE UDF to remove mass from liquid phase. The output is also being saved to a UDM so that it can be used in another DEFINE_SOURCE UDF to add mass to the gas phase. 

      In my simulation results, the mass in the liquid phase is seen to reduce when I compare the inlet and outlet mass flowrates but the mass in the gas phase does not show any significant increase. I made a contour plot of the UDM with exponential format values and it seems to be zero in the mixture domain.

    • sjohn
      Subscriber

      I can confirm that mass is being removed but it is not being stored in the UDM. Form the User Defined Menu, I have allocated one spot for the UDM.

      Here is how I am removing mass from the liquid phase and assigning it to the UDM

      #include “udf.h”
      #include “math.h”
       
      /* Define the source term function */
      DEFINE_SOURCE(species_sub_ig2, c, t, dS, eqn)
      {
      real source = 0.0;
      real temperature = 0.0;
      real k = 0.0;
      real vol_fract = 0.0;
      real density = 0.0;
      real A = 3.85E4;
      real B= 948;
       
      Thread *phase_thread = THREAD_SUB_THREAD(t, 1);
       
      if (phase_thread != NULL)
      {
      vol_fract = C_VOF(c, phase_thread);
      density = C_R(c, phase_thread);
      temperature = C_T(c, phase_thread);
      k = A * (B * temperature);
      source = -k * vol_fract * density;
      }
      else
      {
      source = 0.0;
      }
       
      /* Store the source term in user-defined memory */
      C_UDMI(c, t, 0) = – source; /* Assuming UDM index is 0 */
       
      dS[eqn] = -k;
       
      return source;
      }
      • sjohn
        Subscriber

        I have tried to add #include "sg_mphase.h" in case C_VOF needs it but I get some warning when I try to include it.

    • Rob
      Forum Moderator

      What is going into the UDM? 

      • sjohn
        Subscriber

        See 4th line from the bottom. That statement defines what is going into the UDM.

    • Rob
      Forum Moderator

      Yes, and what value is that? Ie what does the contour of UDM look like? 

    • sjohn
      Subscriber

      I already mentioned in my first post that it is zero.

      Actually, I figured out the issue and solved it.

    • Rob
      Forum Moderator

      OK, please post your solution so others may benefit. 

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