Fluids

Fluids

Hooking UDS to the model

    • Vassili BRIODEAU
      Subscriber

      Hello everyone,


      I have been interpreting some User-defined functions, and now I would like to use User defined scalars. Quite a lot of people use them, yet the documentation is not that clear about the steps to follow. Basically, after interpreting, when I launch the calculation, Fluent crashes and closes. I don't have time to see what kind of error it is, but I think it is written: MPI error.


      I will describe the steps I use, hoping it would help others.


      Step 1: Writing the UDF in a .c file


      /* Defining the adsoprtion of the system */ /********************************************/

      #include "udf.h"

      int ads;

      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,ads)=71.6*exp(-A*A/(E*E));}
      end_c_loop(c,t)}
      }


              DEFINE_SOURCE(energy_source,c,t,dS,eqn){
                  real e_source;
                  e_source=-C_UDSI_M1(c,t,ads)*0.496056352e3*3080*sqrt(log(71.6/C_UDSI_M1(c,t,ads)));
                  dS[eqn]=0.0;
                  return e_source;
              }


       Step 2: Interpreting the UDF



      Step 3: Adding a User Defined Scalar (UDS)


      In Flux function, I chose Adsorption, corresponding to the UDF using the UDS



      Step 4: Hooking the UDF


      I hooked adsorption as an adjust function



      Step 5: In Cell Zone condition>cross Source>Source>Energy source> Choose UDF energy_source.



      Step 6: Initializing. Everything ok (hybrid initialization)


      Step 7: Running calculation. When it comes to the first iteration, Fluent crashes. Infortunately, I don't have time to take a screenshot.


      Where does it come from? Did I forget a step or something in the programme?


      Regards,

    • Vassili BRIODEAU
      Subscriber

      Hello,


      Small update: I compiled the function instead of interpreting it. Then while compiling, I got the following error messages


      udf_names.c(6) : error C2449: trouv? '{' au niveau de la port?e du fichier (en-t?te de fonction manquantÿ?)


      udf_names.c(18) : fatal error C1004: fin de fichier inattendue rencontr?e


       


      Translation to English:


      found '{' at file scope (missing function header?)


      unexpected end of file found


       


      I looked on the internet, the first error means I could have a semicolon after an opening bracket, the second means the end semicolon is missing, however, I see neither one nor the other error in the programme.


       


      Regards,

    • marinak
      Subscriber

      Bonjour!


      1. Have you tried running any example from User Guide?


      2. How do you compile/attach your UDF? This is how it works for me:


      /define/user-defined/compiled-functions/


      load


      3. Why do you define ads variable outside DEFINE_ADJUST?


      4. I would try to remove almost everything and leave simple code smth like result = 1; and try to compile it.


      5. Also remove all the comments, sometimes compilator does not understand that /* initiates comment and gives errors. (In fact,i think it might be the case here)

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