Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Need help with UDF. “999999: mpt_accept: error: accept failed: No error.”

TAGGED: , ,

    • Zwernjayden
      Subscriber

      I want my udf to update the surface tempurature to T(f), and the mass flow inlet to m_dot at the end. When try and use the DEFINE_ADJUST macro it crashes and says "999999: mpt_accept: error: accept failed: No error." The current code below compiles and works at printing the values (although they aren't really what I expected). I have also attached the pseudo code of what I am trying to do.

      #include "udf.h"
      #include
      DEFINE_EXECUTE_AT_END(print_heat_flux)
      {
          Domain *d;
          Thread *t;
          face_t f;
          real Ts, heat_flux, Hv, r, Ts_old, Ts_new, m_dot, T;  // Declare all variables at the top of the block
          real error;
          int iter;
          d = Get_Domain(1);  // Adjust the domain ID as per your case
       
          /* Loop over all face threads in the domain */
          thread_loop_f(t, d)
          {
              /* Check if this is the boundary with the ID you're interested in */
              if (THREAD_ID(t) == 6)  // Adjust the surface ID as per your case
              {
                  /* Loop over all faces in this thread */
                  begin_f_loop(f, t)
                  {
                      Ts = F_T(f, t);           // Get the temperature at face f
                      heat_flux = BOUNDARY_HEAT_FLUX(f, t); // Calculate the heat flux
                      printf("Heat flux on face %d: %g W/m^2\n", f, heat_flux);
      Ts_old = Ts;
      iter = 0;
      error = 1;
      while (error>1e-6 && iter <10)
      {
      Hv = 2033631 + 310000 + 1500;
      r = heat_flux/(Hv*900);
      Ts_new = 20557.188 / (8.314 * (log(0.01104) - log(r)));
      error=fabs(Ts_new-Ts_old);
      iter++;
      }
      T(f)=Ts+0.1*(Ts_new-Ts);
      r = heat_flux/(Hv*900);
      printf("Regression Rate: %g\n", r);
      m_dot=900*r;
      printf("M_dot: %g\n", m_dot);
                  }
                  end_f_loop(f, t)
              }
          }
      }

       

    • Rob
      Forum Moderator

      We'd normally use DEFINE_PROFILE to set boundary conditions. Is this for a transient flow?

    • Zwernjayden
      Subscriber

      Its steady state. Would it be like this? Im a bit confused how the arguments for the F_PROFILE work. What does the i and the i+1 do? It says its supposed to determine which profile is which but I don't see a way to actually select it in the GUI.

      #include "udf.h"
      #include
       
      DEFINE_PROFILE(combined_surface_and_mass_flow_profile, t, i)
      {
          face_t f;
          real Ts, heat_flux, Hv, r, Ts_old, Ts_new, m_dot, error;
          int iter;
         
       
          begin_f_loop(f, t)
          {
              if (THREAD_ID(t) == 6)  // Select fuel grain surface
              {
                  // Initial values and heat flux retrieval
                  Ts = F_T(f, t);
                  heat_flux = BOUNDARY_HEAT_FLUX(f, t);
       
                  // Iterative calculation for new surface temperature
                  Ts_old = Ts;
                  iter = 0;
                  error = 1;
                  while (error > 1e-6 && iter < 10)
                  {
                      Hv = 2033631 + 310000 + 1500 * (Ts_old - 298);  // Update Hv formula as needed
                      r = heat_flux / (Hv * 754);  // Regression rate calculation
                      Ts_new = 20557.188 / (8.314 * (log(0.01104) - log(r)));  // New surface temperature calculation
                      error = fabs(Ts_new - Ts_old);  // Compute error
                      Ts_old = Ts_new;  // Prepare for next iteration
                      iter++;
                  }
                  // Update the surface temperature profile at the face
                  F_PROFILE(f, t, i) = (Ts + 0.1 * (Ts_new - Ts));
          r = heat_flux / (Hv * 754);
                  // Compute mass flow rate based on the final regression rate
                  m_dot = 754 * r;  // Use the same r calculated for temperature
                  F_PROFILE(f, t, i+1) = m_dot;  // Assuming 'position + 1' is the correct slot for mass flow rate
              }
          }
          end_f_loop(f, t)
      }

       

    • Rob
      Forum Moderator

      i , i+1 , i++ are generally integers and used to count up for "something". I'm not sure you should be using them like that in  F_PROFILE(f, t, i+1)  as i may be the surface ID: check the macro. 

      In a steady case you're trying to update a boundary at each iteration so effectively you're changing the problem. If there's no damping you may find you oscillate around a value until the solver fails. 

      Rather than trying to write ever more complex code, take a step back and figure out exactly what you're trying to acheive. Can it be done by running a model and manually altering a value to then run it again? 

Viewing 3 reply threads
  • The topic ‘Need help with UDF. “999999: mpt_accept: error: accept failed: No error.”’ is closed to new replies.