UDF crashes fluent
1 Attachment(s)
I'm trying to update both the surface temp and the mass flow rate of a mass flow inlet boundary condition, in one DEFINE_PROFILE UDF. When I start the calculation it crashes. I have attached the code and the pseudo code I am working from. I am bit confused on how to use the i argument for F_PROFILE when I need to update 2 things. How can I select which one is which in the fluent GUI?
#include "udf.h" #include <math.h> #define Hg 2033631 //J/kg #define Hf -310000 //J/kg #define Cp 1500 //J/kg #define A .01104 //m/s #define E 20557.188 #define rho 754 #define R 8.314 #define tol 1e-6 #define T_ref 298 DEFINE_PROFILE(combined_surface_and_mass_flow_prof ile, t, i) { face_t f; real Ts, heat_flux, Hv, r, Ts_old, Ts_new, m_dot, error; int iter; int i; 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 > tol && iter < 10) { Hv = Hg - Hf + Cp * (Ts_old - T_ref); // Update Hv formula as needed r = heat_flux / (Hv * rho); // Regression rate calculation Ts_new = E / (R * (log(A) - 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 * rho); // Compute mass flow rate based on the final regression rate m_dot = rho * 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) } |
All times are GMT -4. The time now is 19:34. |