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.

User Defined Scalar(UDS) for Nucleation rate in Crystallization

    • jayasriyadav
      Subscriber

      This is UDS which i am using to visualize nucleation rate in crystallization. Along with this UDS i am also using a UDF(it is running properly).

      #include "udf.h"
       
      /* Define UDS Source Term for Nucleation Rate */
      DEFINE_SOURCE(nucleation_uds_source, cell, thread, dS, eqn)
      {
          real J;
          
          /* Retrieve the nucleation rate from UDM (assuming it's stored in UDM[2] in your nucleation UDF) */
          J = C_UDMI(cell, thread, 2); 
          
          /* Store nucleation rate in UDS[0] for visualization */
          C_UDSI(cell, thread, 0) = J; 
          
          /* No derivative dependency */
          dS[eqn] = 0.0;
          
          return J;
      }
       
      /* Define Diffusive Flux for UDS */
      DEFINE_UDS_FLUX(nucleation_uds_flux, f, thread, i)
      {
          return 0.0; /* No flux term, as we only visualize J */
      }

      And i am getting a floating point exception error , these are my errors while running simulation. Is there anything wrong in my uds?
      Divergence detected in AMG solver: uds-0
      Error at host: floating point exception

    • Rob
      Forum Moderator

      You're setting a UDS source as being equal to the UDM. What does the UDS do, and is the UDM value physically sensible? 

    • jayasriyadav
      Subscriber

      I need UDS for the visualization of Nucleation rate , I am storing values of Nucleation rate from the UDF and using it for UDS.
      This is my UDF for the Nucleation rate,

      /* Negated forms that are more commonly used */
      /**********************************************************/
      #if !RP_HOST
      /* either serial or compute node process is involved */
      #endif
      /**********************************************************/
      /*UDF that computes the particle nucleation rate*/
      /**********************************************************/
      #include "udf.h"
      #include "sg_pb.h"
      #include "sg_mphase.h"
      DEFINE_PB_NUCLEATION_RATE(nuc_rate, cell, thread)
      {
      real SS;
      real J;
      real p1 = 0.052; /* nuc constant */
      real p2 = 1000.; /*nuc const activation energy constant J/mol */
      real p3 = 5.8; /* nucleation law power index */
      real R = 8.314; /*gas constant j/mol.k*/
      real T, T1, solute_mass_frac, solubility, solubility_mass;
      real solute_mol_wt, solvent_mol_wt;
      Thread *tc = THREAD_SUPER_THREAD(thread); /*obtain mixture thread */
      Thread **pt = THREAD_SUB_THREADS(tc); /* pointer to sub_threads */
      Thread *tp = pt[P_PHASE]; /* primary phase thread */
      solute_mol_wt = 136.0; /* molecular weight of kdp */
      solvent_mol_wt = 18.; /* molecular weight of water */
      solute_mass_frac = C_YI(cell,tp,0); /* mass fraction of solute in primary phase (solvent) */
      T1 = C_T(cell,tp); /* Temperature of primary phase in Kelvin */
      T = (T1-273.15); /* Temperature of primary phase in degree Celcius */
      solubility_mass = 15.24+(2.06*0.1*T)+(1.01*0.01*pow(T,2))-(1.45*0.0001*pow(T,3))+(1.23*0.000001*pow(T,4)); /* mass solubility in percentage*/
      solubility = (solubility_mass/100.0); /* Solubility Law relating equilibrium solute mole fraction to Temperature*/
      SS = solute_mass_frac/solubility; /* Definition of Supersaturation */
      if (SS <= 1.)
      {
      J = 0.;
      }
      else
      {
      J = p1*exp(-p2/(R*T1))*pow((SS-1),p3);
      C_UDMI(cell,tc,2) = J;
      /* saving local nucleation rate to memory */
      C_UDMI(cell,tc,0) = SS;
      /* saving local supersaturation to memory */
      }
      return J;
      }
      /***************************************************************/

       

    • Rob
      Forum Moderator

      I assume you've got sufficient UDM & UDS assigned? And is the UDM value sensible? I'd also question any curve fit at 1e-5.x^4 for precision! 

    • jayasriyadav
      Subscriber

      I don't know much about UDS, Can you help me to write a correct UDS for my UDF, so that I can see the contours of nucleation rate.
      Currently I'm not getting contour for this UDS.I'm attaching contour for your reference.

    • Rob
      Forum Moderator

      The above means the Scalar value is nonsense. So, if you plot the UDM do you see a more sensible result?  Given the code compiles it's gramatically correct, so next step is to figure out what part of the maths isn't right. Staff aren't permitted to debug code, we're limited to hints and suggesting you read the manual. 

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