Fluids

Fluids

How to access cell temperature in DEFINE_DPM_SCALAR_UPDATE

    • roytorc
      Subscriber

      I am trying to access cell temperature using "c->temp" which works in Fluent 17.2. However, using the same thing in Fluent 2019R1 gives me 0 output. Here is the code I'm using. Could anyone advise.


       



      #include "udf.h"


      #include "stdio.h"


      #include "string.h"


      #include "stdlib.h"


       


      #define mesh_size 103456


      #define Ad 4e21 /* 1/s */


      #define Ed 142000 * 4.18 * 0.95 /* kJ/kmol */


      #define R 8.314 /* kJ/kmol.K */


       


       


      DEFINE_INIT(thermal_age_setup,domain)


      {


      if(NULLP(user_particle_vars)) Init_User_Particle_Vars();


      strcpy(user_particle_vars[0].name, "thermal-age");


      strcpy(user_particle_vars[0].label, "Thermal Age");


      strcpy(user_particle_vars[1].name, "thermal-age-0");


      strcpy(user_particle_vars[1].label, "Thermal Age 0");


      }


       


      DEFINE_DPM_SCALAR_UPDATE(thermal_age, cell, thread, initialize, p)


      {


      cphase_state_t *c = &(p->cphase);


         


      if(initialize)


      {


      P_USER_REAL(p,0) = 0.0;


      P_USER_REAL(p, 1) = Ad * exp(-Ed / R / c->temp);


      }


      else if (P_POS(p)[0] < 0.175)


      {


      P_USER_REAL(p,0) = 0.0;


      P_USER_REAL(p,1) = Ad * exp(-Ed / R / c->temp);


      }


      else


      {


      P_USER_REAL(p,0) = P_USER_REAL(p,0) + P_DT(p) * 0.5 * (P_USER_REAL(p,1) + Ad * exp(-Ed / R / c->temp));


      P_USER_REAL(p,1) = Ad * exp(-Ed / R / c->temp);


      }


      }


    • DrAmine
      Ansys Employee
      Check the manual. There was a change in the structure so that you need to tell which phase it is. In an example you can find that. Other way is to find the cell where the particle is located.
    • roytorc
      Subscriber

      Thank you for your reply. Could you elaborate more on ' you need to tell which phase it is'. Also, is using C_T(P_CELL(p), P_CELL_THREAD(p)) equivalent to c->temp? I have tried that and I don't think it gave me the same result.


       


      I forgot to mentioned that Fluent 17.2 was in linux and Fluent 19R1 is in windows10.

    • roytorc
      Subscriber

      I modified my code to cphase[0] and I think it work now. 


       


      However, I ran my previous code on Fluent17.2 (windows10) and got the MPI error while using the same UDF in Fluent17.2(Linux) had no problem. Could you please advise the reason of this circumstance.

    • DrAmine
      Ansys Employee

      No I apologize here. Use the latest release and check if it is working.

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