Fluids

Fluids

UDF and window console termination error/problem

    • hbilal1076
      Subscriber

      Dear Concern,


      In Ansys Fluent, when I compile and load the UDF file, and also in the Cell zone conditions>Fluid I added/enabled the source term and uploaded the UDF file and even initialize but when I click on calculate, after 5 second the console window get terminated/crashed/disappeared.

      Before getting crashed I see this below error




      999999: mpt_accept: error: accept failed: no such file or directory

      999999: mpt_accept: error: accept failed: no such file or directory

      999999: mpt_accept: error: accept failed: no such file or directory

      999999: mpt_accept: error: accept failed: no such file or directory


      ----error analysis-----

      (0-1) on DESKTOP-145MM28

      C: PROGRA ~1 ANSYSI~1 ANSYSS~1v212fluentfluent21.2.0win642D_nodef1 m.exepi2021 ended prematurely and may have crashed exit code 2


      ----error analysis-----





      I tried the other UDF sample model from fluent manual and it work well and get calculated.


      Kindly explain the possible mistake or the modification that I need to do in my attached UDF.




      #include "udf.h"

      #include "pdf_props.h"

      #include "pdf_table.h"

      #include "mem.h"

      #include "materials.h"


      /*********Constant Declarations*************************************/

      #define c_alph 54.0 /* Units: 1/s */

      #define N_avog 6.022045e+26 /* 1/kmol */

      #define c_bet 1.0 /* no units */

      #define rho_soot 1800.0 /* kg/m3 */

      #define T_alph 21000.0 /* activation temperature of soot inception in K */

      #define N_norm 1.0e+15 /* Moss-Brookes model: normalizing parameter */

      #define l 1.0 /* l indicates the particle nucleation sensitivity to Pressure: defined as 1.0 for now */

      #define PI 3.14159265358979324 /* Pi as a constant...alternatively pi=4.0*atan(1.0) */

      #define SpNo 19 /* The number of species in the mechanism file: should be adjusted according to the mechanism */

      #define Species 7 /* This is the index for the species of interest (CO2 in this case) */

      /*********End Constant Declarations*********************************/


      DEFINE_SOURCE(n_sourceterm, c, ct, dS, eqn)

      {

      /*********Variable Declarations*************************************/

      double dNdT, dp, X_CO2, T, P, rho_cell, M, N, Ysoot, bNuc, R;

      double x[SpNo], y[SpNo]; /* x is the array for species mole fractions and y is the array for mass fractions */

      int id_co2;

      /*********End Variable Declarations*********************************/


      /*********Variable Assignments**************************************/

      Material *mat = THREAD_MATERIAL(ct);

      id_co2 = mixture_specie_index(mat, "co2");

      Pdf_XY(c, ct, x, y); /* Calling the species mole and mass fractions for this cell */

      X_CO2 = x[id_co2]; /* arbitrarily defined for now */

      T = C_T(c, ct); /* Temperature at the cell */

      if (c == 400)

      Message("Temp is %g , species %", T);

      P = C_P(c, ct); /* Cell Presdsure */

      if (c == 400)

      Message("Press is %g , ", P);

      rho_cell = C_R(c, ct); /* Cell average Density */

      R = UNIVERSAL_GAS_CONSTANT; /* Universal gas constant is called with the built-in Fluent Macro */


      Ysoot = C_UDSI(c, ct, 0); /* Calling soot mass fraction from m_sourceterm scalar */

      if (c == 400)

      Message("Ysoot is %g , ", Ysoot);


      bNuc = C_UDSI(c, ct, 1); /* Calling soot number density from n_sourceterm scalar */

      if (c == 400)

      Message("bNuc is %g , ", bNuc);

      /**********End Variable Assignments*********************************/


      /**********Start Calculations************************************** */

      M = rho_cell * Ysoot;

      N = bNuc * rho_cell * N_norm;

      dp = pow(((6.0 * M)/(PI * N * rho_soot)), (1.0/3.0));

      dNdT = c_alph * N_avog * pow(((X_CO2 * P)/(R * T)), l) * exp(-1.0 * T_alph / T) - c_bet * pow(((24.0 * R * T) / ( rho_soot * N_avog)), 0.5) * sqrt(dp) * pow(N, 2);

      if (c == 400)

      Message("dNdT is %g , ", dNdT);

      /**********End of Calculations**************************************/


      return (dNdT / N_norm);


      }

    • Rob
      Ansys Employee
      I'm not sure why you're using the IF(c==400) lines, otherwise I'm not checking the rest of the code.
    • Karthik R
      Administrator
      Hello:
      To add to Rob's thought, please use 'fprintf' or 'message' statements to make sure that your code is running as intended. This would be the best way to identify the root cause of this issue and debug it. You should be able to find the syntax for these commands in the Fluent customization manual.
      Karthik
    • hbilal1076
      Subscriber
      Dear Prof. Rob and Kremella Thank you very much for your reply.
      The error process is changes now, when I load UDF and click on built it worked and in console "done building targets" appear, but when I click on compile, in the console the following error occurred.


      ===============Message from the Cortex Process================================
      Compute processes interrupted. Processing can be resumed.
      =============================================================================
      Error: Error code: 126\n



      For your convenience I attached the screenshot.
      Please help. TIA



    • Rob
      Ansys Employee
      Assuming you've added enough UDS space I'm not sure. Compile/Build will flag if the code is grammatically correct. Load just makes it available to the solver; you then need to hook up the terms. If it's then failing it's something you've written. Rather than using the source term, can you put the output into a UDM and return a fixed value to test the code?
Viewing 4 reply threads
  • You must be logged in to reply to this topic.