Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Regarding UDF

    • ritwik
      Subscriber

      I am modelling an adsorption model for a zeolite column. The UDF for mass source term is:

      #include "udf.h"

      int ads;

      int domain_q_ads = 0;

      int domain_d_ads = 1;

      DEFINE_ADJUST(q_ads, domain)

      {

         Thread *t;cell_t c; real dt;

         thread_loop_c(t,domain){

         begin_c_loop(c,t){

            dt = RP_Get_Real("physical-time-step")

            C_UDSI(c,t,0)=C_UDSI_M1(c,t,q_ads)

            +0,15*dt*(C_UDSI_M1(c,t,ads)-C_UDSI_M1(c,t,q_ads));}

         end_c_loop(c,t);}   

      }


      DEFINE_ADJUST(d_ads, domain)

      {

         Thread *t; cell_t c;

         thread_loop_c(t,domain){

            begin_c_loop(c,t)

            {

               C_UDSI(c,t,1)=-0,532224*0,15*

               (C_UDSI(c,t,ads)-C_UDSI(c,t,q_ads));}

            end_c_loop(c,t);

         }   

      }

      DEFINE_SOURCE(m_src,c,t,dS,eqn)

      {

         dS[eqn] = 0,0;

         return C_UDSI_M1(c,t,d_ads);

      }

      When i try to compile, the console shows this error and the fluent window stopped working. I am allocating 2 memory location for UDM.

    • DrAmine
      Ansys Employee
      Look carefully into the lines where you want to access the previous time step results..
    • DrAmine
      Ansys Employee
      And ensure you are defining two UDS's.
    • ritwik
      Subscriber
      Yes i am defing two UDS

    • ritwik
      Subscriber
      I am not understanding. I am new to the fluent and udfs. Can you please elaborate?

      Thank you
    • DrAmine
      Ansys Employee
      So then please go through the Customization Manual and if possible a couple of Self paced Training on the Ansys Learning Hub.
      Another Hint: what is q_ads? Is it defined somewhere?
    • ritwik
      Subscriber
      #include "udf.h"
      int i;
      /*Adsorption*/
      DEFINE_ADJUST(adsorption,d)
      {
      Thread*t; cell_t c; real E,A,P;
      thread_loop_c(t,d)
      {
      begin_c_loop (c,t)
      {
      real tem=C_T(c,t);
      P=C_P(c,t)+RP_Get_Real("operating-pressure");
      E=3080+18,9*tem;
      A=8,31429*tem*log(1.47E9/P);
      C_UDSI(c,t,i)=71.6*exp(-A*A/(E*E));
      }
      end_c_loop(c,t)
      }
      }
      DEFINE_ADJUST(q_ads, d)
      {
      Thread *t;cell_t c; real dt;
      thread_loop_c(t,d){ /*q_ads is the UDF name i am defining*/
      begin_c_loop(c,t){
      dt = RP_Get_Real("physical-time-step")/*int i is number of UDS*/
      C_UDSI(c,t,i)=C_UDSI(c,t,i)+0.15.*dt*(C_UDSI(c,t,i)-C_UDSI(c,t,i));}
      end_c_loop(c,t)
      }
      }
      I am allocating 2 UDS and 4 UDM
      After go through the manual, i modified the UDF. Can you please tell me, where i have gone wrong?

    • DrAmine
      Ansys Employee
      i is undefined for UDS. It should be 0, 1 2 etc. to refer to the proper UDS.
    • ritwik
      Subscriber
      #include "udf.h"
      int i;
      DEFINE_ADJUST(adsorption,d)
      {
      Thread*t; cell_t c; real E,A,P;
      thread_loop_c(t,d)
      {
      begin_c_loop (c,t)
      {
      real tem=C_T(c,t);
      P=C_P(c,t)+RP_Get_Real("operating-pressure");
      E=3080+18,9*tem;
      A=8,31429*tem*log(1.47E9/P);
      C_UDSI(c,t,0)=71.6*exp(-A*A/(E*E));
      }
      end_c_loop(c,t)
      }
      }
      DEFINE_ADJUST(q_ads, d)
      {
      Thread *t;cell_t c; real dt;
      thread_loop_c(t,d){
      begin_c_loop(c,t){
      dt = RP_Get_Real("physical-time-step")
      C_UDSI(c,t,0)=C_UDSI_M1(c,t,i)
      +0.15.*dt*(C_UDSI_M1(c,t,0)-C_UDSI_M1(c,t,1));}
      end_c_loop(c,t)
      }
      }
      I have changed it.
      But same problem is coming.
    • Rob
      Forum Moderator
      You've not defined a few of the variables (REAL, INTEGER etc) and I wonder if using a comma is permitted in C, you might need a full stop for a decimal. As you're using 2021 compile the code with the built in compiler: if nothing else it'll give us a better idea if the code is OK.
    • DrAmine
      Ansys Employee
      Again your UDS and index. Check what Fluent reports when compiling.
    • ritwik
      Subscriber
      when i tried to compile the udf
      The udf is:
      #include "udf.h"
      int ads;
      real C1;
      /*Adsorption*/

      DEFINE_ADJUST(adsorption,domain){
      Thread*t; cell_t c; real E,A,P;
      thread_loop_c(t,domain){
      begin_c_loop (c,t){
      real tem=C_T(c,t);
      P=C_P(c,t)+RP_Get_Real("operating-pressure");
      E=3080+18,9*tem;
      A=8,31429*tem*log(1.47E9/P);
      C_UDSI(c,t,0)=71.6*exp(-A*A/(E*E));
      C1 = C_UDSI(c,t,0);}
      end_c_loop(c,t)}
      }
      /*Mass source term*/

      DEFINE_ADJUST(q_ads, domain)
      {
      Thread *t;cell_t c; real dt;
      thread_loop_c(t,domain){
      begin_c_loop(c,t){
      dt = RP_Get_Real("physical-time-step")
      C_UDSI(c,t,0)=C_UDSI(c,t,0)
      +0,15*dt*(C1-C_UDSI(c,t,0));}
      end_c_loop(c,t);}
      this error is showing.
      Can you please help me? What is this error meant?
    • Secorreaz
      Subscriber
      In the end your udf was able to compile correctly.??
    • ritwik
      Subscriber
      This udf was not compiled, I have to modified in order to get compiled succesfully
    • DrAmine
      Ansys Employee
      .
    • Secorreaz
      Subscriber
      And did you manage to modify it to run successfully or did you abandon the work?
    • ritwik
      Subscriber
      No, It is running successfully

    • mechE
      Subscriber

      Ritwik, can you please share how did you resolve the problem?

    • Amani Chouat
      Subscriber

      i work in the some problem , (adsoptive hydrogen storage using Udf) , how did you resolve the problem please ,

      Ps:i don't have much idea about UDF 

Viewing 18 reply threads
  • The topic ‘Regarding UDF’ is closed to new replies.