Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

use of temperature and mass fraction gradients in UDF

    • Raiq33
      Subscriber
      Hi,Currently, I'm using non-premixed combustion model and aiming to modify some equations using UDF. In this modification, I need to use the temperature and mass fraction gradients. It is true that there are macros for these gradients but when I included them in the UDF file, I got errors. nIn the UDF manual, I found a code ( showgrad.c), which can be used to show the available gradients in my model. When I used that code, the available gradient variables for my particular case and data files are pressure and velocities gradients.My question is how I can use the temperature gradient ?.For the mass fraction gradient, it is written in the UDF manual that the mass fraction gradient is available only for the density-based solver and to use it in the pressure-based solver, I need to set the rpvar 'species/save-gradients? to #t. Hence, I typed in the text command the followingnn(rpsetvar 'species/save-gradients? #t)nnbut unfortunately, nothing has changed. So, is there any way to make the mass fraction gradient available in my model?Thanks in advance for your help. n
    • YasserSelima
      Subscriber
      Hello,ntype (rpgetvar 'species/save-gradients?) and see if you get true (#t) or not ... nAlso if you want to recall gradient of any variable, save it to C_UDSI and then you can recall the gradient by C_UDSI_G ... don't forget to disable solving the UDS associated with this variable.nAnd for the temperature, yes you can use the temperature gradient ... C_T_G(c,t)nn
    • Raiq33
      Subscriber
      thanks for your reply. nI typed (rpsetvar 'species/save-gradients? #t) in the console but nothing has changed. I do not know if there is another way to make the mass fraction gradient available in the model or not. n
    • YasserSelima
      Subscriber
      (%rpgetvar 'species/save-gradients?) .. this should give you the value of the variable . See if it is true or falsen
    • Raiq33
      Subscriber
      nAs expected, the value of the variable is false. Then, when I used the following command, (rpsetvar 'species/save-gradients? #t), the value of the variable becomes true. After that, I used the showgrad.c code to show the available gradients in my model but the gradient of species mass fraction was not one of the available gradient variables for my case and data files. nI'm totally confused. n
    • YasserSelima
      Subscriber
      run one iteration / timestep and checkn
    • Raiq33
      Subscriber
      This is what I did. n
    • YasserSelima
      Subscriber
      Not sure why ... now you have to go with solution of UDS ... nUse Define_AdjustnLoop through all threads and cellsnSave the mass fraction into C_UDSI(c,t,i)nNow you can call the gradient from any other function using C_UDSI_G(c,t,i) ... this will have 2/3 components in x, y and z direction.nDon't forget to increase the number of user defined scalar and disable solving the equationn
    • Ramesh Chandra Mishra
      Subscriber

      Hi

      i am solving an equation which requires concentration gradient as a term. So i write concentration as mass fraction*density to a C_UDSI and then use C_UDSI_G to solve the equation. But I am getting zero everytime. Please note that i don't disable solving the equation for UDS. Is it because of that or there is something to be done in my case file?

      A snippet of code is as follows:

      thread_loop_f(t, d)
      {
          begin_f_loop(f,t)
          {
              F_CENTROID(x, f, t);
      if (x[0] >= 108  && x[0] <=  126 &&  x[1] == 18 && x[2] >= 90  && x[2] <= 126 )
      {
                          F_AREA(A,f,t);
      co = F_C0(f, t);              
      to = THREAD_T0(t);      //obtaining corresponding thread of adjacent cell
      real integrand;
      real conc_grad_roof;
      real mu_t_roof = C_MU_T(co,to);        //turbulent viscosity 
      C_UDSI(co,to,0)= C_YI(co,to,0) * RHO_1;   //storing concentration of CO as user defined scalar(UDS)
      conc_grad_roof=(C_UDSI_G(co,to,0)[1]);       //concentration gradient of CO
       
      integrand = (mu_t_roof /0.7)*conc_grad_roof;     //TURBULENT POLLUTANT FLUX
      PCH_turb_roof -= integrand*NV_MAG(A);            //Overall value of PCH integral
                      }
                  }
                                
              end_f_loop(f,t)
      }
    • Rob
      Forum Moderator

      You're mixing face and cell loops, that may not be helping. 

Viewing 9 reply threads
  • The topic ‘use of temperature and mass fraction gradients in UDF’ is closed to new replies.