Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

Fluent Crash while initialization with UDF and UDS

    • Zery Triputra
      Subscriber
      Hi everyone, I'm having trouble initializing my model. 
      My fluent crash when i try to initialize my model.
      I use UDS and UDF, my simulation is 2D, single phase. \
      I aim to get the simulation results in the form of the distribution of Dissolved Oxygen in the pond.
      Is there anyone can check my UDF is wrong or not ?

      My UDF :

      #include "udf.h"

      DEFINE_PROFILE(inlet_velocity, thread, position)
      {
          real x[ND_ND];
          real vel = 0.32; // Kecepatan masukan inlet (m/s)

          face_t f;
          begin_f_loop(f, thread)
          {
              F_CENTROID(x, f, thread);
              F_PROFILE(f, thread, position) = vel;
          }
          end_f_loop(f, thread)
      }


      #define Cs 0.0085  //  dissolved oksigen concentration saturated (kg/m^3)
      #define C_initial 0.003  // l C (kg/m^3)
      #define a 22.34  // coefficient source item (1/s)

      DEFINE_SOURCE(mass_source, c, t, dS, eqn)
      {
          real S, C;
          real time = CURRENT_TIME;

          // Calculation of value S (mass source item) based on the one degree reaction model
          S = a * (Cs - C_initial);

          // deficit value S
          S *= exp(-0.1 * time);  // Nilai penurunan dapat disesuaikan

          // update value C
          C = C_initial + (Cs - C_initial) * (1 - exp(-a * time));

          // stop iteration when C is maximum ( saturated)
          if (C >= Cs) {
              C = Cs;
              S = 0.0;
          }

          // Assign value C to UDS (User Defined Scalar)
          C_UDSI(c, t, 0) = C;

          dS[eqn] = 0.0; // 
          return S;
      }

    • Rob
      Ansys Employee

      How many scalars did you tell Fluent you were using?  Check the lines

        // deficit value S
          S *= exp(-0.1 * time);  // Nilai penurunan dapat disesuaikan

    • Zery Triputra
      Subscriber

      i use 2 scalars in this simulation 

    • Rob
      Ansys Employee

      And did you assign memory for that in User Defined tab? 

      If you did. Turn off the source terms, run a few iterations/one time step and try again. If any of those data calls don't have a value you may have a problem. Also, using 1-3 letter variables can cause problems if they're also used in Fluent somewhere else, hence I often use real/integer over DEFINE for coefficients. 

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