Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Bad termination of fluent simulation

    • Mark Fullerton
      Subscriber

      Hello all,

      I have been trying to run a fluent simulation with a compiled heterogeneous reaction UDF, I have opened fluent through the VS 2019 command prompt, however, whenever I try to run the calculation I get the following error: 

      I have run the simulation without the UDF and it runs smoothly, when I compile the UDF onto fluent no errors or warnings are given so I don't believe there to be anything wrong with my code, and I have tried to use the built-in compiler but that just ends up giving a similar bad termination error. 

      Does anyone have any idea on how to remedy this, any help would be much appreciated.

      Kind regards,

      Mark

    • Federico
      Ansys Employee

      Your UDF is likely the culprit if it runs fine without it, not in the syntax of the code since it compiles without errors but in how it is set up or what it is doing.

      Can you show us what your UDF looks like?

      • Mark Fullerton
        Subscriber

        This is currently the udf that I am trying to input, which aims to define a reaction between two immiscible liquids (methanol and oil)

        #include "udf.h"

        #define Pre 2.333e+7 /*Pre exponential factor, 1/sec*/
        #define EA 43400 /*Activation energy, J/mol*/
        #define R 8.3145 /*Universal gas constant, J/molK*/

        #define liquid_primary_index 0 /*defining WCO mixture index*/
        #define liquid_wco_index 0 /*wco in mixture index*/
        #define liquid_fame_index 1 /*fame in mixture index*/
        #define liquid_gly_index 2 /*glycerol in mixture index*/

        #define liquid_secondary_index 1 /*defining MeOH mixture index*/
        #define meoh_index 0 /*wco in meoh mixture index*/

        DEFINE_HET_RXN_RATE(Arrh, c, t, r, mw, yi, rr, rr_t)
        {
            Thread** pt = THREAD_SUB_THREADS(t);
            Thread* pri_t = pt[0]; /*Thread for WCO phase*/
            Thread* sec_t = pt[1]; /*Thread for methanol phase*/
            Thread* thi_t = pt[2]; /*Thread for FAME phase*/
            Thread* fou_t = pt[3]; /*Thread for glycerol phase*/

            real T_sec = C_T(c, sec_t); /*Temperature of methanol phase*/
            real T_thi = C_T(c, thi_t); /*Temperature of FAME phase*/
            real MFO = C_YI(c, pri_t, 1); /*Mass fraction of oil*/
            real MFM = C_YI(c, sec_t, 1); /*Mass fraction of MeOH*/
            real MFF = C_YI(c, thi_t, 1); /*Mass fraction of fame*/
            real MFG = C_YI(c, fou_t, 1); /*Mass fraction of glycerol*/
            real RHOO = C_R(c, pri_t); /*Density of oil*/
            real RHOM = C_R(c, sec_t); /*Density of MeOH*/
            real RHOF = C_R(c, thi_t); /*Density of fame*/
            real RHOG = C_R(c, fou_t); /*Density of glycerol*/

            real O_conc = (RHOO * MFO) / mw[liquid_primary_index][liquid_wco_index]; /*concentration of oil*/
            real M_conc = (RHOM * MFM) / mw[liquid_secondary_index][meoh_index]; /*concentration of MeOH*/
            real F_conc = (RHOF * MFF) / mw[liquid_primary_index][liquid_fame_index]; /*concentration of FAME*/
            real G_conc = (RHOG * MFG) / mw[liquid_primary_index][liquid_gly_index]; /*concentration of glycerol*/
            real MOR = M_conc / O_conc; /*Methanol to oil molar ratio*/

            if (MOR > 6)
                *rr = Pre * exp(-EA / (R * T_sec)) * O_conc;
            else
                *rr = Pre * exp(-EA / (R * T_sec)) * O_conc * pow(M_conc, 3);
            
            *rr_t = *rr;
        }  

         

        Kind regards,

        Mark

    • Federico
      Ansys Employee

      Can you try loading a different (simple) UDF to make sure that it loads correctly?

      If it doesn't, you might need to look at checking your environment 4.1.2.6 Setting Environment Options in Fluent Launcher

      • Mark Fullerton
        Subscriber

        Hello,

        I think I may have fixed the problem as I changed my UDF restarted my whole computer and this problem doesn't seem to occur anymore.

        Kind regards,

        Mark

    • Rob
      Forum Moderator

      Probably not linked to the problem, are you running four phases in this model? Or would you be better off with a species mixture in one or more phases? 

      • Mark Fullerton
        Subscriber

        Hello,

        Yeah I have since changed my model for two phases with a species mixture and changed my code accordingly.

        Kind regards,

        Mark

    • jcooper
      Ansys Employee

       

      Hi Mark:

      Some errors will allow you to compile, but the routine won’t work once the code is hooked and running because there is some violation of the array and pointer conventions.

      In the DEFINE_HET_RXN_RATE example from the Fluent customization manual, I see the thread declarations as follows:

      Below are yours:

      The space between ‘Thread’ and ‘*’ may be changing the meaning of these lines at runtime, where the compiler just parses these and thinks everything is just fine.

      The code will usually proceed until the fatal error, so you could also try a few debugging write statements sprinked throughout the UDF to let you know what the last lines before the crash are.

      I hope this helps.

      Best Regards,

      Judy

       

Viewing 4 reply threads
  • The topic ‘Bad termination of fluent simulation’ is closed to new replies.