April 15, 2024 at 6:31 pm
Zwernjayden
Bbp_participant
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)
}
Â